7#ifndef PXR_USD_USD_SKEL_BLEND_SHAPE_QUERY_H
8#define PXR_USD_USD_SKEL_BLEND_SHAPE_QUERY_H
13#include "pxr/usd/usdSkel/api.h"
15#include "pxr/usd/usdSkel/inbetweenShape.h"
22PXR_NAMESPACE_OPEN_SCOPE
41 bool IsValid()
const {
return bool(_prim); }
44 explicit operator bool()
const {
return IsValid(); }
58 size_t GetNumBlendShapes()
const {
return _blendShapes.size(); }
60 size_t GetNumSubShapes()
const {
return _subShapes.size(); }
67 USDSKEL_API std::vector<VtIntArray>
75 USDSKEL_API std::vector<VtVec3fArray>
85 USDSKEL_API std::vector<VtVec3fArray>
99 VtFloatArray* subShapeWeights,
100 VtUIntArray* blendShapeIndices,
101 VtUIntArray* subShapeIndices)
const;
107 VtFloatArray* subShapeWeights)
const;
120 const std::vector<VtIntArray>& blendShapePointIndices,
121 const std::vector<VtVec3fArray>& subShapePointOffsets,
137 const std::vector<VtIntArray>& blendShapePointIndices,
138 const std::vector<VtVec3fArray>& subShapeNormalOffsets,
154 VtVec2iArray* ranges)
const;
157 std::string GetDescription()
const;
163 _SubShape() =
default;
165 _SubShape(
unsigned blendShapeIndex,
int inbetweenIndex,
float weight)
166 : _blendShapeIndex(blendShapeIndex),
167 _inbetweenIndex(inbetweenIndex),
170 unsigned GetBlendShapeIndex()
const {
return _blendShapeIndex; }
172 int GetInbetweenIndex()
const {
return _inbetweenIndex; }
174 bool IsInbetween()
const {
return _inbetweenIndex >= 0; }
175 bool IsNullShape()
const {
return _weight == 0.0f; }
176 bool IsPrimaryShape()
const {
return _weight == 1.0f; }
178 float GetWeight()
const {
return _weight; }
181 unsigned _blendShapeIndex = 0;
182 int _inbetweenIndex = 0;
186 struct _SubShapeCompareByWeight {
187 bool operator()(
const _SubShape& lhs,
const _SubShape& rhs)
const
188 {
return lhs.GetWeight() < rhs.GetWeight(); }
190 bool operator()(
float lhs,
const _SubShape& rhs)
const
191 {
return lhs < rhs.GetWeight(); }
196 size_t firstSubShape = 0;
197 size_t numSubShapes = 0;
201 std::vector<_SubShape> _subShapes;
202 std::vector<_BlendShape> _blendShapes;
203 std::vector<UsdSkelInbetweenShape> _inbetweens;
206PXR_NAMESPACE_CLOSE_SCOPE
Represents a range of contiguous elements.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Provides API for authoring and extracting all the skinning-related data that lives in the "geometry h...
Describes a target blend shape, possibly containing inbetween shapes.
Helper class used to resolve blend shape weights, including inbetweens.
USDSKEL_API bool ComputePackedShapeTable(VtVec4fArray *offsets, VtVec2iArray *ranges) const
Compute a packed shape table combining all sub-shapes.
USDSKEL_API bool ComputeSubShapeWeights(const TfSpan< const float > &weights, VtFloatArray *subShapeWeights, VtUIntArray *blendShapeIndices, VtUIntArray *subShapeIndices) const
Compute the resolved weights for all sub-shapes bound to this prim.
USDSKEL_API std::vector< VtIntArray > ComputeBlendShapePointIndices() const
Compute an array holding the point indices of all shapes.
USDSKEL_API size_t GetBlendShapeIndex(size_t subShapeIndex) const
Returns the blend shape index corresponding to the i'th sub-shape.
USDSKEL_API bool ComputeDeformedNormals(const TfSpan< const float > subShapeWeights, const TfSpan< const unsigned > blendShapeIndices, const TfSpan< const unsigned > subShapeIndices, const std::vector< VtIntArray > &blendShapePointIndices, const std::vector< VtVec3fArray > &subShapeNormalOffsets, TfSpan< GfVec3f > noramls) const
Deform normals using the resolved sub-shapes given by subShapeWeights, blendShapeIndices and subShape...
USDSKEL_API std::vector< VtVec3fArray > ComputeSubShapePointOffsets() const
Compute an array holding the point offsets of all sub-shapes.
USDSKEL_API bool ComputeDeformedPoints(const TfSpan< const float > subShapeWeights, const TfSpan< const unsigned > blendShapeIndices, const TfSpan< const unsigned > subShapeIndices, const std::vector< VtIntArray > &blendShapePointIndices, const std::vector< VtVec3fArray > &subShapePointOffsets, TfSpan< GfVec3f > points) const
Deform points using the resolved sub-shapes given by subShapeWeights, blendShapeIndices and subShapeI...
bool IsValid() const
Return true if this query is valid.
USDSKEL_API std::vector< VtVec3fArray > ComputeSubShapeNormalOffsets() const
Compute an array holding the normal offsets of all sub-shapes.
USDSKEL_API UsdSkelInbetweenShape GetInbetween(size_t subShapeIndex) const
Returns the inbetween shape corresponding to sub-shape i, if any.
const UsdPrim & GetPrim() const
Returns the prim the blend shapes apply to.
USDSKEL_API bool ComputeFlattenedSubShapeWeights(const TfSpan< const float > &weights, VtFloatArray *subShapeWeights) const
Compute a flattened array of weights for all sub-shapes.
USDSKEL_API UsdSkelBlendShape GetBlendShape(size_t blendShapeIndex) const
Returns the blend shape corresponding to blendShapeIndex.
Schema wrapper for UsdAttribute for authoring and introspecting attributes that serve as inbetween sh...