Page MenuHome

Correct CoM set-origin code for solid objects.
ClosedPublic

Authored by Bill Currie (taniwha) on May 12 2017, 1:27 AM.

Details

Summary

The old version is now accessed via center of area. This version works best
with manifold meshes, but will work in general with non-manifold meshes,
but will not be accurate. Even zero-area faces do not cause problems. Also,

it does not completely fall over when given a planar object with 0 volume.

source/blender/blenkernel/BKE_mesh.h | 1 +
source/blender/blenkernel/intern/mesh_evaluate.c | 72 ++++++++++++++++++++++++
source/blender/editors/object/object_transform.c | 6 +-
3 files changed, 78 insertions(+), 1 deletion(-)

Diff Detail

Event Timeline

Nice patch, from testing with zero & near-zero area faces, this works better then the current method so would prefer to replace it instead of adding a new method.

source/blender/blenkernel/intern/mesh_evaluate.c
2038

No reason to copy into vectors, can assign coords to const float * as use them in-place.

2230

Should check total_volume != 0.0f instead.

The diff removes the old CoM code, uses more efficient vector access, and corrects some comments, as per feedback from ideasman.

Also add that the tetrahedron centroid algorithm comes from http://www.globalspec.com/reference/52702/203279/4-8-the-centroid-of-a-tetrahedron

This revision is now accepted and ready to land.May 12 2017, 3:10 AM