Skip to content

Commit

Permalink
Write custom primitives even when they already exist #768 (#769)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastien Blaineau-Ortega <sebastien.blaineau.ortega@autodesk.com>
  • Loading branch information
2 people authored and sirpalee committed Jun 1, 2021
1 parent f632ca9 commit 56cddbd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
15 changes: 3 additions & 12 deletions translator/writer/write_arnold_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,15 @@ 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
|| nodeEntryType == AI_NODE_CAMERA || nodeEntryType == AI_NODE_LIGHT);

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
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 1 addition & 6 deletions translator/writer/write_geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 56cddbd

Please sign in to comment.