Skip to content

Commit

Permalink
Matching to Houdini build 18.5.37.
Browse files Browse the repository at this point in the history
  • Loading branch information
SideFX authored and Prisms User committed Nov 22, 2019
1 parent 0b1a893 commit c512979
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 22 deletions.
10 changes: 5 additions & 5 deletions src/houdini/custom/USD/GEO_FilePrimAgentUtils.C
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ PXR_NAMESPACE_OPEN_SCOPE
TF_DEFINE_PUBLIC_TOKENS(GEO_AgentPrimTokens, GEO_AGENT_PRIM_TOKENS);

void
GEObuildJointList(const GU_AgentRig &rig, VtTokenArray &joint_list,
GEObuildJointList(const GU_AgentRig &rig, VtTokenArray &joint_paths,
UT_Array<exint> &joint_order)
{
joint_order.setSizeNoInit(rig.transformCount());
joint_list.reserve(rig.transformCount());
joint_paths.reserve(rig.transformCount());

UT_WorkBuffer buf;
exint ordered_idx = 0;
Expand All @@ -35,18 +35,18 @@ GEObuildJointList(const GU_AgentRig &rig, VtTokenArray &joint_list,
const exint parent_idx = rig.parentIndex(xform_idx);
if (parent_idx >= 0)
{
buf.append(joint_list[joint_order[parent_idx]].GetString());
buf.append(joint_paths[joint_order[parent_idx]].GetString());
buf.append('/');
}

buf.append(rig.transformName(xform_idx));
joint_list.push_back(TfToken(buf.toStdString()));
joint_paths.push_back(TfToken(buf.toStdString()));
joint_order[xform_idx] = ordered_idx;
}

#ifdef UT_DEBUG
// Validate the hierarchy.
UsdSkelTopology topo(joint_list);
UsdSkelTopology topo(joint_paths);
std::string errors;
if (!topo.Validate(&errors))
UT_ASSERT_MSG(false, errors.c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/houdini/custom/USD/GEO_FilePrimAgentUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ TF_DECLARE_PUBLIC_TOKENS(GEO_AgentPrimTokens, GEO_AGENT_PRIM_TOKENS);
/// Build a list of the joint names in the format required by UsdSkel (i.e.
/// full paths such as "A/B/C"), and ordered so that parents appear before
/// children.
void GEObuildJointList(const GU_AgentRig &rig, VtTokenArray &joint_list,
void GEObuildJointList(const GU_AgentRig &rig, VtTokenArray &joint_paths,
UT_Array<exint> &joint_order);

/// Convert a list of joint transforms from GU_Agent::Matrix4Type to
Expand Down
41 changes: 29 additions & 12 deletions src/houdini/custom/USD/GEO_FilePrimUtils.C
Original file line number Diff line number Diff line change
Expand Up @@ -1862,7 +1862,7 @@ static void
initSkeletonPrim(const GEO_FilePrim &defn_root, GEO_FilePrimMap &fileprimmap,
const GEO_ImportOptions &options, const GU_AgentRig &rig,
const GEO_AgentSkeleton &skeleton,
const VtTokenArray &joint_list,
const VtTokenArray &joint_paths,
const UT_Array<exint> &joint_order)
{
SdfPath skel_path = defn_root.getPath().AppendChild(skeleton.myName);
Expand All @@ -1876,7 +1876,24 @@ initSkeletonPrim(const GEO_FilePrim &defn_root, GEO_FilePrimMap &fileprimmap,
// Record the joint list.
GEO_FileProp *prop = skel_prim.addProperty(
UsdSkelTokens->joints, SdfValueTypeNames->TokenArray,
new GEO_FilePropConstantSource<VtTokenArray>(joint_list));
new GEO_FilePropConstantSource<VtTokenArray>(joint_paths));
prop->setValueIsDefault(true);
prop->setValueIsUniform(true);

// Also record the original unique joint names from GU_AgentRig.
// These can be used instead of the full paths when importing into another
// format (e.g. back to SOPs).
VtTokenArray joint_names;
joint_names.resize(joint_paths.size());
for (exint i = 0, n = rig.transformCount(); i < n; ++i)
{
joint_names[joint_order[i]] =
TfToken(rig.transformName(i).toStdString());
}

prop = skel_prim.addProperty(
UsdSkelTokens->jointNames, SdfValueTypeNames->TokenArray,
new GEO_FilePropConstantSource<VtTokenArray>(joint_names));
prop->setValueIsDefault(true);
prop->setValueIsUniform(true);

Expand All @@ -1895,7 +1912,7 @@ initSkeletonPrim(const GEO_FilePrim &defn_root, GEO_FilePrimMap &fileprimmap,
// provide animation for all of the joints, but this ensures that the
// source skeleton (which doesn't have an animation source) looks
// reasonable if it's viewed.
UsdSkelTopology topology(joint_list);
UsdSkelTopology topology(joint_paths);
VtMatrix4dArray rest_xforms;
UsdSkelComputeJointLocalTransforms(topology, bind_xforms, &rest_xforms);

Expand All @@ -1913,12 +1930,12 @@ initSkelAnimationPrim(GEO_FilePrim &anim_prim, const GU_Agent &agent,
{
// Add the joint list property.
UT_Array<exint> joint_order;
VtTokenArray joint_list;
GEObuildJointList(rig, joint_list, joint_order);
VtTokenArray joint_paths;
GEObuildJointList(rig, joint_paths, joint_order);

GEO_FileProp *prop = anim_prim.addProperty(
UsdSkelTokens->joints, SdfValueTypeNames->TokenArray,
new GEO_FilePropConstantSource<VtTokenArray>(joint_list));
new GEO_FilePropConstantSource<VtTokenArray>(joint_paths));
prop->setValueIsDefault(true);
prop->setValueIsUniform(true);

Expand Down Expand Up @@ -2217,7 +2234,7 @@ initAgentShapePrim(GEO_FilePrimMap &fileprimmap,
const GU_AgentShapeLib::Shape &shape,
const SdfPath &shapelib_path, const GU_AgentRig &rig,
const UT_Array<exint> &joint_order,
const VtTokenArray &joint_list,
const VtTokenArray &joint_paths,
const UT_Map<exint, TfToken> &usd_shape_names)
{
UT_ASSERT(usd_shape_names.contains(shape.uniqueId()));
Expand Down Expand Up @@ -2261,7 +2278,7 @@ initAgentShapePrim(GEO_FilePrimMap &fileprimmap,
if (xform_idx >= 0)
{
const exint usd_joint_idx = joint_order[xform_idx];
referenced_joints.push_back(joint_list[usd_joint_idx]);
referenced_joints.push_back(joint_paths[usd_joint_idx]);
}
else
referenced_joints.push_back(TfToken());
Expand Down Expand Up @@ -3015,8 +3032,8 @@ GEOinitGTPrim(GEO_FilePrim &fileprim,
// through the joint names and must be ordered so that parents appear
// before children (unlike GU_AgentRig).
UT_Array<exint> joint_order;
VtTokenArray joint_list;
GEObuildJointList(rig, joint_list, joint_order);
VtTokenArray joint_paths;
GEObuildJointList(rig, joint_paths, joint_order);

UT_Map<exint, TfToken> usd_shape_names;
GEObuildUsdShapeNames(*defn.shapeLibrary(), usd_shape_names);
Expand All @@ -3030,7 +3047,7 @@ GEOinitGTPrim(GEO_FilePrim &fileprim,
for (const GEO_AgentSkeleton &skeleton : skeletons)
{
initSkeletonPrim(fileprim, fileprimmap, options, rig, skeleton,
joint_list, joint_order);
joint_paths, joint_order);
}

// During refinement the shape library geometry was also refined
Expand All @@ -3056,7 +3073,7 @@ GEOinitGTPrim(GEO_FilePrim &fileprim,
{
initAgentShapePrim(fileprimmap, shapelib,
*shapelib.findShape(shape_name),
shapelib_path, rig, joint_order, joint_list,
shapelib_path, rig, joint_order, joint_paths,
usd_shape_names);
}
}
Expand Down
20 changes: 16 additions & 4 deletions src/houdini/lib/H_USD/HUSD/XUSD_Data.C
Original file line number Diff line number Diff line change
Expand Up @@ -1401,11 +1401,17 @@ XUSD_Data::createFlattenedLayer(
// stop processing at payloads/references anyway.
SdfLayerRefPtr flattened = HUSDflattenLayers(getOrCreateStageForFlattening(
response, UsdStage::LoadNone));
std::string savepath;

// Clear the save control. Mostly we want to ensure this layer is never
// marked as a Placeholder. But we don't really want to preserve any of
// the other possible values either.
HUSDsetSaveControl(flattened, UT_StringHolder::theEmptyString);
// the other possible values either. Make an exception if the flattened
// layer has a save path set. Then we can assume the layer was intended
// to be saved explicitly.
if (HUSDgetSavePath(flattened, savepath))
HUSDsetSaveControl(flattened, HUSD_Constants::getSaveControlExplicit());
else
HUSDsetSaveControl(flattened, UT_StringHolder::theEmptyString);

return flattened;
}
Expand All @@ -1418,11 +1424,17 @@ XUSD_Data::createFlattenedStage(
// with the payload.
SdfLayerRefPtr flattened = getOrCreateStageForFlattening(
response, UsdStage::LoadAll)->Flatten();
std::string savepath;

// Clear the save control. Mostly we want to ensure this layer is never
// marked as a Placeholder. But we don't really want to preserve any of
// the other possible values either.
HUSDsetSaveControl(flattened, UT_StringHolder::theEmptyString);
// the other possible values either. Make an exception if the flattened
// layer has a save path set. Then we can assume the layer was intended
// to be saved explicitly.
if (HUSDgetSavePath(flattened, savepath))
HUSDsetSaveControl(flattened, HUSD_Constants::getSaveControlExplicit());
else
HUSDsetSaveControl(flattened, UT_StringHolder::theEmptyString);

return flattened;
}
Expand Down

0 comments on commit c512979

Please sign in to comment.