From 80c67efd81264fbe4dec71b4a994d18cb2fa5871 Mon Sep 17 00:00:00 2001 From: Alec Jacobson Date: Fri, 3 Feb 2023 09:11:54 -0500 Subject: [PATCH] add back missing ddm function --- src/direct_delta_mush.cpp | 109 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 src/direct_delta_mush.cpp diff --git a/src/direct_delta_mush.cpp b/src/direct_delta_mush.cpp new file mode 100644 index 00000000..6ee03c29 --- /dev/null +++ b/src/direct_delta_mush.cpp @@ -0,0 +1,109 @@ +#include +#include +#include +#include + +const char* ds_direct_delta_mush = R"igl_Qu8mg5v7( +Perform Direct Delta Mush Skinning. +Computes Direct Delta Mesh Skinning (Variant 0) from +"Direct Delta Mush Skinning and Variants" + +Parameters +---------- +v #V by 3 list of rest pose vertex positions +t #E*4 by 3 list of bone pose transformations +omega #V by #E*10 list of precomputated matrix values + +Returns +------- +u #V by 3 list of output vertex positions + +See also +-------- + + +Notes +----- +None + +Examples +-------- +)igl_Qu8mg5v7"; + +npe_function(direct_delta_mush) +npe_doc(ds_direct_delta_mush) + +npe_arg(v, dense_double) +npe_arg(t, dense_double) +npe_arg(omega, dense_double) + +npe_begin_code() + assert_cols_equals(v, 3, "v"); + assert_valid_bone_transforms(t, "t"); + assert_rows_equals(t, (omega.cols() * 4) / 10, "t"); + + std::vector> + t_affine(t.rows() / 4); + + for(int bone = 0; bone < t_affine.size(); ++bone) + { + t_affine[bone] = Eigen::Affine3d::Identity(); + t_affine[bone].matrix().block(0, 0, 3, 4) = t.block(bone * 4, 0, 4, 3).transpose(); + } + + EigenDenseLike u; + igl::direct_delta_mush(v, t_affine, omega, u); + return npe::move(u); + +npe_end_code() + +const char* ds_direct_delta_mush_precomp = R"igl_Qu8mg5v7( +Do the Omega precomputation necessary for Direct Delta Mush Skinning. + +Parameters +---------- +v #V by 3 list of rest pose vertex positions +f #F by 3 list of triangle indices into rows of V +w #V by #Edges list of weights +p number of smoothing iterations +lambda rotation smoothing step size +kappa translation smoothness step size +alpha translation smoothness blending weight + +Returns +------- +omega : #V by #E*10 list of precomputated matrix values + +See also +-------- + + +Notes +----- +None + +Examples +-------- +)igl_Qu8mg5v7"; + +npe_function(direct_delta_mush_precomputation) +npe_doc(ds_direct_delta_mush_precomp) + +npe_arg(v, dense_double) +npe_arg(f, dense_int, dense_long, dense_longlong) +npe_arg(w, npe_matches(v)) +npe_arg(p, int) +npe_arg(lambda, double) +npe_arg(kappa, double) +npe_arg(alpha, double) + +npe_begin_code() + assert_valid_3d_tri_mesh(v, f); + + Eigen::MatrixXd w_copy = w.template cast(); + + EigenDenseLike omega; + igl::direct_delta_mush_precomputation(v, f, w_copy, p, lambda, kappa, alpha, omega); + return npe::move(omega); + +npe_end_code()