@@ -58,6 +58,9 @@ struct _BlendShapeAttributesNames
5858 const char * ict { " inputComponentsTarget" };
5959 const char * sn { " supportNegativeWeights" };
6060 const char * w { " weight" };
61+ const char * ibig { " inbetweenInfoGroup" };
62+ const char * ibi { " inbetweenInfo" };
63+ const char * ibtn { " inbetweenTargetName" };
6164};
6265
6366TfStaticData<_BlendShapeAttributesNames> _BlendShapeAttributes;
@@ -68,7 +71,8 @@ void _AddBlendShape(
6871 unsigned int targetIdx,
6972 float weight,
7073 const MPointArray& deltas,
71- MIntArray& indices)
74+ MIntArray& indices,
75+ bool isInBetween = false )
7276{
7377 const auto blendShapeObj = fnBlendShape.object ();
7478
@@ -132,7 +136,22 @@ void _AddBlendShape(
132136 plgInCompTarget.setValue (compObj);
133137 }
134138
135- if (!blendShapeName.empty ()) {
139+ // If weight is not 1.0, that means we are creating an inbetween shape
140+ if (isInBetween) {
141+ auto inBetweenTargetNameAttr = fnBlendShape.attribute (_BlendShapeAttributes->ibtn );
142+ auto inBetweenInfoGroupAttr = fnBlendShape.attribute (_BlendShapeAttributes->ibig );
143+ auto inBetweenInfoAttr = fnBlendShape.attribute (_BlendShapeAttributes->ibi );
144+ MPlug plgInBetweenTargetName (blendShapeObj, inBetweenTargetNameAttr);
145+ plgInBetweenTargetName.selectAncestorLogicalIndex (targetIdx, inBetweenInfoGroupAttr);
146+ plgInBetweenTargetName.selectAncestorLogicalIndex (
147+ convertWeightToIndex (weight), inBetweenInfoAttr);
148+
149+ // USD inbetweens are named: "inbetween:<name>"
150+ // Remove the inbetween prefix
151+ auto inBetweenName = blendShapeName.substr (blendShapeName.find_first_of (" :" ) + 1 );
152+
153+ plgInBetweenTargetName.setString (MString (inBetweenName.c_str ()));
154+ } else {
136155 MPlug plgWeight (blendShapeObj, inputWeightAttr);
137156 plgWeight.selectAncestorLogicalIndex (targetIdx, inputWeightAttr);
138157
@@ -283,11 +302,12 @@ bool UsdMayaTranslatorBlendShape::Read(const UsdPrim& meshPrim, UsdMayaPrimReade
283302
284303 _AddBlendShape (
285304 blendFn,
286- " " ,
305+ inBetweenName ,
287306 static_cast <unsigned int >(targetIdx),
288307 ibWeight,
289308 inBetweenDeltasPointsArray,
290- inBetweenIndicesIntArray);
309+ inBetweenIndicesIntArray,
310+ true );
291311 }
292312 }
293313 return true ;
0 commit comments