7#ifndef PXR_USD_IMAGING_USD_IMAGING_INSTANCE_ADAPTER_H
8#define PXR_USD_IMAGING_USD_IMAGING_INSTANCE_ADAPTER_H
13#include "pxr/usdImaging/usdImaging/api.h"
16#include "pxr/base/tf/hashmap.h"
20PXR_NAMESPACE_OPEN_SCOPE
87 bool ShouldCullChildren()
const override;
90 bool IsInstancerAdapter()
const override;
99 HdDirtyBits* timeVaryingBits,
101 instancerContext = NULL)
const override;
107 HdDirtyBits requestedBits,
109 instancerContext = NULL)
const override;
131 void MarkDirty(
UsdPrim const& prim,
140 void MarkRefineLevelDirty(
UsdPrim const& prim,
145 void MarkReprDirty(
UsdPrim const& prim,
150 void MarkCullStyleDirty(
UsdPrim const& prim,
155 void MarkRenderTagDirty(
UsdPrim const& prim,
160 void MarkTransformDirty(
UsdPrim const& prim,
165 void MarkVisibilityDirty(
UsdPrim const& prim,
185 SdfPath const& cachePath)
const override;
190 SdfPath const& cachePath)
const override;
196 size_t maxSampleCount,
204 size_t maxNumSamples,
213 size_t maxNumSamples,
216 VtIntArray *sampleIndices)
override;
222 TfToken const& instanceInheritablePurpose)
const override;
245 bool IsChildPath(
const SdfPath& path)
const override;
260 bool ignoreRootTransform =
false)
const override;
281 HdExtComputationInputDescriptorVector
282 GetExtComputationInputs(
UsdPrim const& prim,
289 HdExtComputationOutputDescriptorVector
290 GetExtComputationOutputs(
UsdPrim const& prim,
296 HdExtComputationPrimvarDescriptorVector
297 GetExtComputationPrimvars(
300 HdInterpolation interpolation,
305 GetExtComputationInput(
314 GetExtComputationKernel(
321 GetInstanceIndices(
UsdPrim const& instancerPrim,
322 SdfPath const& instancerCachePath,
323 SdfPath const& prototypeCachePath,
331 VtIntArray *outIndices)
const override;
339 SdfPath const &parentInstancerPath,
351 HdInstancerContext *instancerContext)
const override;
354 SdfPathVector GetScenePrimPaths(
356 std::vector<int>
const& instanceIndices,
357 std::vector<HdInstancerContext> *instancerCtxs)
const override;
360 bool PopulateSelection(
364 int const hydraInstanceIndex,
365 VtIntArray
const &parentInstanceIndices,
366 HdSelectionSharedPtr
const &result)
const override;
373 HdVolumeFieldDescriptorVector
374 GetVolumeFieldDescriptors(
UsdPrim const& usdPrim,
SdfPath const &
id,
379 void _RemovePrim(
SdfPath const& cachePath,
387 SdfPath const& parentProxyPath);
391 struct _InstancerData;
393 bool _IsChildPrim(
UsdPrim const& prim,
394 SdfPath const& cachePath)
const;
397 bool _PrimIsInstancer(
UsdPrim const& prim)
const;
404 const UsdImagingPrimAdapterSharedPtr& primAdapter,
409 void _ResyncPath(
SdfPath const& cachePath,
414 void _ResyncInstancer(
SdfPath const& instancerPath,
419 struct _ComputeInstanceMapFn;
420 VtIntArray _ComputeInstanceMap(
UsdPrim const& instancerPrim,
421 _InstancerData
const& instrData,
428 struct _ComputeInstanceMapVariabilityFn;
429 bool _ComputeInstanceMapVariability(
UsdPrim const& instancerPrim,
430 _InstancerData
const& instrData)
const;
434 _ProtoPrim
const& _GetProtoPrim(
SdfPath const& instancerPath,
440 bool _GetProtoPrimForChild(
443 _ProtoPrim
const** proto,
448 struct _ComputeInstanceTransformFn;
449 bool _ComputeInstanceTransforms(
UsdPrim const& instancer,
450 VtMatrix4dArray* transforms,
454 struct _GatherInstanceTransformTimeSamplesFn;
455 bool _GatherInstanceTransformsTimeSamples(
UsdPrim const& instancer,
457 std::vector<double>* outTimes)
461 struct _GatherInstancePrimvarTimeSamplesFn;
462 bool _GatherInstancePrimvarTimeSamples(
UsdPrim const& instancer,
465 std::vector<double>* outTimes)
470 struct _IsInstanceTransformVaryingFn;
471 bool _IsInstanceTransformVarying(
UsdPrim const& instancer)
const;
476 template<
typename T>
struct _ComputeInheritedPrimvarFn;
479 bool _ComputeInheritedPrimvar(
UsdPrim const& instancer,
484 bool _ComputeInheritedPrimvar(
UsdPrim const& instancer,
492 struct _IsInstanceInheritedPrimvarVaryingFn;
493 bool _IsInstanceInheritedPrimvarVarying(
UsdPrim const& instancer)
const;
495 struct _PopulateInstanceSelectionFn;
496 struct _GetScenePrimPathsFn;
497 struct _GetInstanceCategoriesFn;
526 template <
typename Functor>
527 void _RunForAllInstancesToDraw(
UsdPrim const& instancer, Functor* fn)
const;
528 template <
typename Functor>
529 bool _RunForAllInstancesToDrawImpl(
UsdPrim const& instancer,
530 std::vector<UsdPrim>* instanceContext,
534 typedef TfHashMap<SdfPath, size_t, SdfPath::Hash> _InstancerDrawCounts;
535 size_t _CountAllInstancesToDraw(
UsdPrim const& instancer)
const;
536 size_t _CountAllInstancesToDrawImpl(
UsdPrim const& instancer,
537 _InstancerDrawCounts* drawCounts)
const;
548 UsdImagingPrimAdapterSharedPtr adapter;
552 typedef TfHashMap<SdfPath, _ProtoPrim, SdfPath::Hash> _PrimMap;
557 struct _InstancerData {
558 _InstancerData() : numInstancesToDraw(0), refresh(false) { }
577 bool operator==(
const PrimvarInfo& rhs)
const;
578 bool operator<(
const PrimvarInfo& rhs)
const;
580 std::vector<PrimvarInfo> inheritedPrimvars;
584 SdfPathSet instancePaths;
591 mutable size_t numInstancesToDraw;
604 mutable std::vector<Visibility> visibility;
612 SdfPathSet childPointInstancers;
615 SdfPathVector nestedInstances;
618 SdfPathVector parentInstances;
623 mutable bool refresh;
630 typedef std::unordered_map<SdfPath, _InstancerData, SdfPath::Hash>
632 _InstancerDataMap _instancerData;
638 typedef TfHashMap<SdfPath, SdfPath, SdfPath::Hash>
639 _InstanceToInstancerMap;
640 _InstanceToInstancerMap _instanceToInstancerMap;
662 typedef TfHashMultiMap<SdfPath, SdfPath, SdfPath::Hash>
663 _PrototypeToInstancerMap;
664 _PrototypeToInstancerMap _prototypeToInstancerMap;
668 typedef std::unordered_map<SdfPath, SdfPath, SdfPath::Hash>
669 _ProtoPrimToInstancerMap;
670 _ProtoPrimToInstancerMap _protoPrimToInstancerMap;
673PXR_NAMESPACE_CLOSE_SCOPE
A basic mathematical interval class.
Stores a 4x4 matrix of double elements.
Basic type: 3-dimensional floating point range.
HighlightMode
Selection modes allow differentiation in selection highlight behavior.
A path value used to locate objects in layers or scenegraphs.
Represents a value type name, i.e.
Token for efficient comparison, assignment, and hashing of known strings.
This proxy class exposes a subset of the private Delegate API to PrimAdapters.
Delegate support for instanced prims.
USDIMAGING_API 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.
USDIMAGING_API SdfPathVector GetInstancerPrototypes(UsdPrim const &usdPrim, SdfPath const &cachePath) const override
Return the list of known prototypes of this prim.
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.
USDIMAGING_API 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.
USDIMAGING_API std::vector< VtArray< TfToken > > GetInstanceCategories(UsdPrim const &prim) override
Return an array of the categories used by each instance.
USDIMAGING_API bool GetDoubleSided(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
Reads double-sided from the given prim. If not authored, returns false.
USDIMAGING_API SdfPath GetScenePrimPath(SdfPath const &cachePath, int instanceIndex, HdInstancerContext *instancerContext) const override
USDIMAGING_API GfMatrix4d GetRelativeInstancerTransform(SdfPath const &parentInstancerPath, SdfPath const &instancerPath, UsdTimeCode time) const override
Returns the transform of protoInstancerPath relative to instancerPath.
USDIMAGING_API VtValue GetTopology(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
Gets the topology object of a specific Usd prim.
USDIMAGING_API 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...
USDIMAGING_API SdfPath Populate(UsdPrim const &prim, UsdImagingIndexProxy *index, UsdImagingInstancerContext const *instancerContext=nullptr) override
Called to populate the RenderIndex for this UsdPrim.
USDIMAGING_API HdCullStyle GetCullStyle(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
Gets the cullstyle of a specific path in the scene graph.
USDIMAGING_API 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.
USDIMAGING_API GfRange3d GetExtent(UsdPrim const &usdPrim, SdfPath const &cachePath, UsdTimeCode time) const override
Reads the extent from the given prim.
USDIMAGING_API PxOsdSubdivTags GetSubdivTags(UsdPrim const &usdPrim, SdfPath const &cachePath, UsdTimeCode time) const override
Get the subdiv tags for this prim.
USDIMAGING_API 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 ...
USDIMAGING_API 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.
USDIMAGING_API GfMatrix4d GetInstancerTransform(UsdPrim const &instancerPrim, SdfPath const &instancerPath, UsdTimeCode time) const override
Get the instancer transform for the given prim.
USDIMAGING_API 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.
USDIMAGING_API 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...
USDIMAGING_API void ProcessPrimRemoval(SdfPath const &cachePath, UsdImagingIndexProxy *index) override
Removes all associated Rprims and dependencies from the render index without scheduling them for repo...
USDIMAGING_API TfToken GetPurpose(UsdPrim const &usdPrim, SdfPath const &cachePath, TfToken const &instanceInheritablePurpose) const override
Returns the purpose token for prim.
USDIMAGING_API SdfPath GetInstancerId(UsdPrim const &usdPrim, SdfPath const &cachePath) const override
Return the instancerId for this prim.
USDIMAGING_API 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...
Base class for all PrimAdapters.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
A forward iterator into a UsdPrimRange.
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Object used by instancer prim adapters to pass along context about the instancer and instance prim to...