Skip to content

Commit

Permalink
Fix parent/child handling in getGeometryBindings (#1113)
Browse files Browse the repository at this point in the history
The matching logic was reversed for membership, so that parent assignments would override child assignments. That is the logic should be to check if the path of the assignment is completely contained within the path to the geometry being tested.
  • Loading branch information
kwokcb authored Oct 22, 2022
1 parent 8bd5164 commit 0ee79b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion javascript/MaterialXView/source/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ export class Material
// and assign to the associatged geometry. If there are no looks
// then the first material is found and assignment to all the
// geometry.
this._materials = [];
this._materials.length = 0;
this._defaultMaterial = null;
var looks = doc.getLooks();
if (looks.length)
Expand Down Expand Up @@ -633,6 +633,16 @@ export class Material
let newAssignment;
if (collection || geom)
{
// Remove leading "/" from collection and geom for
// later assignment comparison checking
if (collection && collection.charAt(0) == "/")
{
collection = collection.slice(1);
}
if (geom && geom.charAt(0) == "/")
{
geom = geom.slice(1);
}
newAssignment = new MaterialAssign(shader, geom, collection);
}
else
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXCore/Look.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ vector<MaterialAssignPtr> getGeometryBindings(ConstNodePtr materialNode, const s
{
if (matAssign->getReferencedMaterial() == materialNode)
{
if (geomStringsMatch(geom, matAssign->getActiveGeom()))
if (geomStringsMatch(matAssign->getActiveGeom(), geom, true))
{
matAssigns.push_back(matAssign);
continue;
Expand Down

0 comments on commit 0ee79b2

Please sign in to comment.