diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-11-10 23:43:45 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-11-10 23:43:45 +0300 |
commit | 37e4a311b0ad9da7177e50620efc3561e2dd7045 (patch) | |
tree | 8aea2cc851ab828ee040d601ed4c776283fd639a /source/blender/editors/armature | |
parent | 4617bb68ba4b1c5ab459673fffd98bf7203bb4f2 (diff) |
Math Lib
* Convert all code to use new functions.
* Branch maintainers may want to skip this commit, and run this
conversion script instead, if they use a lot of math functions
in new code:
http://www.pasteall.org/9052/python
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r-- | source/blender/editors/armature/armature_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/armature/editarmature.c | 266 | ||||
-rw-r--r-- | source/blender/editors/armature/editarmature_generate.c | 68 | ||||
-rw-r--r-- | source/blender/editors/armature/editarmature_retarget.c | 180 | ||||
-rw-r--r-- | source/blender/editors/armature/editarmature_sketch.c | 122 | ||||
-rw-r--r-- | source/blender/editors/armature/meshlaplacian.c | 98 | ||||
-rw-r--r-- | source/blender/editors/armature/poseSlide.c | 10 | ||||
-rw-r--r-- | source/blender/editors/armature/poselib.c | 2 | ||||
-rw-r--r-- | source/blender/editors/armature/poseobject.c | 36 | ||||
-rw-r--r-- | source/blender/editors/armature/reeb.c | 94 |
10 files changed, 439 insertions, 439 deletions
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index e49e3d99c49..560a1458dfd 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -39,7 +39,7 @@ #include "DNA_view3d_types.h" #include "DNA_windowmanager_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BKE_context.h" diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 6dad0b6e90f..f89caa7b2c1 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -51,7 +51,7 @@ #include "DNA_curve_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_ghash.h" @@ -185,13 +185,13 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone eBone->roll= 0.0f; /* roll fixing */ - VecSubf(delta, eBone->tail, eBone->head); + sub_v3_v3v3(delta, eBone->tail, eBone->head); vec_roll_to_mat3(delta, 0.0f, postmat); - Mat3CpyMat4(premat, curBone->arm_mat); + copy_m3_m4(premat, curBone->arm_mat); - Mat3Inv(imat, postmat); - Mat3MulMat3(difmat, imat, premat); + invert_m3_m3(imat, postmat); + mul_m3_m3m3(difmat, imat, premat); eBone->roll = (float)atan2(difmat[2][0], difmat[2][2]); @@ -250,19 +250,19 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist) if (ebone) { /* Get the ebone premat */ - VecSubf(delta, ebone->tail, ebone->head); + sub_v3_v3v3(delta, ebone->tail, ebone->head); vec_roll_to_mat3(delta, ebone->roll, premat); /* Get the bone postmat */ - Mat3CpyMat4(postmat, curBone->arm_mat); + copy_m3_m4(postmat, curBone->arm_mat); - Mat3Inv(imat, premat); - Mat3MulMat3(difmat, imat, postmat); + invert_m3_m3(imat, premat); + mul_m3_m3m3(difmat, imat, postmat); #if 0 printf ("Bone %s\n", curBone->name); - printmatrix4("premat", premat); - printmatrix4("postmat", postmat); - printmatrix4("difmat", difmat); + print_m4("premat", premat); + print_m4("postmat", postmat); + print_m4("difmat", difmat); printf ("Roll = %f\n", (-atan2(difmat[2][0], difmat[2][2]) * (180.0/M_PI))); #endif curBone->roll = (float)-atan2(difmat[2][0], difmat[2][2]); @@ -287,7 +287,7 @@ void ED_armature_from_edit(Object *obedit) /* remove zero sized bones, this gives instable restposes */ for (eBone=arm->edbo->first; eBone; eBone= neBone) { - float len= VecLenf(eBone->head, eBone->tail); + float len= len_v3v3(eBone->head, eBone->tail); neBone= eBone->next; if (len <= 0.000001f) { /* FLT_EPSILON is too large? */ EditBone *fBone; @@ -350,22 +350,22 @@ void ED_armature_from_edit(Object *obedit) float delta[3]; /* Get the parent's matrix (rotation only) */ - VecSubf(delta, eBone->parent->tail, eBone->parent->head); + sub_v3_v3v3(delta, eBone->parent->tail, eBone->parent->head); vec_roll_to_mat3(delta, eBone->parent->roll, M_parentRest); /* Get this bone's matrix (rotation only) */ - VecSubf(delta, eBone->tail, eBone->head); + sub_v3_v3v3(delta, eBone->tail, eBone->head); vec_roll_to_mat3(delta, eBone->roll, M_boneRest); /* Invert the parent matrix */ - Mat3Inv(iM_parentRest, M_parentRest); + invert_m3_m3(iM_parentRest, M_parentRest); /* Get the new head and tail */ - VecSubf(newBone->head, eBone->head, eBone->parent->tail); - VecSubf(newBone->tail, eBone->tail, eBone->parent->tail); + sub_v3_v3v3(newBone->head, eBone->head, eBone->parent->tail); + sub_v3_v3v3(newBone->tail, eBone->tail, eBone->parent->tail); - Mat3MulVecfl(iM_parentRest, newBone->head); - Mat3MulVecfl(iM_parentRest, newBone->tail); + mul_m3_v3(iM_parentRest, newBone->head); + mul_m3_v3(iM_parentRest, newBone->tail); } } /* ...otherwise add this bone to the armature's bonebase */ @@ -390,15 +390,15 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4]) { EditBone *ebone; bArmature *arm= ob->data; - float scale = Mat4ToScalef(mat); /* store the scale of the matrix here to use on envelopes */ + float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */ /* Put the armature into editmode */ ED_armature_to_edit(ob); /* Do the rotations */ for (ebone = arm->edbo->first; ebone; ebone=ebone->next){ - Mat4MulVecfl(mat, ebone->head); - Mat4MulVecfl(mat, ebone->tail); + mul_m4_v3(mat, ebone->head); + mul_m4_v3(mat, ebone->tail); ebone->rad_head *= scale; ebone->rad_tail *= scale; @@ -429,8 +429,8 @@ void docenter_armature (Scene *scene, View3D *v3d, Object *ob, int centermode) if (centermode == 2) { float *fp= give_cursor(scene, v3d); VECCOPY(cent, fp); - Mat4Invert(ob->imat, ob->obmat); - Mat4MulVecfl(ob->imat, cent); + invert_m4_m4(ob->imat, ob->obmat); + mul_m4_v3(ob->imat, cent); } else { INIT_MINMAX(min, max); @@ -447,8 +447,8 @@ void docenter_armature (Scene *scene, View3D *v3d, Object *ob, int centermode) /* Do the adjustments */ for (ebone= arm->edbo->first; ebone; ebone=ebone->next) { - VecSubf(ebone->head, ebone->head, cent); - VecSubf(ebone->tail, ebone->tail, cent); + sub_v3_v3v3(ebone->head, ebone->head, cent); + sub_v3_v3v3(ebone->tail, ebone->tail, cent); } /* Turn the list into an armature */ @@ -456,9 +456,9 @@ void docenter_armature (Scene *scene, View3D *v3d, Object *ob, int centermode) /* Adjust object location for new centerpoint */ if(centermode && obedit==NULL) { - Mat3CpyMat4(omat, ob->obmat); + copy_m3_m4(omat, ob->obmat); - Mat3MulVecfl(omat, cent); + mul_m3_v3(omat, cent); ob->loc[0] += cent[0]; ob->loc[1] += cent[1]; ob->loc[2] += cent[2]; @@ -524,7 +524,7 @@ static void applyarmature_fix_boneparents (Scene *scene, Object *armob) ED_object_apply_obmat(ob); what_does_parent(scene, ob, &workob); - Mat4Invert(ob->parentinv, workob.obmat); + invert_m4_m4(ob->parentinv, workob.obmat); } } } @@ -572,16 +572,16 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) float delta[3], eul[3]; /* obtain new auto y-rotation */ - VecSubf(delta, curbone->tail, curbone->head); + sub_v3_v3v3(delta, curbone->tail, curbone->head); vec_roll_to_mat3(delta, 0.0f, premat); - Mat3Inv(imat, premat); + invert_m3_m3(imat, premat); /* get pchan 'visual' matrix */ - Mat3CpyMat4(pmat, pchan->pose_mat); + copy_m3_m4(pmat, pchan->pose_mat); /* remove auto from visual and get euler rotation */ - Mat3MulMat3(tmat, imat, pmat); - Mat3ToEul(tmat, eul); + mul_m3_m3m3(tmat, imat, pmat); + mat3_to_eul( eul,tmat); /* just use this euler-y as new roll value */ curbone->roll= eul[1]; @@ -769,8 +769,8 @@ int join_armature_exec(bContext *C, wmOperator *op) //BASACT->flag &= ~OB_MODE_POSE; /* Find the difference matrix */ - Mat4Invert(oimat, ob->obmat); - Mat4MulMat4(mat, base->object->obmat, oimat); + invert_m4_m4(oimat, ob->obmat); + mul_m4_m4m4(mat, base->object->obmat, oimat); /* Copy bones and posechannels from the object to the edit armature */ for (pchan=opose->chanbase.first; pchan; pchan=pchann) { @@ -790,23 +790,23 @@ int join_armature_exec(bContext *C, wmOperator *op) float delta[3]; /* Get the premat */ - VecSubf(delta, curbone->tail, curbone->head); + sub_v3_v3v3(delta, curbone->tail, curbone->head); vec_roll_to_mat3(delta, curbone->roll, temp); - Mat4One(premat); /* Mat4MulMat34 only sets 3x3 part */ - Mat4MulMat34(premat, temp, mat); + unit_m4(premat); /* Mat4MulMat34 only sets 3x3 part */ + mul_m4_m3m4(premat, temp, mat); - Mat4MulVecfl(mat, curbone->head); - Mat4MulVecfl(mat, curbone->tail); + mul_m4_v3(mat, curbone->head); + mul_m4_v3(mat, curbone->tail); /* Get the postmat */ - VecSubf(delta, curbone->tail, curbone->head); + sub_v3_v3v3(delta, curbone->tail, curbone->head); vec_roll_to_mat3(delta, curbone->roll, temp); - Mat4CpyMat3(postmat, temp); + copy_m4_m3(postmat, temp); /* Find the roll */ - Mat4Invert(imat, premat); - Mat4MulMat4(difmat, postmat, imat); + invert_m4_m4(imat, premat); + mul_m4_m4m4(difmat, postmat, imat); curbone->roll -= (float)atan2(difmat[2][0], difmat[2][2]); } @@ -1997,16 +1997,16 @@ float ED_rollBoneToVector(EditBone *bone, float new_up_axis[3]) float mat[3][3], nor[3], up_axis[3], vec[3]; float roll; - VecSubf(nor, bone->tail, bone->head); + sub_v3_v3v3(nor, bone->tail, bone->head); vec_roll_to_mat3(nor, 0, mat); VECCOPY(up_axis, mat[2]); - roll = NormalizedVecAngle2(new_up_axis, up_axis); + roll = angle_normalized_v3v3(new_up_axis, up_axis); - Crossf(vec, up_axis, new_up_axis); + cross_v3_v3v3(vec, up_axis, new_up_axis); - if (Inpf(vec, nor) < 0) + if (dot_v3v3(vec, nor) < 0) { roll = -roll; } @@ -2023,21 +2023,21 @@ void auto_align_ebone_zaxisup(Scene *scene, View3D *v3d, EditBone *ebone) float targetmat[3][3], imat[3][3], diffmat[3][3]; /* Find the current bone matrix */ - VecSubf(delta, ebone->tail, ebone->head); + sub_v3_v3v3(delta, ebone->tail, ebone->head); vec_roll_to_mat3(delta, 0.0f, curmat); /* Make new matrix based on y axis & z-up */ VECCOPY(yaxis, curmat[1]); - Mat3One(targetmat); + unit_m3(targetmat); VECCOPY(targetmat[0], xaxis); VECCOPY(targetmat[1], yaxis); VECCOPY(targetmat[2], zaxis); - Mat3Ortho(targetmat); + normalize_m3(targetmat); /* Find the difference between the two matrices */ - Mat3Inv(imat, targetmat); - Mat3MulMat3(diffmat, imat, curmat); + invert_m3_m3(imat, targetmat); + mul_m3_m3m3(diffmat, imat, curmat); // old-method... let's see if using mat3_to_vec_roll is more accurate //ebone->roll = atan2(diffmat[2][0], diffmat[2][2]); @@ -2055,28 +2055,28 @@ void auto_align_ebone_tocursor(Scene *scene, View3D *v3d, EditBone *ebone) float vec[3]; /* find the current bone matrix as a 4x4 matrix (in Armature Space) */ - VecSubf(delta, ebone->tail, ebone->head); + sub_v3_v3v3(delta, ebone->tail, ebone->head); vec_roll_to_mat3(delta, ebone->roll, curmat); - Mat4CpyMat3(mat, curmat); + copy_m4_m3(mat, curmat); VECCOPY(mat[3], ebone->head); /* multiply bone-matrix by object matrix (so that bone-matrix is in WorldSpace) */ - Mat4MulMat4(tmat, mat, obedit->obmat); - Mat4Invert(imat, tmat); + mul_m4_m4m4(tmat, mat, obedit->obmat); + invert_m4_m4(imat, tmat); /* find position of cursor relative to bone */ - VecMat4MulVecfl(vec, imat, cursor); + mul_v3_m4v3(vec, imat, cursor); /* check that cursor is in usable position */ if ((IS_EQ(vec[0], 0)==0) && (IS_EQ(vec[2], 0)==0)) { /* Compute a rotation matrix around y */ rot[1] = (float)atan2(vec[0], vec[2]); rot[0] = rot[2] = 0.0f; - EulToMat4(rot, rmat); + eul_to_mat4( rmat,rot); /* Multiply the bone matrix by rotation matrix. This should be new bone-matrix */ - Mat4MulMat4(tmat, rmat, mat); - Mat3CpyMat4(curmat, tmat); + mul_m4_m4m4(tmat, rmat, mat); + copy_m3_m4(curmat, tmat); /* Now convert from new bone-matrix, back to a roll value (in radians) */ mat3_to_vec_roll(curmat, delta, &ebone->roll); @@ -2278,16 +2278,16 @@ void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d) VECCOPY(curs, give_cursor(scene, v3d)); /* Get inverse point for head and orientation for tail */ - Mat4Invert(obedit->imat, obedit->obmat); - Mat4MulVecfl(obedit->imat, curs); + invert_m4_m4(obedit->imat, obedit->obmat); + mul_m4_v3(obedit->imat, curs); if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) - Mat3CpyMat4(obmat, rv3d->viewmat); - else Mat3One(obmat); + copy_m3_m4(obmat, rv3d->viewmat); + else unit_m3(obmat); - Mat3CpyMat4(viewmat, obedit->obmat); - Mat3MulMat3(totmat, obmat, viewmat); - Mat3Inv(imat, totmat); + copy_m3_m4(viewmat, obedit->obmat); + mul_m3_m3m3(totmat, obmat, viewmat); + invert_m3_m3(imat, totmat); ED_armature_deselectall(obedit, 0, 0); @@ -2297,9 +2297,9 @@ void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d) VECCOPY(bone->head, curs); if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) - VecAddf(bone->tail, bone->head, imat[1]); // bone with unit length 1 + add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1 else - VecAddf(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z + add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z } @@ -2375,16 +2375,16 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *op) curs= give_cursor(scene, v3d); VECCOPY(newbone->tail, curs); - VecSubf(newbone->tail, newbone->tail, obedit->obmat[3]); + sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]); if (a==1) newbone->tail[0]= -newbone->tail[0]; - Mat3CpyMat4(mat, obedit->obmat); - Mat3Inv(imat, mat); - Mat3MulVecfl(imat, newbone->tail); + copy_m3_m4(mat, obedit->obmat); + invert_m3_m3(imat, mat); + mul_m3_v3(imat, newbone->tail); - newbone->length= VecLenf(newbone->head, newbone->tail); + newbone->length= len_v3v3(newbone->head, newbone->tail); newbone->rad_tail= newbone->length*0.05f; newbone->dist= newbone->length*0.25f; @@ -2429,7 +2429,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e if(mval[0]!=IS_CLIPPED) { window_to_3d_delta(ar, dvec, mval[0]-mx, mval[1]-my); - VecSubf(fp, fp, dvec); + sub_v3_v3v3(fp, fp, dvec); } else { @@ -2885,7 +2885,7 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points) } for (ebp= points->first; ebp; ebp= ebp->next) { - if (VecEqual(ebp->vec, vec)) { + if (equals_v3v3(ebp->vec, vec)) { if (eb_tail) { if ((ebp->head_owner) && (ebp->head_owner->parent == ebo)) { /* so this bone's tail owner is this bone */ @@ -2969,8 +2969,8 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) fp= give_cursor(scene, v3d); VECCOPY (curs, fp); - Mat4Invert(obedit->imat, obedit->obmat); - Mat4MulVecfl(obedit->imat, curs); + invert_m4_m4(obedit->imat, obedit->obmat); + mul_m4_v3(obedit->imat, curs); /* Create a bone */ newbone= add_points_bone(obedit, ebp->vec, curs); @@ -3005,14 +3005,14 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) /* get cursor location */ VECCOPY(curs, fp); - Mat4Invert(obedit->imat, obedit->obmat); - Mat4MulVecfl(obedit->imat, curs); + invert_m4_m4(obedit->imat, obedit->obmat); + mul_m4_v3(obedit->imat, curs); /* get distances */ - VecSubf(vecA, ebp->vec, curs); - VecSubf(vecB, ebp2->vec, curs); - distA= VecLength(vecA); - distB= VecLength(vecB); + sub_v3_v3v3(vecA, ebp->vec, curs); + sub_v3_v3v3(vecB, ebp2->vec, curs); + distA= len_v3(vecA); + distB= len_v3(vecB); /* compare distances - closer one therefore acts as direction for bone to go */ headtail= (distA < distB) ? 2 : 1; @@ -3494,16 +3494,16 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) VECCOPY(curs, give_cursor(CTX_data_scene(C),CTX_wm_view3d(C))); /* Get inverse point for head and orientation for tail */ - Mat4Invert(obedit->imat, obedit->obmat); - Mat4MulVecfl(obedit->imat, curs); + invert_m4_m4(obedit->imat, obedit->obmat); + mul_m4_v3(obedit->imat, curs); if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) - Mat3CpyMat4(obmat, rv3d->viewmat); - else Mat3One(obmat); + copy_m3_m4(obmat, rv3d->viewmat); + else unit_m3(obmat); - Mat3CpyMat4(viewmat, obedit->obmat); - Mat3MulMat3(totmat, obmat, viewmat); - Mat3Inv(imat, totmat); + copy_m3_m4(viewmat, obedit->obmat); + mul_m3_m3m3(totmat, obmat, viewmat); + invert_m3_m3(imat, totmat); ED_armature_deselectall(obedit, 0, 0); @@ -3513,9 +3513,9 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) VECCOPY(bone->head, curs); if(rv3d && (U.flag & USER_ADD_VIEWALIGNED)) - VecAddf(bone->tail, bone->head, imat[1]); // bone with unit length 1 + add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1 else - VecAddf(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z + add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, obedit); @@ -3748,7 +3748,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *op) * - connected flag is only set if points are coincidental */ ebo->parent= child; - if ((child) && VecEqual(ebo->head, child->tail)) + if ((child) && equals_v3v3(ebo->head, child->tail)) ebo->flag |= BONE_CONNECTED; else ebo->flag &= ~BONE_CONNECTED; @@ -3834,12 +3834,12 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo if (mode == ARM_PAR_CONNECT) { /* Connected: Child bones will be moved to the parent tip */ selbone->flag |= BONE_CONNECTED; - VecSubf(offset, actbone->tail, selbone->head); + sub_v3_v3v3(offset, actbone->tail, selbone->head); VECCOPY(selbone->head, actbone->tail); selbone->rad_head= actbone->rad_tail; - VecAddf(selbone->tail, selbone->tail, offset); + add_v3_v3v3(selbone->tail, selbone->tail, offset); /* offset for all its children */ for (ebone = edbo->first; ebone; ebone=ebone->next) { @@ -3847,8 +3847,8 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo for (par= ebone->parent; par; par= par->parent) { if (par==selbone) { - VecAddf(ebone->head, ebone->head, offset); - VecAddf(ebone->tail, ebone->tail, offset); + add_v3_v3v3(ebone->head, ebone->head, offset); + add_v3_v3v3(ebone->tail, ebone->tail, offset); break; } } @@ -4199,13 +4199,13 @@ static void fix_connected_bone(EditBone *ebone) { float diff[3]; - if (!(ebone->parent) || !(ebone->flag & BONE_CONNECTED) || VecEqual(ebone->parent->tail, ebone->head)) + if (!(ebone->parent) || !(ebone->flag & BONE_CONNECTED) || equals_v3v3(ebone->parent->tail, ebone->head)) return; /* if the parent has moved we translate child's head and tail accordingly*/ - VecSubf(diff, ebone->parent->tail, ebone->head); - VecAddf(ebone->head, ebone->head, diff); - VecAddf(ebone->tail, ebone->tail, diff); + sub_v3_v3v3(diff, ebone->parent->tail, ebone->head); + add_v3_v3v3(ebone->head, ebone->head, diff); + add_v3_v3v3(ebone->tail, ebone->tail, diff); return; } @@ -4227,14 +4227,14 @@ static void bone_align_to_bone(ListBase *edbo, EditBone *selbone, EditBone *actb { float selboneaxis[3], actboneaxis[3], length; - VecSubf(actboneaxis, actbone->tail, actbone->head); - Normalize(actboneaxis); + sub_v3_v3v3(actboneaxis, actbone->tail, actbone->head); + normalize_v3(actboneaxis); - VecSubf(selboneaxis, selbone->tail, selbone->head); - length = VecLength(selboneaxis); + sub_v3_v3v3(selboneaxis, selbone->tail, selbone->head); + length = len_v3(selboneaxis); - VecMulf(actboneaxis, length); - VecAddf(selbone->tail, selbone->head, actboneaxis); + mul_v3_fl(actboneaxis, length); + add_v3_v3v3(selbone->tail, selbone->head, actboneaxis); selbone->roll = actbone->roll; /* if the bone being aligned has connected descendants they must be moved @@ -4720,10 +4720,10 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m /* compute root and tip */ if (bbone) { VECCOPY(root[j], bbone[segments].mat[3]); - Mat4MulVecfl(bone->arm_mat, root[j]); + mul_m4_v3(bone->arm_mat, root[j]); if ((segments+1) < bone->segments) { VECCOPY(tip[j], bbone[segments+1].mat[3]) - Mat4MulVecfl(bone->arm_mat, tip[j]); + mul_m4_v3(bone->arm_mat, tip[j]); } else VECCOPY(tip[j], bone->arm_tail) @@ -4733,8 +4733,8 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m VECCOPY(tip[j], bone->arm_tail); } - Mat4MulVecfl(par->obmat, root[j]); - Mat4MulVecfl(par->obmat, tip[j]); + mul_m4_v3(par->obmat, root[j]); + mul_m4_v3(par->obmat, tip[j]); /* set selected */ if (wpmode) { @@ -4788,7 +4788,7 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m for (i=0; i < mesh->totvert; i++) { if (!vertsfilled) VECCOPY(verts[i], mesh->mvert[i].co) - Mat4MulVecfl(ob->obmat, verts[i]); + mul_m4_v3(ob->obmat, verts[i]); } /* compute the weights based on gathered vertices and bones */ @@ -4798,7 +4798,7 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m } else { envelope_bone_weighting(ob, mesh, verts, numbones, bonelist, dgrouplist, - dgroupflip, root, tip, selected, Mat4ToScalef(par->obmat)); + dgroupflip, root, tip, selected, mat4_to_scale(par->obmat)); } /* free the memory allocated */ @@ -4969,10 +4969,10 @@ static int pose_clear_rot_exec(bContext *C, wmOperator *op) if (pchan->rotmode == ROT_MODE_QUAT) { QUATCOPY(quat1, pchan->quat); - QuatToEul(pchan->quat, oldeul); + quat_to_eul( oldeul,pchan->quat); } else if (pchan->rotmode == ROT_MODE_AXISANGLE) { - AxisAngleToEulO(pchan->rotAxis, pchan->rotAngle, oldeul, EULER_ORDER_DEFAULT); + axis_angle_to_eulO( oldeul, EULER_ORDER_DEFAULT,pchan->rotAxis, pchan->rotAngle); } else { VECCOPY(oldeul, pchan->eul); @@ -4988,14 +4988,14 @@ static int pose_clear_rot_exec(bContext *C, wmOperator *op) eul[2]= oldeul[2]; if (pchan->rotmode == ROT_MODE_QUAT) { - EulToQuat(eul, pchan->quat); + eul_to_quat( pchan->quat,eul); /* quaternions flip w sign to accumulate rotations correctly */ if ((quat1[0]<0.0f && pchan->quat[0]>0.0f) || (quat1[0]>0.0f && pchan->quat[0]<0.0f)) { - QuatMulf(pchan->quat, -1.0f); + mul_qt_fl(pchan->quat, -1.0f); } } else if (pchan->rotmode == ROT_MODE_AXISANGLE) { - EulOToAxisAngle(eul, EULER_ORDER_DEFAULT, pchan->rotAxis, &pchan->rotAngle); + eulO_to_axis_angle( pchan->rotAxis, &pchan->rotAngle,eul, EULER_ORDER_DEFAULT); } else { VECCOPY(pchan->eul, eul); @@ -5618,13 +5618,13 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode current = iter->p; - VecSubf(vec1, previous, parent->head); - VecSubf(vec2, current, previous); + sub_v3_v3v3(vec1, previous, parent->head); + sub_v3_v3v3(vec2, current, previous); - len1 = Normalize(vec1); - len2 = Normalize(vec2); + len1 = normalize_v3(vec1); + len2 = normalize_v3(vec2); - if (len1 > 0.0f && len2 > 0.0f && Inpf(vec1, vec2) < angleLimit) + if (len1 > 0.0f && len2 > 0.0f && dot_v3v3(vec1, vec2) < angleLimit) { VECCOPY(parent->tail, previous); @@ -5685,18 +5685,18 @@ float arcLengthRatio(ReebArc *arc) float embedLength = 0.0f; int i; - arcLength = VecLenf(arc->head->p, arc->tail->p); + arcLength = len_v3v3(arc->head->p, arc->tail->p); if (arc->bcount > 0) { /* Add the embedding */ for ( i = 1; i < arc->bcount; i++) { - embedLength += VecLenf(arc->buckets[i - 1].p, arc->buckets[i].p); + embedLength += len_v3v3(arc->buckets[i - 1].p, arc->buckets[i].p); } /* Add head and tail -> embedding vectors */ - embedLength += VecLenf(arc->head->p, arc->buckets[0].p); - embedLength += VecLenf(arc->tail->p, arc->buckets[arc->bcount - 1].p); + embedLength += len_v3v3(arc->head->p, arc->buckets[0].p); + embedLength += len_v3v3(arc->tail->p, arc->buckets[arc->bcount - 1].p); } else { @@ -5756,8 +5756,8 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) /* Copy orientation from source */ VECCOPY(dst->loc, src->obmat[3]); - Mat4ToEul(src->obmat, dst->rot); - Mat4ToSize(src->obmat, dst->size); + mat4_to_eul( dst->rot,src->obmat); + mat4_to_size( dst->size,src->obmat); where_is_object(scene, obedit); diff --git a/source/blender/editors/armature/editarmature_generate.c b/source/blender/editors/armature/editarmature_generate.c index d327ed34839..124528811c7 100644 --- a/source/blender/editors/armature/editarmature_generate.c +++ b/source/blender/editors/armature/editarmature_generate.c @@ -39,7 +39,7 @@ #include "DNA_armature_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_graph.h" #include "BKE_utildefines.h" @@ -52,18 +52,18 @@ void setBoneRollFromNormal(EditBone *bone, float *no, float invmat[][4], float tmat[][3]) { - if (no != NULL && !VecIsNull(no)) + if (no != NULL && !is_zero_v3(no)) { float tangent[3], vec[3], normal[3]; VECCOPY(normal, no); - Mat3MulVecfl(tmat, normal); + mul_m3_v3(tmat, normal); - VecSubf(tangent, bone->tail, bone->head); - Projf(vec, tangent, normal); - VecSubf(normal, normal, vec); + sub_v3_v3v3(tangent, bone->tail, bone->head); + project_v3_v3v3(vec, tangent, normal); + sub_v3_v3v3(normal, normal, vec); - Normalize(normal); + normalize_v3(normal); bone->roll = ED_rollBoneToVector(bone, normal); } @@ -86,11 +86,11 @@ float calcArcCorrelation(BArcIterator *iter, int start, int end, float v0[3], fl float v[3]; IT_peek(iter, i); - VecSubf(v, iter->p, v0); - avg_t += Inpf(v, n); + sub_v3_v3v3(v, iter->p, v0); + avg_t += dot_v3v3(v, n); } - avg_t /= Inpf(n, n); + avg_t /= dot_v3v3(n, n); avg_t += 1.0f; /* adding start (0) and end (1) values */ avg_t /= len; @@ -101,14 +101,14 @@ float calcArcCorrelation(BArcIterator *iter, int start, int end, float v0[3], fl float dt; IT_peek(iter, i); - VecSubf(v, iter->p, v0); - Projf(d, v, n); - VecSubf(v, v, d); + sub_v3_v3v3(v, iter->p, v0); + project_v3_v3v3(d, v, n); + sub_v3_v3v3(v, v, d); - dt = VecLength(d) - avg_t; + dt = len_v3(d) - avg_t; s_t += dt * dt; - s_xyz += Inpf(v, v); + s_xyz += dot_v3v3(v, v); } /* adding start(0) and end(1) values to s_t */ @@ -143,7 +143,7 @@ int nextFixedSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int sta IT_peek(iter, i); v2 = iter->p; - stroke_length += VecLenf(v1, v2); + stroke_length += len_v3v3(v1, v2); v1 = v2; } @@ -165,7 +165,7 @@ int nextFixedSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int sta IT_peek(iter, i); v2 = iter->p; - current_length += VecLenf(v1, v2); + current_length += len_v3v3(v1, v2); if (current_length >= length_threshold) { @@ -194,7 +194,7 @@ int nextAdaptativeSubdivision(ToolSettings *toolsettings, BArcIterator *iter, in { /* Calculate normal */ IT_peek(iter, i); - VecSubf(n, iter->p, head); + sub_v3_v3v3(n, iter->p, head); if (calcArcCorrelation(iter, start, i, start_p, n) < correlation_threshold) { @@ -226,7 +226,7 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st vec1 = iter->p; /* If lengthLimit hits the current segment */ - if (VecLenf(vec1, head) > lengthLimit) + if (len_v3v3(vec1, head) > lengthLimit) { if (same == 0) { @@ -234,13 +234,13 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st float a, b, c, f; /* Solve quadratic distance equation */ - VecSubf(dv, vec1, vec0); - a = Inpf(dv, dv); + sub_v3_v3v3(dv, vec1, vec0); + a = dot_v3v3(dv, dv); - VecSubf(off, vec0, head); - b = 2 * Inpf(dv, off); + sub_v3_v3v3(off, vec0, head); + b = 2 * dot_v3v3(dv, off); - c = Inpf(off, off) - (lengthLimit * lengthLimit); + c = dot_v3v3(off, off) - (lengthLimit * lengthLimit); f = (-b + (float)sqrt(b * b - 4 * a * c)) / (2 * a); @@ -249,8 +249,8 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st if (isnan(f) == 0 && f < 1.0f) { VECCOPY(p, dv); - VecMulf(p, f); - VecAddf(p, p, vec0); + mul_v3_fl(p, f); + add_v3_v3v3(p, p, vec0); } else { @@ -261,12 +261,12 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st { float dv[3]; - VecSubf(dv, vec1, vec0); - Normalize(dv); + sub_v3_v3v3(dv, vec1, vec0); + normalize_v3(dv); VECCOPY(p, dv); - VecMulf(p, lengthLimit); - VecAddf(p, p, head); + mul_v3_fl(p, lengthLimit); + add_v3_v3v3(p, p, head); } return i - 1; /* restart at lower bound */ @@ -321,8 +321,8 @@ EditBone * subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase * } /* going to next bone, fix parent */ - Mat4MulVecfl(invmat, parent->tail); - Mat4MulVecfl(invmat, parent->head); + mul_m4_v3(invmat, parent->tail); + mul_m4_v3(invmat, parent->head); setBoneRollFromNormal(parent, normal, invmat, tmat); parent = child; // new child is next parent @@ -342,8 +342,8 @@ EditBone * subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase * } /* fix last bone */ - Mat4MulVecfl(invmat, parent->tail); - Mat4MulVecfl(invmat, parent->head); + mul_m4_v3(invmat, parent->tail); + mul_m4_v3(invmat, parent->head); setBoneRollFromNormal(parent, iter->no, invmat, tmat); lastBone = parent; diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index 824e7be94d9..946b7398773 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -48,7 +48,7 @@ #include "DNA_view3d_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_ghash.h" #include "BLI_graph.h" @@ -162,7 +162,7 @@ void getEditBoneRollUpAxis(EditBone *bone, float roll, float up_axis[3]) { float mat[3][3], nor[3]; - VecSubf(nor, bone->tail, bone->head); + sub_v3_v3v3(nor, bone->tail, bone->head); vec_roll_to_mat3(nor, roll, mat); VECCOPY(up_axis, mat[2]); @@ -173,35 +173,35 @@ float rollBoneByQuatAligned(EditBone *bone, float old_up_axis[3], float qrot[4], float nor[3], new_up_axis[3], x_axis[3], z_axis[3]; VECCOPY(new_up_axis, old_up_axis); - QuatMulVecf(qrot, new_up_axis); + mul_qt_v3(qrot, new_up_axis); - VecSubf(nor, bone->tail, bone->head); + sub_v3_v3v3(nor, bone->tail, bone->head); - Crossf(x_axis, nor, aligned_axis); - Crossf(z_axis, x_axis, nor); + cross_v3_v3v3(x_axis, nor, aligned_axis); + cross_v3_v3v3(z_axis, x_axis, nor); - Normalize(new_up_axis); - Normalize(x_axis); - Normalize(z_axis); + normalize_v3(new_up_axis); + normalize_v3(x_axis); + normalize_v3(z_axis); - if (Inpf(new_up_axis, x_axis) < 0) + if (dot_v3v3(new_up_axis, x_axis) < 0) { - VecMulf(x_axis, -1); + mul_v3_fl(x_axis, -1); } - if (Inpf(new_up_axis, z_axis) < 0) + if (dot_v3v3(new_up_axis, z_axis) < 0) { - VecMulf(z_axis, -1); + mul_v3_fl(z_axis, -1); } - if (NormalizedVecAngle2(x_axis, new_up_axis) < NormalizedVecAngle2(z_axis, new_up_axis)) + if (angle_normalized_v3v3(x_axis, new_up_axis) < angle_normalized_v3v3(z_axis, new_up_axis)) { - RotationBetweenVectorsToQuat(qroll, new_up_axis, x_axis); /* set roll rotation quat */ + rotation_between_vecs_to_quat(qroll, new_up_axis, x_axis); /* set roll rotation quat */ return ED_rollBoneToVector(bone, x_axis); } else { - RotationBetweenVectorsToQuat(qroll, new_up_axis, z_axis); /* set roll rotation quat */ + rotation_between_vecs_to_quat(qroll, new_up_axis, z_axis); /* set roll rotation quat */ return ED_rollBoneToVector(bone, z_axis); } } @@ -220,11 +220,11 @@ float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4], float if (previous->bone) { - VecSubf(vec_first, previous->bone->tail, previous->bone->head); + sub_v3_v3v3(vec_first, previous->bone->tail, previous->bone->head); } else if (previous->prev->bone) { - VecSubf(vec_first, edge->bone->head, previous->prev->bone->tail); + sub_v3_v3v3(vec_first, edge->bone->head, previous->prev->bone->tail); } else { @@ -232,25 +232,25 @@ float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4], float return rollBoneByQuatAligned(edge->bone, edge->up_axis, qrot, qroll, up_axis); } - VecSubf(vec_second, edge->bone->tail, edge->bone->head); + sub_v3_v3v3(vec_second, edge->bone->tail, edge->bone->head); - Normalize(vec_first); - Normalize(vec_second); + normalize_v3(vec_first); + normalize_v3(vec_second); - Crossf(normal, vec_first, vec_second); - Normalize(normal); + cross_v3_v3v3(normal, vec_first, vec_second); + normalize_v3(normal); - AxisAngleToQuat(qroll, vec_second, edge->up_angle); + axis_angle_to_quat(qroll, vec_second, edge->up_angle); - QuatMulVecf(qroll, normal); + mul_qt_v3(qroll, normal); VECCOPY(new_up_axis, edge->up_axis); - QuatMulVecf(qrot, new_up_axis); + mul_qt_v3(qrot, new_up_axis); - Normalize(new_up_axis); + normalize_v3(new_up_axis); /* real qroll between normal and up_axis */ - RotationBetweenVectorsToQuat(qroll, new_up_axis, normal); + rotation_between_vecs_to_quat(qroll, new_up_axis, normal); return ED_rollBoneToVector(edge->bone, normal); } @@ -261,9 +261,9 @@ float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4]) float new_up_axis[3]; VECCOPY(new_up_axis, old_up_axis); - QuatMulVecf(qrot, new_up_axis); + mul_qt_v3(qrot, new_up_axis); - Normalize(new_up_axis); + normalize_v3(new_up_axis); return ED_rollBoneToVector(bone, new_up_axis); } @@ -431,7 +431,7 @@ static void RIG_appendEdgeToArc(RigArc *arc, RigEdge *edge) RIG_calculateEdgeAngles(last_edge, edge); } - edge->length = VecLenf(edge->head, edge->tail); + edge->length = len_v3v3(edge->head, edge->tail); arc->length += edge->length; @@ -675,22 +675,22 @@ static void RIG_calculateEdgeAngles(RigEdge *edge_first, RigEdge *edge_second) { float vec_first[3], vec_second[3]; - VecSubf(vec_first, edge_first->tail, edge_first->head); - VecSubf(vec_second, edge_second->tail, edge_second->head); + sub_v3_v3v3(vec_first, edge_first->tail, edge_first->head); + sub_v3_v3v3(vec_second, edge_second->tail, edge_second->head); - Normalize(vec_first); - Normalize(vec_second); + normalize_v3(vec_first); + normalize_v3(vec_second); - edge_first->angle = NormalizedVecAngle2(vec_first, vec_second); + edge_first->angle = angle_normalized_v3v3(vec_first, vec_second); if (edge_second->bone != NULL) { float normal[3]; - Crossf(normal, vec_first, vec_second); - Normalize(normal); + cross_v3_v3v3(normal, vec_first, vec_second); + normalize_v3(normal); - edge_second->up_angle = NormalizedVecAngle2(normal, edge_second->up_axis); + edge_second->up_angle = angle_normalized_v3v3(normal, edge_second->up_axis); } } @@ -715,27 +715,27 @@ static int RIG_parentControl(RigControl *ctrl, EditBone *link) float offset[3]; int flag = 0; - VecSubf(offset, ctrl->bone->head, link->head); + sub_v3_v3v3(offset, ctrl->bone->head, link->head); /* if root matches, check for direction too */ - if (Inpf(offset, offset) < 0.0001) + if (dot_v3v3(offset, offset) < 0.0001) { float vbone[3], vparent[3]; flag |= RIG_CTRL_FIT_ROOT; - VecSubf(vbone, ctrl->bone->tail, ctrl->bone->head); - VecSubf(vparent, link->tail, link->head); + sub_v3_v3v3(vbone, ctrl->bone->tail, ctrl->bone->head); + sub_v3_v3v3(vparent, link->tail, link->head); /* test for opposite direction */ - if (Inpf(vbone, vparent) > 0) + if (dot_v3v3(vbone, vparent) > 0) { float nor[3]; float len; - Crossf(nor, vbone, vparent); + cross_v3_v3v3(nor, vbone, vparent); - len = Inpf(nor, nor); + len = dot_v3v3(nor, nor); if (len < 0.0001) { flag |= RIG_CTRL_FIT_BONE; @@ -869,8 +869,8 @@ static void RIG_reconnectControlBones(RigGraph *rg) { int fit = 0; - fit = VecLenf(ctrl->bone->head, edge->bone->head) < 0.0001; - fit = fit || VecLenf(ctrl->bone->tail, edge->bone->tail) < 0.0001; + fit = len_v3v3(ctrl->bone->head, edge->bone->head) < 0.0001; + fit = fit || len_v3v3(ctrl->bone->tail, edge->bone->tail) < 0.0001; if (fit) { @@ -1026,13 +1026,13 @@ static void RIG_reconnectControlBones(RigGraph *rg) /* don't link with parent */ if (bone->parent != ctrl->bone) { - if (VecLenf(ctrl->bone->tail, bone->head) < 0.01) + if (len_v3v3(ctrl->bone->tail, bone->head) < 0.01) { ctrl->tail_mode = TL_HEAD; ctrl->link_tail = bone; break; } - else if (VecLenf(ctrl->bone->tail, bone->tail) < 0.01) + else if (len_v3v3(ctrl->bone->tail, bone->tail) < 0.01) { ctrl->tail_mode = TL_TAIL; ctrl->link_tail = bone; @@ -1132,7 +1132,7 @@ static void RIG_removeUneededOffsets(RigGraph *rg) if (first_edge->bone == NULL) { - if (first_edge->bone == NULL && VecLenf(first_edge->tail, arc->head->p) <= 0.001) + if (first_edge->bone == NULL && len_v3v3(first_edge->tail, arc->head->p) <= 0.001) { BLI_remlink(&arc->edges, first_edge); MEM_freeN(first_edge); @@ -1262,7 +1262,7 @@ static void RIG_removeUneededOffsets(RigGraph *rg) if (last_edge->bone == NULL) { - if (VecLenf(last_edge->head, arc->tail->p) <= 0.001) + if (len_v3v3(last_edge->head, arc->tail->p) <= 0.001) { BLI_remlink(&arc->edges, last_edge); MEM_freeN(last_edge); @@ -1438,7 +1438,7 @@ void RIG_printNode(RigNode *node, char name[]) else if (node->symmetry_flag & SYM_RADIAL) printf("Symmetry RADIAL\n"); - printvecf("symmetry axis", node->symmetry_axis); + print_v3("symmetry axis", node->symmetry_axis); } } @@ -1464,7 +1464,7 @@ void RIG_printCtrl(RigControl *ctrl, char *indent) printf("%sLink: %s\n", indent, ctrl->link ? ctrl->link->name : "!NONE!"); sprintf(text, "%soffset", indent); - printvecf(text, ctrl->offset); + print_v3(text, ctrl->offset); printf("%sFlag: %i\n", indent, ctrl->flag); } @@ -1761,15 +1761,15 @@ static void finalizeControl(RigGraph *rigg, RigControl *ctrl, float resize) tail_vec = ctrl->link_tail->head; } - VecSubf(v1, ctrl->bone->tail, ctrl->bone->head); - VecSubf(v2, tail_vec, ctrl->bone->head); + sub_v3_v3v3(v1, ctrl->bone->tail, ctrl->bone->head); + sub_v3_v3v3(v2, tail_vec, ctrl->bone->head); VECCOPY(ctrl->bone->tail, tail_vec); - RotationBetweenVectorsToQuat(qtail, v1, v2); - QuatMul(ctrl->qrot, qtail, ctrl->qrot); + rotation_between_vecs_to_quat(qtail, v1, v2); + mul_qt_qtqt(ctrl->qrot, qtail, ctrl->qrot); - resize = VecLength(v2) / VecLenf(ctrl->head, ctrl->tail); + resize = len_v3(v2) / len_v3v3(ctrl->head, ctrl->tail); } ctrl->bone->roll = rollBoneByQuat(ctrl->bone, ctrl->up_axis, ctrl->qrot); @@ -1801,10 +1801,10 @@ static void repositionControl(RigGraph *rigg, RigControl *ctrl, float head[3], f float parent_offset[3], tail_offset[3]; VECCOPY(parent_offset, ctrl->offset); - VecMulf(parent_offset, resize); - QuatMulVecf(qrot, parent_offset); + mul_v3_fl(parent_offset, resize); + mul_qt_v3(qrot, parent_offset); - VecAddf(ctrl->bone->head, head, parent_offset); + add_v3_v3v3(ctrl->bone->head, head, parent_offset); ctrl->flag |= RIG_CTRL_HEAD_DONE; @@ -1812,11 +1812,11 @@ static void repositionControl(RigGraph *rigg, RigControl *ctrl, float head[3], f if (ctrl->tail_mode == TL_NONE) { - VecSubf(tail_offset, ctrl->tail, ctrl->head); - VecMulf(tail_offset, resize); - QuatMulVecf(qrot, tail_offset); + sub_v3_v3v3(tail_offset, ctrl->tail, ctrl->head); + mul_v3_fl(tail_offset, resize); + mul_qt_v3(qrot, tail_offset); - VecAddf(ctrl->bone->tail, ctrl->bone->head, tail_offset); + add_v3_v3v3(ctrl->bone->tail, ctrl->bone->head, tail_offset); ctrl->flag |= RIG_CTRL_TAIL_DONE; } @@ -1835,20 +1835,20 @@ static void repositionBone(bContext *C, RigGraph *rigg, RigEdge *edge, float vec bone = edge->bone; - VecSubf(v1, edge->tail, edge->head); - VecSubf(v2, vec1, vec0); + sub_v3_v3v3(v1, edge->tail, edge->head); + sub_v3_v3v3(v2, vec1, vec0); - l1 = Normalize(v1); - l2 = Normalize(v2); + l1 = normalize_v3(v1); + l2 = normalize_v3(v2); resize = l2 / l1; - RotationBetweenVectorsToQuat(qrot, v1, v2); + rotation_between_vecs_to_quat(qrot, v1, v2); VECCOPY(bone->head, vec0); VECCOPY(bone->tail, vec1); - if (!VecIsNull(up_axis)) + if (!is_zero_v3(up_axis)) { float qroll[4]; @@ -1862,10 +1862,10 @@ static void repositionBone(bContext *C, RigGraph *rigg, RigEdge *edge, float vec } else { - QuatOne(qroll); + unit_qt(qroll); } - QuatMul(qrot, qroll, qrot); + mul_qt_qtqt(qrot, qroll, qrot); } else { @@ -1979,9 +1979,9 @@ static float costDistance(BArcIterator *iter, float *vec0, float *vec1, int i0, if (distance_weight > 0) { - VecSubf(v1, vec0, vec1); + sub_v3_v3v3(v1, vec0, vec1); - v1_inpf = Inpf(v1, v1); + v1_inpf = dot_v3v3(v1, v1); if (v1_inpf > 0) { @@ -1992,11 +1992,11 @@ static float costDistance(BArcIterator *iter, float *vec0, float *vec1, int i0, bucket = IT_peek(iter, j); - VecSubf(v2, bucket->p, vec1); + sub_v3_v3v3(v2, bucket->p, vec1); - Crossf(c, v1, v2); + cross_v3_v3v3(c, v1, v2); - dist = Inpf(c, c) / v1_inpf; + dist = dot_v3v3(c, c) / v1_inpf; max_dist = dist > max_dist ? dist : max_dist; } @@ -2020,9 +2020,9 @@ static float costAngle(float original_angle, float vec_first[3], float vec_secon { float current_angle; - if (!VecIsNull(vec_first) && !VecIsNull(vec_second)) + if (!is_zero_v3(vec_first) && !is_zero_v3(vec_second)) { - current_angle = saacos(Inpf(vec_first, vec_second)); + current_angle = saacos(dot_v3v3(vec_first, vec_second)); return angle_weight * fabs(current_angle - original_angle); } @@ -2056,8 +2056,8 @@ static float calcCostLengthDistance(BArcIterator *iter, float **vec_cache, RigEd float vec[3]; float length; - VecSubf(vec, vec2, vec1); - length = Normalize(vec); + sub_v3_v3v3(vec, vec2, vec1); + length = normalize_v3(vec); return costLength(edge->length, length) + costDistance(iter, vec1, vec2, i1, i2); } @@ -2069,15 +2069,15 @@ static float calcCostAngleLengthDistance(BArcIterator *iter, float **vec_cache, float length2; float new_cost = 0; - VecSubf(vec_second, vec2, vec1); - length2 = Normalize(vec_second); + sub_v3_v3v3(vec_second, vec2, vec1); + length2 = normalize_v3(vec_second); /* Angle cost */ if (edge->prev) { - VecSubf(vec_first, vec1, vec0); - Normalize(vec_first); + sub_v3_v3v3(vec_first, vec1, vec0); + normalize_v3(vec_first); new_cost += costAngle(edge->prev->angle, vec_first, vec_second, angle_weight); } @@ -2352,13 +2352,13 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri { vec1 = bucket->p; - embedding_length += VecLenf(vec0, vec1); + embedding_length += len_v3v3(vec0, vec1); vec0 = vec1; bucket = IT_next(iter); } - embedding_length += VecLenf(node_end->p, vec1); + embedding_length += len_v3v3(node_end->p, vec1); /* fit bones */ initArcIterator(iter, earc, node_start); @@ -2377,7 +2377,7 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri while (bucket && new_bone_length > length) { - length += VecLenf(previous_vec, vec1); + length += len_v3v3(previous_vec, vec1); bucket = IT_next(iter); previous_vec = vec1; vec1 = bucket->p; diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index b3dd8f35137..7bb2fa9009d 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -39,7 +39,7 @@ #include "RNA_access.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_graph.h" #include "BLI_ghash.h" @@ -416,10 +416,10 @@ ReebNode *sk_pointToNode(SK_Point *pt, float imat[][4], float tmat[][3]) node = MEM_callocN(sizeof(ReebNode), "reeb node"); VECCOPY(node->p, pt->p); - Mat4MulVecfl(imat, node->p); + mul_m4_v3(imat, node->p); VECCOPY(node->no, pt->no); - Mat3MulVecfl(tmat, node->no); + mul_m3_v3(tmat, node->no); return node; } @@ -439,10 +439,10 @@ ReebArc *sk_strokeToArc(SK_Stroke *stk, float imat[][4], float tmat[][3]) for (i = 0; i < arc->bcount; i++) { VECCOPY(arc->buckets[i].p, stk->points[i + 1].p); - Mat4MulVecfl(imat, arc->buckets[i].p); + mul_m4_v3(imat, arc->buckets[i].p); VECCOPY(arc->buckets[i].no, stk->points[i + 1].no); - Mat3MulVecfl(tmat, arc->buckets[i].no); + mul_m3_v3(tmat, arc->buckets[i].no); } return arc; @@ -457,10 +457,10 @@ void sk_retargetStroke(bContext *C, SK_Stroke *stk) ReebArc *arc; RigGraph *rg; - Mat4Invert(imat, obedit->obmat); + invert_m4_m4(imat, obedit->obmat); - Mat3CpyMat4(tmat, obedit->obmat); - Mat3Transp(tmat); + copy_m3_m4(tmat, obedit->obmat); + transpose_m3(tmat); arc = sk_strokeToArc(stk, imat, tmat); @@ -505,16 +505,16 @@ void sk_drawEdge(GLUquadric *quad, SK_Point *pt0, SK_Point *pt1, float size) float vec1[3], vec2[3] = {0, 0, 1}, axis[3]; float angle, length; - VecSubf(vec1, pt1->p, pt0->p); - length = Normalize(vec1); - Crossf(axis, vec2, vec1); + sub_v3_v3v3(vec1, pt1->p, pt0->p); + length = normalize_v3(vec1); + cross_v3_v3v3(axis, vec2, vec1); - if (VecIsNull(axis)) + if (is_zero_v3(axis)) { axis[1] = 1; } - angle = NormalizedVecAngle2(vec2, vec1); + angle = angle_normalized_v3v3(vec2, vec1); glRotatef(angle * 180 / M_PI + 180, axis[0], axis[1], axis[2]); @@ -528,14 +528,14 @@ void sk_drawNormal(GLUquadric *quad, SK_Point *pt, float size, float height) glPushMatrix(); - Crossf(axis, vec2, pt->no); + cross_v3_v3v3(axis, vec2, pt->no); - if (VecIsNull(axis)) + if (is_zero_v3(axis)) { axis[1] = 1; } - angle = NormalizedVecAngle2(vec2, pt->no); + angle = angle_normalized_v3v3(vec2, pt->no); glRotatef(angle * 180 / M_PI, axis[0], axis[1], axis[2]); @@ -576,8 +576,8 @@ void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int end) float d_rgb[3] = {1, 1, 1}; VECCOPY(rgb, color); - VecSubf(d_rgb, d_rgb, rgb); - VecMulf(d_rgb, 1.0f / (float)stk->nb_points); + sub_v3_v3v3(d_rgb, d_rgb, rgb); + mul_v3_fl(d_rgb, 1.0f / (float)stk->nb_points); for (i = 0; i < stk->nb_points; i++) { @@ -614,7 +614,7 @@ void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int end) glPopMatrix(); - VecAddf(rgb, rgb, d_rgb); + add_v3_v3v3(rgb, rgb, d_rgb); } } @@ -756,7 +756,7 @@ SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, short if ((bone->flag & BONE_CONNECTED) == 0) { VECCOPY(vec, bone->head); - Mat4MulVecfl(ob->obmat, vec); + mul_m4_v3(ob->obmat, vec); project_short_noclip(ar, vec, pval); pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]); @@ -772,7 +772,7 @@ SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, short VECCOPY(vec, bone->tail); - Mat4MulVecfl(ob->obmat, vec); + mul_m4_v3(ob->obmat, vec); project_short_noclip(ar, vec, pval); pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]); @@ -977,13 +977,13 @@ float sk_distanceDepth(bContext *C, float p1[3], float p2[3]) float vec[3]; float distance; - VecSubf(vec, p1, p2); + sub_v3_v3v3(vec, p1, p2); - Projf(vec, vec, rv3d->viewinv[2]); + project_v3_v3v3(vec, vec, rv3d->viewinv[2]); - distance = VecLength(vec); + distance = len_v3(vec); - if (Inpf(rv3d->viewinv[2], vec) > 0) + if (dot_v3v3(rv3d->viewinv[2], vec) > 0) { distance *= -1; } @@ -1000,19 +1000,19 @@ void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end, float float progress = 0; int i; - progress = VecLenf(stk->points[start].p, stk->points[start - 1].p); + progress = len_v3v3(stk->points[start].p, stk->points[start - 1].p); for (i = start; i <= end; i++) { float ray_start[3], ray_normal[3]; - float delta = VecLenf(stk->points[i].p, stk->points[i + 1].p); + float delta = len_v3v3(stk->points[i].p, stk->points[i + 1].p); float pval[2]; project_float(ar, stk->points[i].p, pval); viewray(ar, v3d, pval, ray_start, ray_normal); - VecMulf(ray_normal, distance * progress / length); - VecAddf(stk->points[i].p, stk->points[i].p, ray_normal); + mul_v3_fl(ray_normal, distance * progress / length); + add_v3_v3v3(stk->points[i].p, stk->points[i].p, ray_normal); progress += delta ; } @@ -1037,7 +1037,7 @@ void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_DrawData /* method taken from editview.c - mouse_cursor() */ project_short_noclip(ar, fp, cval); window_to_3d_delta(ar, dvec, cval[0] - dd->mval[0], cval[1] - dd->mval[1]); - VecSubf(vec, fp, dvec); + sub_v3_v3v3(vec, fp, dvec); } int sk_getStrokeDrawPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd) @@ -1132,9 +1132,9 @@ int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Strok { p2->flag = 1; - VecAddf(vec, p1->p, p2->p); - VecMulf(vec, 0.5f); - new_size = VecLenf(p1->p, p2->p); + add_v3_v3v3(vec, p1->p, p2->p); + mul_v3_fl(vec, 0.5f); + new_size = len_v3v3(p1->p, p2->p); } else { @@ -1149,7 +1149,7 @@ int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Strok break; } - new_dist = VecLenf(last_p, vec); + new_dist = len_v3v3(last_p, vec); if (new_dist < dist) { @@ -1248,7 +1248,7 @@ int sk_addStrokeSnapPoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_Dra length = 0; for (i = stk->nb_points - 2; i > 0; i--) { - length += VecLenf(stk->points[i].p, stk->points[i + 1].p); + length += len_v3v3(stk->points[i].p, stk->points[i + 1].p); total++; if (stk->points[i].mode == PT_SNAP || stk->points[i].type == PT_EXACT) { @@ -1494,10 +1494,10 @@ void sk_convertStroke(bContext *C, SK_Stroke *stk) head = NULL; - Mat4Invert(invmat, obedit->obmat); + invert_m4_m4(invmat, obedit->obmat); - Mat3CpyMat4(tmat, obedit->obmat); - Mat3Transp(tmat); + copy_m3_m4(tmat, obedit->obmat); + transpose_m3(tmat); for (i = 0; i < stk->nb_points; i++) { @@ -1543,8 +1543,8 @@ void sk_convertStroke(bContext *C, SK_Stroke *stk) VECCOPY(bone->head, head->p); VECCOPY(bone->tail, pt->p); - Mat4MulVecfl(invmat, bone->head); - Mat4MulVecfl(invmat, bone->tail); + mul_m4_v3(invmat, bone->head); + mul_m4_v3(invmat, bone->tail); setBoneRollFromNormal(bone, head->no, invmat, tmat); } @@ -1624,7 +1624,7 @@ int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gesture) project_float(ar, gesture->points[g_i].p, g_p1); project_float(ar, gesture->points[g_i + 1].p, g_p2); - if (LineIntersectLineStrict(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) + if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) { SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection"); @@ -1633,9 +1633,9 @@ int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gesture) isect->after = s_i + 1; isect->stroke = gesture; - VecSubf(isect->p, gesture->points[s_i + 1].p, gesture->points[s_i].p); - VecMulf(isect->p, lambda); - VecAddf(isect->p, isect->p, gesture->points[s_i].p); + sub_v3_v3v3(isect->p, gesture->points[s_i + 1].p, gesture->points[s_i].p); + mul_v3_fl(isect->p, lambda); + add_v3_v3v3(isect->p, isect->p, gesture->points[s_i].p); BLI_addtail(list, isect); @@ -1711,7 +1711,7 @@ int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, SK_Strok project_float(ar, gesture->points[g_i].p, g_p1); project_float(ar, gesture->points[g_i + 1].p, g_p2); - if (LineIntersectLineStrict(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) + if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) { SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection"); float ray_start[3], ray_end[3]; @@ -1727,7 +1727,7 @@ int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, SK_Strok mval[1] = vi[1]; viewline(ar, v3d, mval, ray_start, ray_end); - LineIntersectLine( stk->points[s_i].p, + isect_line_line_v3( stk->points[s_i].p, stk->points[s_i + 1].p, ray_start, ray_end, @@ -1768,7 +1768,7 @@ int sk_getSegments(SK_Stroke *segments, SK_Stroke *gesture) float n[3]; /* Calculate normal */ - VecSubf(n, gesture->points[i].p, vec); + sub_v3_v3v3(n, gesture->points[i].p, vec); if (calcArcCorrelation(iter, j, i, vec, n) < CORRELATION_THRESHOLD) { @@ -1818,10 +1818,10 @@ int sk_detectTrimGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) float s1[3], s2[3]; float angle; - VecSubf(s1, gest->segments->points[1].p, gest->segments->points[0].p); - VecSubf(s2, gest->segments->points[2].p, gest->segments->points[1].p); + sub_v3_v3v3(s1, gest->segments->points[1].p, gest->segments->points[0].p); + sub_v3_v3v3(s2, gest->segments->points[2].p, gest->segments->points[1].p); - angle = RAD2DEG(VecAngle2(s1, s2)); + angle = RAD2DEG(angle_v2v2(s1, s2)); if (angle > 60 && angle < 120) { @@ -1837,7 +1837,7 @@ void sk_applyTrimGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) SK_Intersection *isect; float trim_dir[3]; - VecSubf(trim_dir, gest->segments->points[2].p, gest->segments->points[1].p); + sub_v3_v3v3(trim_dir, gest->segments->points[2].p, gest->segments->points[1].p); for (isect = gest->intersections.first; isect; isect = isect->next) { @@ -1849,10 +1849,10 @@ void sk_applyTrimGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) VECCOPY(pt.p, isect->p); VECCOPY(pt.no, isect->stroke->points[isect->before].no); - VecSubf(stroke_dir, isect->stroke->points[isect->after].p, isect->stroke->points[isect->before].p); + sub_v3_v3v3(stroke_dir, isect->stroke->points[isect->after].p, isect->stroke->points[isect->before].p); /* same direction, trim end */ - if (Inpf(stroke_dir, trim_dir) > 0) + if (dot_v3v3(stroke_dir, trim_dir) > 0) { sk_replaceStrokePoint(isect->stroke, &pt, isect->after); sk_trimStroke(isect->stroke, 0, isect->after); @@ -1936,10 +1936,10 @@ int sk_detectDeleteGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) float s1[3], s2[3]; float angle; - VecSubf(s1, gest->segments->points[1].p, gest->segments->points[0].p); - VecSubf(s2, gest->segments->points[2].p, gest->segments->points[1].p); + sub_v3_v3v3(s1, gest->segments->points[1].p, gest->segments->points[0].p); + sub_v3_v3v3(s2, gest->segments->points[2].p, gest->segments->points[1].p); - angle = RAD2DEG(VecAngle2(s1, s2)); + angle = RAD2DEG(angle_v2v2(s1, s2)); if (angle > 120) { @@ -2062,16 +2062,16 @@ int sk_detectReverseGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) if (isect->gesture_index < isect->next->gesture_index) { - VecSubf(start_v, isect->p, gest->stk->points[0].p); - VecSubf(end_v, sk_lastStrokePoint(gest->stk)->p, isect->next->p); + sub_v3_v3v3(start_v, isect->p, gest->stk->points[0].p); + sub_v3_v3v3(end_v, sk_lastStrokePoint(gest->stk)->p, isect->next->p); } else { - VecSubf(start_v, isect->next->p, gest->stk->points[0].p); - VecSubf(end_v, sk_lastStrokePoint(gest->stk)->p, isect->p); + sub_v3_v3v3(start_v, isect->next->p, gest->stk->points[0].p); + sub_v3_v3v3(end_v, sk_lastStrokePoint(gest->stk)->p, isect->p); } - angle = RAD2DEG(VecAngle2(start_v, end_v)); + angle = RAD2DEG(angle_v2v2(start_v, end_v)); if (angle > 120) { diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 9847bdc3283..b9019410348 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -40,7 +40,7 @@ #include "DNA_modifier_types.h" #include "DNA_scene_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_edgehash.h" #include "BLI_memarena.h" @@ -151,16 +151,16 @@ static float cotan_weight(float *v1, float *v2, float *v3) { float a[3], b[3], c[3], clen; - VecSubf(a, v2, v1); - VecSubf(b, v3, v1); - Crossf(c, a, b); + sub_v3_v3v3(a, v2, v1); + sub_v3_v3v3(b, v3, v1); + cross_v3_v3v3(c, a, b); - clen = VecLength(c); + clen = len_v3(c); if (clen == 0.0f) return 0.0f; - return Inpf(a, b)/clen; + return dot_v3v3(a, b)/clen; } static void laplacian_triangle_area(LaplacianSystem *sys, int i1, int i2, int i3) @@ -177,21 +177,21 @@ static void laplacian_triangle_area(LaplacianSystem *sys, int i1, int i2, int i3 t2= cotan_weight(v2, v3, v1); t3= cotan_weight(v3, v1, v2); - if(RAD2DEG(VecAngle3(v2, v1, v3)) > 90) obtuse= 1; - else if(RAD2DEG(VecAngle3(v1, v2, v3)) > 90) obtuse= 2; - else if(RAD2DEG(VecAngle3(v1, v3, v2)) > 90) obtuse= 3; + if(RAD2DEG(angle_v3v3v3(v2, v1, v3)) > 90) obtuse= 1; + else if(RAD2DEG(angle_v3v3v3(v1, v2, v3)) > 90) obtuse= 2; + else if(RAD2DEG(angle_v3v3v3(v1, v3, v2)) > 90) obtuse= 3; if (obtuse > 0) { - area= AreaT3Dfl(v1, v2, v3); + area= area_tri_v3(v1, v2, v3); varea[i1] += (obtuse == 1)? area: area*0.5; varea[i2] += (obtuse == 2)? area: area*0.5; varea[i3] += (obtuse == 3)? area: area*0.5; } else { - len1= VecLenf(v2, v3); - len2= VecLenf(v1, v3); - len3= VecLenf(v1, v2); + len1= len_v3v3(v2, v3); + len2= len_v3v3(v1, v3); + len3= len_v3v3(v1, v2); t1 *= len1*len1; t2 *= len2*len2; @@ -446,7 +446,7 @@ static int heat_ray_bone_visible(LaplacianSystem *sys, int vertex, int bone) VECCOPY(isec.start, sys->heat.verts[vertex]); - PclosestVL3Dfl(end, isec.start, sys->heat.root[bone], sys->heat.tip[bone]); + closest_to_line_segment_v3(end, isec.start, sys->heat.root[bone], sys->heat.tip[bone]); VECSUB(isec.vec, end, isec.start); isec.labda = 1.0f - 1e-5; @@ -462,11 +462,11 @@ static float heat_bone_distance(LaplacianSystem *sys, int vertex, int bone) float closest[3], d[3], dist, cosine; /* compute euclidian distance */ - PclosestVL3Dfl(closest, sys->heat.verts[vertex], + closest_to_line_segment_v3(closest, sys->heat.verts[vertex], sys->heat.root[bone], sys->heat.tip[bone]); - VecSubf(d, sys->heat.verts[vertex], closest); - dist= Normalize(d); + sub_v3_v3v3(d, sys->heat.verts[vertex], closest); + dist= normalize_v3(d); /* if the vertex normal does not point along the bone, increase distance */ cosine= INPR(d, sys->heat.vnors[vertex]); @@ -536,15 +536,15 @@ void heat_calc_vnormals(LaplacianSystem *sys) v2= (*face)[1]; v3= (*face)[2]; - CalcNormFloat(sys->verts[v1], sys->verts[v2], sys->verts[v3], fnor); + normal_tri_v3( fnor,sys->verts[v1], sys->verts[v2], sys->verts[v3]); - VecAddf(sys->heat.vnors[v1], sys->heat.vnors[v1], fnor); - VecAddf(sys->heat.vnors[v2], sys->heat.vnors[v2], fnor); - VecAddf(sys->heat.vnors[v3], sys->heat.vnors[v3], fnor); + add_v3_v3v3(sys->heat.vnors[v1], sys->heat.vnors[v1], fnor); + add_v3_v3v3(sys->heat.vnors[v2], sys->heat.vnors[v2], fnor); + add_v3_v3v3(sys->heat.vnors[v3], sys->heat.vnors[v3], fnor); } for(a=0; a<sys->totvert; a++) - Normalize(sys->heat.vnors[a]); + normalize_v3(sys->heat.vnors[a]); } static void heat_laplacian_create(LaplacianSystem *sys) @@ -746,8 +746,8 @@ static void rigid_add_half_edge_to_R(LaplacianSystem *sys, EditVert *v1, EditVer float e[3], e_[3]; int i; - VecSubf(e, sys->rigid.origco[v1->tmp.l], sys->rigid.origco[v2->tmp.l]); - VecSubf(e_, v1->co, v2->co); + sub_v3_v3v3(e, sys->rigid.origco[v1->tmp.l], sys->rigid.origco[v2->tmp.l]); + sub_v3_v3v3(e_, v1->co, v2->co); /* formula (5) */ for (i=0; i<3; i++) { @@ -767,9 +767,9 @@ static void rigid_orthogonalize_R(float R[][3]) { HMatrix M, Q, S; - Mat4CpyMat3(M, R); + copy_m4_m3(M, R); polar_decomp(M, Q, S); - Mat3CpyMat4(R, Q); + copy_m3_m4(R, Q); } static void rigid_add_half_edge_to_rhs(LaplacianSystem *sys, EditVert *v1, EditVert *v2, float w) @@ -780,15 +780,15 @@ static void rigid_add_half_edge_to_rhs(LaplacianSystem *sys, EditVert *v1, EditV if (sys->vpinned[v1->tmp.l]) return; - Mat3AddMat3(Rsum, sys->rigid.R[v1->tmp.l], sys->rigid.R[v2->tmp.l]); - Mat3Transp(Rsum); + add_m3_m3m3(Rsum, sys->rigid.R[v1->tmp.l], sys->rigid.R[v2->tmp.l]); + transpose_m3(Rsum); - VecSubf(rhs, sys->rigid.origco[v1->tmp.l], sys->rigid.origco[v2->tmp.l]); - Mat3MulVecfl(Rsum, rhs); - VecMulf(rhs, 0.5f); - VecMulf(rhs, w); + sub_v3_v3v3(rhs, sys->rigid.origco[v1->tmp.l], sys->rigid.origco[v2->tmp.l]); + mul_m3_v3(Rsum, rhs); + mul_v3_fl(rhs, 0.5f); + mul_v3_fl(rhs, w); - VecAddf(sys->rigid.rhs[v1->tmp.l], sys->rigid.rhs[v1->tmp.l], rhs); + add_v3_v3v3(sys->rigid.rhs[v1->tmp.l], sys->rigid.rhs[v1->tmp.l], rhs); } static void rigid_add_edge_to_rhs(LaplacianSystem *sys, EditVert *v1, EditVert *v2, float w) @@ -916,7 +916,7 @@ void rigid_deform_begin(EditMesh *em) sys->rigid.origco = MEM_callocN(sizeof(float)*3*totvert, "RigidDeformCo"); for(a=0, eve=em->verts.first; eve; eve=eve->next, a++) - VecCopyf(sys->rigid.origco[a], eve->co); + copy_v3_v3(sys->rigid.origco[a], eve->co); sys->areaweights= 0; sys->storeweights= 1; @@ -940,7 +940,7 @@ void rigid_deform_end(int cancel) if(cancel) for(a=0, eve=em->verts.first; eve; eve=eve->next, a++) if(!eve->pinned) - VecCopyf(eve->co, sys->rigid.origco[a]); + copy_v3_v3(eve->co, sys->rigid.origco[a]); if(sys->rigid.R) MEM_freeN(sys->rigid.R); if(sys->rigid.rhs) MEM_freeN(sys->rigid.rhs); @@ -1034,7 +1034,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], VECSUB(edge2, vert2, vert0); /* begin calculating determinant - also used to calculate U parameter */ - Crossf(pvec, dir, edge2); + cross_v3_v3v3(pvec, dir, edge2); /* if determinant is near zero, ray lies in plane of triangle */ det = INPR(edge1, pvec); @@ -1052,7 +1052,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], return 0; /* prepare to test V parameter */ - Crossf(qvec, tvec, edge1); + cross_v3_v3v3(qvec, tvec, edge1); /* calculate V parameter and test bounds */ v = INPR(dir, qvec) * inv_det; @@ -1158,20 +1158,20 @@ static int meshdeform_intersect(MeshDeformBind *mdb, Isect *isec) hit = meshdeform_tri_intersect(isec->start, end, face[0], face[1], face[2], co, uvw); if(hit) { - CalcNormFloat(face[0], face[1], face[2], nor); + normal_tri_v3( nor,face[0], face[1], face[2]); } else { hit= meshdeform_tri_intersect(isec->start, end, face[0], face[2], face[3], co, uvw); - CalcNormFloat(face[0], face[2], face[3], nor); + normal_tri_v3( nor,face[0], face[2], face[3]); } } else { hit= meshdeform_tri_intersect(isec->start, end, face[0], face[1], face[2], co, uvw); - CalcNormFloat(face[0], face[1], face[2], nor); + normal_tri_v3( nor,face[0], face[1], face[2]); } if(hit) { - len= VecLenf(isec->start, co)/VecLenf(isec->start, end); + len= len_v3v3(isec->start, co)/len_v3v3(isec->start, end); if(len < isec->labda) { isec->labda= len; isec->hit.face = mface; @@ -1219,7 +1219,7 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float isect->co[1]= co1[1] + isec.vec[1]*len; isect->co[2]= co1[2] + isec.vec[2]*len; - isect->len= VecLenf(co1, isect->co); + isect->len= len_v3v3(co1, isect->co); if(isect->len < MESHDEFORM_LEN_THRESHOLD) isect->len= MESHDEFORM_LEN_THRESHOLD; @@ -1237,7 +1237,7 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float VECCOPY(vert[1], cagecos[mface->v2]); VECCOPY(vert[2], cagecos[mface->v3]); if(mface->v4) VECCOPY(vert[3], cagecos[mface->v4]); - MeanValueWeights(vert, isect->nvert, isect->co, isect->uvw); + interp_weights_poly_v3( isect->uvw,vert, isect->nvert, isect->co); return isect; } @@ -1260,7 +1260,7 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co) VECCOPY(start, co); VECSUB(dir, outside, start); - Normalize(dir); + normalize_v3(dir); isect = meshdeform_ray_tree_intersect(mdb, start, outside); if(isect && !isect->facing) @@ -1650,7 +1650,7 @@ static void meshdeform_matrix_solve(MeshDeformBind *mdb) for(b=0; b<mdb->totvert; b++) { if(mdb->inside[b]) { VECCOPY(vec, mdb->vertexcos[b]); - Mat4MulVecfl(mdb->cagemat, vec); + mul_m4_v3(mdb->cagemat, vec); gridvec[0]= (vec[0] - mdb->min[0] - mdb->halfwidth[0])/mdb->width[0]; gridvec[1]= (vec[1] - mdb->min[1] - mdb->halfwidth[1])/mdb->width[1]; gridvec[2]= (vec[2] - mdb->min[2] - mdb->halfwidth[2])/mdb->width[2]; @@ -1720,7 +1720,7 @@ void harmonic_coordinates_bind(Scene *scene, MeshDeformModifierData *mmd, float mdb.cagedm= mesh_create_derived_no_deform(scene, mmd->object, NULL, CD_MASK_BAREMESH); mdb.totcagevert= mdb.cagedm->getNumVerts(mdb.cagedm); mdb.cagecos= MEM_callocN(sizeof(*mdb.cagecos)*mdb.totcagevert, "MeshDeformBindCos"); - Mat4CpyMat4(mdb.cagemat, cagemat); + copy_m4_m4(mdb.cagemat, cagemat); mvert= mdb.cagedm->getVertArray(mdb.cagedm); for(a=0; a<mdb.totcagevert; a++) @@ -1781,7 +1781,7 @@ void harmonic_coordinates_bind(Scene *scene, MeshDeformModifierData *mmd, float totinside= 0; for(a=0; a<mdb.totvert; a++) { VECCOPY(vec, mdb.vertexcos[a]); - Mat4MulVecfl(mdb.cagemat, vec); + mul_m4_v3(mdb.cagemat, vec); mdb.inside[a]= meshdeform_inside_cage(&mdb, vec); if(mdb.inside[a]) totinside++; @@ -1821,7 +1821,7 @@ void harmonic_coordinates_bind(Scene *scene, MeshDeformModifierData *mmd, float mmd->bindcos= (float*)mdb.cagecos; mmd->totvert= mdb.totvert; mmd->totcagevert= mdb.totcagevert; - Mat4CpyMat4(mmd->bindmat, mmd->object->obmat); + copy_m4_m4(mmd->bindmat, mmd->object->obmat); if(mmd->flag & MOD_MDEF_DYNAMIC_BIND) { mmd->totinfluence= 0; @@ -1868,7 +1868,7 @@ void harmonic_coordinates_bind(Scene *scene, MeshDeformModifierData *mmd, float /* transform bindcos to world space */ for(a=0; a<mdb.totcagevert; a++) - Mat4MulVecfl(mmd->object->obmat, mmd->bindcos+a*3); + mul_m4_v3(mmd->object->obmat, mmd->bindcos+a*3); /* free */ mdb.cagedm->release(mdb.cagedm); diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 1e0df79d0e6..e5d334e4d06 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -34,7 +34,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" #include "BLI_dlrbTree.h" @@ -461,7 +461,7 @@ static void pose_slide_apply_quat (tPoseSlideOp *pso, tPChanFCurveLink *pfl) /* perform blending */ if (pso->mode == POSESLIDE_BREAKDOWN) { /* just perform the interpol between quat_prev and quat_next using pso->percentage as a guide */ - QuatInterpol(pchan->quat, quat_prev, quat_next, pso->percentage); + interp_qt_qtqt(pchan->quat, quat_prev, quat_next, pso->percentage); } else { float quat_interp[4], quat_orig[4]; @@ -470,16 +470,16 @@ static void pose_slide_apply_quat (tPoseSlideOp *pso, tPChanFCurveLink *pfl) /* perform this blending several times until a satisfactory result is reached */ while (iters-- > 0) { /* calculate the interpolation between the endpoints */ - QuatInterpol(quat_interp, quat_prev, quat_next, (cframe-pso->prevFrame) / (pso->nextFrame-pso->prevFrame) ); + interp_qt_qtqt(quat_interp, quat_prev, quat_next, (cframe-pso->prevFrame) / (pso->nextFrame-pso->prevFrame) ); /* make a copy of the original rotation */ QUATCOPY(quat_orig, pchan->quat); /* tricky interpolations - mode-dependent blending between original and new */ if (pso->mode == POSESLIDE_RELAX) // xxx this was the original code, so should work fine - QuatInterpol(pchan->quat, quat_orig, quat_interp, 1.0f/6.0f); + interp_qt_qtqt(pchan->quat, quat_orig, quat_interp, 1.0f/6.0f); else // I'm just guessing here... - QuatInterpol(pchan->quat, quat_orig, quat_interp, 6.0f/5.0f); + interp_qt_qtqt(pchan->quat, quat_orig, quat_interp, 6.0f/5.0f); } } } diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 565a4782377..0837e9cb48a 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -34,7 +34,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" #include "BLI_dlrbTree.h" diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index d7741c2a5ef..18750d96f86 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -33,7 +33,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" @@ -279,7 +279,7 @@ void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob) VECCOPY(fp, pchan->pose_tail); } - Mat4MulVecfl(ob->obmat, fp); + mul_m4_v3(ob->obmat, fp); } } } @@ -405,7 +405,7 @@ static int pose_calculate_paths_exec (bContext *C, wmOperator *op) VECCOPY(fp, pchan->pose_tail); } - Mat4MulVecfl(ob->obmat, fp); + mul_m4_v3(ob->obmat, fp); } } } @@ -814,13 +814,13 @@ void pose_copy_menu(Scene *scene) float tmp_quat[4]; /* need to convert to quat first (in temp var)... */ - Mat4ToQuat(delta_mat, tmp_quat); - QuatToAxisAngle(tmp_quat, pchan->rotAxis, &pchan->rotAngle); + mat4_to_quat( tmp_quat,delta_mat); + quat_to_axis_angle( pchan->rotAxis, &pchan->rotAngle,tmp_quat); } else if (pchan->rotmode == ROT_MODE_QUAT) - Mat4ToQuat(delta_mat, pchan->quat); + mat4_to_quat( pchan->quat,delta_mat); else - Mat4ToEulO(delta_mat, pchan->eul, pchan->rotmode); + mat4_to_eulO( pchan->eul, pchan->rotmode,delta_mat); } break; case 11: /* Visual Size */ @@ -828,7 +828,7 @@ void pose_copy_menu(Scene *scene) float delta_mat[4][4], size[4]; armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat); - Mat4ToSize(delta_mat, size); + mat4_to_size( size,delta_mat); VECCOPY(pchan->size, size); } } @@ -1020,23 +1020,23 @@ static int pose_paste_exec (bContext *C, wmOperator *op) else if (pchan->rotmode > 0) { /* quat/axis-angle to euler */ if (chan->rotmode == ROT_MODE_AXISANGLE) - AxisAngleToEulO(chan->rotAxis, chan->rotAngle, pchan->eul, pchan->rotmode); + axis_angle_to_eulO( pchan->eul, pchan->rotmode,chan->rotAxis, chan->rotAngle); else - QuatToEulO(chan->quat, pchan->eul, pchan->rotmode); + quat_to_eulO( pchan->eul, pchan->rotmode,chan->quat); } else if (pchan->rotmode == ROT_MODE_AXISANGLE) { /* quat/euler to axis angle */ if (chan->rotmode > 0) - EulOToAxisAngle(chan->eul, chan->rotmode, pchan->rotAxis, &pchan->rotAngle); + eulO_to_axis_angle( pchan->rotAxis, &pchan->rotAngle,chan->eul, chan->rotmode); else - QuatToAxisAngle(chan->quat, pchan->rotAxis, &pchan->rotAngle); + quat_to_axis_angle( pchan->rotAxis, &pchan->rotAngle,chan->quat); } else { /* euler/axis-angle to quat */ if (chan->rotmode > 0) - EulOToQuat(chan->eul, chan->rotmode, pchan->quat); + eulO_to_quat( pchan->quat,chan->eul, chan->rotmode); else - AxisAngleToQuat(pchan->quat, chan->rotAxis, pchan->rotAngle); + axis_angle_to_quat(pchan->quat, chan->rotAxis, pchan->rotAngle); } /* paste flipped pose? */ @@ -1051,10 +1051,10 @@ static int pose_paste_exec (bContext *C, wmOperator *op) else if (pchan->rotmode == ROT_MODE_AXISANGLE) { float eul[3]; - AxisAngleToEulO(pchan->rotAxis, pchan->rotAngle, eul, EULER_ORDER_DEFAULT); + axis_angle_to_eulO( eul, EULER_ORDER_DEFAULT,pchan->rotAxis, pchan->rotAngle); eul[1]*= -1; eul[2]*= -1; - EulOToAxisAngle(eul, EULER_ORDER_DEFAULT, pchan->rotAxis, &pchan->rotAngle); + eulO_to_axis_angle( pchan->rotAxis, &pchan->rotAngle,eul, EULER_ORDER_DEFAULT); // experimental method (uncomment to test): #if 0 @@ -1066,10 +1066,10 @@ static int pose_paste_exec (bContext *C, wmOperator *op) else { float eul[3]; - QuatToEul(pchan->quat, eul); + quat_to_eul( eul,pchan->quat); eul[1]*= -1; eul[2]*= -1; - EulToQuat(eul, pchan->quat); + eul_to_quat( pchan->quat,eul); } } diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index 132d9edf8d0..05b0dc267ff 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -45,7 +45,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_edgehash.h" #include "BLI_ghash.h" @@ -498,12 +498,12 @@ void repositionNodes(ReebGraph *rg) float p[3]; VECCOPY(p, ((ReebArc*)arc)->buckets[0].p); - VecMulf(p, 1.0f / arc->head->degree); - VecAddf(arc->head->p, arc->head->p, p); + mul_v3_fl(p, 1.0f / arc->head->degree); + add_v3_v3v3(arc->head->p, arc->head->p, p); VECCOPY(p, ((ReebArc*)arc)->buckets[((ReebArc*)arc)->bcount - 1].p); - VecMulf(p, 1.0f / arc->tail->degree); - VecAddf(arc->tail->p, arc->tail->p, p); + mul_v3_fl(p, 1.0f / arc->tail->degree); + add_v3_v3v3(arc->tail->p, arc->tail->p, p); } } } @@ -634,15 +634,15 @@ void verifyMultiResolutionLinks(ReebGraph *rg, int level) void addVertToBucket(EmbedBucket *b, float co[3]) { b->nv++; - VecLerpf(b->p, b->p, co, 1.0f / b->nv); + interp_v3_v3v3(b->p, b->p, co, 1.0f / b->nv); } void removeVertFromBucket(EmbedBucket *b, float co[3]) { - VecMulf(b->p, (float)b->nv); - VecSubf(b->p, b->p, co); + mul_v3_fl(b->p, (float)b->nv); + sub_v3_v3v3(b->p, b->p, co); b->nv--; - VecMulf(b->p, 1.0f / (float)b->nv); + mul_v3_fl(b->p, 1.0f / (float)b->nv); } void mergeBuckets(EmbedBucket *bDst, EmbedBucket *bSrc) @@ -650,7 +650,7 @@ void mergeBuckets(EmbedBucket *bDst, EmbedBucket *bSrc) if (bDst->nv > 0 && bSrc->nv > 0) { bDst->nv += bSrc->nv; - VecLerpf(bDst->p, bDst->p, bSrc->p, (float)bSrc->nv / (float)(bDst->nv)); + interp_v3_v3v3(bDst->p, bDst->p, bSrc->p, (float)bSrc->nv / (float)(bDst->nv)); } else if (bSrc->nv > 0) { @@ -797,7 +797,7 @@ static void interpolateBuckets(ReebArc *arc, float *start_p, float *end_p, int s { EmbedBucket *empty = arc->buckets + j; empty->nv = 1; - VecLerpf(empty->p, start_p, end_p, (float)(j - start_index + 1) / total); + interp_v3_v3v3(empty->p, start_p, end_p, (float)(j - start_index + 1) / total); } } @@ -873,20 +873,20 @@ static void ExtendArcBuckets(ReebArc *arc) previous = iter->p, IT_next(iter) ) { - average_length += VecLenf(previous, iter->p); + average_length += len_v3v3(previous, iter->p); } average_length /= (arc->bcount - 1); first_bucket = arc->buckets; last_bucket = arc->buckets + (arc->bcount - 1); - length = VecLenf(first_bucket->p, arc->head->p); + length = len_v3v3(first_bucket->p, arc->head->p); if (length > 2 * average_length) { padding_head = (int)floor(length / average_length); } - length = VecLenf(last_bucket->p, arc->tail->p); + length = len_v3v3(last_bucket->p, arc->tail->p); if (length > 2 * average_length) { padding_tail = (int)floor(length / average_length); @@ -945,12 +945,12 @@ void calculateArcLength(ReebArc *arc) { vec1 = iter->p; - arc->length += VecLenf(vec0, vec1); + arc->length += len_v3v3(vec0, vec1); vec0 = vec1; } - arc->length += VecLenf(arc->tail->p, vec1); + arc->length += len_v3v3(arc->tail->p, vec1); } void calculateGraphLength(ReebGraph *rg) @@ -982,8 +982,8 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) float normal[3]; int j = i + 1; - VecAddf(tangent, ring[i].n, ring[j].n); - Crossf(normal, tangent, axis); + add_v3_v3v3(tangent, ring[i].n, ring[j].n); + cross_v3_v3v3(normal, tangent, axis); node1 = (ReebNode*)BLI_otherNode(ring[i].arc, root_node); node2 = (ReebNode*)BLI_otherNode(ring[j].arc, root_node); @@ -993,7 +993,7 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) /* mirror first node and mix with the second */ BLI_mirrorAlongAxis(node1->p, root_node->p, normal); - VecLerpf(node2->p, node2->p, node1->p, 1.0f / (j + 1)); + interp_v3_v3v3(node2->p, node2->p, node1->p, 1.0f / (j + 1)); /* Merge buckets * there shouldn't be any null arcs here, but just to be safe @@ -1030,7 +1030,7 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) /* mirror on axis */ BLI_mirrorAlongAxis(bucket1->p, root_node->p, normal); /* add bucket2 in bucket1 */ - VecLerpf(bucket2->p, bucket2->p, bucket1->p, (float)bucket1->nv / (float)(bucket2->nv)); + interp_v3_v3v3(bucket2->p, bucket2->p, bucket1->p, (float)bucket1->nv / (float)(bucket2->nv)); } } } @@ -1044,8 +1044,8 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) float normal[3]; int j = i - 1; - VecAddf(tangent, ring[i].n, ring[j].n); - Crossf(normal, tangent, axis); + add_v3_v3v3(tangent, ring[i].n, ring[j].n); + cross_v3_v3v3(normal, tangent, axis); node1 = (ReebNode*)BLI_otherNode(ring[i].arc, root_node); node2 = (ReebNode*)BLI_otherNode(ring[j].arc, root_node); @@ -1111,8 +1111,8 @@ void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BAr BLI_mirrorAlongAxis(p, root_node->p, nor); /* average with node1 */ - VecAddf(node1->p, node1->p, p); - VecMulf(node1->p, 0.5f); + add_v3_v3v3(node1->p, node1->p, p); + mul_v3_fl(node1->p, 0.5f); /* mirror back on node2 */ VECCOPY(node2->p, node1->p); @@ -1153,7 +1153,7 @@ void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BAr /* mirror on axis */ BLI_mirrorAlongAxis(bucket2->p, root_node->p, nor); /* add bucket2 in bucket1 */ - VecLerpf(bucket1->p, bucket1->p, bucket2->p, (float)bucket2->nv / (float)(bucket1->nv)); + interp_v3_v3v3(bucket1->p, bucket1->p, bucket2->p, (float)bucket2->nv / (float)(bucket1->nv)); /* copy and mirror back to bucket2 */ bucket2->nv = bucket1->nv; @@ -1200,8 +1200,8 @@ void postprocessGraph(ReebGraph *rg, char mode) for(index = 1; index < bcount - 1; index++) { - VecLerpf(buckets[index].p, buckets[index].p, buckets[index - 1].p, fac1 / (fac1 + fac2)); - VecLerpf(buckets[index].p, buckets[index].p, buckets[index + 1].p, fac3 / (fac1 + fac2 + fac3)); + interp_v3_v3v3(buckets[index].p, buckets[index].p, buckets[index - 1].p, fac1 / (fac1 + fac2)); + interp_v3_v3v3(buckets[index].p, buckets[index].p, buckets[index + 1].p, fac3 / (fac1 + fac2 + fac3)); } } } @@ -1339,7 +1339,7 @@ int joinSubgraphsEnds(ReebGraph *rg, float threshold, int nb_subgraphs) { if (end_node->subgraph_index != subgraph) { - float distance = VecLenf(start_node->p, end_node->p); + float distance = len_v3v3(start_node->p, end_node->p); if (distance < threshold && distance < min_distance) { @@ -1597,7 +1597,7 @@ void filterNullReebGraph(ReebGraph *rg) blend = (float)newNode->degree / (float)(newNode->degree + removedNode->degree); // blending factors - VecLerpf(newNode->p, removedNode->p, newNode->p, blend); + interp_v3_v3v3(newNode->p, removedNode->p, newNode->p, blend); filterArc(rg, newNode, removedNode, arc, 0); @@ -1808,16 +1808,16 @@ int filterSmartReebGraph(ReebGraph *rg, float threshold) VECCOPY(midpoint, vec1); - distance = VecLenf(midpoint, efa->cent); + distance = len_v3v3(midpoint, efa->cent); if (min_distance == -1 || distance < min_distance) { min_distance = distance; - VecSubf(tangent, vec1, vec0); - Normalize(tangent); + sub_v3_v3v3(tangent, vec1, vec0); + normalize_v3(tangent); - angle = Inpf(tangent, efa->n); + angle = dot_v3v3(tangent, efa->n); } previous = bucket; @@ -1829,7 +1829,7 @@ int filterSmartReebGraph(ReebGraph *rg, float threshold) efa->tmp.fp = saacos(fabs(angle)); #endif #else - VecAddf(avg_vec, avg_vec, efa->n); + add_v3_v3v3(avg_vec, avg_vec, efa->n); #endif } @@ -1837,8 +1837,8 @@ int filterSmartReebGraph(ReebGraph *rg, float threshold) #if 0 avg_angle /= total; #else - VecMulf(avg_vec, 1.0 / total); - avg_angle = Inpf(avg_vec, avg_vec); + mul_v3_fl(avg_vec, 1.0 / total); + avg_angle = dot_v3v3(avg_vec, avg_vec); #endif arc->angle = avg_angle; @@ -2064,8 +2064,8 @@ void REEB_exportGraph(ReebGraph *rg, int count) fprintf(f, "b nv:%i %f %f %f\n", arc->buckets[i].nv, arc->buckets[i].p[0], arc->buckets[i].p[1], arc->buckets[i].p[2]); } - VecAddf(p, arc->tail->p, arc->head->p); - VecMulf(p, 0.5f); + add_v3_v3v3(p, arc->tail->p, arc->head->p); + mul_v3_fl(p, 0.5f); fprintf(f, "angle %0.3f %0.3f %0.3f %0.3f %i\n", p[0], p[1], p[2], arc->angle, BLI_ghash_size(arc->faces)); exportNode(f, "v2", arc->tail); @@ -2501,7 +2501,7 @@ ReebEdge * createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2) float co[3]; float f = (arc->buckets[i].val - offset) / len; - VecLerpf(co, v1->p, v2->p, f); + interp_v3_v3v3(co, v1->p, v2->p, f); addVertToBucket(&(arc->buckets[i]), co); } #endif @@ -2690,16 +2690,16 @@ static float cotan_weight(float *v1, float *v2, float *v3) { float a[3], b[3], c[3], clen; - VecSubf(a, v2, v1); - VecSubf(b, v3, v1); - Crossf(c, a, b); + sub_v3_v3v3(a, v2, v1); + sub_v3_v3v3(b, v3, v1); + cross_v3_v3v3(c, a, b); - clen = VecLength(c); + clen = len_v3(c); if (clen == 0.0f) return 0.0f; - return Inpf(a, b)/clen; + return dot_v3v3(a, b)/clen; } void addTriangle(EditVert *v1, EditVert *v2, EditVert *v3, int e1, int e2, int e3) @@ -3077,7 +3077,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) { if (eed->v1->h == 0 && eed->v2->h == 0) { - eed->tmp.fp = VecLenf(eed->v1->co, eed->v2->co); + eed->tmp.fp = len_v3v3(eed->v1->co, eed->v2->co); } } @@ -3112,7 +3112,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) /* vertex is already processed and distance is smaller than current minimum */ if (closest_eve->f1 == 1) { - float distance = VecLenf(closest_eve->co, eve->co); + float distance = len_v3v3(closest_eve->co, eve->co); if (distance < min_distance) { min_distance = distance; @@ -3688,7 +3688,7 @@ void REEB_draw() if (G.scene->toolsettings->skgen_options & SKGEN_DISP_INDEX) { - VecLerpf(vec, arc->head->p, arc->tail->p, 0.5f); + interp_v3_v3v3(vec, arc->head->p, arc->tail->p, 0.5f); s += sprintf(s, "%i (%i-%i-%i) ", i, arc->symmetry_level, arc->symmetry_flag, arc->symmetry_group); if (G.scene->toolsettings->skgen_options & SKGEN_DISP_WEIGHT) |