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>
24PXR_NAMESPACE_OPEN_SCOPE
47 instancerContext=
nullptr)
override;
60 HdDirtyBits* timeVaryingBits,
62 instancerContext =
nullptr)
const override;
69 HdDirtyBits requestedBits,
71 instancerContext=
nullptr)
const override;
80 const TfToken& propertyName)
override;
91 void MarkDirty(
const UsdPrim& prim,
97 void MarkRefineLevelDirty(
UsdPrim const& prim,
102 void MarkReprDirty(
UsdPrim const& prim,
107 void MarkCullStyleDirty(
UsdPrim const& prim,
112 void MarkRenderTagDirty(
UsdPrim const& prim,
117 void MarkTransformDirty(
const UsdPrim& prim,
122 void MarkVisibilityDirty(
const UsdPrim& prim,
127 void MarkMaterialDirty(
const UsdPrim& prim,
135 void InvokeComputation(
SdfPath const& cachePath,
167 TfToken const& instanceInheritablePurpose)
184 SdfPath const& cachePath)
const override;
187 HdExtComputationInputDescriptorVector
188 GetExtComputationInputs(
UsdPrim const& prim,
194 HdExtComputationOutputDescriptorVector
195 GetExtComputationOutputs(
UsdPrim const& prim,
201 HdExtComputationPrimvarDescriptorVector
202 GetExtComputationPrimvars(
205 HdInterpolation interpolation,
210 GetExtComputationInput(
219 SampleExtComputationInput(
225 size_t maxSampleCount,
227 VtValue *sampleValues)
override;
231 GetExtComputationKernel(
242 VtIntArray *outIndices)
const override;
253 TfToken const &subprim)
override;
256 HdContainerDataSourceHandle GetImagingSubprimData(
266 UsdImagingPropertyInvalidationType invalidationType)
override;
272 void _RemovePrim(
const SdfPath& cachePath,
279 bool _IsCallbackForSkeleton(
const UsdPrim& prim)
const;
288 float _GetSkeletonDisplayOpacity(
const UsdPrim& prim,
291 void _TrackBoneMeshVariability(
294 HdDirtyBits* timeVaryingBits,
296 instancerContext =
nullptr)
const;
298 void _UpdateBoneMeshForTime(
302 HdDirtyBits requestedBits,
308 bool _IsAffectedByTimeVaryingSkelAnim(
const SdfPath& skinnedPrimPath)
311 void _RemoveSkinnedPrimAndComputations(
const SdfPath& cachePath,
317 bool _IsSkinningComputationPath(
const SdfPath& cachePath)
const;
320 _IsSkinningInputAggregatorComputationPath(
const SdfPath& cachePath)
const;
322 void _TrackSkinningComputationVariability(
324 const SdfPath& computationPath,
325 HdDirtyBits* timeVaryingBits,
327 instancerContext =
nullptr)
const;
329 VtVec3fArray _GetSkinnedPrimPoints(
const UsdPrim& skinnedPrim,
330 const SdfPath& skinnedPrimCachePath,
333 SdfPath _GetSkinningComputationPath(
const SdfPath& skinnedPrimPath)
const;
335 SdfPath _GetSkinningInputAggregatorComputationPath(
336 const SdfPath& skinnedPrimPath)
const;
340 std::string _LoadSkinningComputeKernel(
const TfToken& kernelKey);
343 const std::string& _GetLBSSkinningComputeKernel();
346 const std::string& _GetDQSSkinningComputeKernel();
351 bool _IsSkinnedPrimPath(
const SdfPath& cachePath)
const;
353 void _TrackSkinnedPrimVariability(
356 HdDirtyBits* timeVaryingBits,
358 instancerContext =
nullptr)
const;
360 void _UpdateSkinnedPrimForTime(
364 HdDirtyBits requestedBits,
372 _GetExtComputationInputForSkinningComputation(
380 _GetExtComputationInputForInputAggregator(
388 _SampleExtComputationInputForSkinningComputation(
394 size_t maxSampleCount,
399 _SampleExtComputationInputForInputAggregator(
405 size_t maxSampleCount,
421 SdfPathSet skelRootPaths;
428 VtVec3fArray ComputePoints(
UsdTimeCode time)
const;
432 TfToken ComputePurpose()
const;
437 VtVec3fArray _boneMeshPoints;
438 VtIntArray _boneMeshJointIndices;
442 _SkelData* _GetSkelData(
const SdfPath& cachePath)
const;
446 std::unordered_map<SdfPath, std::shared_ptr<_SkelData>, SdfPath::Hash>;
447 _SkelDataMap _skelDataCache;
450 struct _SkinnedPrimData {
451 _SkinnedPrimData() =
default;
456 _SkinnedPrimData(
const SdfPath& skelPath,
461 std::shared_ptr<UsdSkelBlendShapeQuery> blendShapeQuery;
464 SdfPath skelPath, skelRootPath;
465 bool hasJointInfluences =
false;
468 const _SkinnedPrimData* _GetSkinnedPrimData(
const SdfPath& cachePath)
const;
470 using _SkinnedPrimDataMap =
471 std::unordered_map<SdfPath, _SkinnedPrimData, SdfPath::Hash>;
472 _SkinnedPrimDataMap _skinnedPrimDataCache;
479 using _SkelBindingMap =
480 std::unordered_map<SdfPath, UsdSkelBinding, SdfPath::Hash>;
481 _SkelBindingMap _skelBindingMap;
485PXR_NAMESPACE_CLOSE_SCOPE
Basic type: 3-dimensional floating point range.
Basic type for a vector of 3 float components.
Represents a set of data source locators closed under descendancy.
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 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.
An abstract adapter class for prims that are instanceable.
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.
Prim adapter for UsdSkel's Skeleton.
USDSKELIMAGING_API void ProcessPrimResync(SdfPath const &primPath, UsdImagingIndexProxy *index) override
When a PrimResync event occurs, the prim may have been deleted entirely, adapter plug-ins should over...
USDSKELIMAGING_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...
USDSKELIMAGING_API TfToken GetPurpose(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &instanceInheritablePurpose) const override
Returns the purpose token for prim.
USDSKELIMAGING_API SdfPath Populate(const UsdPrim &prim, UsdImagingIndexProxy *index, const UsdImagingInstancerContext *instancerContext=nullptr) override
Called to populate the RenderIndex for this UsdPrim.
USDSKELIMAGING_API VtValue GetTopology(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
Gets the topology object of a specific Usd prim.
USDSKELIMAGING_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.
USDSKELIMAGING_API PxOsdSubdivTags GetSubdivTags(UsdPrim const &usdPrim, SdfPath const &cachePath, UsdTimeCode time) const override
Get the subdiv tags for this prim.
USDSKELIMAGING_API void ProcessPrimRemoval(SdfPath const &primPath, UsdImagingIndexProxy *index) override
Removes all associated Rprims and dependencies from the render index without scheduling them for repo...
USDSKELIMAGING_API HdDirtyBits ProcessPropertyChange(const UsdPrim &prim, const SdfPath &cachePath, const TfToken &propertyName) override
Returns a bit mask of attributes to be updated, or HdChangeTracker::AllDirty if the entire prim must ...
USDSKELIMAGING_API bool IsSupported(const UsdImagingIndexProxy *index) const override
Returns true if the adapter can be populated into the target index.
USDSKELIMAGING_API GfRange3d GetExtent(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
Reads the extent from the given prim.
USDSKELIMAGING_API void TrackVariability(const UsdPrim &prim, const SdfPath &cachePath, HdDirtyBits *timeVaryingBits, const UsdImagingInstancerContext *instancerContext=nullptr) const override
Thread Safe.
USDSKELIMAGING_API void UpdateForTime(const UsdPrim &prim, const SdfPath &cachePath, UsdTimeCode time, HdDirtyBits requestedBits, const UsdImagingInstancerContext *instancerContext=nullptr) const override
Thread Safe.
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.