36 std::span<
const Eigen::Vector3<T>> worldVecs,
38 std::span<DfdvType> dfdv)
const {
40 MT_CHECK(worldVecs.size() == 1,
"Expected exactly one world vector for vertex plane");
43 const auto& constraint = this->
constraints_[constrIndex];
49 const Eigen::Vector3<T> sourceNormal =
51 Eigen::Vector3<T>
normal = constraint.normal;
52 if (sourceNormal.dot(
normal) < T(0)) {
57 const T distance = (worldVecs[0] - constraint.point).
dot(
normal);
60 if (constraint.above && distance > T(0)) {
68 MT_CHECK(dfdv.size() == 1,
"Expected exactly one dfdv for vertex plane");
69 dfdv[0] =
normal.transpose();
#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:
VertexErrorFunctionT(const Character &character, const ParameterTransform ¶meterTransform, const T &lossAlpha=GeneralizedLossT< T >::kL2, const T &lossC=T(1))
std::vector< VertexPlaneDataT< T > > constraints_
Eigen::Matrix< T, FuncDim, 1 > FuncType
static constexpr T kLegacyWeight
Error function that constrains mesh vertices to a plane.
void evalFunction(size_t constrIndex, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, std::span< const Eigen::Vector3< T > > worldVecs, FuncType &f, std::span< DfdvType > dfdv) const final
Computes the residual and derivatives.
VertexPlaneErrorFunctionT(const Character &character, const ParameterTransform ¶meterTransform, const T &lossAlpha=GeneralizedLossT< T >::kL2, const T &lossC=T(1))
T normal(const T &mean, const T &sigma)
Normally distributed value via the global Random singleton.
FloatP dot(const Eigen::MatrixBase< Derived > &v1, const Vector3P< S > &v2)
Computes dot product of Eigen::Vector3f and 3-vector of packets.
ParameterTransformT< float > ParameterTransform
decltype(auto) cast(const ContainerType< ObjectType > &originalContainer)
Casts the scalar type of objects in a container that support the cast<>() method.
A character model with skeletal structure, mesh, and optional components.
Represents the complete state of a model's mesh.
std::unique_ptr< MeshT< T > > posedMesh_
Posed mesh after the skeleton transforms have been applied.
Represents the complete state of a skeleton.
Constraint data for a vertex plane target.