24 #ifndef PXR_USD_IMAGING_USD_IMAGING_PRIM_ADAPTER_H 25 #define PXR_USD_IMAGING_USD_IMAGING_PRIM_ADAPTER_H 30 #include "pxr/usdImaging/usdImaging/api.h" 31 #include "pxr/usdImaging/usdImaging/version.h" 36 #include "pxr/imaging/hd/changeTracker.h" 37 #include "pxr/imaging/hd/selection.h" 38 #include "pxr/usd/usd/attribute.h" 40 #include "pxr/usd/usd/timeCode.h" 44 #include "pxr/base/tf/type.h" 48 PXR_NAMESPACE_OPEN_SCOPE
60 using UsdImagingPrimAdapterSharedPtr =
61 std::shared_ptr<class UsdImagingPrimAdapter>;
68 :
public std::enable_shared_from_this<UsdImagingPrimAdapter>
89 virtual HdContainerDataSourceHandle GetImagingSubprimData(
109 instancerContext =
nullptr) = 0;
114 static bool ShouldCullSubtree(
UsdPrim const& prim);
120 virtual bool ShouldCullChildren()
const;
125 virtual bool ShouldIgnoreNativeInstanceSubtrees()
const;
131 virtual bool IsInstancerAdapter()
const;
162 virtual bool CanPopulateUsdInstance()
const;
175 HdDirtyBits* timeVaryingBits,
177 instancerContext =
nullptr)
const = 0;
186 HdDirtyBits requestedBits,
188 instancerContext =
nullptr)
const = 0;
213 TfToken const& propertyName) = 0;
229 virtual void MarkDirty(
UsdPrim const& prim,
235 virtual void MarkRefineLevelDirty(
UsdPrim const& prim,
240 virtual void MarkReprDirty(
UsdPrim const& prim,
245 virtual void MarkCullStyleDirty(
UsdPrim const& prim,
250 virtual void MarkRenderTagDirty(
UsdPrim const& prim,
255 virtual void MarkTransformDirty(
UsdPrim const& prim,
260 virtual void MarkVisibilityDirty(
UsdPrim const& prim,
265 virtual void MarkMaterialDirty(
UsdPrim const& prim,
270 virtual void MarkLightParamsDirty(
UsdPrim const& prim,
275 virtual void MarkWindowPolicyDirty(
UsdPrim const& prim,
280 virtual void MarkCollectionsDirty(
UsdPrim const& prim,
288 virtual void InvokeComputation(
SdfPath const& cachePath,
297 virtual std::vector<VtArray<TfToken>>
315 size_t maxNumSamples,
323 SdfPath const& cachePath)
const;
329 SdfPath const& cachePath)
const;
342 size_t maxNumSamples,
345 VtIntArray *sampleIndices);
366 SdfPath const &protoInstancerPath,
377 HdInstancerContext *instancerCtx)
const;
380 virtual SdfPathVector GetScenePrimPaths(
SdfPath const& cachePath,
381 std::vector<int>
const& instanceIndices,
382 std::vector<HdInstancerContext> *instancerCtxs)
const;
410 virtual bool PopulateSelection(
414 int const hydraInstanceIndex,
415 VtIntArray
const &parentInstanceIndices,
416 HdSelectionSharedPtr
const &result)
const;
423 virtual HdVolumeFieldDescriptorVector
424 GetVolumeFieldDescriptors(
UsdPrim const& usdPrim,
SdfPath const &
id,
440 bool IsChildPath(
SdfPath const& path)
const;
459 TfToken const& instanceInheritablePurpose)
const;
475 bool ignoreRootTransform =
false)
const;
482 size_t maxNumSamples,
495 VtIntArray *outIndices)
const;
558 virtual const TfTokenVector &GetExtComputationSceneInputNames(
559 SdfPath const& cachePath)
const;
562 virtual HdExtComputationInputDescriptorVector
563 GetExtComputationInputs(
UsdPrim const& prim,
569 virtual HdExtComputationOutputDescriptorVector
570 GetExtComputationOutputs(
UsdPrim const& prim,
576 virtual HdExtComputationPrimvarDescriptorVector
577 GetExtComputationPrimvars(
580 HdInterpolation interpolation,
585 GetExtComputationInput(
594 SampleExtComputationInput(
600 size_t maxSampleCount,
606 GetExtComputationKernel(
613 GetInstanceIndices(
UsdPrim const& instancerPrim,
614 SdfPath const& instancerCachePath,
615 SdfPath const& prototypeCachePath,
628 using Keys = UsdImagingPrimvarDescCache::Key;
630 template <
typename T>
638 template <
typename T>
647 UsdImaging_NonlinearSampleCountCache*
648 _GetNonlinearSampleCountCache()
const;
650 UsdImaging_BlurScaleCache*
651 _GetBlurScaleCache()
const;
661 const UsdImagingPrimAdapterSharedPtr&
662 _GetPrimAdapter(
UsdPrim const& prim,
bool ignoreInstancing =
false)
const;
665 const UsdImagingPrimAdapterSharedPtr&
666 _GetAdapter(
TfToken const& adapterKey)
const;
675 SdfPath _GetPrimPathFromInstancerChain(
676 SdfPathVector
const& instancerChain)
const;
679 UsdTimeCode _GetTimeWithOffset(
float offset)
const;
683 SdfPath _ConvertCachePathToIndexPath(
SdfPath const& cachePath)
const;
687 SdfPath _ConvertIndexPathToCachePath(
SdfPath const& indexPath)
const;
691 TfToken _GetMaterialBindingPurpose()
const;
708 bool _IsPrimvarFilteringNeeded()
const;
717 bool _IsInInvisedPaths(
SdfPath const& usdPath)
const;
730 HdDirtyBits dirtyFlag,
TfToken const& perfToken,
731 HdDirtyBits* dirtyFlags,
bool isInherited,
732 bool* exists =
nullptr)
const;
741 bool _IsTransformVarying(
UsdPrim prim,
742 HdDirtyBits dirtyFlag,
744 HdDirtyBits* dirtyFlags)
const;
750 HdPrimvarDescriptorVector* vec,
752 HdInterpolation interp,
754 bool indexed =
false)
const;
759 HdPrimvarDescriptorVector* vec,
767 void _ComputeAndMergePrimvar(
771 HdPrimvarDescriptorVector* primvarDescs,
772 HdInterpolation *interpOverride =
nullptr)
const;
776 static bool _HasPrimvarsPrefix(
TfToken const& propertyName);
788 HdDirtyBits _ProcessNonPrefixedPrimvarPropertyChange(
793 HdInterpolation
const& primvarInterp,
794 HdDirtyBits valueChangeDirtyBit = HdChangeTracker::DirtyPrimvar)
const;
799 HdDirtyBits _ProcessPrefixedPrimvarPropertyChange(
803 HdDirtyBits valueChangeDirtyBit = HdChangeTracker::DirtyPrimvar,
804 bool inherited =
true)
const;
806 virtual void _RemovePrim(
SdfPath const& cachePath,
813 void _ResyncDependents(
SdfPath const& usdPath,
817 UsdImaging_CollectionCache& _GetCollectionCache()
const;
820 UsdStageRefPtr _GetStage()
const;
823 UsdImaging_CoordSysBindingStrategy::value_type
824 _GetCoordSysBindings(
UsdPrim const& prim)
const;
827 UsdImaging_InheritedPrimvarStrategy::value_type
828 _GetInheritedPrimvars(
UsdPrim const& prim)
const;
833 TfToken const& primvarName)
const;
839 Usd_PrimFlagsConjunction _GetDisplayPredicate()
const;
842 Usd_PrimFlagsConjunction _GetDisplayPredicateForPrototypes()
const;
845 bool _DoesDelegateSupportCoordSys()
const;
849 static HdInterpolation _UsdToHdInterpolation(
TfToken const& usdInterp);
859 virtual UsdImagingPrimAdapterSharedPtr New()
const = 0;
863 class UsdImagingPrimAdapterFactory :
public UsdImagingPrimAdapterFactoryBase {
865 virtual UsdImagingPrimAdapterSharedPtr New()
const 867 return std::make_shared<T>();
872 PXR_NAMESPACE_CLOSE_SCOPE
874 #endif // PXR_USD_IMAGING_USD_IMAGING_PRIM_ADAPTER_H USDIMAGING_API TfToken GetInheritablePurpose(UsdPrim const &prim) const
Returns the purpose token for prim, but only if it is inheritable by child prims (i....
USDIMAGING_API SdfPath GetMaterialUsdPath(UsdPrim const &prim) const
Gets the material path for the given prim, walking up namespace if necessary.
Interface class that defines the execution environment for the client to run a computation.
bool Get(T *value, UsdTimeCode time=UsdTimeCode::Default()) const
Perform value resolution to fetch the value of this attribute at the requested UsdTimeCode time,...
Basic type: 3-dimensional floating point range.
USDIMAGING_API VtArray< VtIntArray > GetPerPrototypeIndices(UsdPrim const &prim, UsdTimeCode time) const
Computes the per-prototype instance indices for a UsdGeomPointInstancer.
virtual USDIMAGING_API GfMatrix4d GetInstancerTransform(UsdPrim const &instancerPrim, SdfPath const &instancerPath, UsdTimeCode time) const
Get the instancer transform for the given prim.
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 ...
USDIMAGING_API bool _GetSceneLightsEnabled() const
Returns whether lights found in the usdscene are enabled.
virtual USDIMAGING_API PxOsdSubdivTags GetSubdivTags(UsdPrim const &usdPrim, SdfPath const &cachePath, UsdTimeCode time) const
Get the subdiv tags for this prim.
HighlightMode
Selection modes allow differentiation in selection highlight behavior.
This proxy class exposes a subset of the private Delegate API to PrimAdapters.
USDIMAGING_API void SetDelegate(UsdImagingDelegate *delegate)
A thread-local XformCache provided by the delegate.
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 SdfPath GetInstancerId(UsdPrim const &usdPrim, SdfPath const &cachePath) const
Return the instancerId for this prim.
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...
Base class of all factory types.
USD_API UsdAttribute GetAttribute(const TfToken &attrName) const
Return a UsdAttribute with the name attrName.
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.
Token for efficient comparison, assignment, and hashing of known strings.
virtual USDIMAGING_API GfRange3d GetExtent(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
Reads the extent from the given prim.
Stores a 4x4 matrix of double elements.
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
This class is used as a context object with global stage information, that gets passed down to dataso...
Base class for all PrimAdapters.
USDIMAGING_API TfToken GetModelDrawMode(UsdPrim const &prim)
Gets the model:drawMode attribute for the given prim, walking up the namespace if necessary.
Represents a set of data source locators closed under descendancy.
virtual USDIMAGING_API GfMatrix4d GetRelativeInstancerTransform(SdfPath const &instancerPath, SdfPath const &protoInstancerPath, UsdTimeCode time) const
Returns the transform of protoInstancerPath relative to instancerPath.
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.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
std::vector< TfToken > TfTokenVector
Convenience types.
A basic mathematical interval class.
Represents an arbitrary dimensional rectangular container class.
A path value used to locate objects in layers or scenegraphs.
A cache for primvar descriptors.
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.
virtual USDIMAGING_API SdfPath GetScenePrimPath(SdfPath const &cachePath, int instanceIndex, HdInstancerContext *instancerCtx) const
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 USDIMAGING_API VtValue GetTopology(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
Gets the topology object of a specific Usd prim.
virtual USDIMAGING_API TfToken GetPurpose(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &instanceInheritablePurpose) const
Returns the purpose token for 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.
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.
Object used by instancer prim adapters to pass along context about the instancer and instance prim to...
Schema wrapper for UsdAttribute for authoring and introspecting attributes that are primvars.
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...
USDIMAGING_API bool _GetSceneMaterialsEnabled() const
Returns whether custom shading of prims is enabled.
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 SdfPath Populate(UsdPrim const &prim, UsdImagingIndexProxy *index, UsdImagingInstancerContext const *instancerContext=nullptr)=0
Called to populate the RenderIndex for this UsdPrim.
The primary translation layer between the Hydra (Hd) core and the Usd scene graph.
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...
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 bool IsSupported(UsdImagingIndexProxy const *index) const
Returns true if the adapter can be populated into the target index.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
USDIMAGING_API GfMatrix4d GetRootTransform() const
The root transform provided by the delegate.
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 SdfPathVector GetInstancerPrototypes(UsdPrim const &usdPrim, SdfPath const &cachePath) const
Return the list of known prototypes of this prim.
virtual USDIMAGING_API std::vector< VtArray< TfToken > > GetInstanceCategories(UsdPrim const &prim)
Return an array of the categories used by each instance.