29 const Eigen::Vector3<T>& targetPos,
30 const Eigen::Vector3<T>& targetNorm,
32 const std::string& n =
"")
71 T sourceNormalWeight = T(1),
72 T targetNormalWeight = T(0),
74 const T& lossC = T(1),
83 std::span<
const Eigen::Vector3<T>> worldVecs,
85 std::span<DfdvType> dfdv)
const final;
92 Eigen::Ref<Eigen::VectorX<T>> gradient)
override;
99 Eigen::Ref<Eigen::MatrixX<T>> jacobian,
100 Eigen::Ref<Eigen::VectorX<T>> residual,
101 int& usedRows)
override;
105 computeAccurateNormalDerivatives_ = enable;
110 return computeAccurateNormalDerivatives_;
116 void buildVertexToFaceAdjacency(
const MeshStateT<T>& meshState)
const;
118 T sourceNormalWeight_;
119 T targetNormalWeight_;
120 bool computeAccurateNormalDerivatives_ =
false;
124 mutable std::vector<std::vector<size_t>> vertexToFaceAdjacency_;
125 mutable bool vertexToFaceAdjacencyValid_ =
false;
static constexpr T kL2
Special-case alpha values that are either at a singularity in the general formula or simplify to a cl...
VertexErrorFunctionT(const Character &character, const ParameterTransform ¶meterTransform, const T &lossAlpha=GeneralizedLossT< T >::kL2, const T &lossC=T(1))
Eigen::Matrix< T, FuncDim, 1 > FuncType
Eigen::Matrix< T, FuncDim, 3 > DfdvType
bool computeAccurateNormalDerivatives() const
double getGradient(const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::VectorX< T > > gradient) override
Override to handle normal rotation correction terms via SkeletonDerivativeT.
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
Override to handle normal rotation correction terms via SkeletonDerivativeT.
VertexNormalErrorFunctionT(const Character &character, const ParameterTransform ¶meterTransform, T sourceNormalWeight=T(1), T targetNormalWeight=T(0), const T &lossAlpha=GeneralizedLossT< T >::kL2, const T &lossC=T(1), bool computeAccurateNormalDerivatives=false)
Constructor.
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.
~VertexNormalErrorFunctionT() override=default
VertexErrorFunctionT< float, VertexNormalDataT< float >, 1 > Base
void setComputeAccurateNormalDerivatives(bool enable)
Enable or disable the expensive d(normal)/d(blendShapeWeight) computation.
ParameterTransformT< float > ParameterTransform
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.
VertexConstraintData()=default
Eigen::Vector3< T > targetPosition
Target position in world space.
VertexNormalDataT(size_t vIndex, const Eigen::Vector3< T > &targetPos, const Eigen::Vector3< T > &targetNorm, float w, const std::string &n="")
VertexNormalDataT()=default
Eigen::Vector3< T > targetNormal
Target normal direction (will be flipped if facing away from source normal).