Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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() == COMMENT_TYPE_STRING)
{
continue;
}
children.push_back(child);
}
vector <ElementPtr> rhsChildren;
for (ElementPtr child : rhs->getChildren())
{
if (child->getCategory() == COMMENT_TYPE_STRING)
{
continue;
}
rhsChildren.push_back(child);
}
if (children.size() != rhsChildren.size())
{
if (results)
Expand Down
1 change: 1 addition & 0 deletions source/MaterialXCore/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const string SURFACE_MATERIAL_NODE_STRING = "surfacematerial";
const string VOLUME_MATERIAL_NODE_STRING = "volumematerial";
const string MULTI_OUTPUT_TYPE_STRING = "multioutput";
const string NONE_TYPE_STRING = "none";
const string COMMENT_TYPE_STRING = "comment";
const string VALUE_STRING_TRUE = "true";
const string VALUE_STRING_FALSE = "false";
const string NAME_PREFIX_SEPARATOR = ":";
Expand Down
1 change: 1 addition & 0 deletions source/MaterialXCore/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ extern MX_CORE_API const string SURFACE_MATERIAL_NODE_STRING;
extern MX_CORE_API const string VOLUME_MATERIAL_NODE_STRING;
extern MX_CORE_API const string MULTI_OUTPUT_TYPE_STRING;
extern MX_CORE_API const string NONE_TYPE_STRING;
extern MX_CORE_API const string COMMENT_TYPE_STRING;
extern MX_CORE_API const string VALUE_STRING_TRUE;
extern MX_CORE_API const string VALUE_STRING_FALSE;
extern MX_CORE_API const string NAME_PREFIX_SEPARATOR;
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::COMMENT_TYPE_STRING);
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::COMMENT_TYPE_STRING);
comment->setDocString("Comment 2");
comment = doc2->addChildOfCategory(mx::COMMENT_TYPE_STRING);
comment->setDocString("Comment 3");

mx::ElementEquivalenceOptions options;
mx::ElementEquivalenceResultVec results;
Expand Down
1 change: 1 addition & 0 deletions source/PyMaterialX/PyMaterialXCore/PyTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ void bindPyTypes(py::module& mod)
mod.attr("VOLUME_MATERIAL_NODE_STRING") = mx::VOLUME_MATERIAL_NODE_STRING;
mod.attr("MULTI_OUTPUT_TYPE_STRING") = mx::MULTI_OUTPUT_TYPE_STRING;
mod.attr("NONE_TYPE_STRING") = mx::NONE_TYPE_STRING;
mod.attr("COMMENT_TYPE_STRING") = mx::COMMENT_TYPE_STRING;
mod.attr("VALUE_STRING_TRUE") = mx::VALUE_STRING_TRUE;
mod.attr("VALUE_STRING_FALSE") = mx::VALUE_STRING_FALSE;
mod.attr("NAME_PREFIX_SEPARATOR") = mx::NAME_PREFIX_SEPARATOR;
Expand Down