Skip to content

Commit

Permalink
Merge pull request #1733 from Autodesk/t-tindj/MAYA-113606/validate_x…
Browse files Browse the repository at this point in the history
…form_token_

Add Validation for Xform token
  • Loading branch information
Krystian Ligenza authored Sep 29, 2021
2 parents 6b0486e + 3b48aed commit 89ddd99
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/mayaUsd/ufe/UsdTransform3dMayaXformStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@ bool setXformOpOrder(const UsdGeomXformable& xformable)

using NextTransform3dFn = std::function<Ufe::Transform3d::Ptr()>;

bool hasValidSuffix(const std::vector<UsdGeomXformOp>& xformOps)
{
TF_FOR_ALL(iter, xformOps)
{
const UsdGeomXformOp& xformOp = *iter;
auto ndx = gOpNameToNdx.find(xformOp.GetName());
if (ndx == gOpNameToNdx.end())
return false;
}
return true;
}

Ufe::Transform3d::Ptr
createTransform3d(const Ufe::SceneItem::Ptr& item, NextTransform3dFn nextTransform3dFn)
{
Expand All @@ -157,6 +169,10 @@ createTransform3d(const Ufe::SceneItem::Ptr& item, NextTransform3dFn nextTransfo
return UsdTransform3dMayaXformStack::create(usdItem);
}

// reject tokens not in gOpNameToNdx
if (!hasValidSuffix(xformOps))
return nextTransform3dFn();

// If the prim supports the Maya transform stack, create a Maya transform
// stack interface for it, otherwise delegate to the next handler in the
// chain of responsibility.
Expand Down

0 comments on commit 89ddd99

Please sign in to comment.