7#ifndef PXR_USD_IMAGING_USD_SKEL_IMAGING_SKELETON_ADAPTER_H
8#define PXR_USD_IMAGING_USD_SKEL_IMAGING_SKELETON_ADAPTER_H
11#include "pxr/usdImaging/usdImaging/instanceablePrimAdapter.h"
12#include "pxr/usdImaging/usdSkelImaging/api.h"
14#include "pxr/imaging/hd/meshTopology.h"
22#include <unordered_map>
25PXR_NAMESPACE_OPEN_SCOPE
37 UsdSkelImagingSkeletonAdapter()
42 virtual ~UsdSkelImagingSkeletonAdapter();
49 instancerContext=
nullptr)
override;
62 HdDirtyBits* timeVaryingBits,
64 instancerContext =
nullptr)
const override;
71 HdDirtyBits requestedBits,
73 instancerContext=
nullptr)
const override;
82 const TfToken& propertyName)
override;
93 void MarkDirty(
const UsdPrim& prim,
99 void MarkRefineLevelDirty(
UsdPrim const& prim,
104 void MarkReprDirty(
UsdPrim const& prim,
109 void MarkCullStyleDirty(
UsdPrim const& prim,
114 void MarkRenderTagDirty(
UsdPrim const& prim,
119 void MarkTransformDirty(
const UsdPrim& prim,
124 void MarkVisibilityDirty(
const UsdPrim& prim,
129 void MarkMaterialDirty(
const UsdPrim& prim,
137 void InvokeComputation(
SdfPath const& cachePath,
169 TfToken const& instanceInheritablePurpose)
186 SdfPath const& cachePath)
const override;
189 HdExtComputationInputDescriptorVector
190 GetExtComputationInputs(
UsdPrim const& prim,
196 HdExtComputationOutputDescriptorVector
197 GetExtComputationOutputs(
UsdPrim const& prim,
203 HdExtComputationPrimvarDescriptorVector
204 GetExtComputationPrimvars(
207 HdInterpolation interpolation,
212 GetExtComputationInput(
221 SampleExtComputationInput(
227 size_t maxSampleCount,
229 VtValue *sampleValues)
override;
233 GetExtComputationKernel(
244 VtIntArray *outIndices)
const override;
250 void _RemovePrim(
const SdfPath& cachePath,
257 bool _IsCallbackForSkeleton(
const UsdPrim& prim)
const;
266 float _GetSkeletonDisplayOpacity(
const UsdPrim& prim,
269 void _TrackBoneMeshVariability(
272 HdDirtyBits* timeVaryingBits,
274 instancerContext =
nullptr)
const;
276 void _UpdateBoneMeshForTime(
280 HdDirtyBits requestedBits,
286 bool _IsAffectedByTimeVaryingSkelAnim(
const SdfPath& skinnedPrimPath)
289 void _RemoveSkinnedPrimAndComputations(
const SdfPath& cachePath,
295 bool _IsSkinningComputationPath(
const SdfPath& cachePath)
const;
298 _IsSkinningInputAggregatorComputationPath(
const SdfPath& cachePath)
const;
300 void _TrackSkinningComputationVariability(
302 const SdfPath& computationPath,
303 HdDirtyBits* timeVaryingBits,
305 instancerContext =
nullptr)
const;
307 VtVec3fArray _GetSkinnedPrimPoints(
const UsdPrim& skinnedPrim,
308 const SdfPath& skinnedPrimCachePath,
311 SdfPath _GetSkinningComputationPath(
const SdfPath& skinnedPrimPath)
const;
313 SdfPath _GetSkinningInputAggregatorComputationPath(
314 const SdfPath& skinnedPrimPath)
const;
318 std::string _LoadSkinningComputeKernel(
const TfToken& kernelKey);
321 const std::string& _GetLBSSkinningComputeKernel();
324 const std::string& _GetDQSSkinningComputeKernel();
329 bool _IsSkinnedPrimPath(
const SdfPath& cachePath)
const;
331 void _TrackSkinnedPrimVariability(
334 HdDirtyBits* timeVaryingBits,
336 instancerContext =
nullptr)
const;
338 void _UpdateSkinnedPrimForTime(
342 HdDirtyBits requestedBits,
350 _GetExtComputationInputForSkinningComputation(
358 _GetExtComputationInputForInputAggregator(
366 _SampleExtComputationInputForSkinningComputation(
372 size_t maxSampleCount,
377 _SampleExtComputationInputForInputAggregator(
383 size_t maxSampleCount,
395 SdfPathSet skelRootPaths;
402 VtVec3fArray ComputePoints(
UsdTimeCode time)
const;
406 TfToken ComputePurpose()
const;
411 VtVec3fArray _boneMeshPoints;
412 VtIntArray _boneMeshJointIndices;
416 _SkelData* _GetSkelData(
const SdfPath& cachePath)
const;
420 std::unordered_map<SdfPath, std::shared_ptr<_SkelData>, SdfPath::Hash>;
421 _SkelDataMap _skelDataCache;
424 struct _SkinnedPrimData {
425 _SkinnedPrimData() =
default;
430 _SkinnedPrimData(
const SdfPath& skelPath,
435 std::shared_ptr<UsdSkelBlendShapeQuery> blendShapeQuery;
438 SdfPath skelPath, skelRootPath;
439 bool hasJointInfluences =
false;
442 const _SkinnedPrimData* _GetSkinnedPrimData(
const SdfPath& cachePath)
const;
444 using _SkinnedPrimDataMap =
445 std::unordered_map<SdfPath, _SkinnedPrimData, SdfPath::Hash>;
446 _SkinnedPrimDataMap _skinnedPrimDataCache;
453 using _SkelBindingMap =
454 std::unordered_map<SdfPath, UsdSkelBinding, SdfPath::Hash>;
455 _SkelBindingMap _skelBindingMap;
459PXR_NAMESPACE_CLOSE_SCOPE
Basic type: 3-dimensional floating point range.
Basic type for a vector of 3 float components.
Interface class that defines the execution environment for the client to run a computation.
Topology data for meshes.
A path value used to locate objects in layers or scenegraphs.
Token for efficient comparison, assignment, and hashing of known strings.
This proxy class exposes a subset of the private Delegate API to PrimAdapters.
An abstract adapter class for prims that are instanceable.
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 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.
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.
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 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 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 bool GetDoubleSided(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
Reads double-sided from the given prim. If not authored, returns false.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Class providing efficient queries of primitives that provide skel animation.
Helper object that describes the binding of a skeleton to a set of skinnable objects.
Thread-safe cache for accessing query objects for evaluating skeletal data.
Primary interface to reading bound skeleton data.
Object used for querying resolved bindings for skinning.
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.