24 #ifndef PXR_USD_IMAGING_USD_IMAGING_INSTANCE_ADAPTER_H 25 #define PXR_USD_IMAGING_USD_IMAGING_INSTANCE_ADAPTER_H 32 #include "pxr/base/tf/hashmap.h" 36 PXR_NAMESPACE_OPEN_SCOPE
104 virtual bool ShouldCullChildren()
const override;
106 virtual bool IsInstancerAdapter()
const override;
114 HdDirtyBits* timeVaryingBits,
116 instancerContext = NULL)
const override;
121 HdDirtyBits requestedBits,
123 instancerContext = NULL)
const override;
141 virtual void MarkDirty(
UsdPrim const& prim,
149 virtual void MarkRefineLevelDirty(
UsdPrim const& prim,
153 virtual void MarkReprDirty(
UsdPrim const& prim,
157 virtual void MarkCullStyleDirty(
UsdPrim const& prim,
161 virtual void MarkRenderTagDirty(
UsdPrim const& prim,
165 virtual void MarkTransformDirty(
UsdPrim const& prim,
169 virtual void MarkVisibilityDirty(
UsdPrim const& prim,
186 SdfPath const& cachePath)
const override;
190 SdfPath const& cachePath)
const override;
195 size_t maxSampleCount,
202 size_t maxNumSamples,
210 size_t maxNumSamples,
213 VtIntArray *sampleIndices)
override;
218 TfToken const& instanceInheritablePurpose)
const override;
247 bool ignoreRootTransform =
false)
const override;
253 HdExtComputationInputDescriptorVector
254 GetExtComputationInputs(
UsdPrim const& prim,
260 HdExtComputationOutputDescriptorVector
261 GetExtComputationOutputs(
UsdPrim const& prim,
266 HdExtComputationPrimvarDescriptorVector
267 GetExtComputationPrimvars(
270 HdInterpolation interpolation,
274 GetExtComputationInput(
282 GetExtComputationKernel(
288 GetInstanceIndices(
UsdPrim const& instancerPrim,
289 SdfPath const& instancerCachePath,
290 SdfPath const& prototypeCachePath,
297 VtIntArray *outIndices)
const override;
304 SdfPath const &parentInstancerPath,
315 HdInstancerContext *instancerContext)
const override;
317 virtual SdfPathVector GetScenePrimPaths(
319 std::vector<int>
const& instanceIndices,
320 std::vector<HdInstancerContext> *instancerCtxs)
const override;
322 virtual bool PopulateSelection(
326 int const hydraInstanceIndex,
327 VtIntArray
const &parentInstanceIndices,
328 HdSelectionSharedPtr
const &result)
const override;
334 virtual HdVolumeFieldDescriptorVector
335 GetVolumeFieldDescriptors(
UsdPrim const& usdPrim,
SdfPath const &
id,
339 virtual void _RemovePrim(
SdfPath const& cachePath,
347 SdfPath const& parentProxyPath);
351 struct _InstancerData;
353 bool _IsChildPrim(
UsdPrim const& prim,
354 SdfPath const& cachePath)
const;
357 bool _PrimIsInstancer(
UsdPrim const& prim)
const;
369 UsdImagingPrimAdapterSharedPtr
const& primAdapter,
370 UsdImagingPrimAdapterSharedPtr
const& instancerAdapter,
372 bool *isLeafInstancer);
375 void _ResyncPath(
SdfPath const& cachePath,
380 void _ResyncInstancer(
SdfPath const& instancerPath,
385 struct _ComputeInstanceMapFn;
386 VtIntArray _ComputeInstanceMap(
UsdPrim const& instancerPrim,
387 _InstancerData
const& instrData,
394 struct _ComputeInstanceMapVariabilityFn;
395 bool _ComputeInstanceMapVariability(
UsdPrim const& instancerPrim,
396 _InstancerData
const& instrData)
const;
400 _ProtoPrim
const& _GetProtoPrim(
SdfPath const& instancerPath,
406 bool _GetProtoPrimForChild(
409 _ProtoPrim
const** proto,
414 struct _ComputeInstanceTransformFn;
415 bool _ComputeInstanceTransforms(
UsdPrim const& instancer,
416 VtMatrix4dArray* transforms,
420 struct _GatherInstanceTransformTimeSamplesFn;
421 bool _GatherInstanceTransformsTimeSamples(
UsdPrim const& instancer,
423 std::vector<double>* outTimes)
427 struct _GatherInstancePrimvarTimeSamplesFn;
428 bool _GatherInstancePrimvarTimeSamples(
UsdPrim const& instancer,
431 std::vector<double>* outTimes)
436 struct _IsInstanceTransformVaryingFn;
437 bool _IsInstanceTransformVarying(
UsdPrim const& instancer)
const;
442 template<
typename T>
struct _ComputeInheritedPrimvarFn;
445 bool _ComputeInheritedPrimvar(
UsdPrim const& instancer,
450 bool _ComputeInheritedPrimvar(
UsdPrim const& instancer,
458 struct _IsInstanceInheritedPrimvarVaryingFn;
459 bool _IsInstanceInheritedPrimvarVarying(
UsdPrim const& instancer)
const;
461 struct _PopulateInstanceSelectionFn;
462 struct _GetScenePrimPathsFn;
463 struct _GetInstanceCategoriesFn;
492 template <
typename Functor>
493 void _RunForAllInstancesToDraw(
UsdPrim const& instancer, Functor* fn)
const;
494 template <
typename Functor>
495 bool _RunForAllInstancesToDrawImpl(
UsdPrim const& instancer,
496 std::vector<UsdPrim>* instanceContext,
500 typedef TfHashMap<SdfPath, size_t, SdfPath::Hash> _InstancerDrawCounts;
501 size_t _CountAllInstancesToDraw(
UsdPrim const& instancer)
const;
502 size_t _CountAllInstancesToDrawImpl(
UsdPrim const& instancer,
503 _InstancerDrawCounts* drawCounts)
const;
514 UsdImagingPrimAdapterSharedPtr adapter;
518 typedef TfHashMap<SdfPath, _ProtoPrim, SdfPath::Hash> _PrimMap;
523 struct _InstancerData {
524 _InstancerData() : numInstancesToDraw(0), refresh(
false) { }
543 bool operator==(
const PrimvarInfo& rhs)
const;
544 bool operator<(
const PrimvarInfo& rhs)
const;
546 std::vector<PrimvarInfo> inheritedPrimvars;
550 SdfPathSet instancePaths;
557 mutable size_t numInstancesToDraw;
570 mutable std::vector<Visibility> visibility;
578 SdfPathSet childPointInstancers;
581 SdfPathVector nestedInstances;
584 SdfPathVector parentInstances;
589 mutable bool refresh;
596 typedef std::unordered_map<SdfPath, _InstancerData, SdfPath::Hash>
598 _InstancerDataMap _instancerData;
604 typedef TfHashMap<SdfPath, SdfPath, SdfPath::Hash>
605 _InstanceToInstancerMap;
606 _InstanceToInstancerMap _instanceToInstancerMap;
628 typedef TfHashMultiMap<SdfPath, SdfPath, SdfPath::Hash>
629 _PrototypeToInstancerMap;
630 _PrototypeToInstancerMap _prototypeToInstancerMap;
634 typedef std::unordered_map<SdfPath, SdfPath, SdfPath::Hash>
635 _ProtoPrimToInstancerMap;
636 _ProtoPrimToInstancerMap _protoPrimToInstancerMap;
640 PXR_NAMESPACE_CLOSE_SCOPE
642 #endif // PXR_USD_IMAGING_USD_IMAGING_INSTANCE_ADAPTER_H bool GetVisible(UsdPrim const &usdPrim, SdfPath const &cachePath, UsdTimeCode time) const override
Returns true if the given prim is visible, taking into account inherited visibility values.
SdfPath GetInstancerId(UsdPrim const &usdPrim, SdfPath const &cachePath) const override
Return the instancerId for this prim.
virtual SdfPath Populate(UsdPrim const &prim, UsdImagingIndexProxy *index, UsdImagingInstancerContext const *instancerContext=nullptr) override
Called to populate the RenderIndex for this UsdPrim.
Basic type: 3-dimensional floating point range.
virtual void ProcessPrimResync(SdfPath const &cachePath, UsdImagingIndexProxy *index) override
When a PrimResync event occurs, the prim may have been deleted entirely, adapter plug-ins should over...
HdCullStyle GetCullStyle(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
Gets the cullstyle of a specific path in the scene graph.
std::vector< VtArray< TfToken > > GetInstanceCategories(UsdPrim const &prim) override
Return an array of the categories used by each instance.
HighlightMode
Selection modes allow differentiation in selection highlight behavior.
Represents a value type name, i.e.
This proxy class exposes a subset of the private Delegate API to PrimAdapters.
virtual void ProcessPrimRemoval(SdfPath const &cachePath, UsdImagingIndexProxy *index) override
Removes all associated Rprims and dependencies from the render index without scheduling them for repo...
size_t SampleInstancerTransform(UsdPrim const &instancerPrim, SdfPath const &instancerPath, UsdTimeCode time, size_t maxSampleCount, float *sampleTimes, GfMatrix4d *sampleValues) override
Sample the instancer transform for the given prim.
GfMatrix4d GetTransform(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, bool ignoreRootTransform=false) const override
Fetches the transform for the given prim at the given time from a pre-computed cache of prim transfor...
Token for efficient comparison, assignment, and hashing of known strings.
virtual void UpdateForTime(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, HdDirtyBits requestedBits, UsdImagingInstancerContext const *instancerContext=NULL) const override
Populates the cache for the given prim, time and requestedBits.
GfMatrix4d GetInstancerTransform(UsdPrim const &instancerPrim, SdfPath const &instancerPath, UsdTimeCode time) const override
Get the instancer transform for the given prim.
Stores a 4x4 matrix of double elements.
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Base class for all PrimAdapters.
GfRange3d GetExtent(UsdPrim const &usdPrim, SdfPath const &cachePath, UsdTimeCode time) const override
Reads the extent from the given prim.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
A basic mathematical interval class.
bool GetDoubleSided(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
Reads double-sided from the given prim. If not authored, returns false.
VtValue GetTopology(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
Gets the topology object of a specific Usd prim.
A path value used to locate objects in layers or scenegraphs.
virtual SdfPath GetScenePrimPath(SdfPath const &cachePath, int instanceIndex, HdInstancerContext *instancerContext) const override
TfToken GetPurpose(UsdPrim const &usdPrim, SdfPath const &cachePath, TfToken const &instanceInheritablePurpose) const override
Returns the purpose token for prim.
Delegate support for instanced prims.
VtValue Get(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &key, UsdTimeCode time, VtIntArray *outIndices) const override
Gets the value of the parameter named key for the given prim (which has the given cache path) and giv...
PxOsdSubdivTags GetSubdivTags(UsdPrim const &usdPrim, SdfPath const &cachePath, UsdTimeCode time) const override
Get the subdiv tags for this prim.
size_t SampleTransform(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, size_t maxNumSamples, float *sampleTimes, GfMatrix4d *sampleValues) override
Samples the transform for the given prim.
virtual void TrackVariability(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits *timeVaryingBits, UsdImagingInstancerContext const *instancerContext=NULL) const override
For the given prim, variability is detected and stored in timeVaryingBits.
VT_API bool operator==(VtDictionary const &, VtDictionary const &)
Equality comparison.
Object used by instancer prim adapters to pass along context about the instancer and instance prim to...
virtual HdDirtyBits ProcessPropertyChange(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &propertyName) override
Returns a bit mask of attributes to be updated, or HdChangeTracker::AllDirty if the entire prim must ...
A forward iterator into a UsdPrimRange.
size_t SamplePrimvar(UsdPrim const &usdPrim, SdfPath const &cachePath, TfToken const &key, UsdTimeCode time, size_t maxNumSamples, float *sampleTimes, VtValue *sampleValues, VtIntArray *sampleIndices) override
Sample the primvar for the given prim.
SdfPathVector GetInstancerPrototypes(UsdPrim const &usdPrim, SdfPath const &cachePath) const override
Return the list of known prototypes of this prim.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
virtual GfMatrix4d GetRelativeInstancerTransform(SdfPath const &parentInstancerPath, SdfPath const &instancerPath, UsdTimeCode time) const override
Returns the transform of protoInstancerPath relative to instancerPath.