49 const Eigen::Vector3<T>& upDirection = Eigen::Vector3<T>::UnitY(),
67 Eigen::Ref<Eigen::VectorX<T>> gradient)
final;
73 Eigen::Ref<Eigen::MatrixX<T>> jacobian,
74 Eigen::Ref<Eigen::VectorX<T>> residual,
116 struct HeightResult {
118 std::vector<size_t> minVertexIndices;
119 std::vector<T> minVertexWeights;
120 std::vector<size_t> maxVertexIndices;
121 std::vector<T> maxVertexWeights;
126 [[nodiscard]] HeightResult calculateHeight()
const;
129 template <
typename Derived>
130 void calculateVertexJacobian(
132 const Eigen::Vector3<T>& jacobianDirection,
133 Eigen::MatrixBase<Derived>& jacobian)
const;
136 void calculateVertexGradient(
138 const Eigen::Vector3<T>& gradientDirection,
139 Eigen::Ref<Eigen::VectorX<T>> gradient)
const;
142 void calculateDWorldPos(
144 const Eigen::Vector3<T>& d_restPos,
145 Eigen::Vector3<T>& d_worldPos)
const;
147 const Character& character_;
150 Eigen::Vector3<T> upDirection_;
165 mutable SkeletonStateT<T> skeletonState_;
173 mutable MeshStateT<T> meshState_;
~HeightErrorFunctionT() override
bool needsMesh() const override
Override to indicate this function does NOT require mesh state (we maintain our own meshes).
HeightErrorFunctionT(HeightErrorFunctionT &&other) noexcept=delete
void setTargetHeight(float height)
double getJacobian(const ModelParametersT< T > &modelParameters, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::MatrixX< T > > jacobian, Eigen::Ref< Eigen::VectorX< T > > residual, int &usedRows) final
void setUpDirection(const Eigen::Vector3< T > &upDirection)
Set the up direction for height measurement.
double getError(const ModelParametersT< T > &modelParameters, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState) final
const Eigen::Vector3< T > & getUpDirection() const
Get the up direction.
HeightErrorFunctionT(const Character &character, T targetHeight, const Eigen::Vector3< T > &upDirection=Eigen::Vector3< T >::UnitY(), size_t k=1)
Construct a height error function.
const Character * getCharacter() const override
Get the character.
size_t getJacobianSize() const final
HeightErrorFunctionT & operator=(const HeightErrorFunctionT &other)=delete
HeightErrorFunctionT & operator=(HeightErrorFunctionT &&other)=delete
HeightErrorFunctionT(const HeightErrorFunctionT &other)=delete
float getTargetHeight() const
double getGradient(const ModelParametersT< T > &modelParameters, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::VectorX< T > > gradient) final
SkeletonErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt)
std::bitset< kMaxModelParams > ParameterSet
Bitset for model parameter enablement.
A character model with skeletal structure, mesh, and optional components.
Represents the complete state of a model's mesh.
A vector of size numModelParams holding the values of all model parameters for a character.
Represents the complete state of a skeleton.