24#ifndef PXR_USD_IMAGING_USD_IMAGING_INSTANCE_ADAPTER_H
25#define PXR_USD_IMAGING_USD_IMAGING_INSTANCE_ADAPTER_H
30#include "pxr/usdImaging/usdImaging/api.h"
33#include "pxr/base/tf/hashmap.h"
37PXR_NAMESPACE_OPEN_SCOPE
104 bool ShouldCullChildren()
const override;
107 bool IsInstancerAdapter()
const override;
116 HdDirtyBits* timeVaryingBits,
118 instancerContext = NULL)
const override;
124 HdDirtyBits requestedBits,
126 instancerContext = NULL)
const override;
148 void MarkDirty(
UsdPrim const& prim,
157 void MarkRefineLevelDirty(
UsdPrim const& prim,
162 void MarkReprDirty(
UsdPrim const& prim,
167 void MarkCullStyleDirty(
UsdPrim const& prim,
172 void MarkRenderTagDirty(
UsdPrim const& prim,
177 void MarkTransformDirty(
UsdPrim const& prim,
182 void MarkVisibilityDirty(
UsdPrim const& prim,
202 SdfPath const& cachePath)
const override;
207 SdfPath const& cachePath)
const override;
213 size_t maxSampleCount,
221 size_t maxNumSamples,
230 size_t maxNumSamples,
233 VtIntArray *sampleIndices)
override;
239 TfToken const& instanceInheritablePurpose)
const override;
262 bool IsChildPath(
const SdfPath& path)
const override;
277 bool ignoreRootTransform =
false)
const override;
298 HdExtComputationInputDescriptorVector
299 GetExtComputationInputs(
UsdPrim const& prim,
306 HdExtComputationOutputDescriptorVector
307 GetExtComputationOutputs(
UsdPrim const& prim,
313 HdExtComputationPrimvarDescriptorVector
314 GetExtComputationPrimvars(
317 HdInterpolation interpolation,
322 GetExtComputationInput(
331 GetExtComputationKernel(
338 GetInstanceIndices(
UsdPrim const& instancerPrim,
339 SdfPath const& instancerCachePath,
340 SdfPath const& prototypeCachePath,
348 VtIntArray *outIndices)
const override;
356 SdfPath const &parentInstancerPath,
368 HdInstancerContext *instancerContext)
const override;
371 SdfPathVector GetScenePrimPaths(
373 std::vector<int>
const& instanceIndices,
374 std::vector<HdInstancerContext> *instancerCtxs)
const override;
377 bool PopulateSelection(
381 int const hydraInstanceIndex,
382 VtIntArray
const &parentInstanceIndices,
383 HdSelectionSharedPtr
const &result)
const override;
390 HdVolumeFieldDescriptorVector
391 GetVolumeFieldDescriptors(
UsdPrim const& usdPrim,
SdfPath const &
id,
396 void _RemovePrim(
SdfPath const& cachePath,
404 SdfPath const& parentProxyPath);
408 struct _InstancerData;
410 bool _IsChildPrim(
UsdPrim const& prim,
411 SdfPath const& cachePath)
const;
414 bool _PrimIsInstancer(
UsdPrim const& prim)
const;
421 const UsdImagingPrimAdapterSharedPtr& primAdapter,
426 void _ResyncPath(
SdfPath const& cachePath,
431 void _ResyncInstancer(
SdfPath const& instancerPath,
436 struct _ComputeInstanceMapFn;
437 VtIntArray _ComputeInstanceMap(
UsdPrim const& instancerPrim,
438 _InstancerData
const& instrData,
445 struct _ComputeInstanceMapVariabilityFn;
446 bool _ComputeInstanceMapVariability(
UsdPrim const& instancerPrim,
447 _InstancerData
const& instrData)
const;
451 _ProtoPrim
const& _GetProtoPrim(
SdfPath const& instancerPath,
457 bool _GetProtoPrimForChild(
460 _ProtoPrim
const** proto,
465 struct _ComputeInstanceTransformFn;
466 bool _ComputeInstanceTransforms(
UsdPrim const& instancer,
467 VtMatrix4dArray* transforms,
471 struct _GatherInstanceTransformTimeSamplesFn;
472 bool _GatherInstanceTransformsTimeSamples(
UsdPrim const& instancer,
474 std::vector<double>* outTimes)
478 struct _GatherInstancePrimvarTimeSamplesFn;
479 bool _GatherInstancePrimvarTimeSamples(
UsdPrim const& instancer,
482 std::vector<double>* outTimes)
487 struct _IsInstanceTransformVaryingFn;
488 bool _IsInstanceTransformVarying(
UsdPrim const& instancer)
const;
493 template<
typename T>
struct _ComputeInheritedPrimvarFn;
496 bool _ComputeInheritedPrimvar(
UsdPrim const& instancer,
501 bool _ComputeInheritedPrimvar(
UsdPrim const& instancer,
509 struct _IsInstanceInheritedPrimvarVaryingFn;
510 bool _IsInstanceInheritedPrimvarVarying(
UsdPrim const& instancer)
const;
512 struct _PopulateInstanceSelectionFn;
513 struct _GetScenePrimPathsFn;
514 struct _GetInstanceCategoriesFn;
543 template <
typename Functor>
544 void _RunForAllInstancesToDraw(
UsdPrim const& instancer, Functor* fn)
const;
545 template <
typename Functor>
546 bool _RunForAllInstancesToDrawImpl(
UsdPrim const& instancer,
547 std::vector<UsdPrim>* instanceContext,
551 typedef TfHashMap<SdfPath, size_t, SdfPath::Hash> _InstancerDrawCounts;
552 size_t _CountAllInstancesToDraw(
UsdPrim const& instancer)
const;
553 size_t _CountAllInstancesToDrawImpl(
UsdPrim const& instancer,
554 _InstancerDrawCounts* drawCounts)
const;
565 UsdImagingPrimAdapterSharedPtr adapter;
569 typedef TfHashMap<SdfPath, _ProtoPrim, SdfPath::Hash> _PrimMap;
574 struct _InstancerData {
575 _InstancerData() : numInstancesToDraw(0), refresh(false) { }
594 bool operator==(
const PrimvarInfo& rhs)
const;
595 bool operator<(
const PrimvarInfo& rhs)
const;
597 std::vector<PrimvarInfo> inheritedPrimvars;
601 SdfPathSet instancePaths;
608 mutable size_t numInstancesToDraw;
621 mutable std::vector<Visibility> visibility;
629 SdfPathSet childPointInstancers;
632 SdfPathVector nestedInstances;
635 SdfPathVector parentInstances;
640 mutable bool refresh;
647 typedef std::unordered_map<SdfPath, _InstancerData, SdfPath::Hash>
649 _InstancerDataMap _instancerData;
655 typedef TfHashMap<SdfPath, SdfPath, SdfPath::Hash>
656 _InstanceToInstancerMap;
657 _InstanceToInstancerMap _instanceToInstancerMap;
679 typedef TfHashMultiMap<SdfPath, SdfPath, SdfPath::Hash>
680 _PrototypeToInstancerMap;
681 _PrototypeToInstancerMap _prototypeToInstancerMap;
685 typedef std::unordered_map<SdfPath, SdfPath, SdfPath::Hash>
686 _ProtoPrimToInstancerMap;
687 _ProtoPrimToInstancerMap _protoPrimToInstancerMap;
690PXR_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...