Path: blob/master/thirdparty/jolt_physics/Jolt/Skeleton/SkeletonPose.h
9912 views
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)1// SPDX-FileCopyrightText: 2021 Jorrit Rouwe2// SPDX-License-Identifier: MIT34#pragma once56#include <Jolt/Skeleton/Skeleton.h>7#include <Jolt/Skeleton/SkeletalAnimation.h>89JPH_NAMESPACE_BEGIN1011#ifdef JPH_DEBUG_RENDERER12class DebugRenderer;13#endif // JPH_DEBUG_RENDERER1415/// Instance of a skeleton, contains the pose the current skeleton is in16class JPH_EXPORT SkeletonPose17{18public:19JPH_OVERRIDE_NEW_DELETE2021using JointState = SkeletalAnimation::JointState;22using JointStateVector = Array<JointState>;23using Mat44Vector = Array<Mat44>;2425///@name Skeleton26///@{27void SetSkeleton(const Skeleton *inSkeleton);28const Skeleton * GetSkeleton() const { return mSkeleton; }29///@}3031/// Extra offset applied to the root (and therefore also to all of its children)32void SetRootOffset(RVec3Arg inOffset) { mRootOffset = inOffset; }33RVec3 GetRootOffset() const { return mRootOffset; }3435///@name Properties of the joints36///@{37uint GetJointCount() const { return (uint)mJoints.size(); }38const JointStateVector & GetJoints() const { return mJoints; }39JointStateVector & GetJoints() { return mJoints; }40const JointState & GetJoint(int inJoint) const { return mJoints[inJoint]; }41JointState & GetJoint(int inJoint) { return mJoints[inJoint]; }42///@}4344///@name Joint matrices45///@{46const Mat44Vector & GetJointMatrices() const { return mJointMatrices; }47Mat44Vector & GetJointMatrices() { return mJointMatrices; }48const Mat44 & GetJointMatrix(int inJoint) const { return mJointMatrices[inJoint]; }49Mat44 & GetJointMatrix(int inJoint) { return mJointMatrices[inJoint]; }50///@}5152/// Convert the joint states to joint matrices53void CalculateJointMatrices();5455/// Convert joint matrices to joint states56void CalculateJointStates();5758/// Outputs the joint matrices in local space (ensure that outMatrices has GetJointCount() elements, assumes that values in GetJoints() is up to date)59void CalculateLocalSpaceJointMatrices(Mat44 *outMatrices) const;6061#ifdef JPH_DEBUG_RENDERER62/// Draw settings63struct DrawSettings64{65bool mDrawJoints = true;66bool mDrawJointOrientations = true;67bool mDrawJointNames = false;68};6970/// Draw current pose71void Draw(const DrawSettings &inDrawSettings, DebugRenderer *inRenderer, RMat44Arg inOffset = RMat44::sIdentity()) const;72#endif // JPH_DEBUG_RENDERER7374private:75RefConst<Skeleton> mSkeleton; ///< Skeleton definition76RVec3 mRootOffset { RVec3::sZero() }; ///< Extra offset applied to the root (and therefore also to all of its children)77JointStateVector mJoints; ///< Local joint orientations (local to parent Joint)78Mat44Vector mJointMatrices; ///< Local joint matrices (local to world matrix)79};8081JPH_NAMESPACE_END828384