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"
36PXR_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;
264 HdExtComputationInputDescriptorVector
265 GetExtComputationInputs(
UsdPrim const& prim,
271 HdExtComputationOutputDescriptorVector
272 GetExtComputationOutputs(
UsdPrim const& prim,
277 HdExtComputationPrimvarDescriptorVector
278 GetExtComputationPrimvars(
281 HdInterpolation interpolation,
285 GetExtComputationInput(
293 GetExtComputationKernel(
299 GetInstanceIndices(
UsdPrim const& instancerPrim,
300 SdfPath const& instancerCachePath,
301 SdfPath const& prototypeCachePath,
308 VtIntArray *outIndices)
const override;
315 SdfPath const &parentInstancerPath,
326 HdInstancerContext *instancerContext)
const override;
328 virtual SdfPathVector GetScenePrimPaths(
330 std::vector<int>
const& instanceIndices,
331 std::vector<HdInstancerContext> *instancerCtxs)
const override;
333 virtual bool PopulateSelection(
337 int const hydraInstanceIndex,
338 VtIntArray
const &parentInstanceIndices,
339 HdSelectionSharedPtr
const &result)
const override;
345 virtual HdVolumeFieldDescriptorVector
346 GetVolumeFieldDescriptors(
UsdPrim const& usdPrim,
SdfPath const &
id,
350 virtual void _RemovePrim(
SdfPath const& cachePath,
358 SdfPath const& parentProxyPath);
362 struct _InstancerData;
364 bool _IsChildPrim(
UsdPrim const& prim,
365 SdfPath const& cachePath)
const;
368 bool _PrimIsInstancer(
UsdPrim const& prim)
const;
380 UsdImagingPrimAdapterSharedPtr
const& primAdapter,
381 UsdImagingPrimAdapterSharedPtr
const& instancerAdapter,
383 bool *isLeafInstancer);
386 void _ResyncPath(
SdfPath const& cachePath,
391 void _ResyncInstancer(
SdfPath const& instancerPath,
396 struct _ComputeInstanceMapFn;
397 VtIntArray _ComputeInstanceMap(
UsdPrim const& instancerPrim,
398 _InstancerData
const& instrData,
405 struct _ComputeInstanceMapVariabilityFn;
406 bool _ComputeInstanceMapVariability(
UsdPrim const& instancerPrim,
407 _InstancerData
const& instrData)
const;
411 _ProtoPrim
const& _GetProtoPrim(
SdfPath const& instancerPath,
417 bool _GetProtoPrimForChild(
420 _ProtoPrim
const** proto,
425 struct _ComputeInstanceTransformFn;
426 bool _ComputeInstanceTransforms(
UsdPrim const& instancer,
427 VtMatrix4dArray* transforms,
431 struct _GatherInstanceTransformTimeSamplesFn;
432 bool _GatherInstanceTransformsTimeSamples(
UsdPrim const& instancer,
434 std::vector<double>* outTimes)
438 struct _GatherInstancePrimvarTimeSamplesFn;
439 bool _GatherInstancePrimvarTimeSamples(
UsdPrim const& instancer,
442 std::vector<double>* outTimes)
447 struct _IsInstanceTransformVaryingFn;
448 bool _IsInstanceTransformVarying(
UsdPrim const& instancer)
const;
453 template<
typename T>
struct _ComputeInheritedPrimvarFn;
456 bool _ComputeInheritedPrimvar(
UsdPrim const& instancer,
461 bool _ComputeInheritedPrimvar(
UsdPrim const& instancer,
469 struct _IsInstanceInheritedPrimvarVaryingFn;
470 bool _IsInstanceInheritedPrimvarVarying(
UsdPrim const& instancer)
const;
472 struct _PopulateInstanceSelectionFn;
473 struct _GetScenePrimPathsFn;
474 struct _GetInstanceCategoriesFn;
503 template <
typename Functor>
504 void _RunForAllInstancesToDraw(
UsdPrim const& instancer, Functor* fn)
const;
505 template <
typename Functor>
506 bool _RunForAllInstancesToDrawImpl(
UsdPrim const& instancer,
507 std::vector<UsdPrim>* instanceContext,
511 typedef TfHashMap<SdfPath, size_t, SdfPath::Hash> _InstancerDrawCounts;
512 size_t _CountAllInstancesToDraw(
UsdPrim const& instancer)
const;
513 size_t _CountAllInstancesToDrawImpl(
UsdPrim const& instancer,
514 _InstancerDrawCounts* drawCounts)
const;
525 UsdImagingPrimAdapterSharedPtr adapter;
529 typedef TfHashMap<SdfPath, _ProtoPrim, SdfPath::Hash> _PrimMap;
534 struct _InstancerData {
535 _InstancerData() : numInstancesToDraw(0), refresh(false) { }
554 bool operator==(
const PrimvarInfo& rhs)
const;
555 bool operator<(
const PrimvarInfo& rhs)
const;
557 std::vector<PrimvarInfo> inheritedPrimvars;
561 SdfPathSet instancePaths;
568 mutable size_t numInstancesToDraw;
581 mutable std::vector<Visibility> visibility;
589 SdfPathSet childPointInstancers;
592 SdfPathVector nestedInstances;
595 SdfPathVector parentInstances;
600 mutable bool refresh;
607 typedef std::unordered_map<SdfPath, _InstancerData, SdfPath::Hash>
609 _InstancerDataMap _instancerData;
615 typedef TfHashMap<SdfPath, SdfPath, SdfPath::Hash>
616 _InstanceToInstancerMap;
617 _InstanceToInstancerMap _instanceToInstancerMap;
639 typedef TfHashMultiMap<SdfPath, SdfPath, SdfPath::Hash>
640 _PrototypeToInstancerMap;
641 _PrototypeToInstancerMap _prototypeToInstancerMap;
645 typedef std::unordered_map<SdfPath, SdfPath, SdfPath::Hash>
646 _ProtoPrimToInstancerMap;
647 _ProtoPrimToInstancerMap _protoPrimToInstancerMap;
651PXR_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.
bool GetDoubleSided(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
Reads double-sided from the given prim. If not authored, returns false.
virtual GfMatrix4d GetRelativeInstancerTransform(SdfPath const &parentInstancerPath, SdfPath const &instancerPath, UsdTimeCode time) const override
Returns the transform of protoInstancerPath relative to instancerPath.
PxOsdSubdivTags GetSubdivTags(UsdPrim const &usdPrim, SdfPath const &cachePath, UsdTimeCode time) const override
Get the subdiv tags for this prim.
GfRange3d GetExtent(UsdPrim const &usdPrim, SdfPath const &cachePath, UsdTimeCode time) const override
Reads the extent from the given prim.
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.
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.
HdCullStyle GetCullStyle(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
Gets the cullstyle of a specific path in the scene graph.
SdfPath GetInstancerId(UsdPrim const &usdPrim, SdfPath const &cachePath) const override
Return the instancerId for this prim.
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 ...
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...
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.
TfToken GetPurpose(UsdPrim const &usdPrim, SdfPath const &cachePath, TfToken const &instanceInheritablePurpose) const override
Returns the purpose token for 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.
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...
VtValue GetTopology(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
Gets the topology object of a specific Usd prim.
std::vector< VtArray< TfToken > > GetInstanceCategories(UsdPrim const &prim) override
Return an array of the categories used by each instance.
virtual void ProcessPrimRemoval(SdfPath const &cachePath, UsdImagingIndexProxy *index) override
Removes all associated Rprims and dependencies from the render index without scheduling them for repo...
virtual SdfPath Populate(UsdPrim const &prim, UsdImagingIndexProxy *index, UsdImagingInstancerContext const *instancerContext=nullptr) override
Called to populate the RenderIndex for this UsdPrim.
GfMatrix4d GetInstancerTransform(UsdPrim const &instancerPrim, SdfPath const &instancerPath, UsdTimeCode time) const override
Get the instancer 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.
virtual SdfPath GetScenePrimPath(SdfPath const &cachePath, int instanceIndex, HdInstancerContext *instancerContext) const override
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...
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.
SdfPathVector GetInstancerPrototypes(UsdPrim const &usdPrim, SdfPath const &cachePath) const override
Return the list of known prototypes of this prim.
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...