26#include <axel/BoundingBox.h>
31#include <unordered_set>
43 [[nodiscard]]
size_t size()
const {
48 [[nodiscard]]
bool empty()
const {
75template <
typename T,
typename SdfColl
iderType = SDFColl
iderT<
float>>
86 const std::vector<SdfColliderType>& sdfColliders,
87 const std::vector<int>& participatingVertices = {},
88 const std::vector<T>& vertexWeights = {},
89 bool filterRestPoseIntersections =
true,
90 uint8_t maxCollisionsPerVertex = 1);
115 int& usedRows) override;
129 return activeVertexIndices_.size();
133 return boneCollisionPairs_.size();
139 void organizeVerticesByBone(
140 const std::vector<int>& participatingVertices,
141 const std::vector<T>& weights);
143 void initializeBoneCollisionPairs(
bool filterRestPoseIntersections);
145 [[nodiscard]]
bool testRestPoseIntersection(
147 size_t sdfColliderIndex,
155 size_t sdfColliderIndex,
158 [[nodiscard]] axel::BoundingBox<T> computeBoneBoundingBox(
162 [[nodiscard]] axel::BoundingBox<T> computeColliderWorldBoundingBox(
163 size_t sdfColliderIndex,
166 void accumulateJointGradient(
169 const Eigen::Vector3<T>& posd,
170 const Eigen::Vector3<T>& direction,
171 Eigen::Ref<Eigen::VectorX<T>> gradient)
const;
173 void accumulateJointJacobian(
176 const Eigen::Vector3<T>& posd,
177 const Eigen::Vector3<T>& direction,
178 Eigen::Ref<Eigen::MatrixX<T>> jacobianRow)
const;
180 void accumulateColliderHierarchyGradient(
182 size_t colliderParent,
183 size_t commonAncestor,
184 const Eigen::Vector3<T>& sdfSurfacePoint,
185 const Eigen::Vector3<T>& direction,
186 Eigen::Ref<Eigen::VectorX<T>> gradient)
const;
188 void accumulateColliderHierarchyJacobian(
190 size_t colliderParent,
191 size_t commonAncestor,
192 const Eigen::Vector3<T>& sdfSurfacePoint,
193 const Eigen::Vector3<T>& direction,
194 Eigen::Ref<Eigen::MatrixX<T>> jacobianRow)
const;
197 std::vector<SdfColliderType> sdfColliders_;
199 std::vector<size_t> activeVertexIndices_;
200 std::vector<BoneVertexRange> boneVertexRanges_;
201 std::vector<T> vertexWeights_;
203 std::vector<BoneCollisionPairT<T>> boneCollisionPairs_;
205 uint8_t maxCollisionsPerVertex_ = 1;
207 std::vector<bool> activePairs_;
208 std::vector<uint8_t> collisionCounts_;
209 std::vector<axel::BoundingBox<T>> boneBBoxCache_;
210 std::vector<bool> boneBBoxValid_;
211 std::vector<axel::BoundingBox<T>> sdfBBoxCache_;
227template <
typename T,
typename SdfColl
iderType>
230 const std::vector<SdfColliderType>& sdfColliders,
231 const std::vector<int>& participatingVertices,
232 const std::vector<T>& vertexWeights,
233 bool filterRestPoseIntersections,
234 uint8_t maxCollisionsPerVertex)
236 character_(character),
237 sdfColliders_(sdfColliders),
238 maxCollisionsPerVertex_(maxCollisionsPerVertex) {
239 MT_CHECK_NOTNULL(character_.mesh,
"Character must have a mesh for SDF collision detection");
241 character_.skinWeights,
"Character must have skin weights for SDF collision detection");
242 MT_CHECK(!sdfColliders_.empty(),
"Must provide at least one SDF collider");
243 MT_CHECK(maxCollisionsPerVertex_ > 0,
"maxCollisionsPerVertex must be positive");
244 MT_CHECK(maxCollisionsPerVertex_ <= 255,
"maxCollisionsPerVertex must be <= 255");
245 organizeVerticesByBone(participatingVertices, vertexWeights);
246 initializeBoneCollisionPairs(filterRestPoseIntersections);
249template <
typename T,
typename SdfColl
iderType>
250void SDFCollisionErrorFunctionT<T, SdfColliderType>::organizeVerticesByBone(
251 const std::vector<int>& participatingVertices,
252 const std::vector<T>& weights) {
253 std::vector<int> vertices;
254 if (participatingVertices.empty()) {
255 vertices.reserve(character_.mesh->vertices.size());
256 for (
int i = 0; i < static_cast<int>(character_.mesh->vertices.size()); ++i) {
257 vertices.push_back(i);
260 vertices = participatingVertices;
263 for (
int vertexIndex : vertices) {
265 vertexIndex >= 0 && vertexIndex <
static_cast<int>(character_.mesh->vertices.size()),
266 "Invalid vertex index: {} (mesh has {} vertices)",
268 character_.mesh->vertices.size());
271 std::vector<T> vertexWeights;
272 if (weights.empty()) {
273 vertexWeights.assign(vertices.size(), T(1));
276 weights.size() == vertices.size(),
277 "Weight count ({}) must match vertex count ({})",
280 vertexWeights = weights;
289 std::vector<VertexInfo> vertexInfos;
290 vertexInfos.reserve(vertices.size());
293 const auto& skinWeights = *character_.skinWeights;
295 for (
size_t i = 0; i < vertices.size(); ++i) {
296 const int vertexIndex = vertices[i];
297 const T weight = vertexWeights[i];
298 const size_t primaryBone = skinWeights.index(vertexIndex, 0);
299 MT_CHECK(primaryBone < character_.skeleton.joints.size());
300 vertexInfos.push_back({
static_cast<size_t>(vertexIndex), weight, primaryBone});
303 std::sort(vertexInfos.begin(), vertexInfos.end(), [](
const VertexInfo& a,
const VertexInfo& b) {
304 return a.primaryBone < b.primaryBone;
307 boneVertexRanges_.resize(character_.skeleton.joints.size());
308 activeVertexIndices_.reserve(vertices.size());
309 vertexWeights_.reserve(vertices.size());
311 size_t currentBone = 0;
312 for (
size_t i = 0; i < vertexInfos.size(); ++i) {
313 const auto& info = vertexInfos[i];
314 while (currentBone < info.primaryBone) {
315 boneVertexRanges_[currentBone].end = i;
317 boneVertexRanges_[currentBone].start = i;
319 activeVertexIndices_.push_back(info.vertexIndex);
320 vertexWeights_.push_back(info.weight);
323 boneVertexRanges_[currentBone].end = activeVertexIndices_.size();
325 while (currentBone < boneVertexRanges_.size()) {
326 boneVertexRanges_[currentBone++] =
327 BoneVertexRange{activeVertexIndices_.size(), activeVertexIndices_.size()};
331template <
typename T,
typename SdfColl
iderType>
332void SDFCollisionErrorFunctionT<T, SdfColliderType>::initializeBoneCollisionPairs(
333 bool filterRestPoseIntersections) {
334 std::unordered_set<size_t> activeBones;
335 for (
size_t boneIndex = 0; boneIndex < boneVertexRanges_.size(); ++boneIndex) {
336 if (!boneVertexRanges_[boneIndex].empty()) {
337 activeBones.insert(boneIndex);
342 this->parameterTransform_.zero().template
cast<T>(), this->skeleton_);
345 updateColliders(restParams);
347 boneCollisionPairs_.clear();
348 boneCollisionPairs_.reserve(activeBones.size() * sdfColliders_.size());
350 for (
size_t boneIndex : activeBones) {
351 if (boneVertexRanges_[boneIndex].empty()) {
354 for (
size_t sdfIndex = 0; sdfIndex < sdfColliders_.size(); ++sdfIndex) {
355 const auto& collider = sdfColliders_[sdfIndex];
356 if (collider.parentJoint() !=
kInvalidIndex && filterRestPoseIntersections &&
357 testRestPoseIntersection(boneIndex, sdfIndex, restState)) {
365template <
typename T,
typename SdfColl
iderType>
366bool SDFCollisionErrorFunctionT<T, SdfColliderType>::testRestPoseIntersection(
368 size_t sdfColliderIndex,
370 const auto& range = boneVertexRanges_[boneIndex];
375 const auto& collider = sdfColliders_[sdfColliderIndex];
376 if (!collider.isValid()) {
382 for (
size_t i = range.start; i < range.end; ++i) {
383 const size_t vertexIndex = activeVertexIndices_[i];
384 const auto& restPos = character_.mesh->vertices[vertexIndex].template
cast<T>();
385 const Vector3<T> localPos = worldToCollider * restPos;
386 const T distance = collider.evaluate(localPos);
387 if (distance < T(0)) {
394template <
typename T,
typename SdfColl
iderType>
395void SDFCollisionErrorFunctionT<T, SdfColliderType>::updateColliders(
397 for (
auto& collider : sdfColliders_) {
398 collider.update(params.v);
402template <
typename T,
typename SdfColl
iderType>
403TransformT<T> SDFCollisionErrorFunctionT<T, SdfColliderType>::computeWorldToColliderTransform(
404 size_t sdfColliderIndex,
407 sdfColliders_[sdfColliderIndex], state);
410template <
typename T,
typename SdfColl
iderType>
417 updateColliders(params);
418 computeActivePairs(meshState, state);
420 double totalError = 0.0;
421 collisionCounts_.assign(activeVertexIndices_.size(), 0);
423 for (
size_t pairIndex = 0; pairIndex < boneCollisionPairs_.size(); ++pairIndex) {
424 if (!activePairs_[pairIndex]) {
427 const auto& pair = boneCollisionPairs_[pairIndex];
428 const auto& range = boneVertexRanges_[pair.boneIndex];
432 const auto& collider = sdfColliders_[pair.sdfColliderIndex];
433 if (!collider.isValid()) {
436 const auto worldToCollider = computeWorldToColliderTransform(pair.sdfColliderIndex, state);
438 for (
size_t i = range.start; i < range.end; ++i) {
439 if (collisionCounts_[i] >= maxCollisionsPerVertex_) {
442 const size_t vertexIndex = activeVertexIndices_[i];
443 const T vertexWeight = vertexWeights_[i];
444 const auto& worldPos = meshState.
posedMesh_->vertices[vertexIndex];
445 const Vector3<T> localPos = worldToCollider * worldPos;
446 const T distance = collider.evaluate(localPos);
448 if (distance < T(0)) {
449 collisionCounts_[i]++;
450 const T penetrationDepth = -distance;
451 totalError +=
static_cast<double>(
460template <
typename T,
typename SdfColl
iderType>
461void SDFCollisionErrorFunctionT<T, SdfColliderType>::accumulateJointGradient(
464 const Eigen::Vector3<T>& posd,
465 const Eigen::Vector3<T>& direction,
466 Eigen::Ref<Eigen::VectorX<T>> gradient)
const {
472 this->activeJointParams_,
473 this->parameterTransform_,
477template <
typename T,
typename SdfColl
iderType>
478void SDFCollisionErrorFunctionT<T, SdfColliderType>::accumulateJointJacobian(
479 const JointStateT<T>& jointState,
481 const Eigen::Vector3<T>& posd,
482 const Eigen::Vector3<T>& direction,
483 Eigen::Ref<Eigen::MatrixX<T>> jacobianRow)
const {
489 this->activeJointParams_,
490 this->parameterTransform_,
494template <
typename T,
typename SdfColl
iderType>
495void SDFCollisionErrorFunctionT<T, SdfColliderType>::accumulateColliderHierarchyGradient(
497 size_t colliderParent,
498 size_t commonAncestor,
499 const Eigen::Vector3<T>& sdfSurfacePoint,
500 const Eigen::Vector3<T>& direction,
501 Eigen::Ref<Eigen::VectorX<T>> gradient)
const {
509 this->activeJointParams_,
510 this->parameterTransform_,
514template <
typename T,
typename SdfColl
iderType>
515void SDFCollisionErrorFunctionT<T, SdfColliderType>::accumulateColliderHierarchyJacobian(
517 size_t colliderParent,
518 size_t commonAncestor,
519 const Eigen::Vector3<T>& sdfSurfacePoint,
520 const Eigen::Vector3<T>& direction,
521 Eigen::Ref<Eigen::MatrixX<T>> jacobianRow)
const {
529 this->activeJointParams_,
530 this->parameterTransform_,
534template <
typename T,
typename SdfColl
iderType>
539 Eigen::Ref<Eigen::VectorX<T>> gradient) {
543 updateColliders(params);
544 computeActivePairs(meshState, state);
546 double totalError = 0.0;
547 collisionCounts_.assign(activeVertexIndices_.size(), 0);
549 for (
size_t pairIndex = 0; pairIndex < boneCollisionPairs_.size(); ++pairIndex) {
550 if (!activePairs_[pairIndex]) {
553 const auto& pair = boneCollisionPairs_[pairIndex];
554 const auto& range = boneVertexRanges_[pair.boneIndex];
558 const auto& collider = sdfColliders_[pair.sdfColliderIndex];
559 if (!collider.isValid()) {
562 const auto worldToCollider = computeWorldToColliderTransform(pair.sdfColliderIndex, state);
563 const auto colliderToWorld = worldToCollider.inverse();
565 for (
size_t i = range.start; i < range.end; ++i) {
566 if (collisionCounts_[i] >= maxCollisionsPerVertex_) {
569 const size_t vertexIndex = activeVertexIndices_[i];
570 const T vertexWeight = vertexWeights_[i];
571 const auto& worldPos = meshState.
posedMesh_->vertices[vertexIndex];
572 const Vector3<T> localPos = worldToCollider * worldPos;
573 const auto [distance, localGradient] = collider.evaluateWithGradient(localPos);
575 if (distance < T(0)) {
576 const T penetrationDepth = -distance;
577 totalError +=
static_cast<double>(
580 collisionCounts_[i]++;
583 const Eigen::Vector3<T> sdfGradient = colliderToWorld.rotation * localGradient;
586 const Eigen::Vector3<T> diff = -penetrationDepth * sdfGradient;
587 const Eigen::Vector3<T> sdfSurfacePoint = worldPos + penetrationDepth * sdfGradient;
590 *character_.skinWeights, this->skeleton_, vertexIndex, collider.parentJoint());
593 character_, *meshState.
restMesh_, state, vertexIndex);
595 const auto [jointIndex, boneWeight, transformedVertex] = skinningIter.
next();
596 if (jointIndex == commonAncestor) {
599 if (std::abs(boneWeight) < std::numeric_limits<T>::epsilon()) {
603 const auto& jointState = state.
jointState[jointIndex];
605 const Eigen::Vector3<T> posd = transformedVertex - jointState.translation();
606 accumulateJointGradient(jointState, paramIndex, posd, boneWeight * wgt * diff, gradient);
610 accumulateColliderHierarchyGradient(
612 collider.parentJoint(),
624template <
typename T,
typename SdfColl
iderType>
629 Eigen::Ref<Eigen::MatrixX<T>> jacobian,
630 Eigen::Ref<Eigen::VectorX<T>> residual,
634 jacobian.cols() ==
static_cast<Eigen::Index
>(this->parameterTransform_.transform.cols()),
635 "Jacobian column count mismatch");
638 updateColliders(params);
639 computeActivePairs(meshState, state);
641 double totalError = 0.0;
643 collisionCounts_.assign(activeVertexIndices_.size(), 0);
645 for (
size_t pairIndex = 0; pairIndex < boneCollisionPairs_.size(); ++pairIndex) {
646 if (!activePairs_[pairIndex]) {
649 const auto& pair = boneCollisionPairs_[pairIndex];
650 const auto& range = boneVertexRanges_[pair.boneIndex];
654 const auto& collider = sdfColliders_[pair.sdfColliderIndex];
655 if (!collider.isValid()) {
658 const auto worldToCollider = computeWorldToColliderTransform(pair.sdfColliderIndex, state);
659 const auto colliderToWorld = worldToCollider.inverse();
661 for (
size_t i = range.start; i < range.end; ++i) {
662 if (collisionCounts_[i] >= maxCollisionsPerVertex_) {
665 const size_t vertexIndex = activeVertexIndices_[i];
666 const T vertexWeight = vertexWeights_[i];
667 const auto& worldPos = meshState.
posedMesh_->vertices[vertexIndex];
668 const Vector3<T> localPos = worldToCollider * worldPos;
669 const auto [distance, localGradient] = collider.evaluateWithGradient(localPos);
671 if (distance < T(0)) {
672 const T penetrationDepth = -distance;
674 currentRow < jacobian.rows() && currentRow < residual.rows(),
675 "Insufficient Jacobian/residual rows");
678 residual[currentRow] = wgt * penetrationDepth;
679 totalError +=
static_cast<double>(
682 ++collisionCounts_[i];
684 jacobian.row(currentRow).setZero();
687 const Eigen::Vector3<T> sdfGradient = colliderToWorld.rotation * localGradient;
689 const T jacobianMagnitude = -wgt;
690 const Eigen::Vector3<T> worldJacobianContribution = jacobianMagnitude * sdfGradient;
691 const Eigen::Vector3<T> sdfSurfacePoint = worldPos + penetrationDepth * sdfGradient;
694 *character_.skinWeights, this->skeleton_, vertexIndex, collider.parentJoint());
697 character_, *meshState.
restMesh_, state, vertexIndex);
699 const auto [jointIndex, boneWeight, transformedVertex] = skinningIter.
next();
700 if (jointIndex == commonAncestor) {
703 if (std::abs(boneWeight) < std::numeric_limits<T>::epsilon()) {
707 const auto& jointState = state.
jointState[jointIndex];
709 const Eigen::Vector3<T> posd = transformedVertex - jointState.translation();
710 accumulateJointJacobian(
714 boneWeight * worldJacobianContribution,
715 jacobian.middleRows(currentRow, 1));
719 accumulateColliderHierarchyJacobian(
721 collider.parentJoint(),
724 -worldJacobianContribution,
725 jacobian.middleRows(currentRow, 1));
732 usedRows = currentRow;
736template <
typename T,
typename SdfColl
iderType>
738 return static_cast<size_t>(maxCollisionsPerVertex_) * activeVertexIndices_.size();
741template <
typename T,
typename SdfColl
iderType>
742void SDFCollisionErrorFunctionT<T, SdfColliderType>::computeActivePairs(
746 activePairs_.assign(boneCollisionPairs_.size(),
false);
748 boneBBoxCache_.resize(boneVertexRanges_.size());
749 boneBBoxValid_.assign(boneVertexRanges_.size(),
false);
750 for (
size_t boneIndex = 0; boneIndex < boneVertexRanges_.size(); ++boneIndex) {
751 if (!boneVertexRanges_[boneIndex].empty()) {
752 boneBBoxCache_[boneIndex] = computeBoneBoundingBox(boneIndex, *meshState.
posedMesh_);
753 boneBBoxValid_[boneIndex] =
true;
757 sdfBBoxCache_.resize(sdfColliders_.size());
758 for (
size_t sdfIndex = 0; sdfIndex < sdfColliders_.size(); ++sdfIndex) {
762 for (
size_t pairIndex = 0; pairIndex < boneCollisionPairs_.size(); ++pairIndex) {
763 const auto& pair = boneCollisionPairs_[pairIndex];
764 if (!boneBBoxValid_[pair.boneIndex]) {
767 activePairs_[pairIndex] =
768 boneBBoxCache_[pair.boneIndex].intersects(sdfBBoxCache_[pair.sdfColliderIndex]);
772template <
typename T,
typename SdfColl
iderType>
773axel::BoundingBox<T> SDFCollisionErrorFunctionT<T, SdfColliderType>::computeBoneBoundingBox(
776 const auto& range = boneVertexRanges_[boneIndex];
778 std::span<const size_t>(activeVertexIndices_).subspan(range.start, range.size()), posedMesh);
781template <
typename T,
typename SdfColl
iderType>
783SDFCollisionErrorFunctionT<T, SdfColliderType>::computeColliderWorldBoundingBox(
784 size_t sdfColliderIndex,
787 sdfColliders_[sdfColliderIndex], state);
#define MT_CHECK_NOTNULL(ptr,...)
Asserts that ptr is not null; on failure, throws std::runtime_error with the optional fmt-style messa...
#define MT_CHECK(condition,...)
Runtime check macros with two interchangeable backends:
SDF-based collision error function that penalizes vertex penetration into SDF colliders.
bool needsMesh() const override
const Character * getCharacter() const override
Returns the character used to update mesh state for SDF collision evaluation.
double getError(const ModelParametersT< float > ¶ms, const SkeletonStateT< float > &state, const MeshStateT< float > &meshState) override
size_t getNumActiveVertices() const
double getJacobian(const ModelParametersT< float > ¶ms, const SkeletonStateT< float > &state, const MeshStateT< float > &meshState, Eigen::Ref< Eigen::MatrixX< float > > jacobian, Eigen::Ref< Eigen::VectorX< float > > residual, int &usedRows) override
SDFCollisionErrorFunctionT(SDFCollisionErrorFunctionT &&) noexcept=default
static constexpr float kSDFCollisionWeight
SDFCollisionErrorFunctionT(const Character &character, const std::vector< SdfColliderType > &sdfColliders, const std::vector< int > &participatingVertices={}, const std::vector< T > &vertexWeights={}, bool filterRestPoseIntersections=true, uint8_t maxCollisionsPerVertex=1)
Constructor with vertex index list and uniform weights.
double getGradient(const ModelParametersT< float > ¶ms, const SkeletonStateT< float > &state, const MeshStateT< float > &meshState, Eigen::Ref< Eigen::VectorX< float > > gradient) override
size_t getJacobianSize() const override
size_t getNumCollisionPairs() const
SDFCollisionErrorFunctionT & operator=(const SDFCollisionErrorFunctionT &)=delete
SDFCollisionErrorFunctionT(const SDFCollisionErrorFunctionT &)=default
const Skeleton & skeleton_
SkeletonErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt)
std::tuple< size_t, T, Eigen::Vector3< T > > next()
TransformT< T > computeWorldToColliderTransform(const SdfColliderType &collider, const SkeletonStateT< T > &state)
Returns the world-to-collider transform for a collider given a skeleton state.
void accumulateColliderHierarchyGradient(const SkeletonStateT< T > &state, size_t colliderParent, size_t commonAncestor, const Eigen::Vector3< T > &sdfSurfacePoint, const Eigen::Vector3< T > &direction, const Skeleton &skeleton, const VectorX< bool > &activeJointParams, const ParameterTransform ¶meterTransform, Eigen::Ref< Eigen::VectorX< T > > gradient)
Accumulates the gradient contribution of a collider's joint hierarchy onto the gradient.
void accumulateJointJacobian(const JointStateT< T > &jointState, size_t paramIndex, const Eigen::Vector3< T > &posd, const Eigen::Vector3< T > &direction, const VectorX< bool > &activeJointParams, const ParameterTransform ¶meterTransform, Eigen::Ref< Eigen::MatrixX< T > > jacobianRow)
Accumulates the Jacobian contribution of a single joint onto one residual row.
axel::BoundingBox< T > computeColliderWorldBoundingBox(const SdfColliderType &collider, const SkeletonStateT< T > &state)
Returns the world-space axis-aligned bounding box of a collider given a skeleton state.
void accumulateJointGradient(const JointStateT< T > &jointState, size_t paramIndex, const Eigen::Vector3< T > &posd, const Eigen::Vector3< T > &direction, const VectorX< bool > &activeJointParams, const ParameterTransform ¶meterTransform, Eigen::Ref< Eigen::VectorX< T > > gradient)
Accumulates the gradient contribution of a single joint onto the model-parameter gradient.
void accumulateColliderHierarchyJacobian(const SkeletonStateT< T > &state, size_t colliderParent, size_t commonAncestor, const Eigen::Vector3< T > &sdfSurfacePoint, const Eigen::Vector3< T > &direction, const Skeleton &skeleton, const VectorX< bool > &activeJointParams, const ParameterTransform ¶meterTransform, Eigen::Ref< Eigen::MatrixX< T > > jacobianRow)
Accumulates the Jacobian contribution of a collider's joint hierarchy onto one residual row.
axel::BoundingBox< T > computeBoneBoundingBox(std::span< const size_t > vertexIndices, const MeshT< T > &posedMesh)
Returns the world-space axis-aligned bounding box enclosing the given posed-mesh vertices.
size_t findCommonAncestorForVertex(const SkinWeights &skinWeights, const Skeleton &skeleton, size_t vertexIndex, size_t sdfParent)
Shared, stateless helpers for SDF-collision error functions.
SDFCollisionErrorFunctionT< double > SDFCollisionErrorFunctiond
SDFCollisionErrorFunctionT< float > SDFCollisionErrorFunction
Eigen::Matrix< T, Dynamic, Dynamic > MatrixX
Dynamic-size, column-major dense matrix.
Vector< T, Dynamic > VectorX
Dynamic-size column vector. Common return type for solver residuals and parameter vectors.
constexpr size_t kParametersPerJoint
constexpr size_t kInvalidIndex
Sentinel value indicating an invalid or unset size_t index.
decltype(auto) cast(const ContainerType< ObjectType > &originalContainer)
Casts the scalar type of objects in a container that support the cast<>() method.
Profiling macros that dispatch to one of three backends, selected at compile time:
#define MT_PROFILE_FUNCTION()
Collision pair information for bone-SDF collider combinations.
size_t sdfColliderIndex
Index into SDFCollisionGeometry.
size_t boneIndex
Primary bone index.
Range structure for efficiently storing vertex indices per bone.
size_t size() const
Returns the number of vertices for this bone.
size_t end
End index in activeVertexIndices_ (exclusive).
bool empty() const
Returns true if this bone has no vertices.
size_t start
Start index in activeVertexIndices_.
A character model with skeletal structure, mesh, and optional components.
static EIGEN_DEVICE_FUNC ModelParametersT< Scalar > Zero(::Eigen::Index size)
Represents the state of a joint with local and global transformations.
Represents the complete state of a model's mesh.
std::unique_ptr< MeshT< T > > posedMesh_
Posed mesh after the skeleton transforms have been applied.
std::unique_ptr< MeshT< T > > restMesh_
Rest positions of the mesh after the shape basis (and potentially facial expression basis) has been a...
A generic mesh representation with support for vertices, faces, lines, and texture coordinates.
A vector of size numModelParams holding the values of all model parameters for a character.
Represents the complete state of a skeleton.
JointStateListT< T > jointState
Computed joint states for all joints in the skeleton.