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,
312 virtual SdfPath GetScenePrimPath(
315 HdInstancerContext *instancerContext)
const override;
317 virtual bool PopulateSelection(
321 int const hydraInstanceIndex,
322 VtIntArray
const &parentInstanceIndices,
323 HdSelectionSharedPtr
const &result)
const override;
329 virtual HdVolumeFieldDescriptorVector
330 GetVolumeFieldDescriptors(
UsdPrim const& usdPrim,
SdfPath const &
id,
334 virtual void _RemovePrim(
SdfPath const& cachePath,
342 SdfPath const& parentProxyPath);
346 struct _InstancerData;
348 bool _IsChildPrim(
UsdPrim const& prim,
349 SdfPath const& cachePath)
const;
352 bool _PrimIsInstancer(
UsdPrim const& prim)
const;
364 UsdImagingPrimAdapterSharedPtr
const& primAdapter,
365 UsdImagingPrimAdapterSharedPtr
const& instancerAdapter,
367 bool *isLeafInstancer);
370 void _ResyncPath(
SdfPath const& cachePath,
375 void _ResyncInstancer(
SdfPath const& instancerPath,
380 struct _ComputeInstanceMapFn;
381 VtIntArray _ComputeInstanceMap(
UsdPrim const& instancerPrim,
382 _InstancerData
const& instrData,
389 struct _ComputeInstanceMapVariabilityFn;
390 bool _ComputeInstanceMapVariability(
UsdPrim const& instancerPrim,
391 _InstancerData
const& instrData)
const;
395 _ProtoPrim
const& _GetProtoPrim(
SdfPath const& instancerPath,
401 bool _GetProtoPrimForChild(
404 _ProtoPrim
const** proto,
409 struct _ComputeInstanceTransformFn;
410 bool _ComputeInstanceTransforms(
UsdPrim const& instancer,
411 VtMatrix4dArray* transforms,
415 struct _GatherInstanceTransformTimeSamplesFn;
416 bool _GatherInstanceTransformsTimeSamples(
UsdPrim const& instancer,
418 std::vector<double>* outTimes)
422 struct _GatherInstancePrimvarTimeSamplesFn;
423 bool _GatherInstancePrimvarTimeSamples(
UsdPrim const& instancer,
426 std::vector<double>* outTimes)
431 struct _IsInstanceTransformVaryingFn;
432 bool _IsInstanceTransformVarying(
UsdPrim const& instancer)
const;
437 template<
typename T>
struct _ComputeInheritedPrimvarFn;
440 bool _ComputeInheritedPrimvar(
UsdPrim const& instancer,
445 bool _ComputeInheritedPrimvar(
UsdPrim const& instancer,
453 struct _IsInstanceInheritedPrimvarVaryingFn;
454 bool _IsInstanceInheritedPrimvarVarying(
UsdPrim const& instancer)
const;
456 struct _PopulateInstanceSelectionFn;
457 struct _GetScenePrimPathFn;
486 template <
typename Functor>
487 void _RunForAllInstancesToDraw(
UsdPrim const& instancer, Functor* fn)
const;
488 template <
typename Functor>
489 bool _RunForAllInstancesToDrawImpl(
UsdPrim const& instancer,
490 std::vector<UsdPrim>* instanceContext,
494 typedef TfHashMap<SdfPath, size_t, SdfPath::Hash> _InstancerDrawCounts;
495 size_t _CountAllInstancesToDraw(
UsdPrim const& instancer)
const;
496 size_t _CountAllInstancesToDrawImpl(
UsdPrim const& instancer,
497 _InstancerDrawCounts* drawCounts)
const;
508 UsdImagingPrimAdapterSharedPtr adapter;
512 typedef TfHashMap<SdfPath, _ProtoPrim, SdfPath::Hash> _PrimMap;
517 struct _InstancerData {
518 _InstancerData() : numInstancesToDraw(0), refreshVariability(
false) { }
537 bool operator==(
const PrimvarInfo& rhs)
const;
538 bool operator<(
const PrimvarInfo& rhs)
const;
540 std::vector<PrimvarInfo> inheritedPrimvars;
544 std::vector<SdfPath> instancePaths;
551 mutable size_t numInstancesToDraw;
564 mutable std::vector<Visibility> visibility;
572 SdfPathSet childPointInstancers;
575 SdfPathVector nestedInstances;
578 SdfPathVector parentInstances;
582 mutable bool refreshVariability;
589 typedef std::unordered_map<SdfPath, _InstancerData, SdfPath::Hash>
591 _InstancerDataMap _instancerData;
597 typedef TfHashMap<SdfPath, SdfPath, SdfPath::Hash>
598 _InstanceToInstancerMap;
599 _InstanceToInstancerMap _instanceToInstancerMap;
621 typedef TfHashMultiMap<SdfPath, SdfPath, SdfPath::Hash>
622 _PrototypeToInstancerMap;
623 _PrototypeToInstancerMap _prototypeToInstancerMap;
627 PXR_NAMESPACE_CLOSE_SCOPE
629 #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.
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.