diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-09-22 09:05:26 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-09-22 09:05:26 +0400 |
commit | dc09774fb62ca3b8fe7e8b0da32d50636884a14b (patch) | |
tree | c10ae2dd78a45c2decbb535abcd6ad5c728e6778 /source/blender/editors/object/object_vgroup.c | |
parent | 7aa14fdbb978393c536503521e8c18708907f9b3 (diff) |
use bli math functions for vgroup_fix operator.
Diffstat (limited to 'source/blender/editors/object/object_vgroup.c')
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 85b62c97438..5265261f3af 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -955,10 +955,8 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in wasChange = FALSE; dm = dm_deform_recalc(scene, ob); dm->getVert(dm, index, &m); - oldPos[0] = m.co[0]; - oldPos[1] = m.co[1]; - oldPos[2] = m.co[2]; - distToStart = norm[0]*oldPos[0] + norm[1]*oldPos[1] + norm[2]*oldPos[2] + d; + copy_v3_v3(oldPos, m.co); + distToStart = dot_v3v3(norm, oldPos) + d; if(distToBe == originalDistToBe) { distToBe += distToStart - distToStart*strength; @@ -1123,18 +1121,14 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength, if(count >= 3) { float d /*, dist */ /* UNUSED */, mag; - float coord[3] = {0}; - float norm[3] = {0}; + float coord[3]; + float norm[3]; getSingleCoordinate(p, count, coord); dm->getVert(dm, i, &m); - norm[0] = m.co[0]-coord[0]; - norm[1] = m.co[1]-coord[1]; - norm[2] = m.co[2]-coord[2]; - mag = sqrt(norm[0]*norm[0] + norm[1]*norm[1] + norm[2]*norm[2]); - if(mag) {// zeros fix - mul_v3_fl(norm, 1.0f/mag); - - d = -norm[0]*coord[0] -norm[1]*coord[1] -norm[2]*coord[2]; + sub_v3_v3v3(norm, m.co, coord); + mag= normalize_v3(norm); + if(mag) { /* zeros fix */ + d = -dot_v3v3(norm, coord); /* dist = (norm[0]*m.co[0] + norm[1]*m.co[1] + norm[2]*m.co[2] + d); */ /* UNUSED */ moveCloserToDistanceFromPlane(scene, ob, me, i, norm, coord, d, distToBe, strength, cp); } |