Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions source/MaterialXCore/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,25 @@ bool Element::isEquivalent(ConstElementPtr rhs, const ElementEquivalenceOptions&
}
}

// Compare children.
const vector<ElementPtr>& children = getChildren();
const vector<ElementPtr>& rhsChildren = rhs->getChildren();
// Compare all child elements that affect functional equivalence.
vector<ElementPtr> children;
for (ElementPtr child : getChildren())
{
if (child->getCategory() == CommentElement::CATEGORY)
{
continue;
}
children.push_back(child);
}
vector <ElementPtr> rhsChildren;
for (ElementPtr child : rhs->getChildren())
{
if (child->getCategory() == CommentElement::CATEGORY)
{
continue;
}
rhsChildren.push_back(child);
}
if (children.size() != rhsChildren.size())
{
if (results)
Expand Down
8 changes: 8 additions & 0 deletions source/MaterialXTest/MaterialXCore/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ TEST_CASE("Document equivalence", "[document]")
unsigned int index = 0;
mx::ElementPtr child = doc->addNodeGraph("mygraph");
mx::NodeGraphPtr graph = child->asA<mx::NodeGraph>();
// Add comment block at the start of the first doc to check skipping
mx::ElementPtr comment = doc->addChildOfCategory(mx::CommentElement::CATEGORY);
comment->setDocString("Comment 1");
for (auto it = inputMap.begin(); it != inputMap.end(); ++it)
{
const std::string inputType = (*it).first;
Expand Down Expand Up @@ -205,6 +208,11 @@ TEST_CASE("Document equivalence", "[document]")
input->setName("input_" + inputType);
}
}
// Add comment blocks at end of second doc to check value and count checks
comment = doc2->addChildOfCategory(mx::CommentElement::CATEGORY);
comment->setDocString("Comment 2");
comment = doc2->addChildOfCategory(mx::CommentElement::CATEGORY);
comment->setDocString("Comment 3");

mx::ElementEquivalenceOptions options;
mx::ElementEquivalenceResultVec results;
Expand Down