Skip to content

Commit 6b8ef8b

Browse files
SideFXPrisms User
authored andcommitted
Matching to Houdini build 18.5.318.
1 parent 5680c96 commit 6b8ef8b

File tree

6 files changed

+120
-28
lines changed

6 files changed

+120
-28
lines changed

src/houdini/custom/RAY/BRAY_HdKarma/BRAY_HdMaterial.C

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,30 @@ namespace
245245
BRAY::ScenePtr &scene,
246246
HdSceneDelegate &delegate)
247247
{
248+
static constexpr UT_StringLit karmaHDA("karma:hda:");
248249
for (auto &&p : node.parameters)
249-
BRAY_HdUtil::appendVexArg(args, BRAY_HdUtil::toStr(p.first), p.second);
250+
{
251+
UT_StringHolder pname = BRAY_HdUtil::toStr(p.first);
252+
if (pname.startsWith(karmaHDA))
253+
{
254+
// Special parameter that indicates we need an import from an HDA
255+
UT_ASSERT(p.second.IsHolding<SdfAssetPath>());
256+
UT_StringHolder hda = BRAY_HdUtil::toStr(p.second);
257+
if (!hda)
258+
{
259+
UT_ErrorLog::error("Unable to resolve HDA path for: {}",
260+
p.first);
261+
}
262+
else
263+
{
264+
scene.loadHDA(hda);
265+
}
266+
}
267+
else
268+
{
269+
BRAY_HdUtil::appendVexArg(args, BRAY_HdUtil::toStr(p.first), p.second);
270+
}
271+
}
250272
if (net.nodes.size() > 1)
251273
{
252274
gatherInputs(for_surface, net, node, inputMap, args,

src/houdini/custom/USD/GEO_FilePrimUtils.C

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,10 @@ GEOinitProperty(GEO_FilePrim &fileprim,
677677
const UsdPrimDefinition *primdef =
678678
UsdSchemaRegistry::GetInstance().FindConcretePrimDefinition(
679679
fileprim.getTypeName());
680-
SdfAttributeSpecHandle attrib_spec =
681-
primdef->GetSchemaAttributeSpec(usd_attr_name);
680+
SdfAttributeSpecHandle attrib_spec;
681+
if (primdef)
682+
attrib_spec = primdef->GetSchemaAttributeSpec(usd_attr_name);
683+
682684
if (attrib_spec)
683685
{
684686
is_uniform = (attrib_spec->GetVariability() == SdfVariabilityUniform);

src/houdini/lib/H_USD/HUSD/HUSD_CreateMaterial.C

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ husdCreateMainPrim( const UsdStageRefPtr &stage, const UT_StringRef &usd_path,
125125

126126
// Add a unique id to this material/nodegraph so that nodes downstream
127127
// can know if its definition has changed.
128-
main_prim.GetPrim().SetCustomDataByKey(HUSDgetMaterialIdToken(),
129-
VtValue(theMaterialIdCounter.add(1)));
128+
if( main_prim )
129+
main_prim.GetPrim().SetCustomDataByKey(HUSDgetMaterialIdToken(),
130+
VtValue(theMaterialIdCounter.add(1)));
130131

131132
return main_prim;
132133
}

src/houdini/lib/H_USD/HUSD/HUSD_Info.C

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ namespace {
199199
public:
200200
UT_StringMap<size_t> myStats[NUM_STAT_GROUPS];
201201
PurposeInfoMap myPurposeMap;
202+
std::map<SdfPath, size_t> myMasterPrims;
202203
};
203204
typedef UT_ThreadSpecificValue<FindPrimStatsTaskThreadData *>
204205
FindPrimStatsTaskThreadDataTLS;
@@ -285,6 +286,10 @@ namespace {
285286
primtype = "Untyped";
286287
stats[primtype]++;
287288

289+
UsdPrim master(prim.GetMaster());
290+
if (master)
291+
threadData->myMasterPrims[master.GetPath()]++;
292+
288293
if ((myFlags & HUSD_Info::STATS_GEOMETRY_COUNTS) == 0)
289294
return;
290295

@@ -386,11 +391,13 @@ namespace {
386391
":Guide",
387392
};
388393
UT_WorkBuffer statbuf;
394+
std::map<SdfPath, size_t> masterprims;
389395

390396
for(auto it = myThreadData.begin(); it != myThreadData.end(); ++it)
391397
{
392398
if(const auto* tdata = it.get())
393399
{
400+
// Add up all the per-purpose primitive counts.
394401
for (int statidx = 0; statidx < NUM_STAT_GROUPS; statidx++)
395402
{
396403
auto &tstats = tdata->myStats[statidx];
@@ -410,8 +417,22 @@ namespace {
410417
stats.getOptionI(statbuf.buffer())+it->second);
411418
}
412419
}
420+
421+
// Make a unified map of all master prims.
422+
for (auto it = tdata->myMasterPrims.begin();
423+
it != tdata->myMasterPrims.end(); ++it)
424+
masterprims[it->first] += it->second;
413425
}
414426
}
427+
if (!masterprims.empty())
428+
{
429+
size_t totalinstances = 0;
430+
431+
for (auto &&it : masterprims)
432+
totalinstances += it.second;
433+
stats.setOptionI("Instance Masters", masterprims.size());
434+
stats.setOptionI("Instances", totalinstances);
435+
}
415436
}
416437
};
417438

src/houdini/lib/H_USD/HUSD/HUSD_Scene.C

Lines changed: 67 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,17 +1587,49 @@ HUSD_Scene::lookupGeomId(const UT_StringRef &path)
15871587
if(entry != myDisplayGeometry.end())
15881588
return entry->second->id();
15891589

1590-
return getOrCreateID(path, GEOMETRY);
1590+
// Path -> Render ID -> Hou Geom ID
1591+
auto rentry = myRenderIDs.find(path);
1592+
if(rentry != myRenderIDs.end())
1593+
{
1594+
auto gentry = myRenderIDtoGeomID.find(rentry->second);
1595+
if(gentry != myRenderIDtoGeomID.end())
1596+
return gentry->second;
1597+
}
1598+
1599+
return -1;
15911600
}
15921601

15931602

15941603
void
15951604
HUSD_Scene::setRenderID(const UT_StringRef &path, int id)
15961605
{
1597-
myRenderIDs[path] = id;
1598-
myRenderPaths[id] = path;
1599-
int pid = getOrCreateID(path);
1600-
myRenderIDtoGeomID[id] = pid;
1606+
int idx = path.findCharIndex('[');
1607+
if(idx != -1)
1608+
{
1609+
UT_StringView base_v(path.c_str(), idx);
1610+
UT_StringHolder base(base_v);
1611+
1612+
int pid = getOrCreateID(base, INSTANCER);
1613+
auto node = myTree->lookupID(pid);
1614+
if(node)
1615+
{
1616+
UT_StringView indices_v(path.c_str()+idx+1,
1617+
path.length() - idx -2);
1618+
UT_StringHolder indices(indices_v);
1619+
int inst_id = node->addInstance(indices, myTree);
1620+
1621+
myRenderIDs[path] = id;
1622+
myRenderPaths[id] = path;
1623+
myRenderIDtoGeomID[id] = inst_id;
1624+
}
1625+
}
1626+
else
1627+
{
1628+
myRenderIDs[path] = id;
1629+
myRenderPaths[id] = path;
1630+
int pid = getOrCreateID(path);
1631+
myRenderIDtoGeomID[id] = pid;
1632+
}
16011633
}
16021634

16031635
int
@@ -1919,6 +1951,18 @@ HUSD_Scene::convertSelection(const char *selection,
19191951
}
19201952
}
19211953

1954+
bool
1955+
HUSD_Scene::hasInstanceSelections()
1956+
{
1957+
for(auto sel : mySelection)
1958+
{
1959+
auto type = getPrimType(sel.first);
1960+
if(type == INSTANCE)
1961+
return true;
1962+
}
1963+
return false;
1964+
}
1965+
19221966
bool
19231967
HUSD_Scene::removeInstanceSelections()
19241968
{
@@ -1927,7 +1971,7 @@ HUSD_Scene::removeInstanceSelections()
19271971
for(auto sel : mySelection)
19281972
{
19291973
auto type = getPrimType(sel.first);
1930-
if(type == INSTANCER || type == INSTANCE)
1974+
if(type == INSTANCE)
19311975
to_remove.append(sel.first);
19321976
}
19331977

@@ -1948,7 +1992,7 @@ HUSD_Scene::removePrimSelections()
19481992
for(auto sel : mySelection)
19491993
{
19501994
auto type = getPrimType(sel.first);
1951-
if(type != INSTANCER && type != INSTANCE)
1995+
if(type != INSTANCE)
19521996
to_remove.append(sel.first);
19531997
}
19541998

@@ -2643,27 +2687,28 @@ HUSD_Scene::isSelected(int id) const
26432687
if(entry != node->myIDPaths->end())
26442688
{
26452689
const UT_StringRef &instance = entry->second;
2646-
UT_ASSERT(instance.startsWith(theQuestionMark));
2647-
2648-
// If nested, check if higher instance levels are selected.
2649-
// Keep stripping off indices until the topmost instance is reached,
2650-
// checking if the instancer is selected at each level.
2651-
const int nest_level = instance.countChar(' ') -1;
2652-
for(int pass =1; pass<nest_level; pass++)
2690+
if(instance.startsWith(theQuestionMark))
26532691
{
2654-
const int idx = instance.lastCharIndex(' ', pass);
2655-
if(idx >= 0)
2692+
// If nested, check if higher instance levels are selected.
2693+
// Keep stripping off indices until the topmost instance is
2694+
// reached, checking if the instancer is selected at each level.
2695+
// Instances generated from Render Delegates (setRenderID())
2696+
// can only have 1 nesting level and don't start with ?.
2697+
const int nest_level = instance.countChar(' ') -1;
2698+
for(int pass =1; pass<nest_level; pass++)
26562699
{
2657-
UT_StringHolder inst_key(instance.c_str(), idx);
2658-
auto ientry = node->myInstances->find(inst_key);
2659-
if(ientry != node->myInstances->end())
2700+
const int idx = instance.lastCharIndex(' ', pass);
2701+
if(idx >= 0)
26602702
{
2661-
if(mySelection.find(ientry->second) != mySelection.end())
2703+
UT_StringHolder inst_key(instance.c_str(), idx);
2704+
auto ientry = node->myInstances->find(inst_key);
2705+
if(ientry != node->myInstances->end() &&
2706+
mySelection.find(ientry->second) != mySelection.end())
26622707
return true;
26632708
}
2709+
else
2710+
break;
26642711
}
2665-
else
2666-
break;
26672712
}
26682713
}
26692714
}

src/houdini/lib/H_USD/HUSD/HUSD_Scene.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ class HUSD_API HUSD_Scene : public UT_NonCopyable
215215
// Convert a pattern to a selection.
216216
voidconvertSelection(const char *selection_pattern,
217217
UT_StringArray &paths);
218-
218+
219+
bool hasInstanceSelections();
219220
// Remove any non-prim (instance) selections.
220221
bool removeInstanceSelections();
221222
// Remove any non-instance (prim) selections.

0 commit comments

Comments
 (0)