From 56cddbd622c1b6ca7ea42f467837f7c1dab4eadb Mon Sep 17 00:00:00 2001 From: Sebastien Blaineau-Ortega Date: Wed, 28 Apr 2021 03:35:43 +0200 Subject: [PATCH] Write custom primitives even when they already exist #768 (#769) Co-authored-by: Sebastien Blaineau-Ortega --- translator/writer/write_arnold_type.cpp | 15 +++------------ translator/writer/write_geometry.cpp | 7 +------ 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/translator/writer/write_arnold_type.cpp b/translator/writer/write_arnold_type.cpp index 2b4e07796e..506e79d7dc 100644 --- a/translator/writer/write_arnold_type.cpp +++ b/translator/writer/write_arnold_type.cpp @@ -48,11 +48,6 @@ void UsdArnoldWriteArnoldType::Write(const AtNode *node, UsdArnoldWriter &writer UsdStageRefPtr stage = writer.GetUsdStage(); // get the current stage defined in the writer SdfPath objPath(nodeName); - UsdPrim prim = stage->GetPrimAtPath(objPath); - if (prim && prim.IsActive()) { - // This primitive was already written, let's early out - return; - } const AtNodeEntry *nodeEntry = AiNodeGetNodeEntry(node); int nodeEntryType = AiNodeEntryGetType(nodeEntry); bool isXformable = (nodeEntryType == AI_NODE_SHAPE @@ -60,7 +55,8 @@ void UsdArnoldWriteArnoldType::Write(const AtNode *node, UsdArnoldWriter &writer if (isXformable) writer.CreateHierarchy(objPath); - prim = stage->DefinePrim(objPath, TfToken(_usdName)); + + UsdPrim prim = stage->DefinePrim(objPath, TfToken(_usdName)); // For arnold nodes that have a transform matrix, we read it as in a // UsdGeomXformable @@ -150,13 +146,8 @@ void UsdArnoldWriteGinstance::Write(const AtNode *node, UsdArnoldWriter &writer) UsdStageRefPtr stage = writer.GetUsdStage(); // get the current stage defined in the writer SdfPath objPath(nodeName); - UsdPrim prim = stage->GetPrimAtPath(objPath); - if (prim && prim.IsActive()) { - // This primitive was already written, let's early out - return; - } writer.CreateHierarchy(objPath); - prim = stage->DefinePrim(objPath, TfToken(_usdName)); + UsdPrim prim = stage->DefinePrim(objPath, TfToken(_usdName)); AtNode *target = (AtNode *)AiNodeGetPtr(node, "node"); if (target) { diff --git a/translator/writer/write_geometry.cpp b/translator/writer/write_geometry.cpp index 4912694705..e127b5853e 100644 --- a/translator/writer/write_geometry.cpp +++ b/translator/writer/write_geometry.cpp @@ -287,14 +287,9 @@ void UsdArnoldWriteProceduralCustom::Write(const AtNode *node, UsdArnoldWriter & SdfPath objPath(nodeName); _exportedAttrs.insert("name"); - UsdPrim prim = stage->GetPrimAtPath(objPath); - if (prim && prim.IsActive()) { - // This primitive was already written, let's early out - return; - } // All custom procedurals are written as ArnoldProceduralCustom schema writer.CreateHierarchy(objPath); - prim = stage->DefinePrim(objPath, TfToken("ArnoldProceduralCustom")); + UsdPrim prim = stage->DefinePrim(objPath, TfToken("ArnoldProceduralCustom")); // Set the procedural node entry name as an attribute "arnold:node_entry" UsdAttribute nodeTypeAttr = prim.CreateAttribute(TfToken("arnold:node_entry"), SdfValueTypeNames->String, false);