7#ifndef PXR_USD_IMAGING_USD_IMAGING_PRIM_ADAPTER_H
8#define PXR_USD_IMAGING_USD_IMAGING_PRIM_ADAPTER_H
13#include "pxr/usdImaging/usdImaging/api.h"
14#include "pxr/usdImaging/usdImaging/version.h"
18#include "pxr/usdImaging/usdImaging/types.h"
20#include "pxr/imaging/hd/changeTracker.h"
21#include "pxr/imaging/hd/selection.h"
22#include "pxr/usd/sdf/path.h"
23#include "pxr/usd/usd/attribute.h"
25#include "pxr/usd/usd/timeCode.h"
29#include "pxr/base/tf/type.h"
33PXR_NAMESPACE_OPEN_SCOPE
45using UsdImagingPrimAdapterSharedPtr =
46 std::shared_ptr<class UsdImagingPrimAdapter>;
53 :
public std::enable_shared_from_this<UsdImagingPrimAdapter>
67 virtual TfToken GetImagingSubprimType(
71 virtual HdContainerDataSourceHandle GetImagingSubprimData(
81 UsdImagingPropertyInvalidationType invalidationType);
125 UsdImagingPropertyInvalidationType invalidationType);
137 instancerContext =
nullptr) = 0;
142 static bool ShouldCullSubtree(
UsdPrim const& prim);
148 virtual bool ShouldCullChildren()
const;
153 virtual bool ShouldIgnoreNativeInstanceSubtrees()
const;
159 virtual bool IsInstancerAdapter()
const;
190 virtual bool CanPopulateUsdInstance()
const;
203 HdDirtyBits* timeVaryingBits,
205 instancerContext =
nullptr)
const = 0;
214 HdDirtyBits requestedBits,
216 instancerContext =
nullptr)
const = 0;
241 TfToken const& propertyName) = 0;
257 virtual void MarkDirty(
UsdPrim const& prim,
263 virtual void MarkRefineLevelDirty(
UsdPrim const& prim,
268 virtual void MarkReprDirty(
UsdPrim const& prim,
273 virtual void MarkCullStyleDirty(
UsdPrim const& prim,
278 virtual void MarkRenderTagDirty(
UsdPrim const& prim,
283 virtual void MarkTransformDirty(
UsdPrim const& prim,
288 virtual void MarkVisibilityDirty(
UsdPrim const& prim,
293 virtual void MarkMaterialDirty(
UsdPrim const& prim,
298 virtual void MarkLightParamsDirty(
UsdPrim const& prim,
303 virtual void MarkWindowPolicyDirty(
UsdPrim const& prim,
308 virtual void MarkCollectionsDirty(
UsdPrim const& prim,
316 virtual void InvokeComputation(
SdfPath const& cachePath,
325 virtual std::vector<VtArray<TfToken>>
343 size_t maxNumSamples,
351 SdfPath const& cachePath)
const;
357 SdfPath const& cachePath)
const;
370 size_t maxNumSamples,
373 VtIntArray *sampleIndices);
394 SdfPath const &protoInstancerPath,
405 HdInstancerContext *instancerCtx)
const;
408 virtual SdfPathVector GetScenePrimPaths(
SdfPath const& cachePath,
409 std::vector<int>
const& instanceIndices,
410 std::vector<HdInstancerContext> *instancerCtxs)
const;
438 virtual bool PopulateSelection(
442 int const hydraInstanceIndex,
443 VtIntArray
const &parentInstanceIndices,
444 HdSelectionSharedPtr
const &result)
const;
451 virtual HdVolumeFieldDescriptorVector
452 GetVolumeFieldDescriptors(
UsdPrim const& usdPrim,
SdfPath const &
id,
492 virtual bool IsChildPath(
const SdfPath& path)
const;
511 TfToken const& instanceInheritablePurpose)
const;
527 bool ignoreRootTransform =
false)
const;
534 size_t maxNumSamples,
547 VtIntArray *outIndices)
const;
615 virtual const TfTokenVector &GetExtComputationSceneInputNames(
616 SdfPath const& cachePath)
const;
619 virtual HdExtComputationInputDescriptorVector
620 GetExtComputationInputs(
UsdPrim const& prim,
626 virtual HdExtComputationOutputDescriptorVector
627 GetExtComputationOutputs(
UsdPrim const& prim,
633 virtual HdExtComputationPrimvarDescriptorVector
634 GetExtComputationPrimvars(
637 HdInterpolation interpolation,
642 GetExtComputationInput(
651 SampleExtComputationInput(
657 size_t maxSampleCount,
663 GetExtComputationKernel(
670 GetInstanceIndices(
UsdPrim const& instancerPrim,
671 SdfPath const& instancerCachePath,
672 SdfPath const& prototypeCachePath,
710 using Keys = UsdImagingPrimvarDescCache::Key;
712 template <
typename T>
720 template <
typename T>
730 UsdImaging_NonlinearSampleCountCache*
731 _GetNonlinearSampleCountCache()
const;
734 UsdImaging_BlurScaleCache*
735 _GetBlurScaleCache()
const;
745 const UsdImagingPrimAdapterSharedPtr&
746 _GetPrimAdapter(
UsdPrim const& prim,
bool ignoreInstancing =
false)
const;
749 const UsdImagingPrimAdapterSharedPtr&
750 _GetAdapter(
TfToken const& adapterKey)
const;
759 SdfPath _GetPrimPathFromInstancerChain(
760 SdfPathVector
const& instancerChain)
const;
763 UsdTimeCode _GetTimeWithOffset(
float offset)
const;
767 SdfPath _ConvertCachePathToIndexPath(
SdfPath const& cachePath)
const;
771 SdfPath _ConvertIndexPathToCachePath(
SdfPath const& indexPath)
const;
775 TfToken _GetMaterialBindingPurpose()
const;
797 bool _IsPrimvarFilteringNeeded()
const;
806 bool _IsInInvisedPaths(
SdfPath const& usdPath)
const;
819 HdDirtyBits dirtyFlag,
TfToken const& perfToken,
820 HdDirtyBits* dirtyFlags,
bool isInherited,
821 bool* exists =
nullptr)
const;
830 bool _IsTransformVarying(
UsdPrim prim,
831 HdDirtyBits dirtyFlag,
833 HdDirtyBits* dirtyFlags)
const;
839 HdPrimvarDescriptorVector* vec,
841 HdInterpolation interp,
843 bool indexed =
false)
const;
848 HdPrimvarDescriptorVector* vec,
856 void _ComputeAndMergePrimvar(
860 HdPrimvarDescriptorVector* primvarDescs,
861 HdInterpolation *interpOverride =
nullptr)
const;
865 static bool _HasPrimvarsPrefix(
TfToken const& propertyName);
877 HdDirtyBits _ProcessNonPrefixedPrimvarPropertyChange(
882 HdInterpolation
const& primvarInterp,
883 HdDirtyBits valueChangeDirtyBit = HdChangeTracker::DirtyPrimvar)
const;
888 HdDirtyBits _ProcessPrefixedPrimvarPropertyChange(
892 HdDirtyBits valueChangeDirtyBit = HdChangeTracker::DirtyPrimvar,
893 bool inherited =
true)
const;
895 virtual void _RemovePrim(
SdfPath const& cachePath,
902 void _ResyncDependents(
SdfPath const& usdPath,
906 UsdImaging_CollectionCache& _GetCollectionCache()
const;
909 UsdStageRefPtr _GetStage()
const;
912 UsdImaging_CoordSysBindingStrategy::value_type
913 _GetCoordSysBindings(
UsdPrim const& prim)
const;
916 UsdImaging_InheritedPrimvarStrategy::value_type
917 _GetInheritedPrimvars(
UsdPrim const& prim)
const;
922 TfToken const& primvarName)
const;
928 Usd_PrimFlagsConjunction _GetDisplayPredicate()
const;
931 Usd_PrimFlagsConjunction _GetDisplayPredicateForPrototypes()
const;
934 bool _DoesDelegateSupportCoordSys()
const;
942 virtual UsdImagingPrimAdapterSharedPtr New()
const = 0;
946class UsdImagingPrimAdapterFactory :
public UsdImagingPrimAdapterFactoryBase {
948 virtual UsdImagingPrimAdapterSharedPtr New()
const
950 return std::make_shared<T>();
954PXR_NAMESPACE_CLOSE_SCOPE
A basic mathematical interval class.
Stores a 4x4 matrix of double elements.
Basic type: 3-dimensional floating point range.
Represents a set of data source locators closed under descendancy.
Interface class that defines the execution environment for the client to run a computation.
HighlightMode
Selection modes allow differentiation in selection highlight behavior.
A path value used to locate objects in layers or scenegraphs.
Token for efficient comparison, assignment, and hashing of known strings.
Base class of all factory types.
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
bool Get(T *value, UsdTimeCode time=UsdTimeCode::Default()) const
Perform value resolution to fetch the value of this attribute at the requested UsdTimeCode time,...
Schema wrapper for UsdAttribute for authoring and introspecting attributes that are primvars.
This class is used as a context object with global stage information, that gets passed down to dataso...
The primary translation layer between the Hydra (Hd) core and the Usd scene graph.
This proxy class exposes a subset of the private Delegate API to PrimAdapters.
Delegate support for instanced prims.
Delegate support for UsdGeomPointInstancer.
Base class for all PrimAdapters.
virtual USDIMAGING_API void ProcessPrimResync(SdfPath const &cachePath, UsdImagingIndexProxy *index)
When a PrimResync event occurs, the prim may have been deleted entirely, adapter plug-ins should over...
USDIMAGING_API SdfPath GetMaterialUsdPath(UsdPrim const &prim) const
Gets the material path for the given prim, walking up namespace if necessary.
virtual USDIMAGING_API VtValue Get(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &key, UsdTimeCode time, VtIntArray *outIndices) const
Gets the value of the parameter named key for the given prim (which has the given cache path) and giv...
virtual HdDirtyBits ProcessPropertyChange(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &propertyName)=0
Returns a bit mask of attributes to be updated, or HdChangeTracker::AllDirty if the entire prim must ...
virtual USDIMAGING_API GfMatrix4d GetTransform(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, bool ignoreRootTransform=false) const
Fetches the transform for the given prim at the given time from a pre-computed cache of prim transfor...
virtual USDIMAGING_API HdCullStyle GetCullStyle(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
Gets the cullstyle of a specific path in the scene graph.
USDIMAGING_API VtArray< VtIntArray > GetPerPrototypeIndices(UsdPrim const &prim, UsdTimeCode time) const
Computes the per-prototype instance indices for a UsdGeomPointInstancer.
USDIMAGING_API HdModelDrawMode GetFullModelDrawMode(UsdPrim const &prim)
Gets the model draw mode object for the given prim, walking up the namespace if necessary.
USDIMAGING_API void SetDelegate(UsdImagingDelegate *delegate)
A thread-local XformCache provided by the delegate.
virtual USDIMAGING_API GfMatrix4d GetRelativeInstancerTransform(SdfPath const &instancerPath, SdfPath const &protoInstancerPath, UsdTimeCode time) const
Returns the transform of protoInstancerPath relative to instancerPath.
virtual 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)
Sample the primvar for the given prim.
virtual USDIMAGING_API PopulationMode GetPopulationMode()
Returns the prim's behavior with regard to population and invalidation.
virtual USDIMAGING_API size_t SampleTransform(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, size_t maxNumSamples, float *sampleTimes, GfMatrix4d *sampleValues)
Samples the transform for the given prim.
virtual SdfPath Populate(UsdPrim const &prim, UsdImagingIndexProxy *index, UsdImagingInstancerContext const *instancerContext=nullptr)=0
Called to populate the RenderIndex for this UsdPrim.
virtual USDIMAGING_API SdfPathVector GetInstancerPrototypes(UsdPrim const &usdPrim, SdfPath const &cachePath) const
Return the list of known prototypes of this prim.
virtual USDIMAGING_API GfMatrix4d GetInstancerTransform(UsdPrim const &instancerPrim, SdfPath const &instancerPath, UsdTimeCode time) const
Get the instancer transform for the given prim.
virtual void TrackVariability(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits *timeVaryingBits, UsdImagingInstancerContext const *instancerContext=nullptr) const =0
For the given prim, variability is detected and stored in timeVaryingBits.
USDIMAGING_API TfToken GetInheritablePurpose(UsdPrim const &prim) const
Returns the purpose token for prim, but only if it is inheritable by child prims (i....
virtual USDIMAGING_API void ProcessPrimRemoval(SdfPath const &cachePath, UsdImagingIndexProxy *index)
Removes all associated Rprims and dependencies from the render index without scheduling them for repo...
virtual USDIMAGING_API bool GetVisible(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
Returns true if the given prim is visible, taking into account inherited visibility values.
virtual USDIMAGING_API std::vector< VtArray< TfToken > > GetInstanceCategories(UsdPrim const &prim)
Return an array of the categories used by each instance.
virtual USDIMAGING_API HdDirtyBits ProcessPrimChange(UsdPrim const &prim, SdfPath const &cachePath, TfTokenVector const &changedFields)
Returns a bit mask of attributes to be updated, or HdChangeTracker::AllDirty if the entire prim must ...
virtual USDIMAGING_API VtValue GetTopology(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
Gets the topology object of a specific Usd prim.
USDIMAGING_API GfMatrix4d GetRootTransform() const
The root transform provided by the delegate.
virtual USDIMAGING_API TfToken GetPurpose(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &instanceInheritablePurpose) const
Returns the purpose token for prim.
static USDIMAGING_API UsdAttribute LookupLightParamAttribute(UsdPrim const &prim, TfToken const ¶mName)
Provides to paramName->UsdAttribute value mappings.
virtual bool IsSupported(UsdImagingIndexProxy const *index) const
Returns true if the adapter can be populated into the target index.
virtual USDIMAGING_API GfRange3d GetExtent(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
Reads the extent from the given prim.
virtual void UpdateForTime(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, HdDirtyBits requestedBits, UsdImagingInstancerContext const *instancerContext=nullptr) const =0
Populates the cache for the given prim, time and requestedBits.
virtual USDIMAGING_API PxOsdSubdivTags GetSubdivTags(UsdPrim const &usdPrim, SdfPath const &cachePath, UsdTimeCode time) const
Get the subdiv tags for this prim.
virtual USDIMAGING_API size_t SampleInstancerTransform(UsdPrim const &instancerPrim, SdfPath const &instancerPath, UsdTimeCode time, size_t maxNumSamples, float *sampleTimes, GfMatrix4d *sampleValues)
Sample the instancer transform for the given prim.
USDIMAGING_API bool _GetSceneLightsEnabled() const
Returns whether lights found in the usdscene are enabled.
USDIMAGING_API TfToken GetModelDrawMode(UsdPrim const &prim)
Gets the model:drawMode attribute for the given prim, walking up the namespace if necessary.
virtual USDIMAGING_API HdDataSourceLocatorSet InvalidateImagingSubprimFromDescendent(UsdPrim const &prim, UsdPrim const &descendentPrim, TfToken const &subprim, TfTokenVector const &properties, UsdImagingPropertyInvalidationType invalidationType)
This is called (for each result of GetImagingSubprims) when this adapter's GetScope() result is Repre...
virtual USDIMAGING_API SdfPath GetInstancerId(UsdPrim const &usdPrim, SdfPath const &cachePath) const
Return the instancerId for this prim.
virtual USDIMAGING_API bool GetDoubleSided(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
Reads double-sided from the given prim. If not authored, returns false.
USDIMAGING_API bool _GetSceneMaterialsEnabled() const
Returns whether custom shading of prims is enabled.
@ RepresentsSelfAndDescendents
The adapter is responsible for USD prims of its registered type as well as any descendents of those p...
@ RepresentedByAncestor
Changes to prims of this adapter's registered type are sent to the first ancestor prim whose adapter'...
@ RepresentsSelf
The adapter is responsible only for USD prims of its registered type.
virtual USDIMAGING_API SdfPath GetScenePrimPath(SdfPath const &cachePath, int instanceIndex, HdInstancerContext *instancerCtx) const
A cache for primvar descriptors.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
USD_API UsdAttribute GetAttribute(const TfToken &attrName) const
Return a UsdAttribute with the name attrName.
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Represents an arbitrary dimensional rectangular container class.
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...
Describes optional alternative imaging behavior for prims.
std::vector< TfToken > TfTokenVector
Convenience types.