From df6cfa1664430eb24b1b0e3f22160377c6004b54 Mon Sep 17 00:00:00 2001 From: Ashwin Bhat Date: Mon, 14 Oct 2024 12:54:29 -0700 Subject: [PATCH] Isolate Datalibrary APIs to Document - Remove use of datalibrary in Element headers --- source/MaterialXCore/Element.h | 10 +++------- source/MaterialXCore/Node.cpp | 3 +-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/source/MaterialXCore/Element.h b/source/MaterialXCore/Element.h index b60d025fc6..2b92dd8094 100644 --- a/source/MaterialXCore/Element.h +++ b/source/MaterialXCore/Element.h @@ -814,17 +814,13 @@ class MX_CORE_API Element : public std::enable_shared_from_this /// @} protected: - // Resolve a reference to a named element at the scope of the given datalibrary and parent, + // Resolve a reference to a named element at the scope of the given parent, // taking the namespace at the scope of this element into account. If no parent // is provided, then the root scope of the document is used. - template shared_ptr resolveNameReference(const string& name, ConstElementPtr parent = nullptr, ConstElementPtr datalibrary = nullptr) const + template shared_ptr resolveNameReference(const string& name, ConstElementPtr parent = nullptr) const { - shared_ptr child = datalibrary ? datalibrary->getChildOfType(getQualifiedName(name)) : nullptr; - if (child) - return child; - ConstElementPtr scope = parent ? parent : getRoot(); - child = scope->getChildOfType(getQualifiedName(name)); + shared_ptr child = scope->getChildOfType(getQualifiedName(name)); return child ? child : scope->getChildOfType(name); } diff --git a/source/MaterialXCore/Node.cpp b/source/MaterialXCore/Node.cpp index 90a2f46889..64ce97e8ce 100644 --- a/source/MaterialXCore/Node.cpp +++ b/source/MaterialXCore/Node.cpp @@ -75,9 +75,8 @@ NodeDefPtr Node::getNodeDef(const string& target, bool allowRoughMatch) const NodeDefPtr resolvedNode = resolveNameReference(getNodeDefString()); if (!resolvedNode && getDocument()->hasDataLibrary()) { - return resolveNameReference(getNodeDefString(), nullptr, getDocument()->getDataLibrary()); + return (getDocument()->getNodeDef(getNodeDefString())); } - return resolvedNode; }