-
Notifications
You must be signed in to change notification settings - Fork 82
Direct delta mush python binding #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alecjacobson
merged 12 commits into
libigl:master
from
kishoreVen:direct-delta-mush-python
Feb 1, 2023
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
830880d
Fix tests by fixing numpy datatype checks
kishoreVen deb538f
Adding python bindings for direct delta mush
kishoreVen 921a389
Test usage of direct delta mush
kishoreVen 0d3476e
Fix bone transformation indexing issue
kishoreVen eb1a2e0
Revert "Fix tests by fixing numpy datatype checks"
kishoreVen 63c5bad
Affine transforms weren't being built right
kishoreVen ea22af0
Updating the commit hash for tutorial and test data download
kishoreVen 33291b8
Adding tutorial for Skinned Shape Deformation
kishoreVen e284244
fix continuous integration with numpy types (#154)
jiangzhongshi b23a4d2
Remove unnecessary copies of arguments
kishoreVen 5d1b2d0
add dtype check for omega
kishoreVen f69815a
Remove unnecessary cast on faces as well
kishoreVen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,4 +45,3 @@ To run the tests: | |
| python setup.py test | ||
| ``` | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| 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) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why only double?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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>(); | ||
|
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() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why only double?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).