56 [[nodiscard]]
const std::vector<VertexSDFConstraintT<T>>&
getConstraints()
const;
72 Eigen::Ref<Eigen::VectorX<T>> gradient)
override;
79 Eigen::Ref<Eigen::MatrixX<T>> jacobian,
80 Eigen::Ref<Eigen::VectorX<T>> residual,
81 int& usedRows)
override;
96 [[nodiscard]] T sampleSDFDistanceWithTransform(
97 const Eigen::Vector3<T>& worldPos,
101 [[nodiscard]] std::pair<T, Eigen::Vector3<T>> sampleSDFDistanceAndGradientWithTransform(
102 const Eigen::Vector3<T>& worldPos,
107 void accumulateJointGradient(
110 const Eigen::Vector3<T>& posd,
111 const Eigen::Vector3<T>& direction,
112 Eigen::Ref<Eigen::VectorX<T>> gradient)
const;
115 void accumulateJointJacobian(
118 const Eigen::Vector3<T>& posd,
119 const Eigen::Vector3<T>& direction,
120 Eigen::Ref<Eigen::MatrixX<T>> jacobianRow)
const;
123 void accumulateColliderHierarchyGradient(
125 size_t colliderParent,
126 size_t commonAncestor,
127 const Eigen::Vector3<T>& sdfSurfacePoint,
128 const Eigen::Vector3<T>& direction,
129 Eigen::Ref<Eigen::VectorX<T>> gradient)
const;
132 void accumulateColliderHierarchyJacobian(
134 size_t colliderParent,
135 size_t commonAncestor,
136 const Eigen::Vector3<T>& sdfSurfacePoint,
137 const Eigen::Vector3<T>& direction,
138 Eigen::Ref<Eigen::MatrixX<T>> jacobianRow)
const;
142 std::vector<VertexSDFConstraintT<T>> constraints_;
SkeletonErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt)
static constexpr float kVertexSDFWeight
~VertexSDFErrorFunctionT() override=default
Destructor.
VertexSDFErrorFunctionT(const Character &character, const SDFColliderT< float > &sdfCollider)
Constructor.
size_t getJacobianSize() const override
Returns the maximum number of Jacobian rows needed.
void clearConstraints()
Clear all constraints.
size_t getNumConstraints() const
Returns the number of constraints.
void addConstraint(const VertexSDFConstraintT< T > &constraint)
Add a constraint specifying a target distance for a vertex.
double getError(const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState) override
Computes the error for the given model parameters and skeleton state.
bool needsMesh() const override
Returns true because this error function requires mesh state.
double getGradient(const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::VectorX< T > > gradient) override
Computes the error and its gradient.
double getJacobian(const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::MatrixX< T > > jacobian, Eigen::Ref< Eigen::VectorX< T > > residual, int &usedRows) override
Computes the Jacobian and residual.
const std::vector< VertexSDFConstraintT< T > > & getConstraints() const
Returns the current constraints.
VertexSDFErrorFunctionT< double > VertexSDFErrorFunctiond
VertexSDFErrorFunctionT< float > VertexSDFErrorFunction
A character model with skeletal structure, mesh, and optional components.
Represents the state of a joint with local and global transformations.
Represents the complete state of a model's mesh.
A vector of size numModelParams holding the values of all model parameters for a character.
SDF collision geometry for character collision detection.
Represents the complete state of a skeleton.
Constraint specifying that a vertex should be at a target signed distance from the SDF.