Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ To run the tests:
python setup.py test
```


1 change: 1 addition & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
python -m pip install --upgrade pip
pip install numpy
pip install scipy
pip install packaging
displayName: 'Install dependencies'

- script: |
Expand Down
4 changes: 2 additions & 2 deletions cmake/PyiglDownloadExternal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function(pyigl_download_test_data)
pyigl_download_project(test_data
SOURCE_DIR "${PYLIBIGL_EXTERNAL}/../data"
GIT_REPOSITORY https://github.com/libigl/libigl-tests-data
GIT_TAG fa8ee953a64a560f24553dd8bda0c6cd4fbb5353
GIT_TAG 19cedf96d70702d8b3a83eb27934780c542356fe
)
endfunction()

Expand All @@ -46,7 +46,7 @@ function(pyigl_download_tutorial_data)
pyigl_download_project(tutorial_data
SOURCE_DIR "${PYLIBIGL_EXTERNAL}/../tutorial/data"
GIT_REPOSITORY https://github.com/libigl/libigl-tutorial-data
GIT_TAG 38bbed76692710af038b90c69bf33d6d0f99476d
GIT_TAG c1f9ede366d02e3531ecbaec5e3769312f31cccd
)
endfunction()

Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import platform
import subprocess

from distutils.version import LooseVersion
from packaging.version import Version
from setuptools import setup, Extension, find_packages
from setuptools.command.build_ext import build_ext

Expand All @@ -24,8 +24,8 @@ def run(self):

# self.debug = True

cmake_version = LooseVersion(re.search(r'version\s*([\d.]+)', out.decode()).group(1))
if cmake_version < '3.2.0':
cmake_version = Version(re.search(r'version\s*([\d.]+)', out.decode()).group(1))
if cmake_version < Version('3.2.0'):
raise RuntimeError("CMake >= 3.2.0 is required")

for ext in self.extensions:
Expand Down
109 changes: 109 additions & 0 deletions src/direct_delta_mush.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#include <common.h>
#include <npe.h>
#include <typedefs.h>
#include <igl/direct_delta_mush.h>

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)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why only double?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the question is about why direct_delta_mush.cpp (https://github.com/libigl/libigl/blob/main/include/igl/direct_delta_mush.cpp#L267) is only double, I think it's because DDM has some artifacts when using single precision.

If the question is why double for our python bindings, it is because I felt that it best reflected that DDM only works on double precision. And that work needs to be done for single precision. IMaybe I can let you pick an option here

Option 1. I can leave this as a comment in the file.
Option 2. Take in float as well and cast it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it looks like the upstream libigl function has Affine3d hard coded. I doubt that double precision is needed, just seems like the libigl function should be better templated. I think Option 1 is fine until libigl changes (happy to merge such a PR there).

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<Eigen::Affine3d, Eigen::aligned_allocator<Eigen::Affine3d>>
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<npe_Matrix_v> 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)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why only double?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same options as the question above since the reason is exactly the same.

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<double>();
Comment thread
kishoreVen marked this conversation as resolved.

EigenDenseLike<npe_Matrix_v> omega;
igl::direct_delta_mush_precomputation(v, f, w_copy, p, lambda, kappa, alpha, omega);
return npe::move(omega);

npe_end_code()
18 changes: 18 additions & 0 deletions src/include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,21 @@ void assert_valid_2d_tri_mesh(const TV& v, const TF& f, std::string v_name="v",
".shape = [" + std::to_string(f.rows()) + ", " + std::to_string(f.cols()) + "]");
}
}

template <typename TV>
void assert_valid_bone_transforms(const TV& t, std::string t_name="t") {
if (t.rows() <= 0) {
throw pybind11::value_error("Invalid number of transforms, " + t_name + " has zero rows (" + t_name +
".shape = [" + std::to_string(t.rows()) + ", " + std::to_string(t.cols()) + "]) ");
}

if (t.cols() != 3) {
throw pybind11::value_error("Invalid number of cols in transforms, " + t_name + " must have shape [#bones * 4, 3] but got " + t_name +
".shape = [" + std::to_string(t.rows()) + ", " + std::to_string(t.cols()) + "]");
}

if (t.rows() % 4 != 0) {
throw pybind11::value_error("Invalid number of rows in transforms, " + t_name + " must have shape [#bones * 4, 3] but got " + t_name +
".shape = [" + std::to_string(t.rows()) + ", " + std::to_string(t.cols()) + "].");
}
}
Loading