Skip to content

Commit df885fc

Browse files
committed
Previously there was an *overlay* of setting visibility=true for point instancer prototypes. This prevents users from (even temporarily) making their prototypes invisible to remove them from the generated image. Instead, this change moves the data to an *underlay* where explicit visibility authoring will effectively be respected.
This is linked to issue #3748 and also lays a bit more groundwork to address issue #3693
1 parent d3991f7 commit df885fc

File tree

2 files changed

+43
-27
lines changed

2 files changed

+43
-27
lines changed

pxr/usdImaging/usdImaging/piPrototypeSceneIndex.cpp

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,15 @@ _ComputeUnderlaySource(const SdfPath &instancer, const SdfPath &prototypeRoot)
7676
}
7777

7878
HdContainerDataSourceHandle
79-
_ComputePrototypeRootOverlaySource(const SdfPath &instancer)
79+
_ComputePrototypeRootUnderlaySource(const SdfPath &instancer)
8080
{
8181
if (instancer.IsEmpty()) {
8282
return nullptr;
8383
}
8484

8585
static HdContainerDataSourceHandle const ds =
8686
HdRetainedContainerDataSource::New(
87-
HdXformSchema::GetSchemaToken(),
88-
HdXformSchema::Builder()
89-
.SetResetXformStack(
90-
HdRetainedTypedSampledDataSource<bool>::New(
91-
true))
92-
.Build(),
93-
// We ignore the visibility authored on a prototype instanced
87+
// By underlaying this data, we do not override visibility explicitly authored on a prototype instanced
9488
// by a point instancer in USD.
9589
HdVisibilitySchema::GetSchemaToken(),
9690
HdVisibilitySchema::Builder()
@@ -101,6 +95,24 @@ _ComputePrototypeRootOverlaySource(const SdfPath &instancer)
10195
return ds;
10296
}
10397

98+
HdContainerDataSourceHandle
99+
_ComputePrototypeRootOverlaySource(const SdfPath &instancer)
100+
{
101+
if (instancer.IsEmpty()) {
102+
return nullptr;
103+
}
104+
105+
static HdContainerDataSourceHandle const ds =
106+
HdRetainedContainerDataSource::New(
107+
HdXformSchema::GetSchemaToken(),
108+
HdXformSchema::Builder()
109+
.SetResetXformStack(
110+
HdRetainedTypedSampledDataSource<bool>::New(
111+
true))
112+
.Build());
113+
return ds;
114+
}
115+
104116
bool
105117
_IsOver(const HdSceneIndexPrim &prim)
106118
{
@@ -132,11 +144,8 @@ UsdImaging_PiPrototypeSceneIndex(
132144
const SdfPath &instancer,
133145
const SdfPath &prototypeRoot)
134146
: HdSingleInputFilteringSceneIndexBase(inputSceneIndex)
147+
, _instancer(instancer)
135148
, _prototypeRoot(prototypeRoot)
136-
, _underlaySource(
137-
_ComputeUnderlaySource(instancer, prototypeRoot))
138-
, _prototypeRootOverlaySource(
139-
_ComputePrototypeRootOverlaySource(instancer))
140149
{
141150
_Populate();
142151
}
@@ -211,20 +220,28 @@ UsdImaging_PiPrototypeSceneIndex::GetPrim(const SdfPath &primPath) const
211220
return prim;
212221
}
213222

214-
if (_underlaySource) {
223+
TfSmallVector<HdContainerDataSourceHandle, 4> dsVec;
224+
225+
if (HdContainerDataSourceHandle ds =
226+
_ComputePrototypeRootOverlaySource(_instancer);
227+
ds && primPath == _prototypeRoot)
228+
dsVec.emplace_back(ds);
229+
230+
dsVec.emplace_back(prim.dataSource);
231+
232+
if (HdContainerDataSourceHandle ds =
233+
_ComputePrototypeRootUnderlaySource(_instancer);
234+
ds && primPath == _prototypeRoot)
235+
dsVec.emplace_back(ds);
236+
237+
if (HdContainerDataSourceHandle ds =
238+
_ComputeUnderlaySource(_instancer, _prototypeRoot))
239+
dsVec.emplace_back(ds);
240+
241+
if (dsVec.size() > 1)
215242
prim.dataSource = HdOverlayContainerDataSource::New(
216-
prim.dataSource,
217-
_underlaySource);
218-
}
219-
220-
if (_prototypeRootOverlaySource) {
221-
if (primPath == _prototypeRoot) {
222-
prim.dataSource = HdOverlayContainerDataSource::New(
223-
_prototypeRootOverlaySource,
224-
prim.dataSource);
225-
}
226-
}
227-
243+
dsVec.size(), dsVec.data());
244+
228245
return prim;
229246
}
230247

pxr/usdImaging/usdImaging/piPrototypeSceneIndex.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,8 @@ class UsdImaging_PiPrototypeSceneIndex final
148148

149149
void _Populate();
150150

151+
SdfPath _instancer;
151152
SdfPath _prototypeRoot;
152-
HdContainerDataSourceHandle _underlaySource;
153-
HdContainerDataSourceHandle _prototypeRootOverlaySource;
154153

155154
// Instancers and overs within the prototype.
156155
// Note that this does not include instancers or overs nested

0 commit comments

Comments
 (0)