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,
276 enum class _ComputationType : uint8_t {
284 bool _IsCallbackForSkeleton(
const UsdPrim& prim)
const;
293 float _GetSkeletonDisplayOpacity(
const UsdPrim& prim,
296 void _TrackBoneMeshVariability(
299 HdDirtyBits* timeVaryingBits,
301 instancerContext =
nullptr)
const;
303 void _UpdateBoneMeshForTime(
307 HdDirtyBits requestedBits,
313 bool _IsAffectedByTimeVaryingSkelAnim(
const SdfPath& skinnedPrimPath)
316 void _RemoveSkinnedPrimAndComputations(
const SdfPath& cachePath,
322 bool _IsSkinningPointsComputationPath(
const SdfPath& cachePath)
const;
324 bool _IsSkinningNormalsComputationPath(
const SdfPath& cachePath)
const;
326 _ComputationType _GetSkinningComputationType(
327 const SdfPath& cachePath)
const;
329 bool _IsSkinningPointsInputAggregatorComputationPath(
330 const SdfPath& cachePath)
const;
332 bool _IsSkinningNormalsInputAggregatorComputationPath(
333 const SdfPath& cachePath)
const;
335 void _TrackSkinningComputationVariability(
337 const SdfPath& computationPath,
338 HdDirtyBits* timeVaryingBits,
340 instancerContext =
nullptr)
const;
342 VtVec3fArray _GetSkinnedPrimPoints(
const UsdPrim& skinnedPrim,
343 const SdfPath& skinnedPrimCachePath,
346 VtVec3fArray _GetSkinnedPrimNormals(
const UsdPrim& skinnedPrim,
347 const SdfPath& skinnedPrimCachePath,
350 VtIntArray _GetSkinnedPrimFaceVertexIndices(
const UsdPrim& skinnedPrim,
351 const SdfPath& skinnedPrimCachePath,
354 SdfPath _GetSkinningComputationPath(
355 const SdfPath& skinnedPrimPath,
356 _ComputationType computationType)
const;
358 SdfPath _GetSkinningInputAggregatorComputationPath(
359 const SdfPath& skinnedPrimPath,
360 _ComputationType computationType)
const;
364 std::string _LoadSkinningComputeKernel(
const TfToken& kernelKey);
367 const std::string& _GetLBSSkinningComputeKernel(
368 _ComputationType computationType);
371 const std::string& _GetDQSSkinningComputeKernel(
372 _ComputationType computationType);
377 bool _IsSkinnedPrimPath(
const SdfPath& cachePath)
const;
379 void _TrackSkinnedPrimVariability(
382 HdDirtyBits* timeVaryingBits,
384 instancerContext =
nullptr)
const;
386 void _UpdateSkinnedPrimForTime(
390 HdDirtyBits requestedBits,
398 _GetExtComputationInputForSkinningComputation(
406 _GetExtComputationInputForInputAggregator(
414 _SampleExtComputationInputForSkinningComputation(
420 size_t maxSampleCount,
425 _SampleExtComputationInputForInputAggregator(
431 size_t maxSampleCount,
444 _ExtractSkinningScaleXforms(
445 const VtMatrix4fArray& skinningXforms,
446 _ComputationType computationType,
447 VtMatrix3fArray* skinningScaleXforms);
451 _ExtractSkinningDualQuats(
452 const VtMatrix4fArray& skinningXforms,
453 _ComputationType computationType,
454 VtVec4fArray* skinningDualQuats);
463 SdfPathSet skelRootPaths;
470 VtVec3fArray ComputePoints(
UsdTimeCode time)
const;
474 TfToken ComputePurpose()
const;
479 VtVec3fArray _boneMeshPoints;
480 VtIntArray _boneMeshJointIndices;
484 _SkelData* _GetSkelData(
const SdfPath& cachePath)
const;
488 std::unordered_map<SdfPath, std::shared_ptr<_SkelData>, SdfPath::Hash>;
489 _SkelDataMap _skelDataCache;
492 struct _SkinnedPrimData {
493 _SkinnedPrimData() =
default;
498 _SkinnedPrimData(
const SdfPath& skelPath,
504 std::shared_ptr<UsdSkelBlendShapeQuery> blendShapeQuery;
507 SdfPath skelPath, skelRootPath;
508 bool hasJointInfluences =
false;
512 const _SkinnedPrimData* _GetSkinnedPrimData(
const SdfPath& cachePath)
const;
514 using _SkinnedPrimDataMap =
515 std::unordered_map<SdfPath, _SkinnedPrimData, SdfPath::Hash>;
516 _SkinnedPrimDataMap _skinnedPrimDataCache;
523 using _SkelBindingMap =
524 std::unordered_map<SdfPath, UsdSkelBinding, SdfPath::Hash>;
525 _SkelBindingMap _skelBindingMap;
529PXR_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.