24#ifndef PXR_USD_IMAGING_USD_IMAGING_POINT_INSTANCER_ADAPTER_H
25#define PXR_USD_IMAGING_USD_IMAGING_POINT_INSTANCER_ADAPTER_H
29#include "pxr/usdImaging/usdImaging/api.h"
30#include "pxr/usdImaging/usdImaging/instanceablePrimAdapter.h"
32#include "pxr/usd/sdf/path.h"
41PXR_NAMESPACE_OPEN_SCOPE
57 bool ShouldCullChildren()
const override;
60 bool IsInstancerAdapter()
const override;
72 TfToken const& subprim)
override;
75 HdContainerDataSourceHandle GetImagingSubprimData(
85 UsdImagingPropertyInvalidationType invalidationType)
override;
94 HdDirtyBits* timeVaryingBits,
96 instancerContext = NULL)
const override;
102 HdDirtyBits requestedBits,
104 instancerContext = NULL)
const override;
125 void MarkDirty(
UsdPrim const& prim,
131 void MarkRefineLevelDirty(
UsdPrim const& prim,
136 void MarkReprDirty(
UsdPrim const& prim,
141 void MarkCullStyleDirty(
UsdPrim const& prim,
146 void MarkRenderTagDirty(
UsdPrim const& prim,
151 void MarkTransformDirty(
UsdPrim const& prim,
156 void MarkVisibilityDirty(
UsdPrim const& prim,
161 void MarkLightParamsDirty(
167 void MarkCollectionsDirty(
185 size_t maxNumSamples,
192 SdfPath const& cachePath)
const override;
197 SdfPath const& cachePath)
const override;
203 bool ignoreRootTransform =
false)
const override;
209 size_t maxNumSamples,
218 size_t maxNumSamples,
221 VtIntArray *sampleIndices)
override;
237 TfToken const& instanceInheritablePurpose)
const override;
279 HdExtComputationInputDescriptorVector
280 GetExtComputationInputs(
UsdPrim const& prim,
286 HdExtComputationOutputDescriptorVector
287 GetExtComputationOutputs(
UsdPrim const& prim,
293 HdExtComputationPrimvarDescriptorVector
294 GetExtComputationPrimvars(
297 HdInterpolation interpolation,
302 GetExtComputationInput(
311 GetExtComputationKernel(
318 GetInstanceIndices(
UsdPrim const& instancerPrim,
319 SdfPath const& instancerCachePath,
320 SdfPath const& prototypeCachePath,
328 VtIntArray *outIndices)
const override;
337 SdfPath const &protoInstancerPath,
348 HdInstancerContext *instancerContext)
const override;
351 SdfPathVector GetScenePrimPaths(
353 std::vector<int>
const& instanceIndices,
354 std::vector<HdInstancerContext> *instancerCtxs)
const override;
357 bool PopulateSelection(
361 int const hydraInstanceIndex,
362 VtIntArray
const &parentInstanceIndices,
363 HdSelectionSharedPtr
const &result)
const override;
370 HdVolumeFieldDescriptorVector
371 GetVolumeFieldDescriptors(
UsdPrim const& usdPrim,
SdfPath const &
id,
395 void _RemovePrim(
SdfPath const& cachePath,
400 struct _InstancerData;
406 void _PopulatePrototype(
int protoIndex,
407 _InstancerData& instrData,
414 void _ProcessPrimRemoval(
SdfPath const& cachePath,
416 SdfPathVector* instancersToReload);
419 void _UnloadInstancer(
SdfPath const& instancerPath,
423 void _UpdateInstancerVisibility(
SdfPath const& instancerPath,
424 _InstancerData
const& instrData,
433 _ProtoPrim
const& _GetProtoPrim(
SdfPath const& instancerPath,
434 SdfPath const& cachePath)
const;
441 bool _GetProtoPrimForChild(
444 _ProtoPrim
const** proto,
448 const UsdPrim _GetProtoUsdPrim(_ProtoPrim
const& proto)
const;
456 SdfPathVector
const& protoPathChain,
463 void _ComputeProtoVisibility(
UsdPrim const& protoRoot,
486 _ProtoPrim() : variabilityBits(0), visible(true) {}
492 UsdImagingPrimAdapterSharedPtr adapter;
500 mutable HdDirtyBits variabilityBits;
504 mutable bool visible;
508 typedef std::unordered_map<SdfPath, _ProtoPrim, SdfPath::Hash> _ProtoPrimMap;
513 struct _InstancerData {
515 SdfPath parentInstancerCachePath;
516 _ProtoPrimMap protoPrimMap;
517 SdfPathVector prototypePaths;
520 PathToIndexMap prototypePathIndices;
527 mutable std::mutex mutex;
528 mutable bool variableVisibility;
529 mutable bool visible;
531 mutable std::atomic_bool initialized = std::atomic_bool(
false);
537 typedef std::unordered_map<
SdfPath ,
539 SdfPath::Hash> _InstancerDataMap;
540 mutable _InstancerDataMap _instancerData;
542 inline static std::atomic_int _globalVariantCounter = std::atomic_int(0);
545PXR_NAMESPACE_CLOSE_SCOPE
Stores a 4x4 matrix of double elements.
Basic type: 3-dimensional floating point range.
Represents a set of data source locators closed under descendancy.
HighlightMode
Selection modes allow differentiation in selection highlight behavior.
A path value used to locate objects in layers or scenegraphs.
This is a space efficient container that mimics the TfHashMap API that uses a vector for storage when...
Token for efficient comparison, assignment, and hashing of known strings.
This class is used as a context object with global stage information, that gets passed down to dataso...
This proxy class exposes a subset of the private Delegate API to PrimAdapters.
Delegate support for instanced prims.
An abstract adapter class for prims that are instanceable.
Delegate support for UsdGeomPointInstancer.
USDIMAGING_API bool GetVisible(UsdPrim const &prim, 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 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.
USDIMAGING_API size_t SampleInstancerTransform(UsdPrim const &instancerPrim, SdfPath const &instancerPath, UsdTimeCode time, size_t maxNumSamples, float *sampleTimes, GfMatrix4d *sampleValues) override
Sample the instancer transform for the given prim.
USDIMAGING_API SdfPath GetScenePrimPath(SdfPath const &cachePath, int instanceIndex, HdInstancerContext *instancerContext) const override
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 bool GetDoubleSided(UsdPrim const &usdPrim, SdfPath const &cachePath, UsdTimeCode time) const override
Reads double-sided from the given prim. If not authored, returns false.
USDIMAGING_API GfMatrix4d GetRelativeInstancerTransform(SdfPath const &instancerPath, SdfPath const &protoInstancerPath, UsdTimeCode time) const override
Returns the transform of protoInstancerPath relative to instancerPath.
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...
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
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...
std::vector< TfToken > TfTokenVector
Convenience types.