46 for (
size_t i = 0; i <
posePrior_->names.size(); i++) {
48 if (
posePrior_->names[i] == this->parameterTransform_.name[j]) {
58 Eigen::VectorX<T> res = Eigen::VectorX<T>::Zero(mp.size());
59 for (
size_t i = 0; i < mp.size(); i++) {
70 if (
invMap_.size() != gsl::narrow_cast<size_t>(params.
size())) {
77 size_t meanShapeIdx = 0;
78 Eigen::VectorX<T> bestDiff;
99 Eigen::Ref<Eigen::VectorX<T>> gradient) {
114 size_t meanShapeIdx = 0;
115 Eigen::VectorX<T> bestDiff;
126 for (
size_t i = 0; i < posePrior.d; i++) {
151 Eigen::Ref<Eigen::MatrixX<T>> jacobian,
152 Eigen::Ref<Eigen::VectorX<T>> residual,
169 size_t meanShapeIdx = 0;
170 Eigen::VectorX<T> bestDiff;
186 this->gradientL_.noalias() = posePrior.L[meanShapeIdx].topRows(posePrior.d) * wgt;
187 residual.head(posePrior.d).noalias() = this->gradientL_ * bestDiff;
190 jacobian.topRows(posePrior.d).setConstant(T(0));
191 for (
size_t i = 0; i <
invMap_.size(); i++) {
193 jacobian.col(i).head(posePrior.d) = this->gradientL_.col(
invMap_[i]);
197 usedRows = gsl::narrow_cast<int>(posePrior.d);
206 size_t meanShapeIdx = 0;
207 Eigen::VectorX<T> bestDiff;
221 Eigen::VectorX<T>& bestDiff,
224 minDist = std::numeric_limits<T>::max();
225 bestR = -std::numeric_limits<T>::max();
236 for (
size_t c = 0; c < posePrior.p; c++) {
237 const Eigen::VectorX<T> diff = subParams - posePrior.mu.row(c).transpose();
238 const T squareDist = T(0.5) * diff.transpose() * posePrior.Cinv[c] * diff;
241 const T R = posePrior.Rpre(c) - squareDist;
245 minDist = squareDist;
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) final
size_t getJacobianSize() const final
Eigen::VectorX< T > getMeanShape(const ModelParametersT< T > ¶ms) const
void setPosePrior(std::shared_ptr< const MppcaT< T > > pp)
double logProbability(const ModelParametersT< T > ¶ms) const
double getGradient(const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::VectorX< T > > gradient) final
std::shared_ptr< const MppcaT< T > > posePrior_
void getBestFitMode(const ModelParametersT< T > ¶ms, size_t &bestIdx, Eigen::VectorX< T > &bestDiff, T &bestR, T &minDist) const
static constexpr T kPosePriorWeight
PosePriorErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt, std::shared_ptr< const MppcaT< T > > pp)
std::vector< size_t > ppMap_
double getError(const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState) final
std::vector< size_t > invMap_
SkeletonErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt)
const ParameterTransform & parameterTransform_
SkeletonT< float > Skeleton
ParameterTransformT< float > ParameterTransform
constexpr size_t kInvalidIndex
Sentinel value indicating an invalid or unset size_t index.
Eigen::VectorX< T > mapParameters(const ModelParametersT< T > &in, const std::vector< size_t > &mp)
Profiling macros that dispatch to one of three backends, selected at compile time:
#define MT_PROFILE_FUNCTION()
A character model with skeletal structure, mesh, and optional components.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE auto size() const
Represents the complete state of a model's mesh.
A vector of size numModelParams holding the values of all model parameters for a character.
Mixture of Probabilistic Principal Component Analyzers (MPPCA).
Represents the complete state of a skeleton.