diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-11-11 13:44:46 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-11-11 13:44:46 +0300 |
commit | 2e3326c1533e992ef7eaa43ed876375af4db5de1 (patch) | |
tree | fe0adcbf314053bd3c079abd4692dea851231aac /source/blender/blenkernel | |
parent | 7fe52eedba00a3008d56ad0d689ed27fcf658220 (diff) | |
parent | e4f10565ea6b4a9015bd5a9e81b77d1d549e9b46 (diff) |
Sculpt: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r24330:24483
Diffstat (limited to 'source/blender/blenkernel')
59 files changed, 2213 insertions, 2172 deletions
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index e5b3adbd0c0..54dd82317fc 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -38,7 +38,7 @@ #include "BKE_DerivedMesh.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_edgehash.h" #include "DNA_cloth_types.h" diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h index 6446b48d553..f957c5e17d4 100644 --- a/source/blender/blenkernel/BKE_constraint.h +++ b/source/blender/blenkernel/BKE_constraint.h @@ -52,7 +52,7 @@ typedef struct bConstraintOb { float startmat[4][4]; /* original matrix (before constraint solving) */ short type; /* type of owner */ - short rotOrder; /* rotation order for constraint owner (as defined in eEulerRotationOrders in BLI_arithb.h) */ + short rotOrder; /* rotation order for constraint owner (as defined in eEulerRotationOrders in BLI_math.h) */ } bConstraintOb; /* ---------------------------------------------------------------------------- */ diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index feba39ee11d..7f64538b10d 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -174,7 +174,7 @@ PointerRNA CTX_data_pointer_get(const bContext *C, const char *member); PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type); ListBase CTX_data_collection_get(const bContext *C, const char *member); ListBase CTX_data_dir_get(const bContext *C); -void CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb); +int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb); void CTX_data_id_pointer_set(bContextDataResult *result, struct ID *id); void CTX_data_pointer_set(bContextDataResult *result, struct ID *id, StructRNA *type, void *data); diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 66776d086d6..f9130e24a08 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -53,6 +53,7 @@ struct GPUMaterial; struct GPUNode; struct GPUNodeStack; struct PointerRNA; +struct bContext; /* ************** NODE TYPE DEFINITIONS ***** */ @@ -83,7 +84,7 @@ typedef struct bNodeType { void (*execfunc)(void *data, struct bNode *, struct bNodeStack **, struct bNodeStack **); /* this line is set on startup of blender */ - void (*uifunc)(struct uiLayout *, struct PointerRNA *ptr); + void (*uifunc)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr); void (*initfunc)(struct bNode *); void (*freestoragefunc)(struct bNode *); @@ -161,6 +162,7 @@ void nodeVerifyType(struct bNodeTree *ntree, struct bNode *node); void nodeAddToPreview(struct bNode *, float *, int, int); void nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node); +void nodeUniqueName(struct bNodeTree *ntree, struct bNode *node); void nodeAddSockets(struct bNode *node, struct bNodeType *ntype); struct bNode *nodeAddNodeType(struct bNodeTree *ntree, int type, struct bNodeTree *ngroup, struct ID *id); void nodeRegisterType(struct ListBase *typelist, const struct bNodeType *ntype) ; diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c index 32065ea5151..d92e8fe4227 100644 --- a/source/blender/blenkernel/intern/BME_tools.c +++ b/source/blender/blenkernel/intern/BME_tools.c @@ -42,7 +42,7 @@ #include "BKE_utildefines.h" #include "BKE_bmesh.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" /*split this all into a seperate bevel.c file in src*/ @@ -88,7 +88,7 @@ BME_TransData *BME_assign_transdata(BME_TransData_Head *td, BME_Mesh *bm, BME_Ve else if (org != NULL) VECCOPY(vtd->org,org); if (vec != NULL) { VECCOPY(vtd->vec,vec); - Normalize(vtd->vec); + normalize_v3(vtd->vec); } vtd->loc = loc; @@ -261,7 +261,7 @@ static BME_Vert *BME_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Edge *e, BME_Edge nv = BME_SEMV(bm,v,e,ne); if (nv == NULL) return NULL; VECSUB(nv->co,v2->co,v->co); - len = VecLength(nv->co); + len = len_v3(nv->co); VECADDFAC(nv->co,v->co,nv->co,len*percent); nv->flag = v->flag; nv->bweight = v->bweight; @@ -335,17 +335,17 @@ static int BME_bevel_get_vec(float *vec, BME_Vert *v1, BME_Vert *v2, BME_TransDa /* compare the transform origins to see if we can use the vert co's; * if they belong to different origins, then we will use the origins to determine * the vector */ - if (VecCompare(vtd1->org,vtd2->org,0.000001f)) { + if (compare_v3v3(vtd1->org,vtd2->org,0.000001f)) { VECSUB(vec,v2->co,v1->co); - if (VecLength(vec) < 0.000001f) { - VecMulf(vec,0); + if (len_v3(vec) < 0.000001f) { + mul_v3_fl(vec,0); } return 0; } else { VECSUB(vec,vtd2->org,vtd1->org); - if (VecLength(vec) < 0.000001f) { - VecMulf(vec,0); + if (len_v3(vec) < 0.000001f) { + mul_v3_fl(vec,0); } return 1; } @@ -363,18 +363,18 @@ static int BME_bevel_get_vec(float *vec, BME_Vert *v1, BME_Vert *v2, BME_TransDa static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int is_forward, BME_TransData_Head *td) { float factor, vec3[3], tmp[3],c1,c2; - Crossf(tmp,vec1,vec2); - Normalize(tmp); - factor = Inpf(up_vec,tmp); + cross_v3_v3v3(tmp,vec1,vec2); + normalize_v3(tmp); + factor = dot_v3v3(up_vec,tmp); if ((factor > 0 && is_forward) || (factor < 0 && !is_forward)) { - Crossf(vec3,vec2,tmp); /* hmm, maybe up_vec should be used instead of tmp */ + cross_v3_v3v3(vec3,vec2,tmp); /* hmm, maybe up_vec should be used instead of tmp */ } else { - Crossf(vec3,tmp,vec2); /* hmm, maybe up_vec should be used instead of tmp */ + cross_v3_v3v3(vec3,tmp,vec2); /* hmm, maybe up_vec should be used instead of tmp */ } - Normalize(vec3); - c1 = Inpf(vec3,vec1); - c2 = Inpf(vec1,vec1); + normalize_v3(vec3); + c1 = dot_v3v3(vec3,vec1); + c2 = dot_v3v3(vec1,vec1); if (fabs(c1) < 0.000001f || fabs(c2) < 0.000001f) { factor = 0.0f; } @@ -435,8 +435,8 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B ne->tflag1 = BME_BEVEL_ORIG; /* mark edge as original, even though it isn't */ BME_bevel_get_vec(vec1,v1,v,td); BME_bevel_get_vec(vec2,v2,v,td); - Crossf(t_up_vec,vec1,vec2); - Normalize(t_up_vec); + cross_v3_v3v3(t_up_vec,vec1,vec2); + normalize_v3(t_up_vec); up_vec = t_up_vec; } else { @@ -486,8 +486,8 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B is_edge = BME_bevel_get_vec(vec1,v,v1,td); /* get the vector we will be projecting onto */ BME_bevel_get_vec(vec2,v,v2,td); /* get the vector we will be projecting parallel to */ - len = VecLength(vec1); - Normalize(vec1); + len = len_v3(vec1); + normalize_v3(vec1); vtd = BME_get_transdata(td, sv); vtd1 = BME_get_transdata(td, v); @@ -525,8 +525,8 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B } VECADDFAC(sv->co,v->co,vec1,dis); VECSUB(vec1,sv->co,vtd1->org); - dis = VecLength(vec1); - Normalize(vec1); + dis = len_v3(vec1); + normalize_v3(vec1); BME_assign_transdata(td, bm, sv, vtd1->org, vtd1->org, vec1, sv->co, dis, scale, maxfactor, vtd->max); return sv; @@ -545,10 +545,10 @@ static float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_Tran } else { VECCOPY(vec2,vtd1->vec); - VecMulf(vec2,vtd1->factor); - if (Inpf(vec1, vec1)) { - Projf(vec2,vec2,vec1); - fac1 = VecLength(vec2)/value; + mul_v3_fl(vec2,vtd1->factor); + if (dot_v3v3(vec1, vec1)) { + project_v3_v3v3(vec2,vec2,vec1); + fac1 = len_v3(vec2)/value; } else { fac1 = 0; @@ -560,10 +560,10 @@ static float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_Tran } else { VECCOPY(vec3,vtd2->vec); - VecMulf(vec3,vtd2->factor); - if (Inpf(vec1, vec1)) { - Projf(vec2,vec3,vec1); - fac2 = VecLength(vec2)/value; + mul_v3_fl(vec3,vtd2->factor); + if (dot_v3v3(vec1, vec1)) { + project_v3_v3v3(vec2,vec3,vec1); + fac2 = len_v3(vec2)/value; } else { fac2 = 0; @@ -571,7 +571,7 @@ static float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_Tran } if (fac1 || fac2) { - max = VecLength(vec1)/(fac1 + fac2); + max = len_v3(vec1)/(fac1 + fac2); if (vtd1->max && (*vtd1->max < 0 || max < *vtd1->max)) { *vtd1->max = max; } @@ -760,12 +760,12 @@ static BME_Poly *BME_bevel_poly(BME_Mesh *bm, BME_Poly *f, float value, int opti for (i=0,ol=f->loopbase,l=ol->next; l->next!=ol; l=l->next) { BME_bevel_get_vec(vec1,l->next->v,ol->v,td); BME_bevel_get_vec(vec2,l->v,ol->v,td); - Crossf(vec3,vec2,vec1); + cross_v3_v3v3(vec3,vec2,vec1); VECADD(up_vec,up_vec,vec3); i++; } - VecMulf(up_vec,1.0f/i); - Normalize(up_vec); + mul_v3_fl(up_vec,1.0f/i); + normalize_v3(up_vec); for (i=0,len=f->len; i<len; i++,l=l->next) { if ((l->e->tflag1 & BME_BEVEL_BEVEL) && (l->e->tflag1 & BME_BEVEL_ORIG)) { @@ -791,10 +791,10 @@ static BME_Poly *BME_bevel_poly(BME_Mesh *bm, BME_Poly *f, float value, int opti } else { VECCOPY(vec2,vtd1->vec); - VecMulf(vec2,vtd1->factor); - if (Inpf(vec1, vec1)) { - Projf(vec2,vec2,vec1); - fac1 = VecLength(vec2)/value; + mul_v3_fl(vec2,vtd1->factor); + if (dot_v3v3(vec1, vec1)) { + project_v3_v3v3(vec2,vec2,vec1); + fac1 = len_v3(vec2)/value; } else { fac1 = 0; @@ -805,17 +805,17 @@ static BME_Poly *BME_bevel_poly(BME_Mesh *bm, BME_Poly *f, float value, int opti } else { VECCOPY(vec3,vtd2->vec); - VecMulf(vec3,vtd2->factor); - if (Inpf(vec1, vec1)) { - Projf(vec2,vec3,vec1); - fac2 = VecLength(vec2)/value; + mul_v3_fl(vec3,vtd2->factor); + if (dot_v3v3(vec1, vec1)) { + project_v3_v3v3(vec2,vec3,vec1); + fac2 = len_v3(vec2)/value; } else { fac2 = 0; } } if (fac1 || fac2) { - max = VecLength(vec1)/(fac1 + fac2); + max = len_v3(vec1)/(fac1 + fac2); if (vtd1->max && (*vtd1->max < 0 || max < *vtd1->max)) { *vtd1->max = max; } @@ -880,7 +880,7 @@ static float BME_bevel_get_angle(BME_Mesh *bm, BME_Edge *e, BME_Vert *v) { } VECSUB(vec1,v1->co,v->co); VECSUB(vec2,v2->co,v->co); - Crossf(vec3,vec1,vec2); + cross_v3_v3v3(vec3,vec1,vec2); l1 = l2; if (l1->v == v) { @@ -893,12 +893,12 @@ static float BME_bevel_get_angle(BME_Mesh *bm, BME_Edge *e, BME_Vert *v) { } VECSUB(vec1,v1->co,v->co); VECSUB(vec2,v2->co,v->co); - Crossf(vec4,vec2,vec1); + cross_v3_v3v3(vec4,vec2,vec1); - Normalize(vec3); - Normalize(vec4); + normalize_v3(vec3); + normalize_v3(vec4); - return Inpf(vec3,vec4); + return dot_v3v3(vec3,vec4); } static int BME_face_sharededges(BME_Poly *f1, BME_Poly *f2){ BME_Loop *l; diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 11e58203bb3..f9abaa9da02 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -52,7 +52,7 @@ #include "DNA_space_types.h" #include "DNA_particle_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_edgehash.h" #include "BLI_editVert.h" @@ -619,20 +619,20 @@ static void emDM__calcFaceCent(EditFace *efa, float cent[3], float (*vertexCos)[ { if (vertexCos) { VECCOPY(cent, vertexCos[(int) efa->v1->tmp.l]); - VecAddf(cent, cent, vertexCos[(int) efa->v2->tmp.l]); - VecAddf(cent, cent, vertexCos[(int) efa->v3->tmp.l]); - if (efa->v4) VecAddf(cent, cent, vertexCos[(int) efa->v4->tmp.l]); + add_v3_v3v3(cent, cent, vertexCos[(int) efa->v2->tmp.l]); + add_v3_v3v3(cent, cent, vertexCos[(int) efa->v3->tmp.l]); + if (efa->v4) add_v3_v3v3(cent, cent, vertexCos[(int) efa->v4->tmp.l]); } else { VECCOPY(cent, efa->v1->co); - VecAddf(cent, cent, efa->v2->co); - VecAddf(cent, cent, efa->v3->co); - if (efa->v4) VecAddf(cent, cent, efa->v4->co); + add_v3_v3v3(cent, cent, efa->v2->co); + add_v3_v3v3(cent, cent, efa->v3->co); + if (efa->v4) add_v3_v3v3(cent, cent, efa->v4->co); } if (efa->v4) { - VecMulf(cent, 0.25f); + mul_v3_fl(cent, 0.25f); } else { - VecMulf(cent, 0.33333333333f); + mul_v3_fl(cent, 0.33333333333f); } } static void emDM_foreachMappedFaceCenter(DerivedMesh *dm, void (*func)(void *userData, int index, float *co, float *no), void *userData) @@ -1498,25 +1498,25 @@ static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, Object *ob, if(efa->v4) { float *v4 = vertexCos[(int) efa->v4->tmp.l]; - CalcNormFloat4(v1, v2, v3, v4, no); - VecAddf(emdm->vertexNos[(int) efa->v4->tmp.l], emdm->vertexNos[(int) efa->v4->tmp.l], no); + normal_quad_v3( no,v1, v2, v3, v4); + add_v3_v3v3(emdm->vertexNos[(int) efa->v4->tmp.l], emdm->vertexNos[(int) efa->v4->tmp.l], no); } else { - CalcNormFloat(v1, v2, v3, no); + normal_tri_v3( no,v1, v2, v3); } - VecAddf(emdm->vertexNos[(int) efa->v1->tmp.l], emdm->vertexNos[(int) efa->v1->tmp.l], no); - VecAddf(emdm->vertexNos[(int) efa->v2->tmp.l], emdm->vertexNos[(int) efa->v2->tmp.l], no); - VecAddf(emdm->vertexNos[(int) efa->v3->tmp.l], emdm->vertexNos[(int) efa->v3->tmp.l], no); + add_v3_v3v3(emdm->vertexNos[(int) efa->v1->tmp.l], emdm->vertexNos[(int) efa->v1->tmp.l], no); + add_v3_v3v3(emdm->vertexNos[(int) efa->v2->tmp.l], emdm->vertexNos[(int) efa->v2->tmp.l], no); + add_v3_v3v3(emdm->vertexNos[(int) efa->v3->tmp.l], emdm->vertexNos[(int) efa->v3->tmp.l], no); } for(i=0, eve= em->verts.first; eve; i++, eve=eve->next) { float *no = emdm->vertexNos[i]; /* following Mesh convention; we use vertex coordinate itself * for normal in this case */ - if (Normalize(no)==0.0) { + if (normalize_v3(no)==0.0) { VECCOPY(no, vertexCos[i]); - Normalize(no); + normalize_v3(no); } } } @@ -2482,7 +2482,7 @@ int editmesh_get_first_deform_matrices(Object *ob, EditMesh *em, float (**deform defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats"); for(a=0; a<numVerts; a++) - Mat3One(defmats[a]); + unit_m3(defmats[a]); } mti->deformMatricesEM(md, ob, em, dm, deformedVerts, defmats, @@ -2554,11 +2554,11 @@ void DM_add_tangent_layer(DerivedMesh *dm) if (mf->v4) { v4= &mvert[mf->v4]; - CalcNormFloat4(v4->co, v3->co, v2->co, v1->co, fno); + normal_quad_v3( fno,v4->co, v3->co, v2->co, v1->co); } else { v4= NULL; - CalcNormFloat(v3->co, v2->co, v1->co, fno); + normal_tri_v3( fno,v3->co, v2->co, v1->co); } if(mtface) { @@ -2569,11 +2569,11 @@ void DM_add_tangent_layer(DerivedMesh *dm) } else { uv1= uv[0]; uv2= uv[1]; uv3= uv[2]; uv4= uv[3]; - spheremap(orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2], &uv[0][0], &uv[0][1]); - spheremap(orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2], &uv[1][0], &uv[1][1]); - spheremap(orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2], &uv[2][0], &uv[2][1]); + map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]); + map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]); + map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]); if(v4) - spheremap(orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2], &uv[3][0], &uv[3][1]); + map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]); } tangent_from_uv(uv1, uv2, uv3, v1->co, v2->co, v3->co, fno, tang); @@ -2603,11 +2603,11 @@ void DM_add_tangent_layer(DerivedMesh *dm) } else { uv1= uv[0]; uv2= uv[1]; uv3= uv[2]; uv4= uv[3]; - spheremap(orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2], &uv[0][0], &uv[0][1]); - spheremap(orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2], &uv[1][0], &uv[1][1]); - spheremap(orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2], &uv[2][0], &uv[2][1]); + map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]); + map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]); + map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]); if(len==4) - spheremap(orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2], &uv[3][0], &uv[3][1]); + map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]); } mf_vi[0]= mf->v1; @@ -2619,7 +2619,7 @@ void DM_add_tangent_layer(DerivedMesh *dm) vtang= find_vertex_tangent(vtangents[mf_vi[j]], mtface ? tf->uv[j] : uv[j]); VECCOPY(tangent[j], vtang); - Normalize(tangent[j]); + normalize_v3(tangent[j]); } } diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 2dec76d1b6b..358a482c3cf 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -64,7 +64,7 @@ #include "BKE_utildefines.h" #include "BIK_api.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_ghash.h" @@ -453,7 +453,7 @@ bPoseChannel *verify_pose_channel(bPose* pose, const char* name) chan->limitmax[0]= chan->limitmax[1]= chan->limitmax[2]= 180.0f; chan->stiffness[0]= chan->stiffness[1]= chan->stiffness[2]= 0.0f; chan->ikrotweight = chan->iklinweight = 0.0f; - Mat4One(chan->constinv); + unit_m4(chan->constinv); BLI_addtail(&pose->chanbase, chan); @@ -471,7 +471,7 @@ bPoseChannel *get_active_posechannel (Object *ob) /* find active */ for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - if ((pchan->bone) && (pchan->bone->flag & BONE_ACTIVE) && (pchan->bone->layer & arm->layer)) + if ((pchan->bone) && (pchan->bone == arm->act_bone) && (pchan->bone->layer & arm->layer)) return pchan; } @@ -611,8 +611,8 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan pchan->rotAngle= chan->rotAngle; QUATCOPY(pchan->quat, chan->quat); pchan->rotmode= chan->rotmode; - Mat4CpyMat4(pchan->chan_mat, (float(*)[4])chan->chan_mat); - Mat4CpyMat4(pchan->pose_mat, (float(*)[4])chan->pose_mat); + copy_m4_m4(pchan->chan_mat, (float(*)[4])chan->chan_mat); + copy_m4_m4(pchan->pose_mat, (float(*)[4])chan->pose_mat); pchan->flag= chan->flag; con= chan->constraints.first; @@ -1013,8 +1013,8 @@ void copy_pose_result(bPose *to, bPose *from) for(pchanfrom= from->chanbase.first; pchanfrom; pchanfrom= pchanfrom->next) { pchanto= get_pose_channel(to, pchanfrom->name); if(pchanto) { - Mat4CpyMat4(pchanto->pose_mat, pchanfrom->pose_mat); - Mat4CpyMat4(pchanto->chan_mat, pchanfrom->chan_mat); + copy_m4_m4(pchanto->pose_mat, pchanfrom->pose_mat); + copy_m4_m4(pchanto->chan_mat, pchanfrom->chan_mat); /* used for local constraints */ VECCOPY(pchanto->loc, pchanfrom->loc); @@ -1040,9 +1040,9 @@ void what_does_obaction (Scene *scene, Object *ob, Object *workob, bPose *pose, clear_workob(workob); /* init workob */ - Mat4CpyMat4(workob->obmat, ob->obmat); - Mat4CpyMat4(workob->parentinv, ob->parentinv); - Mat4CpyMat4(workob->constinv, ob->constinv); + copy_m4_m4(workob->obmat, ob->obmat); + copy_m4_m4(workob->parentinv, ob->parentinv); + copy_m4_m4(workob->constinv, ob->constinv); workob->parent= ob->parent; workob->track= ob->track; @@ -1109,7 +1109,7 @@ static void blend_pose_strides(bPose *dst, bPose *src, float srcweight, short mo dstweight = 1.0F; } - VecLerpf(dst->stride_offset, dst->stride_offset, src->stride_offset, srcweight); + interp_v3_v3v3(dst->stride_offset, dst->stride_offset, src->stride_offset, srcweight); } @@ -1169,27 +1169,27 @@ static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src, execute_action_ipo(achan, &pchan); /* store offset that moves src to location of pchan */ - VecSubf(vec, dpchan->loc, pchan.loc); + sub_v3_v3v3(vec, dpchan->loc, pchan.loc); - Mat4Mul3Vecfl(dpchan->bone->arm_mat, vec); + mul_mat3_m4_v3(dpchan->bone->arm_mat, vec); } } else { /* store offset that moves src to location of dst */ - VecSubf(vec, dpchan->loc, spchan->loc); - Mat4Mul3Vecfl(dpchan->bone->arm_mat, vec); + sub_v3_v3v3(vec, dpchan->loc, spchan->loc); + mul_mat3_m4_v3(dpchan->bone->arm_mat, vec); } /* if blending, we only add with factor scrweight */ - VecMulf(vec, srcweight); + mul_v3_fl(vec, srcweight); - VecAddf(dst->cyclic_offset, dst->cyclic_offset, vec); + add_v3_v3v3(dst->cyclic_offset, dst->cyclic_offset, vec); } } } - VecAddf(dst->cyclic_offset, dst->cyclic_offset, src->cyclic_offset); + add_v3_v3v3(dst->cyclic_offset, dst->cyclic_offset, src->cyclic_offset); } /* added "sizecorr" here, to allow armatures to be scaled and still have striding. @@ -1249,14 +1249,14 @@ static float stridechannel_frame(Object *ob, float sizecorr, bActionStrip *strip if (pdistNewNormalized <= 1) { // search for correction in positive path-direction where_on_path(ob, pdistNewNormalized, vec2, dir); /* vec needs size 4 */ - VecSubf(stride_offset, vec2, vec1); + sub_v3_v3v3(stride_offset, vec2, vec1); } else { // we reached the end of the path, search backwards instead where_on_path(ob, (pathdist-pdist)/path->totdist, vec2, dir); /* vec needs size 4 */ - VecSubf(stride_offset, vec1, vec2); + sub_v3_v3v3(stride_offset, vec1, vec2); } - Mat4Mul3Vecfl(ob->obmat, stride_offset); + mul_mat3_m4_v3(ob->obmat, stride_offset); return striptime; } } @@ -1295,10 +1295,10 @@ static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float } if(foundvert) { /* bring it into armature space */ - VecSubf(min, max, min); + sub_v3_v3v3(min, max, min); bone= get_named_bone(ob->data, strip->offs_bone); /* weak */ if(bone) { - Mat4Mul3Vecfl(bone->arm_mat, min); + mul_mat3_m4_v3(bone->arm_mat, min); /* dominant motion, cyclic_offset was cleared in rest_pose */ if (strip->flag & (ACTSTRIP_CYCLIC_USEX | ACTSTRIP_CYCLIC_USEY | ACTSTRIP_CYCLIC_USEZ)) { @@ -1549,7 +1549,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) } else if(blocktype==ID_AR) { /* apply stride offset to object */ - VecAddf(ob->obmat[3], ob->obmat[3], ob->pose->stride_offset); + add_v3_v3v3(ob->obmat[3], ob->obmat[3], ob->pose->stride_offset); } /* free */ diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 5cae2418e89..a1b138b9a74 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -35,7 +35,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "DNA_listBase.h" @@ -134,11 +134,11 @@ void calc_curvepath(Object *ob) for(a=0; a<tot; a++) { fp++; if(cycl && a==tot-1) - VecSubf(xyz, bevpfirst->vec, bevp->vec); + sub_v3_v3v3(xyz, bevpfirst->vec, bevp->vec); else - VecSubf(xyz, (bevp+1)->vec, bevp->vec); + sub_v3_v3v3(xyz, (bevp+1)->vec, bevp->vec); - *fp= *(fp-1)+VecLength(xyz); + *fp= *(fp-1)+len_v3(xyz); bevp++; } @@ -176,11 +176,11 @@ void calc_curvepath(Object *ob) fac1= fac2/fac1; fac2= 1.0f-fac1; - VecLerpf(pp->vec, bevp->vec, bevpn->vec, fac2); + interp_v3_v3v3(pp->vec, bevp->vec, bevpn->vec, fac2); pp->vec[3]= fac1*bevp->alfa + fac2*bevpn->alfa; pp->radius= fac1*bevp->radius + fac2*bevpn->radius; - QuatInterpol(pp->quat, bevp->quat, bevpn->quat, fac2); - NormalQuat(pp->quat); + interp_qt_qtqt(pp->quat, bevp->quat, bevpn->quat, fac2); + normalize_qt(pp->quat); pp++; } @@ -284,20 +284,20 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir, float *quat, * to more then one index in data which can give divide by zero error */ /* totfac= data[0]+data[1]; - if(totfac>0.000001) QuatInterpol(q1, p0->quat, p1->quat, data[0] / totfac); + if(totfac>0.000001) interp_qt_qtqt(q1, p0->quat, p1->quat, data[0] / totfac); else QUATCOPY(q1, p1->quat); - NormalQuat(q1); + normalize_qt(q1); totfac= data[2]+data[3]; - if(totfac>0.000001) QuatInterpol(q2, p2->quat, p3->quat, data[2] / totfac); + if(totfac>0.000001) interp_qt_qtqt(q2, p2->quat, p3->quat, data[2] / totfac); else QUATCOPY(q1, p3->quat); - NormalQuat(q2); + normalize_qt(q2); totfac = data[0]+data[1]+data[2]+data[3]; - if(totfac>0.000001) QuatInterpol(quat, q1, q2, (data[0]+data[1]) / totfac); + if(totfac>0.000001) interp_qt_qtqt(quat, q1, q2, (data[0]+data[1]) / totfac); else QUATCOPY(quat, q2); - NormalQuat(quat); + normalize_qt(quat); */ // XXX - find some way to make quat interpolation work correctly, above code fails in rare but nasty cases. QUATCOPY(quat, p1->quat); @@ -317,8 +317,8 @@ static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], i BLI_addtail(lb, dob); dob->ob= ob; - Mat4CpyMat4(dob->mat, mat); - Mat4CpyMat4(dob->omat, ob->obmat); + copy_m4_m4(dob->mat, mat); + copy_m4_m4(dob->omat, ob->obmat); dob->origlay= ob->lay; dob->index= index; dob->type= type; @@ -352,20 +352,20 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i /* Group Dupli Offset, should apply after everything else */ if (group->dupli_ofs[0] || group->dupli_ofs[1] || group->dupli_ofs[2]) { - Mat4CpyMat4(tmat, go->ob->obmat); - VecSubf(tmat[3], tmat[3], group->dupli_ofs); - Mat4MulMat4(mat, tmat, ob->obmat); + copy_m4_m4(tmat, go->ob->obmat); + sub_v3_v3v3(tmat[3], tmat[3], group->dupli_ofs); + mul_m4_m4m4(mat, tmat, ob->obmat); } else { - Mat4MulMat4(mat, go->ob->obmat, ob->obmat); + mul_m4_m4m4(mat, go->ob->obmat, ob->obmat); } dob= new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated); dob->no_draw= (dob->origlay & group->layer)==0; if(go->ob->transflag & OB_DUPLI) { - Mat4CpyMat4(dob->ob->obmat, dob->mat); + copy_m4_m4(dob->ob->obmat, dob->mat); object_duplilist_recursive((ID *)group, scene, go->ob, lb, ob->obmat, level+1, animated); - Mat4CpyMat4(dob->ob->obmat, dob->omat); + copy_m4_m4(dob->ob->obmat, dob->omat); } } } @@ -402,7 +402,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, #endif // XXX old animation system where_is_object_time(scene, ob, (float)scene->r.cfra); dob= new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, OB_DUPLIFRAMES, animated); - Mat4CpyMat4(dob->omat, copyob.obmat); + copy_m4_m4(dob->omat, copyob.obmat); } } @@ -430,11 +430,11 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n float vec[3], q2[4], mat[3][3], tmat[4][4], obmat[4][4]; VECCOPY(vec, co); - Mat4MulVecfl(vdd->pmat, vec); - VecSubf(vec, vec, vdd->pmat[3]); - VecAddf(vec, vec, vdd->obmat[3]); + mul_m4_v3(vdd->pmat, vec); + sub_v3_v3v3(vec, vec, vdd->pmat[3]); + add_v3_v3v3(vec, vec, vdd->obmat[3]); - Mat4CpyMat4(obmat, vdd->obmat); + copy_m4_m4(obmat, vdd->obmat); VECCOPY(obmat[3], vec); if(vdd->par->transflag & OB_DUPLIROT) { @@ -445,11 +445,11 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n vec[0]= -no_s[0]; vec[1]= -no_s[1]; vec[2]= -no_s[2]; } - vectoquat(vec, vdd->ob->trackflag, vdd->ob->upflag, q2); + vec_to_quat( q2,vec, vdd->ob->trackflag, vdd->ob->upflag); - QuatToMat3(q2, mat); - Mat4CpyMat4(tmat, obmat); - Mat4MulMat43(obmat, tmat, mat); + quat_to_mat3( mat,q2); + copy_m4_m4(tmat, obmat); + mul_m4_m4m3(obmat, tmat, mat); } dob= new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index, OB_DUPLIVERTS, vdd->animated); if(vdd->orco) @@ -457,10 +457,10 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n if(vdd->ob->transflag & OB_DUPLI) { float tmpmat[4][4]; - Mat4CpyMat4(tmpmat, vdd->ob->obmat); - Mat4CpyMat4(vdd->ob->obmat, obmat); /* pretend we are really this mat */ + copy_m4_m4(tmpmat, vdd->ob->obmat); + copy_m4_m4(vdd->ob->obmat, obmat); /* pretend we are really this mat */ object_duplilist_recursive((ID *)vdd->id, vdd->scene, vdd->ob, vdd->lb, obmat, vdd->level+1, vdd->animated); - Mat4CpyMat4(vdd->ob->obmat, tmpmat); + copy_m4_m4(vdd->ob->obmat, tmpmat); } } @@ -478,7 +478,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl float vec[3], no[3], pmat[4][4]; int lay, totvert, a, oblay; - Mat4CpyMat4(pmat, par->obmat); + copy_m4_m4(pmat, par->obmat); /* simple preventing of too deep nested groups */ if(level>MAX_DUPLI_RECUR) return; @@ -533,9 +533,9 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl when par_space_mat is NULL ob->obmat can be used instead of ob__obmat */ if(par_space_mat) - Mat4MulMat4(vdd.obmat, ob->obmat, par_space_mat); + mul_m4_m4m4(vdd.obmat, ob->obmat, par_space_mat); else - Mat4CpyMat4(vdd.obmat, ob->obmat); + copy_m4_m4(vdd.obmat, ob->obmat); vdd.id= id; vdd.level= level; @@ -544,7 +544,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl vdd.ob= ob; vdd.scene= scene; vdd.par= par; - Mat4CpyMat4(vdd.pmat, pmat); + copy_m4_m4(vdd.pmat, pmat); /* mballs have a different dupli handling */ if(ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */ @@ -596,7 +596,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa /* simple preventing of too deep nested groups */ if(level>MAX_DUPLI_RECUR) return; - Mat4CpyMat4(pmat, par->obmat); + copy_m4_m4(pmat, par->obmat); em = BKE_mesh_get_editmesh(me); if(em) { @@ -664,11 +664,11 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa when par_space_mat is NULL ob->obmat can be used instead of ob__obmat */ if(par_space_mat) - Mat4MulMat4(ob__obmat, ob->obmat, par_space_mat); + mul_m4_m4m4(ob__obmat, ob->obmat, par_space_mat); else - Mat4CpyMat4(ob__obmat, ob->obmat); + copy_m4_m4(ob__obmat, ob->obmat); - Mat3CpyMat4(imat, ob->parentinv); + copy_m3_m4(imat, ob->parentinv); /* mballs have a different dupli handling */ if(ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */ @@ -686,34 +686,34 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa /* translation */ if(v4) - CalcCent4f(cent, v1, v2, v3, v4); + cent_quad_v3(cent, v1, v2, v3, v4); else - CalcCent3f(cent, v1, v2, v3); - Mat4MulVecfl(pmat, cent); + cent_tri_v3(cent, v1, v2, v3); + mul_m4_v3(pmat, cent); - VecSubf(cent, cent, pmat[3]); - VecAddf(cent, cent, ob__obmat[3]); + sub_v3_v3v3(cent, cent, pmat[3]); + add_v3_v3v3(cent, cent, ob__obmat[3]); - Mat4CpyMat4(obmat, ob__obmat); + copy_m4_m4(obmat, ob__obmat); VECCOPY(obmat[3], cent); /* rotation */ - triatoquat(v1, v2, v3, quat); - QuatToMat3(quat, mat); + tri_to_quat( quat,v1, v2, v3); + quat_to_mat3( mat,quat); /* scale */ if(par->transflag & OB_DUPLIFACES_SCALE) { - float size= v4?AreaQ3Dfl(v1, v2, v3, v4):AreaT3Dfl(v1, v2, v3); + float size= v4? area_quad_v3(v1, v2, v3, v4): area_tri_v3(v1, v2, v3); size= sqrt(size) * par->dupfacesca; - Mat3MulFloat(mat[0], size); + mul_m3_fl(mat, size); } - Mat3CpyMat3(mat3, mat); - Mat3MulMat3(mat, imat, mat3); + copy_m3_m3(mat3, mat); + mul_m3_m3m3(mat, imat, mat3); - Mat4CpyMat4(tmat, obmat); - Mat4MulMat43(obmat, tmat, mat); + copy_m4_m4(tmat, obmat); + mul_m4_m4m3(obmat, tmat, mat); dob= new_dupli_object(lb, ob, obmat, lay, a, OB_DUPLIFACES, animated); if(G.rendering) { @@ -744,10 +744,10 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa if(ob->transflag & OB_DUPLI) { float tmpmat[4][4]; - Mat4CpyMat4(tmpmat, ob->obmat); - Mat4CpyMat4(ob->obmat, obmat); /* pretend we are really this mat */ + copy_m4_m4(tmpmat, ob->obmat); + copy_m4_m4(ob->obmat, obmat); /* pretend we are really this mat */ object_duplilist_recursive((ID *)id, scene, ob, lb, ob->obmat, level+1, animated); - Mat4CpyMat4(ob->obmat, tmpmat); + copy_m4_m4(ob->obmat, tmpmat); } } @@ -935,22 +935,22 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p if(psys_get_particle_state(&sim, a, &state, 0) == 0) continue; - QuatToMat4(state.rot, pamat); + quat_to_mat4( pamat,state.rot); VECCOPY(pamat[3], state.co); pamat[3][3]= 1.0f; } if(part->ren_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) { for(go= part->dup_group->gobject.first, b=0; go; go= go->next, b++) { - Mat4MulMat4(tmat, oblist[b]->obmat, pamat); - Mat4MulFloat3((float *)tmat, size*scale); + mul_m4_m4m4(tmat, oblist[b]->obmat, pamat); + mul_mat3_m4_fl(tmat, size*scale); if(par_space_mat) - Mat4MulMat4(mat, tmat, par_space_mat); + mul_m4_m4m4(mat, tmat, par_space_mat); else - Mat4CpyMat4(mat, tmat); + copy_m4_m4(mat, tmat); dob= new_dupli_object(lb, go->ob, mat, par->lay, counter, OB_DUPLIPARTS, animated); - Mat4CpyMat4(dob->omat, obcopylist[b].obmat); + copy_m4_m4(dob->omat, obcopylist[b].obmat); if(G.rendering) psys_get_dupli_texture(par, part, sim.psmd, pa, cpa, dob->uv, dob->orco); } @@ -962,21 +962,21 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p VECCOPY(vec, obmat[3]); obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f; - Mat4CpyMat4(mat, pamat); + copy_m4_m4(mat, pamat); - Mat4MulMat4(tmat, obmat, mat); - Mat4MulFloat3((float *)tmat, size*scale); + mul_m4_m4m4(tmat, obmat, mat); + mul_mat3_m4_fl(tmat, size*scale); if(part->draw & PART_DRAW_GLOBAL_OB) VECADD(tmat[3], tmat[3], vec); if(par_space_mat) - Mat4MulMat4(mat, tmat, par_space_mat); + mul_m4_m4m4(mat, tmat, par_space_mat); else - Mat4CpyMat4(mat, tmat); + copy_m4_m4(mat, tmat); dob= new_dupli_object(lb, ob, mat, ob->lay, counter, OB_DUPLIPARTS, animated); - Mat4CpyMat4(dob->omat, oldobmat); + copy_m4_m4(dob->omat, oldobmat); if(G.rendering) psys_get_dupli_texture(par, part, sim.psmd, pa, cpa, dob->uv, dob->orco); } @@ -1037,7 +1037,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i /* simple preventing of too deep nested groups */ if(level>MAX_DUPLI_RECUR) return; - Mat4CpyMat4(pmat, par->obmat); + copy_m4_m4(pmat, par->obmat); /* in par the family name is stored, use this to find the other objects */ @@ -1062,9 +1062,9 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i vec[1]= fsize*(ct->yof - yof); vec[2]= 0.0; - Mat4MulVecfl(pmat, vec); + mul_m4_v3(pmat, vec); - Mat4CpyMat4(obmat, par->obmat); + copy_m4_m4(obmat, par->obmat); VECCOPY(obmat[3], vec); new_dupli_object(lb, ob, obmat, par->lay, a, OB_DUPLIVERTS, animated); @@ -1122,7 +1122,7 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas if (level==0) { for(dob= duplilist->first; dob; dob= dob->next) if(dob->type == OB_DUPLIGROUP) - Mat4CpyMat4(dob->ob->obmat, dob->mat); + copy_m4_m4(dob->ob->obmat, dob->mat); } } } @@ -1143,7 +1143,7 @@ void free_object_duplilist(ListBase *lb) for(dob= lb->first; dob; dob= dob->next) { dob->ob->lay= dob->origlay; - Mat4CpyMat4(dob->ob->obmat, dob->omat); + copy_m4_m4(dob->ob->obmat, dob->omat); } BLI_freelistN(lb); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 61e754ffbec..e2849825862 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -36,7 +36,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_dynstr.h" #include "DNA_anim_types.h" diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 3a8a3d4efc9..798c3a87846 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -34,7 +34,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "DNA_armature_types.h" @@ -169,10 +169,13 @@ void make_local_armature(bArmature *arm) } } -static void copy_bonechildren (Bone* newBone, Bone* oldBone) +static void copy_bonechildren (Bone* newBone, Bone* oldBone, Bone* actBone, Bone **newActBone) { Bone *curBone, *newChildBone; + if(oldBone == actBone) + *newActBone= newBone; + /* Copy this bone's list*/ BLI_duplicatelist(&newBone->childbase, &oldBone->childbase); @@ -180,7 +183,7 @@ static void copy_bonechildren (Bone* newBone, Bone* oldBone) newChildBone=newBone->childbase.first; for (curBone=oldBone->childbase.first;curBone;curBone=curBone->next){ newChildBone->parent=newBone; - copy_bonechildren(newChildBone,curBone); + copy_bonechildren(newChildBone, curBone, actBone, newActBone); newChildBone=newChildBone->next; } } @@ -189,6 +192,7 @@ bArmature *copy_armature(bArmature *arm) { bArmature *newArm; Bone *oldBone, *newBone; + Bone *newActBone= NULL; newArm= copy_libblock (arm); BLI_duplicatelist(&newArm->bonebase, &arm->bonebase); @@ -197,10 +201,11 @@ bArmature *copy_armature(bArmature *arm) newBone=newArm->bonebase.first; for (oldBone=arm->bonebase.first;oldBone;oldBone=oldBone->next){ newBone->parent=NULL; - copy_bonechildren (newBone, oldBone); + copy_bonechildren (newBone, oldBone, arm->act_bone, &newActBone); newBone=newBone->next; }; + newArm->act_bone= newActBone; return newArm; } @@ -477,7 +482,7 @@ static void equalize_bezier(float *data, int desired) pdist[0]= 0.0f; for(a=0, fp= data; a<MAX_BBONE_SUBDIV; a++, fp+=4) { QUATCOPY(temp[a], fp); - pdist[a+1]= pdist[a]+VecLenf(fp, fp+4); + pdist[a+1]= pdist[a]+len_v3v3(fp, fp+4); } /* do last point */ QUATCOPY(temp[a], fp); @@ -527,16 +532,16 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) if(!rest) { /* check if we need to take non-uniform bone scaling into account */ - scale[0]= VecLength(pchan->pose_mat[0]); - scale[1]= VecLength(pchan->pose_mat[1]); - scale[2]= VecLength(pchan->pose_mat[2]); + scale[0]= len_v3(pchan->pose_mat[0]); + scale[1]= len_v3(pchan->pose_mat[1]); + scale[2]= len_v3(pchan->pose_mat[2]); if(fabs(scale[0] - scale[1]) > 1e-6f || fabs(scale[1] - scale[2]) > 1e-6f) { - Mat4One(scalemat); + unit_m4(scalemat); scalemat[0][0]= scale[0]; scalemat[1][1]= scale[1]; scalemat[2][2]= scale[2]; - Mat4Invert(iscalemat, scalemat); + invert_m4_m4(iscalemat, scalemat); length *= scale[1]; doscale = 1; @@ -559,15 +564,15 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) last point = (0, length, 0) */ if(rest) { - Mat4Invert(imat, pchan->bone->arm_mat); + invert_m4_m4(imat, pchan->bone->arm_mat); } else if(doscale) { - Mat4CpyMat4(posemat, pchan->pose_mat); - Mat4Ortho(posemat); - Mat4Invert(imat, posemat); + copy_m4_m4(posemat, pchan->pose_mat); + normalize_m4(posemat); + invert_m4_m4(imat, posemat); } else - Mat4Invert(imat, pchan->pose_mat); + invert_m4_m4(imat, pchan->pose_mat); if(prev) { float difmat[4][4], result[3][3], imat3[3][3]; @@ -577,7 +582,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) VECCOPY(h1, prev->bone->arm_head) else VECCOPY(h1, prev->pose_head) - Mat4MulVecfl(imat, h1); + mul_m4_v3(imat, h1); if(prev->bone->segments>1) { /* if previous bone is B-bone too, use average handle direction */ @@ -585,21 +590,21 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) roll1= 0.0f; } - Normalize(h1); - VecMulf(h1, -hlength1); + normalize_v3(h1); + mul_v3_fl(h1, -hlength1); if(prev->bone->segments==1) { /* find the previous roll to interpolate */ if(rest) - Mat4MulMat4(difmat, prev->bone->arm_mat, imat); + mul_m4_m4m4(difmat, prev->bone->arm_mat, imat); else - Mat4MulMat4(difmat, prev->pose_mat, imat); - Mat3CpyMat4(result, difmat); // the desired rotation at beginning of next bone + mul_m4_m4m4(difmat, prev->pose_mat, imat); + copy_m3_m4(result, difmat); // the desired rotation at beginning of next bone vec_roll_to_mat3(h1, 0.0f, mat3); // the result of vec_roll without roll - Mat3Inv(imat3, mat3); - Mat3MulMat3(mat3, result, imat3); // the matrix transforming vec_roll to desired roll + invert_m3_m3(imat3, mat3); + mul_m3_m3m3(mat3, result, imat3); // the matrix transforming vec_roll to desired roll roll1= (float)atan2(mat3[2][0], mat3[2][2]); } @@ -616,28 +621,28 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) VECCOPY(h2, next->bone->arm_tail) else VECCOPY(h2, next->pose_tail) - Mat4MulVecfl(imat, h2); + mul_m4_v3(imat, h2); /* if next bone is B-bone too, use average handle direction */ if(next->bone->segments>1); else h2[1]-= length; - Normalize(h2); + normalize_v3(h2); /* find the next roll to interpolate as well */ if(rest) - Mat4MulMat4(difmat, next->bone->arm_mat, imat); + mul_m4_m4m4(difmat, next->bone->arm_mat, imat); else - Mat4MulMat4(difmat, next->pose_mat, imat); - Mat3CpyMat4(result, difmat); // the desired rotation at beginning of next bone + mul_m4_m4m4(difmat, next->pose_mat, imat); + copy_m3_m4(result, difmat); // the desired rotation at beginning of next bone vec_roll_to_mat3(h2, 0.0f, mat3); // the result of vec_roll without roll - Mat3Inv(imat3, mat3); - Mat3MulMat3(mat3, imat3, result); // the matrix transforming vec_roll to desired roll + invert_m3_m3(imat3, mat3); + mul_m3_m3m3(mat3, imat3, result); // the matrix transforming vec_roll to desired roll roll2= (float)atan2(mat3[2][0], mat3[2][2]); /* and only now negate handle */ - VecMulf(h2, -hlength2); + mul_v3_fl(h2, -hlength2); } else { h2[0]= 0.0f; h2[1]= -hlength2; h2[2]= 0.0f; @@ -657,15 +662,15 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) /* make transformation matrices for the segments for drawing */ for(a=0, fp= data[0]; a<bone->segments; a++, fp+=4) { - VecSubf(h1, fp+4, fp); + sub_v3_v3v3(h1, fp+4, fp); vec_roll_to_mat3(h1, fp[3], mat3); // fp[3] is roll - Mat4CpyMat3(result_array[a].mat, mat3); + copy_m4_m3(result_array[a].mat, mat3); VECCOPY(result_array[a].mat[3], fp); if(doscale) { /* correct for scaling when this matrix is used in scaled space */ - Mat4MulSerie(result_array[a].mat, iscalemat, result_array[a].mat, + mul_serie_m4(result_array[a].mat, iscalemat, result_array[a].mat, scalemat, NULL, NULL, NULL, NULL, NULL); } } @@ -696,26 +701,26 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, int use_quaternion, int re /* first matrix is the inverse arm_mat, to bring points in local bone space for finding out which segment it belongs to */ - Mat4Invert(b_bone_mats[0].mat, bone->arm_mat); + invert_m4_m4(b_bone_mats[0].mat, bone->arm_mat); /* then we make the b_bone_mats: - first transform to local bone space - translate over the curve to the bbone mat space - transform with b_bone matrix - transform back into global space */ - Mat4One(tmat); + unit_m4(tmat); for(a=0; a<bone->segments; a++) { if(b_bone_rest) - Mat4Invert(tmat, b_bone_rest[a].mat); + invert_m4_m4(tmat, b_bone_rest[a].mat); else tmat[3][1] = -a*(bone->length/(float)bone->segments); - Mat4MulSerie(b_bone_mats[a+1].mat, pchan->chan_mat, bone->arm_mat, + mul_serie_m4(b_bone_mats[a+1].mat, pchan->chan_mat, bone->arm_mat, b_bone[a].mat, tmat, b_bone_mats[0].mat, NULL, NULL, NULL); if(use_quaternion) - Mat4ToDQuat(bone->arm_mat, b_bone_mats[a+1].mat, &b_bone_dual_quats[a]); + mat4_to_dquat( &b_bone_dual_quats[a],bone->arm_mat, b_bone_mats[a+1].mat); } } @@ -738,13 +743,13 @@ static void b_bone_deform(bPoseChannel *pchan, Bone *bone, float *co, DualQuat * CLAMP(a, 0, bone->segments-1); if(dq) { - DQuatCpyDQuat(dq, &((DualQuat*)pchan->b_bone_dual_quats)[a]); + copy_dq_dq(dq, &((DualQuat*)pchan->b_bone_dual_quats)[a]); } else { - Mat4MulVecfl(b_bone[a+1].mat, co); + mul_m4_v3(b_bone[a+1].mat, co); if(defmat) - Mat3CpyMat4(defmat, b_bone[a+1].mat); + copy_m3_m4(defmat, b_bone[a+1].mat); } } @@ -756,10 +761,10 @@ float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, fl float pdelta[3]; float hsqr, a, l, rad; - VecSubf (bdelta, b2, b1); - l = Normalize (bdelta); + sub_v3_v3v3(bdelta, b2, b1); + l = normalize_v3(bdelta); - VecSubf (pdelta, vec, b1); + sub_v3_v3v3(pdelta, vec, b1); a = bdelta[0]*pdelta[0] + bdelta[1]*pdelta[1] + bdelta[2]*pdelta[2]; hsqr = ((pdelta[0]*pdelta[0]) + (pdelta[1]*pdelta[1]) + (pdelta[2]*pdelta[2])); @@ -804,12 +809,12 @@ static void pchan_deform_mat_add(bPoseChannel *pchan, float weight, float bbonem float wmat[3][3]; if(pchan->bone->segments>1) - Mat3CpyMat3(wmat, bbonemat); + copy_m3_m3(wmat, bbonemat); else - Mat3CpyMat4(wmat, pchan->chan_mat); + copy_m3_m4(wmat, pchan->chan_mat); - Mat3MulFloat((float*)wmat, weight); - Mat3AddMat3(mat, mat, wmat); + mul_m3_fl(wmat, weight); + add_m3_m3m3(mat, mat, wmat); } static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, float mat[][3], float *co) @@ -835,12 +840,12 @@ static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, flo // applies on cop and bbonemat b_bone_deform(pchan, bone, cop, NULL, (mat)?bbonemat:NULL); else - Mat4MulVecfl(pchan->chan_mat, cop); + mul_m4_v3(pchan->chan_mat, cop); // Make this a delta from the base position - VecSubf (cop, cop, co); + sub_v3_v3v3(cop, cop, co); cop[0]*=fac; cop[1]*=fac; cop[2]*=fac; - VecAddf (vec, vec, cop); + add_v3_v3v3(vec, vec, cop); if(mat) pchan_deform_mat_add(pchan, fac, bbonemat, mat); @@ -848,10 +853,10 @@ static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, flo else { if(bone->segments>1) { b_bone_deform(pchan, bone, cop, &bbonedq, NULL); - DQuatAddWeighted(dq, &bbonedq, fac); + add_weighted_dq_dq(dq, &bbonedq, fac); } else - DQuatAddWeighted(dq, pchan->dual_quat, fac); + add_weighted_dq_dq(dq, pchan->dual_quat, fac); } } } @@ -874,7 +879,7 @@ static void pchan_bone_deform(bPoseChannel *pchan, float weight, float *vec, Dua // applies on cop and bbonemat b_bone_deform(pchan, pchan->bone, cop, NULL, (mat)?bbonemat:NULL); else - Mat4MulVecfl(pchan->chan_mat, cop); + mul_m4_v3(pchan->chan_mat, cop); vec[0]+=(cop[0]-co[0])*weight; vec[1]+=(cop[1]-co[1])*weight; @@ -886,10 +891,10 @@ static void pchan_bone_deform(bPoseChannel *pchan, float weight, float *vec, Dua else { if(pchan->bone->segments>1) { b_bone_deform(pchan, pchan->bone, cop, &bbonedq, NULL); - DQuatAddWeighted(dq, &bbonedq, weight); + add_weighted_dq_dq(dq, &bbonedq, weight); } else - DQuatAddWeighted(dq, pchan->dual_quat, weight); + add_weighted_dq_dq(dq, pchan->dual_quat, weight); } (*contrib)+=weight; @@ -918,10 +923,10 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, if(arm->edbo) return; - Mat4Invert(obinv, target->obmat); - Mat4CpyMat4(premat, target->obmat); - Mat4MulMat4(postmat, armOb->obmat, obinv); - Mat4Invert(premat, postmat); + invert_m4_m4(obinv, target->obmat); + copy_m4_m4(premat, target->obmat); + mul_m4_m4m4(postmat, armOb->obmat, obinv); + invert_m4_m4(premat, postmat); /* bone defmats are already in the channels, chan_mat */ @@ -939,7 +944,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, if(use_quaternion) { pchan->dual_quat= &dualquats[totchan++]; - Mat4ToDQuat(pchan->bone->arm_mat, pchan->chan_mat, pchan->dual_quat); + mat4_to_dquat( pchan->dual_quat,pchan->bone->arm_mat, pchan->chan_mat); } } } @@ -1008,7 +1013,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, vec= sumvec; if(defMats) { - Mat3Clr((float*)summat); + zero_m3(summat); smat = summat; } } @@ -1045,7 +1050,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, co= prevCos?prevCos[i]:vertexCos[i]; /* Apply the object's matrix */ - Mat4MulVecfl(premat, co); + mul_m4_v3(premat, co); if(use_dverts && dvert && dvert->totweight) { // use weight groups ? int deformed = 0; @@ -1091,42 +1096,42 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, /* actually should be EPSILON? weight values and contrib can be like 10e-39 small */ if(contrib > 0.0001f) { if(use_quaternion) { - DQuatNormalize(dq, contrib); + normalize_dq(dq, contrib); if(armature_weight != 1.0f) { VECCOPY(dco, co); - DQuatMulVecfl(dq, dco, (defMats)? summat: NULL); - VecSubf(dco, dco, co); - VecMulf(dco, armature_weight); - VecAddf(co, co, dco); + mul_v3m3_dq( dco, (defMats)? summat: NULL,dq); + sub_v3_v3v3(dco, dco, co); + mul_v3_fl(dco, armature_weight); + add_v3_v3v3(co, co, dco); } else - DQuatMulVecfl(dq, co, (defMats)? summat: NULL); + mul_v3m3_dq( co, (defMats)? summat: NULL,dq); smat = summat; } else { - VecMulf(vec, armature_weight/contrib); - VecAddf(co, vec, co); + mul_v3_fl(vec, armature_weight/contrib); + add_v3_v3v3(co, vec, co); } if(defMats) { float pre[3][3], post[3][3], tmpmat[3][3]; - Mat3CpyMat4(pre, premat); - Mat3CpyMat4(post, postmat); - Mat3CpyMat3(tmpmat, defMats[i]); + copy_m3_m4(pre, premat); + copy_m3_m4(post, postmat); + copy_m3_m3(tmpmat, defMats[i]); if(!use_quaternion) /* quaternion already is scale corrected */ - Mat3MulFloat((float*)smat, armature_weight/contrib); + mul_m3_fl(smat, armature_weight/contrib); - Mat3MulSerie(defMats[i], tmpmat, pre, smat, post, + mul_serie_m3(defMats[i], tmpmat, pre, smat, post, NULL, NULL, NULL, NULL); } } /* always, check above code */ - Mat4MulVecfl(postmat, co); + mul_m4_v3(postmat, co); /* interpolate with previous modifier position using weight group */ @@ -1160,7 +1165,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, void get_objectspace_bone_matrix (struct Bone* bone, float M_accumulatedMatrix[][4], int root, int posed) { - Mat4CpyMat4(M_accumulatedMatrix, bone->arm_mat); + copy_m4_m4(M_accumulatedMatrix, bone->arm_mat); } /* **************** Space to Space API ****************** */ @@ -1174,10 +1179,10 @@ void armature_mat_world_to_pose(Object *ob, float inmat[][4], float outmat[][4]) if (ob==NULL) return; /* get inverse of (armature) object's matrix */ - Mat4Invert(obmat, ob->obmat); + invert_m4_m4(obmat, ob->obmat); /* multiply given matrix by object's-inverse to find pose-space matrix */ - Mat4MulMat4(outmat, obmat, inmat); + mul_m4_m4m4(outmat, obmat, inmat); } /* Convert Wolrd-Space Location to Pose-Space Location @@ -1190,7 +1195,7 @@ void armature_loc_world_to_pose(Object *ob, float *inloc, float *outloc) float nLocMat[4][4]; /* build matrix for location */ - Mat4One(xLocMat); + unit_m4(xLocMat); VECCOPY(xLocMat[3], inloc); /* get bone-space cursor matrix and extract location */ @@ -1212,24 +1217,24 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm /* get the inverse matrix of the pchan's transforms */ if (pchan->rotmode) - LocEulSizeToMat4(pc_trans, pchan->loc, pchan->eul, pchan->size); + loc_eul_size_to_mat4(pc_trans, pchan->loc, pchan->eul, pchan->size); else - LocQuatSizeToMat4(pc_trans, pchan->loc, pchan->quat, pchan->size); - Mat4Invert(inv_trans, pc_trans); + loc_quat_size_to_mat4(pc_trans, pchan->loc, pchan->quat, pchan->size); + invert_m4_m4(inv_trans, pc_trans); /* Remove the pchan's transforms from it's pose_mat. * This should leave behind the effects of restpose + * parenting + constraints */ - Mat4MulMat4(pc_posemat, inv_trans, pchan->pose_mat); + mul_m4_m4m4(pc_posemat, inv_trans, pchan->pose_mat); /* get the inverse of the leftovers so that we can remove * that component from the supplied matrix */ - Mat4Invert(inv_posemat, pc_posemat); + invert_m4_m4(inv_posemat, pc_posemat); /* get the new matrix */ - Mat4MulMat4(outmat, inmat, inv_posemat); + mul_m4_m4m4(outmat, inmat, inv_posemat); } /* Convert Pose-Space Location to Bone-Space Location @@ -1242,7 +1247,7 @@ void armature_loc_pose_to_bone(bPoseChannel *pchan, float *inloc, float *outloc) float nLocMat[4][4]; /* build matrix for location */ - Mat4One(xLocMat); + unit_m4(xLocMat); VECCOPY(xLocMat[3], inloc); /* get bone-space cursor matrix and extract location */ @@ -1258,8 +1263,8 @@ void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float { float imat[4][4]; - Mat4Invert(imat, arm_mat); - Mat4MulMat4(delta_mat, pose_mat, imat); + invert_m4_m4(imat, arm_mat); + mul_m4_m4m4(delta_mat, pose_mat, imat); } /* **************** Rotation Mode Conversions ****************************** */ @@ -1275,33 +1280,33 @@ void BKE_rotMode_change_values (float quat[4], float eul[3], float axis[3], floa if (newMode > 0) { /* to euler */ if (oldMode == ROT_MODE_AXISANGLE) { /* axis-angle to euler */ - AxisAngleToEulO(axis, *angle, eul, newMode); + axis_angle_to_eulO( eul, newMode,axis, *angle); } else if (oldMode == ROT_MODE_QUAT) { /* quat to euler */ - QuatToEulO(quat, eul, newMode); + quat_to_eulO( eul, newMode,quat); } /* else { no conversion needed } */ } else if (newMode == ROT_MODE_QUAT) { /* to quat */ if (oldMode == ROT_MODE_AXISANGLE) { /* axis angle to quat */ - AxisAngleToQuat(quat, axis, *angle); + axis_angle_to_quat(quat, axis, *angle); } else if (oldMode > 0) { /* euler to quat */ - EulOToQuat(eul, oldMode, quat); + eulO_to_quat( quat,eul, oldMode); } /* else { no conversion needed } */ } else if (newMode == ROT_MODE_AXISANGLE) { /* to axis-angle */ if (oldMode > 0) { /* euler to axis angle */ - EulOToAxisAngle(eul, oldMode, axis, angle); + eulO_to_axis_angle( axis, angle,eul, oldMode); } else if (oldMode == ROT_MODE_QUAT) { /* quat to axis angle */ - QuatToAxisAngle(quat, axis, angle); + quat_to_axis_angle( axis, angle,quat); } /* when converting to axis-angle, we need a special exception for the case when there is no axis */ @@ -1336,14 +1341,14 @@ void BKE_rotMode_change_values (float quat[4], float eul[3], float axis[3], floa void mat3_to_vec_roll(float mat[][3], float *vec, float *roll) { if (vec) - VecCopyf(vec, mat[1]); + copy_v3_v3(vec, mat[1]); if (roll) { float vecmat[3][3], vecmatinv[3][3], rollmat[3][3]; vec_roll_to_mat3(mat[1], 0.0f, vecmat); - Mat3Inv(vecmatinv, vecmat); - Mat3MulMat3(rollmat, vecmatinv, mat); + invert_m3_m3(vecmatinv, vecmat); + mul_m3_m3m3(rollmat, vecmatinv, mat); *roll= (float)atan2(rollmat[2][0], rollmat[2][2]); } @@ -1358,26 +1363,26 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3]) float rMatrix[3][3], bMatrix[3][3]; VECCOPY (nor, vec); - Normalize (nor); + normalize_v3(nor); /* Find Axis & Amount for bone matrix*/ - Crossf (axis,target,nor); + cross_v3_v3v3(axis,target,nor); - if (Inpf(axis,axis) > 0.0000000000001) { + if (dot_v3v3(axis,axis) > 0.0000000000001) { /* if nor is *not* a multiple of target ... */ - Normalize (axis); + normalize_v3(axis); - theta= NormalizedVecAngle2(target, nor); + theta= angle_normalized_v3v3(target, nor); /* Make Bone matrix*/ - VecRotToMat3(axis, theta, bMatrix); + vec_rot_to_mat3( bMatrix,axis, theta); } else { /* if nor is a multiple of target ... */ float updown; /* point same direction, or opposite? */ - updown = ( Inpf (target,nor) > 0 ) ? 1.0f : -1.0f; + updown = ( dot_v3v3(target,nor) > 0 ) ? 1.0f : -1.0f; /* I think this should work ... */ bMatrix[0][0]=updown; bMatrix[0][1]=0.0; bMatrix[0][2]=0.0; @@ -1386,10 +1391,10 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3]) } /* Make Roll matrix*/ - VecRotToMat3(nor, roll, rMatrix); + vec_rot_to_mat3( rMatrix,nor, roll); /* Combine and output result*/ - Mat3MulMat3 (mat, rMatrix, bMatrix); + mul_m3_m3m3(mat, rMatrix, bMatrix); } @@ -1400,10 +1405,10 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone) float vec[3]; /* Bone Space */ - VecSubf (vec, bone->tail, bone->head); + sub_v3_v3v3(vec, bone->tail, bone->head); vec_roll_to_mat3(vec, bone->roll, bone->bone_mat); - bone->length= VecLenf(bone->head, bone->tail); + bone->length= len_v3v3(bone->head, bone->tail); /* this is called on old file reading too... */ if(bone->xwidth==0.0) { @@ -1416,7 +1421,7 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone) float offs_bone[4][4]; // yoffs(b-1) + root(b) + bonemat(b) /* bone transform itself */ - Mat4CpyMat3(offs_bone, bone->bone_mat); + copy_m4_m3(offs_bone, bone->bone_mat); /* The bone's root offset (is in the parent's coordinate system) */ VECCOPY(offs_bone[3], bone->head); @@ -1425,10 +1430,10 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone) offs_bone[3][1]+= prevbone->length; /* Compose the matrix for this bone */ - Mat4MulMat4(bone->arm_mat, offs_bone, prevbone->arm_mat); + mul_m4_m4m4(bone->arm_mat, offs_bone, prevbone->arm_mat); } else { - Mat4CpyMat3(bone->arm_mat, bone->bone_mat); + copy_m4_m3(bone->arm_mat, bone->bone_mat); VECCOPY(bone->arm_mat[3], bone->head); } @@ -1436,8 +1441,8 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone) VECCOPY(bone->arm_head, bone->arm_mat[3]); /* tail is in current local coord system */ VECCOPY(vec, bone->arm_mat[1]); - VecMulf(vec, bone->length); - VecAddf(bone->arm_tail, bone->arm_head, vec); + mul_v3_fl(vec, bone->length); + add_v3_v3v3(bone->arm_tail, bone->arm_head, vec); /* and the kiddies */ prevbone= bone; @@ -1689,8 +1694,6 @@ static void splineik_init_tree_from_pchan(Object *ob, bPoseChannel *pchan_tip) /* setup new empty array for the points list */ if (ikData->points) MEM_freeN(ikData->points); - // NOTE: just do chainlen+1 always for now, since we may get crashes otherwise - //ikData->numpoints= (ikData->flag & CONSTRAINT_SPLINEIK_NO_ROOT)? ikData->chainlen : ikData->chainlen+1; ikData->numpoints= ikData->chainlen+1; ikData->points= MEM_callocN(sizeof(float)*ikData->numpoints, "Spline IK Binding"); @@ -1749,6 +1752,7 @@ static void splineik_init_tree_from_pchan(Object *ob, bPoseChannel *pchan_tip) maxScale = totLength / splineLen; /* apply scaling correction to all of the temporary points */ + // TODO: this is really not adequate enough on really short chains for (i = 0; i < segcount; i++) jointPoints[i] *= maxScale; } @@ -1820,7 +1824,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o /* step 1a: get xyz positions for the tail endpoint of the bone */ if ( where_on_path(ikData->tar, tree->points[index], vec, dir, NULL, &rad) ) { /* convert the position to pose-space, then store it */ - Mat4MulVecfl(ob->imat, vec); + mul_m4_v3(ob->imat, vec); VECCOPY(poseTail, vec); /* set the new radius */ @@ -1828,28 +1832,21 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o } /* step 1b: get xyz positions for the head endpoint of the bone */ - /* firstly, calculate the position that the path suggests */ if ( where_on_path(ikData->tar, tree->points[index+1], vec, dir, NULL, &rad) ) { /* store the position, and convert it to pose space */ - Mat4MulVecfl(ob->imat, vec); + mul_m4_v3(ob->imat, vec); VECCOPY(poseHead, vec); /* set the new radius (it should be the average value) */ radius = (radius+rad) / 2; } - if ((ikData->flag & CONSTRAINT_SPLINEIK_NO_ROOT) && (pchan == tree->root)) - { - // this is the root bone, and it can be controlled however we like... - // TODO: how do we calculate the offset of the root, if we don't even know the binding? - VECCOPY(poseHead, pchan->pose_head); - } /* step 2: determine the implied transform from these endpoints * - splineVec: the vector direction that the spline applies on the bone * - scaleFac: the factor that the bone length is scaled by to get the desired amount */ - VecSubf(splineVec, poseTail, poseHead); - scaleFac= VecLength(splineVec) / pchan->bone->length; + sub_v3_v3v3(splineVec, poseTail, poseHead); + scaleFac= len_v3(splineVec) / pchan->bone->length; /* step 3: compute the shortest rotation needed to map from the bone rotation to the current axis * - this uses the same method as is used for the Damped Track Constraint (see the code there for details) @@ -1864,49 +1861,68 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o VECCOPY(rmat[0], pchan->pose_mat[0]); VECCOPY(rmat[1], pchan->pose_mat[1]); VECCOPY(rmat[2], pchan->pose_mat[2]); - Mat3Ortho(rmat); + normalize_m3(rmat); /* also, normalise the orientation imposed by the bone, now that we've extracted the scale factor */ - Normalize(splineVec); + normalize_v3(splineVec); /* calculate smallest axis-angle rotation necessary for getting from the * current orientation of the bone, to the spline-imposed direction */ - Crossf(raxis, rmat[1], splineVec); + cross_v3_v3v3(raxis, rmat[1], splineVec); - rangle= Inpf(rmat[1], splineVec); + rangle= dot_v3v3(rmat[1], splineVec); rangle= acos( MAX2(-1.0f, MIN2(1.0f, rangle)) ); /* construct rotation matrix from the axis-angle rotation found above * - this call takes care to make sure that the axis provided is a unit vector first */ - AxisAngleToMat3(raxis, rangle, dmat); + axis_angle_to_mat3( dmat,raxis, rangle); /* combine these rotations so that the y-axis of the bone is now aligned as the spline dictates, * while still maintaining roll control from the existing bone animation */ - Mat3MulMat3(tmat, dmat, rmat); // m1, m3, m2 - Mat3Ortho(tmat); /* attempt to reduce shearing, though I doubt this'll really help too much now... */ - Mat4CpyMat3(poseMat, tmat); + mul_m3_m3m3(tmat, dmat, rmat); // m1, m3, m2 + normalize_m3(tmat); /* attempt to reduce shearing, though I doubt this'll really help too much now... */ + copy_m4_m3(poseMat, tmat); } /* step 4: set the scaling factors for the axes */ + // TODO: include a no-scale option? { /* only multiply the y-axis by the scaling factor to get nice volume-preservation */ - VecMulf(poseMat[1], scaleFac); - - /* set the scaling factors of the x and z axes from the average radius of the curve? */ - if (ikData->flag & CONSTRAINT_SPLINEIK_RAD2FAT) { - VecMulf(poseMat[0], radius); - VecMulf(poseMat[2], radius); + mul_v3_fl(poseMat[1], scaleFac); + + /* set the scaling factors of the x and z axes from... */ + switch (ikData->xzScaleMode) { + case CONSTRAINT_SPLINEIK_XZS_RADIUS: + { + /* radius of curve */ + mul_v3_fl(poseMat[0], radius); + mul_v3_fl(poseMat[2], radius); + } + break; + case CONSTRAINT_SPLINEIK_XZS_ORIGINAL: + { + /* original scales get used */ + float scale; + + /* x-axis scale */ + scale= len_v3(pchan->pose_mat[0]); + mul_v3_fl(poseMat[0], scale); + /* z-axis scale */ + scale= len_v3(pchan->pose_mat[2]); + mul_v3_fl(poseMat[2], scale); + } + break; } } /* step 5: set the location of the bone in the matrix */ - VECCOPY(poseMat[3], pchan->pose_head); + VECCOPY(poseMat[3], poseHead); /* finally, store the new transform */ - Mat4CpyMat4(pchan->pose_mat, poseMat); + copy_m4_m4(pchan->pose_mat, poseMat); VECCOPY(pchan->pose_head, poseHead); VECCOPY(pchan->pose_tail, poseTail); @@ -1958,26 +1974,26 @@ void chan_calc_mat(bPoseChannel *chan) float tmat[3][3]; /* get scaling matrix */ - SizeToMat3(chan->size, smat); + size_to_mat3( smat,chan->size); /* rotations may either be quats, eulers (with various rotation orders), or axis-angle */ if (chan->rotmode > 0) { /* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */ - EulOToMat3(chan->eul, chan->rotmode, rmat); + eulO_to_mat3( rmat,chan->eul, chan->rotmode); } else if (chan->rotmode == ROT_MODE_AXISANGLE) { /* axis-angle - not really that great for 3D-changing orientations */ - AxisAngleToMat3(chan->rotAxis, chan->rotAngle, rmat); + axis_angle_to_mat3( rmat,chan->rotAxis, chan->rotAngle); } else { /* quats are normalised before use to eliminate scaling issues */ - NormalQuat(chan->quat); // TODO: do this with local vars only! - QuatToMat3(chan->quat, rmat); + normalize_qt(chan->quat); // TODO: do this with local vars only! + quat_to_mat3( rmat,chan->quat); } /* calculate matrix of bone (as 3x3 matrix, but then copy the 4x4) */ - Mat3MulMat3(tmat, rmat, smat); - Mat4CpyMat3(chan->chan_mat, tmat); + mul_m3_m3m3(tmat, rmat, smat); + copy_m4_m3(chan->chan_mat, tmat); /* prevent action channels breaking chains */ /* need to check for bone here, CONSTRAINT_TYPE_ACTION uses this call */ @@ -2041,8 +2057,8 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha float mat4[4][4], mat3[3][3]; curve_deform_vector(scene, amod->ob, armob, bone->arm_mat[3], pchan->pose_mat[3], mat3, amod->no_rot_axis); - Mat4CpyMat4(mat4, pchan->pose_mat); - Mat4MulMat34(pchan->pose_mat, mat3, mat4); + copy_m4_m4(mat4, pchan->pose_mat); + mul_m4_m3m4(pchan->pose_mat, mat3, mat4); } } @@ -2059,8 +2075,8 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha /* make a copy of starting conditions */ VECCOPY(loc, pchan->pose_mat[3]); - Mat4ToEul(pchan->pose_mat, eul); - Mat4ToSize(pchan->pose_mat, size); + mat4_to_eul( eul,pchan->pose_mat); + mat4_to_size( size,pchan->pose_mat); VECCOPY(eulo, eul); VECCOPY(sizeo, size); @@ -2070,14 +2086,14 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha nor[0] = BLI_gNoise(amod->noisesize, size[0]+ofs, size[1], size[2], 0, 0) - ofs; nor[1] = BLI_gNoise(amod->noisesize, size[0], size[1]+ofs, size[2], 0, 0) - ofs; nor[2] = BLI_gNoise(amod->noisesize, size[0], size[1], size[2]+ofs, 0, 0) - ofs; - VecAddf(size, size, nor); + add_v3_v3v3(size, size, nor); if (sizeo[0] != 0) - VecMulf(pchan->pose_mat[0], size[0] / sizeo[0]); + mul_v3_fl(pchan->pose_mat[0], size[0] / sizeo[0]); if (sizeo[1] != 0) - VecMulf(pchan->pose_mat[1], size[1] / sizeo[1]); + mul_v3_fl(pchan->pose_mat[1], size[1] / sizeo[1]); if (sizeo[2] != 0) - VecMulf(pchan->pose_mat[2], size[2] / sizeo[2]); + mul_v3_fl(pchan->pose_mat[2], size[2] / sizeo[2]); } if (amod->channels & 2) { /* for rotation */ @@ -2086,10 +2102,10 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha nor[2] = BLI_gNoise(amod->noisesize, eul[0], eul[1], eul[2]+ofs, 0, 0) - ofs; compatible_eul(nor, eulo); - VecAddf(eul, eul, nor); + add_v3_v3v3(eul, eul, nor); compatible_eul(eul, eulo); - LocEulSizeToMat4(pchan->pose_mat, loc, eul, size); + loc_eul_size_to_mat4(pchan->pose_mat, loc, eul, size); } if (amod->channels & 1) { /* for location */ @@ -2097,7 +2113,7 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha nor[1] = BLI_gNoise(amod->noisesize, loc[0], loc[1]+ofs, loc[2], 0, 0) - ofs; nor[2] = BLI_gNoise(amod->noisesize, loc[0], loc[1], loc[2]+ofs, 0, 0) - ofs; - VecAddf(pchan->pose_mat[3], loc, nor); + add_v3_v3v3(pchan->pose_mat[3], loc, nor); } } } @@ -2132,7 +2148,7 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti float offs_bone[4][4]; // yoffs(b-1) + root(b) + bonemat(b) /* bone transform itself */ - Mat4CpyMat3(offs_bone, bone->bone_mat); + copy_m4_m3(offs_bone, bone->bone_mat); /* The bone's root offset (is in the parent's coordinate system) */ VECCOPY(offs_bone[3], bone->head); @@ -2145,39 +2161,39 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti float tmat[4][4]; /* the rotation of the parent restposition */ - Mat4CpyMat4(tmat, parbone->arm_mat); + copy_m4_m4(tmat, parbone->arm_mat); /* the location of actual parent transform */ VECCOPY(tmat[3], offs_bone[3]); offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f; - Mat4MulVecfl(parchan->pose_mat, tmat[3]); + mul_m4_v3(parchan->pose_mat, tmat[3]); - Mat4MulSerie(pchan->pose_mat, tmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); + mul_serie_m4(pchan->pose_mat, tmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); } else if(bone->flag & BONE_NO_SCALE) { float orthmat[4][4]; /* get the official transform, but we only use the vector from it (optimize...) */ - Mat4MulSerie(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); + mul_serie_m4(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); VECCOPY(vec, pchan->pose_mat[3]); /* do this again, but with an ortho-parent matrix */ - Mat4CpyMat4(orthmat, parchan->pose_mat); - Mat4Ortho(orthmat); - Mat4MulSerie(pchan->pose_mat, orthmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); + copy_m4_m4(orthmat, parchan->pose_mat); + normalize_m4(orthmat); + mul_serie_m4(pchan->pose_mat, orthmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); /* copy correct transform */ VECCOPY(pchan->pose_mat[3], vec); } else - Mat4MulSerie(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); + mul_serie_m4(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); } else { - Mat4MulMat4(pchan->pose_mat, pchan->chan_mat, bone->arm_mat); + mul_m4_m4m4(pchan->pose_mat, pchan->chan_mat, bone->arm_mat); /* only rootbones get the cyclic offset (unless user doesn't want that) */ if ((bone->flag & BONE_NO_CYCLICOFFSET) == 0) - VecAddf(pchan->pose_mat[3], pchan->pose_mat[3], ob->pose->cyclic_offset); + add_v3_v3v3(pchan->pose_mat[3], pchan->pose_mat[3], ob->pose->cyclic_offset); } /* do NLA strip modifiers - i.e. curve follow */ @@ -2213,8 +2229,8 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti VECCOPY(pchan->pose_head, pchan->pose_mat[3]); /* calculate tail */ VECCOPY(vec, pchan->pose_mat[1]); - VecMulf(vec, bone->length); - VecAddf(pchan->pose_tail, pchan->pose_head, vec); + mul_v3_fl(vec, bone->length); + add_v3_v3v3(pchan->pose_tail, pchan->pose_head, vec); } /* This only reads anim data from channels, and writes to channels */ @@ -2242,14 +2258,14 @@ void where_is_pose (Scene *scene, Object *ob) for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { bone= pchan->bone; if(bone) { - Mat4CpyMat4(pchan->pose_mat, bone->arm_mat); + copy_m4_m4(pchan->pose_mat, bone->arm_mat); VECCOPY(pchan->pose_head, bone->arm_head); VECCOPY(pchan->pose_tail, bone->arm_tail); } } } else { - Mat4Invert(ob->imat, ob->obmat); // imat is needed + invert_m4_m4(ob->imat, ob->obmat); // imat is needed /* 1. clear flags */ for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { @@ -2287,8 +2303,8 @@ void where_is_pose (Scene *scene, Object *ob) /* calculating deform matrices */ for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { if(pchan->bone) { - Mat4Invert(imat, pchan->bone->arm_mat); - Mat4MulMat4(pchan->chan_mat, imat, pchan->pose_mat); + invert_m4_m4(imat, pchan->bone->arm_mat); + mul_m4_m4m4(pchan->chan_mat, imat, pchan->pose_mat); } } } diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 712fb13cfc0..389009cca76 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -43,7 +43,7 @@ #include "DNA_listBase.h" #include "BLI_rand.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_kdtree.h" #include "BLI_kdopbvh.h" @@ -135,10 +135,10 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, /* estimate future location of target */ get_effector_data(eff, &efd, &epoint, 1); - VecMulf(efd.vel, efd.distance / (val->max_speed * bbd->timestep)); - VecAddf(efd.loc, efd.loc, efd.vel); - VecSubf(efd.vec_to_point, pa->prev_state.co, efd.loc); - efd.distance = VecLength(efd.vec_to_point); + mul_v3_fl(efd.vel, efd.distance / (val->max_speed * bbd->timestep)); + add_v3_v3v3(efd.loc, efd.loc, efd.vel); + sub_v3_v3v3(efd.vec_to_point, pa->prev_state.co, efd.loc); + efd.distance = len_v3(efd.vec_to_point); } if(rule->type == eBoidRuleType_Goal && boids->options & BOID_ALLOW_CLIMB && surface!=0.0f) { @@ -152,17 +152,17 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, priority > 2.0f * gabr->fear_factor) { /* detach from surface and try to fly away from danger */ VECCOPY(efd.vec_to_point, bpa->gravity); - VecMulf(efd.vec_to_point, -1.0f); + mul_v3_fl(efd.vec_to_point, -1.0f); } VECCOPY(bbd->wanted_co, efd.vec_to_point); - VecMulf(bbd->wanted_co, mul); + mul_v3_fl(bbd->wanted_co, mul); bbd->wanted_speed = val->max_speed * priority; /* with goals factor is approach velocity factor */ if(rule->type == eBoidRuleType_Goal && boids->landing_smoothness > 0.0f) { - float len2 = 2.0f*VecLength(pa->prev_state.vel); + float len2 = 2.0f*len_v3(pa->prev_state.vel); surface *= pa->size * boids->height; @@ -198,12 +198,12 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * float radius = val->personal_space * pa->size, ray_dir[3]; VECCOPY(col.co1, pa->prev_state.co); - VecAddf(col.co2, pa->prev_state.co, pa->prev_state.vel); - VecSubf(ray_dir, col.co2, col.co1); - VecMulf(ray_dir, acbr->look_ahead); + add_v3_v3v3(col.co2, pa->prev_state.co, pa->prev_state.vel); + sub_v3_v3v3(ray_dir, col.co2, col.co1); + mul_v3_fl(ray_dir, acbr->look_ahead); col.t = 0.0f; hit.index = -1; - hit.dist = col.ray_len = VecLength(ray_dir); + hit.dist = col.ray_len = len_v3(ray_dir); /* find out closest deflector object */ for(coll = bbd->sim->colliders->first; coll; coll=coll->next) { @@ -224,9 +224,9 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * VECCOPY(bbd->wanted_co, col.nor); - VecMulf(bbd->wanted_co, (1.0f - t) * val->personal_space * pa->size); + mul_v3_fl(bbd->wanted_co, (1.0f - t) * val->personal_space * pa->size); - bbd->wanted_speed = sqrt(t) * VecLength(pa->prev_state.vel); + bbd->wanted_speed = sqrt(t) * len_v3(pa->prev_state.vel); return 1; } @@ -235,39 +235,39 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * //check boids in own system if(acbr->options & BRULE_ACOLL_WITH_BOIDS) { - neighbors = BLI_kdtree_range_search(bbd->sim->psys->tree, acbr->look_ahead * VecLength(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn); + neighbors = BLI_kdtree_range_search(bbd->sim->psys->tree, acbr->look_ahead * len_v3(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn); if(neighbors > 1) for(n=1; n<neighbors; n++) { VECCOPY(co1, pa->prev_state.co); VECCOPY(vel1, pa->prev_state.vel); VECCOPY(co2, (bbd->sim->psys->particles + ptn[n].index)->prev_state.co); VECCOPY(vel2, (bbd->sim->psys->particles + ptn[n].index)->prev_state.vel); - VecSubf(loc, co1, co2); + sub_v3_v3v3(loc, co1, co2); - VecSubf(vec, vel1, vel2); + sub_v3_v3v3(vec, vel1, vel2); - inp = Inpf(vec,vec); + inp = dot_v3v3(vec,vec); /* velocities not parallel */ if(inp != 0.0f) { - t = -Inpf(loc, vec)/inp; + t = -dot_v3v3(loc, vec)/inp; /* cpa is not too far in the future so investigate further */ if(t > 0.0f && t < t_min) { VECADDFAC(co1, co1, vel1, t); VECADDFAC(co2, co2, vel2, t); - VecSubf(vec, co2, co1); + sub_v3_v3v3(vec, co2, co1); - len = Normalize(vec); + len = normalize_v3(vec); /* distance of cpa is close enough */ if(len < 2.0f * val->personal_space * pa->size) { t_min = t; - VecMulf(vec, VecLength(vel1)); - VecMulf(vec, (2.0f - t)/2.0f); - VecSubf(bbd->wanted_co, vel1, vec); - bbd->wanted_speed = VecLength(bbd->wanted_co); + mul_v3_fl(vec, len_v3(vel1)); + mul_v3_fl(vec, (2.0f - t)/2.0f); + sub_v3_v3v3(bbd->wanted_co, vel1, vec); + bbd->wanted_speed = len_v3(bbd->wanted_co); ret = 1; } } @@ -281,39 +281,39 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * ParticleSystem *epsys = psys_get_target_system(bbd->sim->ob, pt); if(epsys) { - neighbors = BLI_kdtree_range_search(epsys->tree, acbr->look_ahead * VecLength(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn); + neighbors = BLI_kdtree_range_search(epsys->tree, acbr->look_ahead * len_v3(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn); if(neighbors > 0) for(n=0; n<neighbors; n++) { VECCOPY(co1, pa->prev_state.co); VECCOPY(vel1, pa->prev_state.vel); VECCOPY(co2, (epsys->particles + ptn[n].index)->prev_state.co); VECCOPY(vel2, (epsys->particles + ptn[n].index)->prev_state.vel); - VecSubf(loc, co1, co2); + sub_v3_v3v3(loc, co1, co2); - VecSubf(vec, vel1, vel2); + sub_v3_v3v3(vec, vel1, vel2); - inp = Inpf(vec,vec); + inp = dot_v3v3(vec,vec); /* velocities not parallel */ if(inp != 0.0f) { - t = -Inpf(loc, vec)/inp; + t = -dot_v3v3(loc, vec)/inp; /* cpa is not too far in the future so investigate further */ if(t > 0.0f && t < t_min) { VECADDFAC(co1, co1, vel1, t); VECADDFAC(co2, co2, vel2, t); - VecSubf(vec, co2, co1); + sub_v3_v3v3(vec, co2, co1); - len = Normalize(vec); + len = normalize_v3(vec); /* distance of cpa is close enough */ if(len < 2.0f * val->personal_space * pa->size) { t_min = t; - VecMulf(vec, VecLength(vel1)); - VecMulf(vec, (2.0f - t)/2.0f); - VecSubf(bbd->wanted_co, vel1, vec); - bbd->wanted_speed = VecLength(bbd->wanted_co); + mul_v3_fl(vec, len_v3(vel1)); + mul_v3_fl(vec, (2.0f - t)/2.0f); + sub_v3_v3v3(bbd->wanted_co, vel1, vec); + bbd->wanted_speed = len_v3(bbd->wanted_co); ret = 1; } } @@ -340,9 +340,9 @@ static int rule_separate(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Pa int ret = 0; if(neighbors > 1 && ptn[1].dist!=0.0f) { - VecSubf(vec, pa->prev_state.co, bbd->sim->psys->particles[ptn[1].index].state.co); - VecMulf(vec, (2.0f * val->personal_space * pa->size - ptn[1].dist) / ptn[1].dist); - VecAddf(bbd->wanted_co, bbd->wanted_co, vec); + sub_v3_v3v3(vec, pa->prev_state.co, bbd->sim->psys->particles[ptn[1].index].state.co); + mul_v3_fl(vec, (2.0f * val->personal_space * pa->size - ptn[1].dist) / ptn[1].dist); + add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); bbd->wanted_speed = val->max_speed; len = ptn[1].dist; ret = 1; @@ -357,9 +357,9 @@ static int rule_separate(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Pa neighbors = BLI_kdtree_range_search(epsys->tree, 2.0f * val->personal_space * pa->size, pa->prev_state.co, NULL, &ptn); if(neighbors > 0 && ptn[0].dist < len) { - VecSubf(vec, pa->prev_state.co, ptn[0].co); - VecMulf(vec, (2.0f * val->personal_space * pa->size - ptn[0].dist) / ptn[1].dist); - VecAddf(bbd->wanted_co, bbd->wanted_co, vec); + sub_v3_v3v3(vec, pa->prev_state.co, ptn[0].co); + mul_v3_fl(vec, (2.0f * val->personal_space * pa->size - ptn[0].dist) / ptn[1].dist); + add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); bbd->wanted_speed = val->max_speed; len = ptn[0].dist; ret = 1; @@ -380,19 +380,19 @@ static int rule_flock(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti if(neighbors > 1) { for(n=1; n<neighbors; n++) { - VecAddf(loc, loc, bbd->sim->psys->particles[ptn[n].index].prev_state.co); - VecAddf(vec, vec, bbd->sim->psys->particles[ptn[n].index].prev_state.vel); + add_v3_v3v3(loc, loc, bbd->sim->psys->particles[ptn[n].index].prev_state.co); + add_v3_v3v3(vec, vec, bbd->sim->psys->particles[ptn[n].index].prev_state.vel); } - VecMulf(loc, 1.0f/((float)neighbors - 1.0f)); - VecMulf(vec, 1.0f/((float)neighbors - 1.0f)); + mul_v3_fl(loc, 1.0f/((float)neighbors - 1.0f)); + mul_v3_fl(vec, 1.0f/((float)neighbors - 1.0f)); - VecSubf(loc, loc, pa->prev_state.co); - VecSubf(vec, vec, pa->prev_state.vel); + sub_v3_v3v3(loc, loc, pa->prev_state.co); + sub_v3_v3v3(vec, vec, pa->prev_state.vel); - VecAddf(bbd->wanted_co, bbd->wanted_co, vec); - VecAddf(bbd->wanted_co, bbd->wanted_co, loc); - bbd->wanted_speed = VecLength(bbd->wanted_co); + add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); + add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, loc); + bbd->wanted_speed = len_v3(bbd->wanted_co); ret = 1; } @@ -410,16 +410,16 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va float vec2[3], t; /* first check we're not blocking the leader*/ - VecSubf(vec, flbr->loc, flbr->oloc); - VecMulf(vec, 1.0f/bbd->timestep); + sub_v3_v3v3(vec, flbr->loc, flbr->oloc); + mul_v3_fl(vec, 1.0f/bbd->timestep); - VecSubf(loc, pa->prev_state.co, flbr->oloc); + sub_v3_v3v3(loc, pa->prev_state.co, flbr->oloc); - mul = Inpf(vec, vec); + mul = dot_v3v3(vec, vec); /* leader is not moving */ if(mul < 0.01) { - len = VecLength(loc); + len = len_v3(loc); /* too close to leader */ if(len < 2.0f * val->personal_space * pa->size) { VECCOPY(bbd->wanted_co, loc); @@ -428,16 +428,16 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va } } else { - t = Inpf(loc, vec)/mul; + t = dot_v3v3(loc, vec)/mul; /* possible blocking of leader in near future */ if(t > 0.0f && t < 3.0f) { VECCOPY(vec2, vec); - VecMulf(vec2, t); + mul_v3_fl(vec2, t); - VecSubf(vec2, loc, vec2); + sub_v3_v3v3(vec2, loc, vec2); - len = VecLength(vec2); + len = len_v3(vec2); if(len < 2.0f * val->personal_space * pa->size) { VECCOPY(bbd->wanted_co, vec2); @@ -454,15 +454,15 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va } else { VECCOPY(loc, flbr->oloc); - VecSubf(vec, flbr->loc, flbr->oloc); - VecMulf(vec, 1.0/bbd->timestep); + sub_v3_v3v3(vec, flbr->loc, flbr->oloc); + mul_v3_fl(vec, 1.0/bbd->timestep); } /* fac is seconds behind leader */ VECADDFAC(loc, loc, vec, -flbr->distance); - VecSubf(bbd->wanted_co, loc, pa->prev_state.co); - bbd->wanted_speed = VecLength(bbd->wanted_co); + sub_v3_v3v3(bbd->wanted_co, loc, pa->prev_state.co); + bbd->wanted_speed = len_v3(bbd->wanted_co); ret = 1; } @@ -473,13 +473,13 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va for(i = 0; i< bbd->sim->psys->totpart; i+=n){ VECCOPY(vec, bbd->sim->psys->particles[i].prev_state.vel); - VecSubf(loc, pa->prev_state.co, bbd->sim->psys->particles[i].prev_state.co); + sub_v3_v3v3(loc, pa->prev_state.co, bbd->sim->psys->particles[i].prev_state.co); - mul = Inpf(vec, vec); + mul = dot_v3v3(vec, vec); /* leader is not moving */ if(mul < 0.01) { - len = VecLength(loc); + len = len_v3(loc); /* too close to leader */ if(len < 2.0f * val->personal_space * pa->size) { VECCOPY(bbd->wanted_co, loc); @@ -488,16 +488,16 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va } } else { - t = Inpf(loc, vec)/mul; + t = dot_v3v3(loc, vec)/mul; /* possible blocking of leader in near future */ if(t > 0.0f && t < t_min) { VECCOPY(vec2, vec); - VecMulf(vec2, t); + mul_v3_fl(vec2, t); - VecSubf(vec2, loc, vec2); + sub_v3_v3v3(vec2, loc, vec2); - len = VecLength(vec2); + len = len_v3(vec2); if(len < 2.0f * val->personal_space * pa->size) { t_min = t; @@ -524,8 +524,8 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va /* fac is seconds behind leader */ VECADDFAC(loc, loc, vec, -flbr->distance); - VecSubf(bbd->wanted_co, loc, pa->prev_state.co); - bbd->wanted_speed = VecLength(bbd->wanted_co); + sub_v3_v3v3(bbd->wanted_co, loc, pa->prev_state.co); + bbd->wanted_speed = len_v3(bbd->wanted_co); ret = 1; } @@ -544,30 +544,30 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va bpa->wander[1] += asbr->wander * (-1.0f + 2.0f * BLI_frand()); bpa->wander[2] += asbr->wander * (-1.0f + 2.0f * BLI_frand()); - Normalize(bpa->wander); + normalize_v3(bpa->wander); VECCOPY(vec, bpa->wander); - QuatMulVecf(pa->prev_state.rot, vec); + mul_qt_v3(pa->prev_state.rot, vec); VECCOPY(bbd->wanted_co, pa->prev_state.ave); - VecMulf(bbd->wanted_co, 1.1f); + mul_v3_fl(bbd->wanted_co, 1.1f); - VecAddf(bbd->wanted_co, bbd->wanted_co, vec); + add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); /* leveling */ if(asbr->level > 0.0f) { - Projf(vec, bbd->wanted_co, bbd->sim->psys->part->acc); - VecMulf(vec, asbr->level); - VecSubf(bbd->wanted_co, bbd->wanted_co, vec); + project_v3_v3v3(vec, bbd->wanted_co, bbd->sim->psys->part->acc); + mul_v3_fl(vec, asbr->level); + sub_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); } } else { VECCOPY(bbd->wanted_co, pa->prev_state.ave); /* may happen at birth */ - if(Inp2f(bbd->wanted_co,bbd->wanted_co)==0.0f) { + if(dot_v2v2(bbd->wanted_co,bbd->wanted_co)==0.0f) { bbd->wanted_co[0] = 2.0f*(0.5f - BLI_frand()); bbd->wanted_co[1] = 2.0f*(0.5f - BLI_frand()); bbd->wanted_co[2] = 2.0f*(0.5f - BLI_frand()); @@ -575,9 +575,9 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va /* leveling */ if(asbr->level > 0.0f) { - Projf(vec, bbd->wanted_co, bbd->sim->psys->part->acc); - VecMulf(vec, asbr->level); - VecSubf(bbd->wanted_co, bbd->wanted_co, vec); + project_v3_v3v3(vec, bbd->wanted_co, bbd->sim->psys->part->acc); + mul_v3_fl(vec, asbr->level); + sub_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); } } @@ -641,20 +641,20 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti } /* decide action if enemy presence found */ if(e_strength > 0.0f) { - VecSubf(bbd->wanted_co, closest_enemy, pa->prev_state.co); + sub_v3_v3v3(bbd->wanted_co, closest_enemy, pa->prev_state.co); /* attack if in range */ if(closest_dist <= bbd->part->boids->range + pa->size + enemy_pa->size) { float damage = BLI_frand(); float enemy_dir[3] = {bbd->wanted_co[0],bbd->wanted_co[1],bbd->wanted_co[2]}; - Normalize(enemy_dir); + normalize_v3(enemy_dir); /* fight mode */ bbd->wanted_speed = 0.0f; /* must face enemy to fight */ - if(Inpf(pa->prev_state.ave, enemy_dir)>0.5f) { + if(dot_v3v3(pa->prev_state.ave, enemy_dir)>0.5f) { bpa = enemy_pa->boid; bpa->data.health -= bbd->part->boids->strength * bbd->timestep * ((1.0f-bbd->part->boids->accuracy)*damage + bbd->part->boids->accuracy); } @@ -669,7 +669,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti if(bpa->data.health/bbd->part->boids->health * bbd->part->boids->aggression < e_strength / f_strength) { /* decide to flee */ if(closest_dist < fbr->flee_distance * fbr->distance) { - VecMulf(bbd->wanted_co, -1.0f); + mul_v3_fl(bbd->wanted_co, -1.0f); bbd->wanted_speed = val->max_speed; } else { /* wait for better odds */ @@ -735,7 +735,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro /* take surface velocity into account */ closest_point_on_surface(surmd, pa->state.co, x, NULL, v); - VecAddf(x, x, v); + add_v3_v3v3(x, x, v); /* get actual position on surface */ closest_point_on_surface(surmd, x, ground_co, ground_nor, NULL); @@ -754,12 +754,12 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro VECCOPY(col.co1, pa->state.co); VECCOPY(col.co2, pa->state.co); - VecAddf(col.co1, col.co1, zvec); - VecSubf(col.co2, col.co2, zvec); - VecSubf(ray_dir, col.co2, col.co1); + add_v3_v3v3(col.co1, col.co1, zvec); + sub_v3_v3v3(col.co2, col.co2, zvec); + sub_v3_v3v3(ray_dir, col.co2, col.co1); col.t = 0.0f; hit.index = -1; - hit.dist = col.ray_len = VecLength(ray_dir); + hit.dist = col.ray_len = len_v3(ray_dir); /* find out upmost deflector object */ for(coll = bbd->sim->colliders->first; coll; coll = coll->next){ @@ -772,9 +772,9 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro /* then use that object */ if(hit.index>=0) { t = hit.dist/col.ray_len; - VecLerpf(ground_co, col.co1, col.co2, t); + interp_v3_v3v3(ground_co, col.co1, col.co2, t); VECCOPY(ground_nor, col.nor); - Normalize(ground_nor); + normalize_v3(ground_nor); return col.hit_ob; } else { @@ -829,23 +829,23 @@ static void boid_climb(BoidSettings *boids, ParticleData *pa, float *surface_co, /* gather apparent gravity */ VECADDFAC(bpa->gravity, bpa->gravity, surface_nor, -1.0); - Normalize(bpa->gravity); + normalize_v3(bpa->gravity); /* raise boid it's size from surface */ - VecMulf(nor, pa->size * boids->height); - VecAddf(pa->state.co, surface_co, nor); + mul_v3_fl(nor, pa->size * boids->height); + add_v3_v3v3(pa->state.co, surface_co, nor); /* remove normal component from velocity */ - Projf(vel, pa->state.vel, surface_nor); - VecSubf(pa->state.vel, pa->state.vel, vel); + project_v3_v3v3(vel, pa->state.vel, surface_nor); + sub_v3_v3v3(pa->state.vel, pa->state.vel, vel); } static float boid_goal_signed_dist(float *boid_co, float *goal_co, float *goal_nor) { float vec[3]; - VecSubf(vec, boid_co, goal_co); + sub_v3_v3v3(vec, boid_co, goal_co); - return Inpf(vec, goal_nor); + return dot_v3v3(vec, goal_nor); } /* wanted_co is relative to boid location */ static int apply_boid_rule(BoidBrainData *bbd, BoidRule *rule, BoidValues *val, ParticleData *pa, float fuzziness) @@ -859,7 +859,7 @@ static int apply_boid_rule(BoidBrainData *bbd, BoidRule *rule, BoidValues *val, if(boid_rules[rule->type](rule, bbd, val, pa)==0) return 0; - if(fuzziness < 0.0f || VecLenCompare(bbd->wanted_co, pa->prev_state.vel, fuzziness * VecLength(pa->prev_state.vel))==0) + if(fuzziness < 0.0f || compare_len_v3v3(bbd->wanted_co, pa->prev_state.vel, fuzziness * len_v3(pa->prev_state.vel))==0) return 1; else return 0; @@ -943,7 +943,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) int n = 0; for(rule = state->rules.first; rule; rule=rule->next) { if(apply_boid_rule(bbd, rule, &val, pa, -1.0f)) { - VecAddf(wanted_co, wanted_co, bbd->wanted_co); + add_v3_v3v3(wanted_co, wanted_co, bbd->wanted_co); wanted_speed += bbd->wanted_speed; n++; bbd->wanted_co[0]=bbd->wanted_co[1]=bbd->wanted_co[2]=bbd->wanted_speed=0.0f; @@ -951,7 +951,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) } if(n > 1) { - VecMulf(wanted_co, 1.0f/(float)n); + mul_v3_fl(wanted_co, 1.0f/(float)n); wanted_speed /= (float)n; } @@ -971,12 +971,12 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) float cvel[3], dir[3]; VECCOPY(dir, pa->prev_state.ave); - Normalize2(dir); + normalize_v2(dir); VECCOPY(cvel, bbd->wanted_co); - Normalize2(cvel); + normalize_v2(cvel); - if(Inp2f(cvel, dir) > 0.95 / mul) + if(dot_v2v2(cvel, dir) > 0.95 / mul) bpa->data.mode = eBoidMode_Liftoff; } else if(val.jump_speed > 0.0f) { @@ -990,20 +990,20 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) float len; VECCOPY(dir, pa->prev_state.ave); - Normalize2(dir); + normalize_v2(dir); VECCOPY(cvel, bbd->wanted_co); - Normalize2(cvel); + normalize_v2(cvel); - len = Vec2Length(pa->prev_state.vel); + len = len_v2(pa->prev_state.vel); /* first of all, are we going in a suitable direction? */ /* or at a suitably slow speed */ - if(Inp2f(cvel, dir) > 0.95f / mul || len <= state->rule_fuzziness) { + if(dot_v2v2(cvel, dir) > 0.95f / mul || len <= state->rule_fuzziness) { /* try to reach goal at highest point of the parabolic path */ - cur_v = Vec2Length(pa->prev_state.vel); + cur_v = len_v2(pa->prev_state.vel); z_v = sasqrt(-2.0f * bbd->part->acc[2] * bbd->wanted_co[2]); - ground_v = Vec2Length(bbd->wanted_co)*sasqrt(-0.5f * bbd->part->acc[2] / bbd->wanted_co[2]); + ground_v = len_v2(bbd->wanted_co)*sasqrt(-0.5f * bbd->part->acc[2] / bbd->wanted_co[2]); len = sasqrt((ground_v-cur_v)*(ground_v-cur_v) + z_v*z_v); @@ -1014,11 +1014,11 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) VECCOPY(jump_v, dir); jump_v[2] = z_v; - VecMulf(jump_v, ground_v); + mul_v3_fl(jump_v, ground_v); - Normalize(jump_v); - VecMulf(jump_v, len); - Vec2Addf(jump_v, jump_v, pa->prev_state.vel); + normalize_v3(jump_v); + mul_v3_fl(jump_v, len); + add_v2_v2v2(jump_v, jump_v, pa->prev_state.vel); } } } @@ -1103,7 +1103,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) VECCOPY(old_dir, pa->prev_state.ave); VECCOPY(wanted_dir, bbd->wanted_co); - new_speed = Normalize(wanted_dir); + new_speed = normalize_v3(wanted_dir); /* first check if we have valid direction we want to go towards */ if(new_speed == 0.0f) { @@ -1111,39 +1111,39 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) } else { float old_dir2[2], wanted_dir2[2], nor[3], angle; - Vec2Copyf(old_dir2, old_dir); - Normalize2(old_dir2); - Vec2Copyf(wanted_dir2, wanted_dir); - Normalize2(wanted_dir2); + copy_v2_v2(old_dir2, old_dir); + normalize_v2(old_dir2); + copy_v2_v2(wanted_dir2, wanted_dir); + normalize_v2(wanted_dir2); /* choose random direction to turn if wanted velocity */ /* is directly behind regardless of z-coordinate */ - if(Inp2f(old_dir2, wanted_dir2) < -0.99f) { + if(dot_v2v2(old_dir2, wanted_dir2) < -0.99f) { wanted_dir[0] = 2.0f*(0.5f - BLI_frand()); wanted_dir[1] = 2.0f*(0.5f - BLI_frand()); wanted_dir[2] = 2.0f*(0.5f - BLI_frand()); - Normalize(wanted_dir); + normalize_v3(wanted_dir); } /* constrain direction with maximum angular velocity */ - angle = saacos(Inpf(old_dir, wanted_dir)); + angle = saacos(dot_v3v3(old_dir, wanted_dir)); angle = MIN2(angle, val.max_ave); - Crossf(nor, old_dir, wanted_dir); - VecRotToQuat(nor, angle, q); + cross_v3_v3v3(nor, old_dir, wanted_dir); + axis_angle_to_quat( q,nor, angle); VECCOPY(new_dir, old_dir); - QuatMulVecf(q, new_dir); - Normalize(new_dir); + mul_qt_v3(q, new_dir); + normalize_v3(new_dir); /* save direction in case resulting velocity too small */ - VecRotToQuat(nor, angle*dtime, q); + axis_angle_to_quat( q,nor, angle*dtime); VECCOPY(pa->state.ave, old_dir); - QuatMulVecf(q, pa->state.ave); - Normalize(pa->state.ave); + mul_qt_v3(q, pa->state.ave); + normalize_v3(pa->state.ave); } /* constrain speed with maximum acceleration */ - old_speed = VecLength(pa->prev_state.vel); + old_speed = len_v3(pa->prev_state.vel); if(bbd->wanted_speed < old_speed) new_speed = MAX2(bbd->wanted_speed, old_speed - val.max_acc); @@ -1152,11 +1152,11 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* combine direction and speed */ VECCOPY(new_vel, new_dir); - VecMulf(new_vel, new_speed); + mul_v3_fl(new_vel, new_speed); /* maintain minimum flying velocity if not landing */ if(level >= landing_level) { - float len2 = Inp2f(new_vel,new_vel); + float len2 = dot_v2v2(new_vel,new_vel); float root; len2 = MAX2(len2, val.min_speed*val.min_speed); @@ -1164,20 +1164,20 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) new_vel[2] = new_vel[2] < 0.0f ? -root : root; - Normalize2(new_vel); - Vec2Mulf(new_vel, sasqrt(len2)); + normalize_v2(new_vel); + mul_v2_fl(new_vel, sasqrt(len2)); } /* finally constrain speed to max speed */ - new_speed = Normalize(new_vel); - VecMulf(new_vel, MIN2(new_speed, val.max_speed)); + new_speed = normalize_v3(new_vel); + mul_v3_fl(new_vel, MIN2(new_speed, val.max_speed)); /* get acceleration from difference of velocities */ - VecSubf(acc, new_vel, pa->prev_state.vel); + sub_v3_v3v3(acc, new_vel, pa->prev_state.vel); /* break acceleration to components */ - Projf(tan_acc, acc, pa->prev_state.ave); - VecSubf(nor_acc, acc, tan_acc); + project_v3_v3v3(tan_acc, acc, pa->prev_state.ave); + sub_v3_v3v3(nor_acc, acc, tan_acc); } /* account for effectors */ @@ -1185,32 +1185,32 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) pdDoEffectors(bbd->sim->psys->effectors, bbd->sim->colliders, bbd->part->effector_weights, &epoint, force, NULL); if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) { - float length = Normalize(force); + float length = normalize_v3(force); length = MAX2(0.0f, length - boids->land_stick_force); - VecMulf(force, length); + mul_v3_fl(force, length); } - VecAddf(acc, acc, force); + add_v3_v3v3(acc, acc, force); /* store smoothed acceleration for nice banking etc. */ VECADDFAC(bpa->data.acc, bpa->data.acc, acc, dtime); - VecMulf(bpa->data.acc, 1.0f / (1.0f + dtime)); + mul_v3_fl(bpa->data.acc, 1.0f / (1.0f + dtime)); /* integrate new location & velocity */ /* by regarding the acceleration as a force at this stage we*/ /* can get better control allthough it's a bit unphysical */ - VecMulf(acc, 1.0f/pa_mass); + mul_v3_fl(acc, 1.0f/pa_mass); VECCOPY(dvec, acc); - VecMulf(dvec, dtime*dtime*0.5f); + mul_v3_fl(dvec, dtime*dtime*0.5f); VECCOPY(bvec, pa->prev_state.vel); - VecMulf(bvec, dtime); - VecAddf(dvec, dvec, bvec); - VecAddf(pa->state.co, pa->state.co, dvec); + mul_v3_fl(bvec, dtime); + add_v3_v3v3(dvec, dvec, bvec); + add_v3_v3v3(pa->state.co, pa->state.co, dvec); VECADDFAC(pa->state.vel, pa->state.vel, acc, dtime); @@ -1224,9 +1224,9 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) float grav[3] = {0.0f, 0.0f, bbd->part->acc[2] < 0.0f ? -1.0f : 0.0f}; /* don't take forward acceleration into account (better banking) */ - if(Inpf(bpa->data.acc, pa->state.vel) > 0.0f) { - Projf(dvec, bpa->data.acc, pa->state.vel); - VecSubf(dvec, bpa->data.acc, dvec); + if(dot_v3v3(bpa->data.acc, pa->state.vel) > 0.0f) { + project_v3_v3v3(dvec, bpa->data.acc, pa->state.vel); + sub_v3_v3v3(dvec, bpa->data.acc, dvec); } else { VECCOPY(dvec, bpa->data.acc); @@ -1234,7 +1234,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* gather apparent gravity */ VECADDFAC(bpa->gravity, grav, dvec, -boids->banking); - Normalize(bpa->gravity); + normalize_v3(bpa->gravity); /* stick boid on goal when close enough */ if(bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) { @@ -1257,7 +1257,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* gather apparent gravity */ VECADDFAC(bpa->gravity, bpa->gravity, grav, dtime); - Normalize(bpa->gravity); + normalize_v3(bpa->gravity); if(boids->options & BOID_ALLOW_LAND) { /* stick boid on goal when close enough */ @@ -1289,15 +1289,15 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) ///* gather apparent gravity to r_ve */ //VECADDFAC(pa->r_ve, pa->r_ve, ground_nor, -1.0); - //Normalize(pa->r_ve); + //normalize_v3(pa->r_ve); ///* raise boid it's size from surface */ - //VecMulf(nor, pa->size * boids->height); - //VecAddf(pa->state.co, ground_co, nor); + //mul_v3_fl(nor, pa->size * boids->height); + //add_v3_v3v3(pa->state.co, ground_co, nor); ///* remove normal component from velocity */ - //Projf(v, pa->state.vel, ground_nor); - //VecSubf(pa->state.vel, pa->state.vel, v); + //project_v3_v3v3(v, pa->state.vel, ground_nor); + //sub_v3_v3v3(pa->state.vel, pa->state.vel, v); break; } case eBoidMode_OnLand: @@ -1323,19 +1323,19 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* Don't take gravity's strength in to account, */ /* otherwise amount of banking is hard to control. */ VECCOPY(grav, ground_nor); - VecMulf(grav, -1.0f); + mul_v3_fl(grav, -1.0f); - Projf(dvec, bpa->data.acc, pa->state.vel); - VecSubf(dvec, bpa->data.acc, dvec); + project_v3_v3v3(dvec, bpa->data.acc, pa->state.vel); + sub_v3_v3v3(dvec, bpa->data.acc, dvec); /* gather apparent gravity */ VECADDFAC(bpa->gravity, grav, dvec, -boids->banking); - Normalize(bpa->gravity); + normalize_v3(bpa->gravity); } else { /* gather negative surface normal */ VECADDFAC(bpa->gravity, bpa->gravity, ground_nor, -1.0f); - Normalize(bpa->gravity); + normalize_v3(bpa->gravity); } break; } @@ -1343,36 +1343,36 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* save direction to state.ave unless the boid is falling */ /* (boids can't effect their direction when falling) */ - if(bpa->data.mode!=eBoidMode_Falling && VecLength(pa->state.vel) > 0.1*pa->size) { + if(bpa->data.mode!=eBoidMode_Falling && len_v3(pa->state.vel) > 0.1*pa->size) { VECCOPY(pa->state.ave, pa->state.vel); - Normalize(pa->state.ave); + normalize_v3(pa->state.ave); } /* apply damping */ if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) - VecMulf(pa->state.vel, 1.0f - 0.2f*bbd->part->dampfac); + mul_v3_fl(pa->state.vel, 1.0f - 0.2f*bbd->part->dampfac); /* calculate rotation matrix based on forward & down vectors */ if(bpa->data.mode == eBoidMode_InAir) { VECCOPY(mat[0], pa->state.ave); - Projf(dvec, bpa->gravity, pa->state.ave); - VecSubf(mat[2], bpa->gravity, dvec); - Normalize(mat[2]); + project_v3_v3v3(dvec, bpa->gravity, pa->state.ave); + sub_v3_v3v3(mat[2], bpa->gravity, dvec); + normalize_v3(mat[2]); } else { - Projf(dvec, pa->state.ave, bpa->gravity); - VecSubf(mat[0], pa->state.ave, dvec); - Normalize(mat[0]); + project_v3_v3v3(dvec, pa->state.ave, bpa->gravity); + sub_v3_v3v3(mat[0], pa->state.ave, dvec); + normalize_v3(mat[0]); VECCOPY(mat[2], bpa->gravity); } - VecMulf(mat[2], -1.0f); - Crossf(mat[1], mat[2], mat[0]); + mul_v3_fl(mat[2], -1.0f); + cross_v3_v3v3(mat[1], mat[2], mat[0]); /* apply rotation */ - Mat3ToQuat_is_ok(mat, q); - QuatCopy(pa->state.rot, q); + mat3_to_quat_is_ok( q,mat); + copy_qt_qt(pa->state.rot, q); } BoidRule *boid_new_rule(int type) diff --git a/source/blender/blenkernel/intern/booleanops.c b/source/blender/blenkernel/intern/booleanops.c index 5f0697f06ce..68e1f61a800 100644 --- a/source/blender/blenkernel/intern/booleanops.c +++ b/source/blender/blenkernel/intern/booleanops.c @@ -33,7 +33,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_ghash.h" @@ -104,7 +104,7 @@ static void VertexIt_Fill(CSG_IteratorPtr it, CSG_IVertex *vert) float global_pos[3]; /* boolean happens in global space, transform both with obmat */ - VecMat4MulVecfl( + mul_v3_m4v3( global_pos, iterator->ob->obmat, verts[iterator->pos].co @@ -327,11 +327,11 @@ static void InterpCSGFace( for (j = 0; j < nr; j++) { // get coordinate into the space of the original mesh if (mapmat) - VecMat4MulVecfl(obco, mapmat, co[j]); + mul_v3_m4v3(obco, mapmat, co[j]); else - VecCopyf(obco, co[j]); + copy_v3_v3(obco, co[j]); - InterpWeightsQ3Dfl(orig_co[0], orig_co[1], orig_co[2], orig_co[3], obco, w[j]); + interp_weights_face_v3( w[j],orig_co[0], orig_co[1], orig_co[2], orig_co[3], obco); } CustomData_interp(&orig_dm->faceData, &dm->faceData, &orig_index, NULL, (float*)w, 1, index); @@ -375,7 +375,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( // we have to map the vertex coordinates back in the coordinate frame // of the resulting object, since it was computed in world space - VecMat4MulVecfl(mvert->co, parinv, csgvert.position); + mul_v3_m4v3(mvert->co, parinv, csgvert.position); } // a hash table to remap materials to indices @@ -478,9 +478,9 @@ DerivedMesh *NewBooleanDerivedMesh_intern( // we map the final object back into ob's local coordinate space. For this // we need to compute the inverse transform from global to ob (inv_mat), // and the transform from ob to ob_select for use in interpolation (map_mat) - Mat4Invert(inv_mat, ob->obmat); - Mat4MulMat4(map_mat, ob_select->obmat, inv_mat); - Mat4Invert(inv_mat, ob_select->obmat); + invert_m4_m4(inv_mat, ob->obmat); + mul_m4_m4m4(map_mat, ob_select->obmat, inv_mat); + invert_m4_m4(inv_mat, ob_select->obmat); { // interface with the boolean module: @@ -526,8 +526,8 @@ DerivedMesh *NewBooleanDerivedMesh_intern( CSG_FreeVertexDescriptor(&vd_o); CSG_FreeFaceDescriptor(&fd_o); } -// else -// XXX error("Unknown internal error in boolean"); + else + printf("Unknown internal error in boolean"); CSG_FreeBooleanOperation(bool_op); diff --git a/source/blender/blenkernel/intern/booleanops_mesh.c b/source/blender/blenkernel/intern/booleanops_mesh.c index 14e32873dbd..15a3d042622 100644 --- a/source/blender/blenkernel/intern/booleanops_mesh.c +++ b/source/blender/blenkernel/intern/booleanops_mesh.c @@ -47,7 +47,7 @@ #include "BKE_library.h" #include "BKE_material.h" -#include "BLI_arithb.h" +#include "BLI_math.h" /** * Implementation of boolean ops mesh interface. @@ -151,7 +151,7 @@ CSG_AddMeshToBlender( if (mesh == NULL) return 0; if (mesh->base == NULL) return 0; - Mat4Invert(inv_mat,mesh->base->object->obmat); + invert_m4_m4(inv_mat,mesh->base->object->obmat); // Create a new blender mesh object - using 'base' as // a template for the new object. diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index b415e7b7b17..2923853d6a7 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -42,7 +42,7 @@ #include "RNA_access.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_rand.h" @@ -846,8 +846,8 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl /* setup starting time, direction vector and accumulated time */ starttime= painter->accumtime; - Vec2Subf(dmousepos, pos, painter->lastmousepos); - len= Normalize2(dmousepos); + sub_v2_v2v2(dmousepos, pos, painter->lastmousepos); + len= normalize_v2(dmousepos); painter->accumtime += curtime - painter->lasttime; /* do paint op over unpainted time distance */ @@ -881,8 +881,8 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl /* setup starting distance, direction vector and accumulated distance */ startdistance= painter->accumdistance; - Vec2Subf(dmousepos, pos, painter->lastmousepos); - len= Normalize2(dmousepos); + sub_v2_v2v2(dmousepos, pos, painter->lastmousepos); + len= normalize_v2(dmousepos); painter->accumdistance += len; /* do paint op over unpainted distance */ diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index f2526231d50..5945be51aac 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -45,7 +45,7 @@ #include "BKE_displist.h" #include "BKE_global.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_linklist.h" #include "MEM_guardedalloc.h" @@ -55,7 +55,7 @@ static float ray_tri_intersection(const BVHTreeRay *ray, const float m_dist, con { float dist; - if(RayIntersectsTriangle((float*)ray->origin, (float*)ray->direction, (float*)v0, (float*)v1, (float*)v2, &dist, NULL)) + if(isect_ray_tri_v3((float*)ray->origin, (float*)ray->direction, (float*)v0, (float*)v1, (float*)v2, &dist, NULL)) return dist; return FLT_MAX; @@ -68,10 +68,10 @@ static float sphereray_tri_intersection(const BVHTreeRay *ray, float radius, con float p1[3]; float plane_normal[3], hit_point[3]; - CalcNormFloat((float*)v0, (float*)v1, (float*)v2, plane_normal); + normal_tri_v3( plane_normal,(float*)v0, (float*)v1, (float*)v2); VECADDFAC( p1, ray->origin, ray->direction, m_dist); - if(SweepingSphereIntersectsTriangleUV((float*)ray->origin, p1, radius, (float*)v0, (float*)v1, (float*)v2, &idist, hit_point)) + if(isect_sweeping_sphere_tri_v3((float*)ray->origin, p1, radius, (float*)v0, (float*)v1, (float*)v2, &idist, hit_point)) { return idist * m_dist; } @@ -384,9 +384,9 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const float w[3], x[3], y[3], z[3]; VECCOPY(w, v0); VECCOPY(x, e0); - VecMulf(x, S); + mul_v3_fl(x, S); VECCOPY(y, e1); - VecMulf(y, T); + mul_v3_fl(y, T); VECADD(z, w, x); VECADD(z, z, y); //VECSUB(d, p, z); @@ -430,7 +430,7 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float *co, nearest->index = index; nearest->dist = dist; VECCOPY(nearest->co, nearest_tmp); - CalcNormFloat(t0, t1, t2, nearest->no); + normal_tri_v3( nearest->no,t0, t1, t2); } t1 = t2; @@ -469,7 +469,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r hit->dist = dist; VECADDFAC(hit->co, ray->origin, ray->direction, dist); - CalcNormFloat(t0, t1, t2, hit->no); + normal_tri_v3( hit->no,t0, t1, t2); } t1 = t2; @@ -492,16 +492,17 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float *co, t0 = vert[ edge->v1 ].co; t1 = vert[ edge->v2 ].co; - PclosestVL3Dfl(nearest_tmp, co, t0, t1); - dist = VecLenf(nearest_tmp, co); + // NOTE: casts to "float*" here are due to co being "const float*" + closest_to_line_segment_v3(nearest_tmp, (float*)co, t0, t1); + dist = len_v3v3(nearest_tmp, (float*)co); if(dist < nearest->dist) { nearest->index = index; nearest->dist = dist; VECCOPY(nearest->co, nearest_tmp); - VecSubf(nearest->no, t0, t1); - Normalize(nearest->no); + sub_v3_v3v3(nearest->no, t0, t1); + normalize_v3(nearest->no); } } diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 7acf77c6f90..a07965c2a58 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -45,7 +45,7 @@ #include "BKE_multires.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_edgehash.h" #include "BLI_editVert.h" @@ -440,7 +440,7 @@ int planes_contain_AABB(PBVHNode *node, void *data) } } - if(Inpf(planes[i], vmin) + planes[i][3] > 0) + if(dot_v3v3(planes[i], vmin) + planes[i][3] > 0) return 0; } @@ -523,12 +523,9 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, /* TODO make this better (cache facenormals as layer?) */ float nor[3]; if(mface->v4) { - CalcNormFloat4(mvert[mface->v1].co, mvert[mface->v2].co, - mvert[mface->v3].co, mvert[mface->v4].co, - nor); + normal_quad_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co); } else { - CalcNormFloat(mvert[mface->v1].co, mvert[mface->v2].co, - mvert[mface->v3].co, nor); + normal_tri_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co); } glNormal3fv(nor); } @@ -697,12 +694,9 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, else { float nor[3]; if(mf->v4) { - CalcNormFloat4(mv[mf->v1].co, mv[mf->v2].co, - mv[mf->v3].co, mv[mf->v4].co, - nor); + normal_quad_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co); } else { - CalcNormFloat(mv[mf->v1].co, mv[mf->v2].co, - mv[mf->v3].co, nor); + normal_tri_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co); } glNormal3fv(nor); } @@ -872,12 +866,9 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us else { float nor[3]; if(mf->v4) { - CalcNormFloat4(mv[mf->v1].co, mv[mf->v2].co, - mv[mf->v3].co, mv[mf->v4].co, - nor); + normal_quad_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co); } else { - CalcNormFloat(mv[mf->v1].co, mv[mf->v2].co, - mv[mf->v3].co, nor); + normal_tri_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co); } glNormal3fv(nor); } @@ -1047,12 +1038,9 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo /* TODO ideally a normal layer should always be available */ float nor[3]; if(mface->v4) { - CalcNormFloat4(mvert[mface->v1].co, mvert[mface->v2].co, - mvert[mface->v3].co, mvert[mface->v4].co, - nor); + normal_quad_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co); } else { - CalcNormFloat(mvert[mface->v1].co, mvert[mface->v2].co, - mvert[mface->v3].co, nor); + normal_tri_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co); } glNormal3fv(nor); } @@ -1389,18 +1377,16 @@ static void cdDM_foreachMappedFaceCenter( orig = i; VECCOPY(cent, mv[mf->v1].co); - VecAddf(cent, cent, mv[mf->v2].co); - VecAddf(cent, cent, mv[mf->v3].co); + add_v3_v3v3(cent, cent, mv[mf->v2].co); + add_v3_v3v3(cent, cent, mv[mf->v3].co); if (mf->v4) { - CalcNormFloat4(mv[mf->v1].co, mv[mf->v2].co, - mv[mf->v3].co, mv[mf->v4].co, no); - VecAddf(cent, cent, mv[mf->v4].co); - VecMulf(cent, 0.25f); + normal_quad_v3( no,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co); + add_v3_v3v3(cent, cent, mv[mf->v4].co); + mul_v3_fl(cent, 0.25f); } else { - CalcNormFloat(mv[mf->v1].co, mv[mf->v2].co, - mv[mf->v3].co, no); - VecMulf(cent, 0.33333333333f); + normal_tri_v3( no,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co); + mul_v3_fl(cent, 0.33333333333f); } func(userData, orig, cent, no); @@ -1750,26 +1736,24 @@ void CDDM_calc_normals(DerivedMesh *dm) float *f_no = face_nors[i]; if(mf->v4) - CalcNormFloat4(mv[mf->v1].co, mv[mf->v2].co, - mv[mf->v3].co, mv[mf->v4].co, f_no); + normal_quad_v3( f_no,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co); else - CalcNormFloat(mv[mf->v1].co, mv[mf->v2].co, - mv[mf->v3].co, f_no); + normal_tri_v3( f_no,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co); - VecAddf(temp_nors[mf->v1], temp_nors[mf->v1], f_no); - VecAddf(temp_nors[mf->v2], temp_nors[mf->v2], f_no); - VecAddf(temp_nors[mf->v3], temp_nors[mf->v3], f_no); + add_v3_v3v3(temp_nors[mf->v1], temp_nors[mf->v1], f_no); + add_v3_v3v3(temp_nors[mf->v2], temp_nors[mf->v2], f_no); + add_v3_v3v3(temp_nors[mf->v3], temp_nors[mf->v3], f_no); if(mf->v4) - VecAddf(temp_nors[mf->v4], temp_nors[mf->v4], f_no); + add_v3_v3v3(temp_nors[mf->v4], temp_nors[mf->v4], f_no); } /* normalize vertex normals and assign */ for(i = 0; i < numVerts; i++, mv++) { float *no = temp_nors[i]; - if (Normalize(no) == 0.0) { + if (normalize_v3(no) == 0.0) { VECCOPY(no, mv->co); - Normalize(no); + normalize_v3(no); } mv->no[0] = (short)(no[0] * 32767.0); @@ -1981,7 +1965,7 @@ DerivedMesh *MultiresDM_new(MultiresSubsurf *ms, DerivedMesh *orig, int numVerts mvert = CustomData_get_layer(&orig->vertData, CD_MVERT); mrdm->orco = MEM_callocN(sizeof(float) * 3 * orig->getNumVerts(orig), "multires orco"); for(i = 0; i < orig->getNumVerts(orig); ++i) - VecCopyf(mrdm->orco[i], mvert[i].co); + copy_v3_v3(mrdm->orco[i], mvert[i].co); } else DM_init(dm, numVerts, numEdges, numFaces); diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 74f88a77e63..4a9cb237c01 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -403,7 +403,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul /* Get the current position. */ VECCOPY(verts->xconst, mvert[i].co); - Mat4MulVecfl(ob->obmat, verts->xconst); + mul_m4_v3(ob->obmat, verts->xconst); } effectors = pdInitEffectors(clmd->scene, ob, NULL, clmd->sim_parms->effector_weights); @@ -723,7 +723,7 @@ static void cloth_to_object (Object *ob, ClothModifierData *clmd, DerivedMesh * if (clmd->clothObject) { /* inverse matrix is not uptodate... */ - Mat4Invert (ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); mvert = CDDM_get_verts(dm); numverts = dm->getNumVerts(dm); @@ -731,7 +731,7 @@ static void cloth_to_object (Object *ob, ClothModifierData *clmd, DerivedMesh * for (i = 0; i < numverts; i++) { VECCOPY (mvert[i].co, cloth->verts[i].x); - Mat4MulVecfl (ob->imat, mvert[i].co); /* cloth is in global coords */ + mul_m4_v3(ob->imat, mvert[i].co); /* cloth is in global coords */ } } } @@ -867,7 +867,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d if(first) { VECCOPY ( verts->x, mvert[i].co ); - Mat4MulVecfl ( ob->obmat, verts->x ); + mul_m4_v3( ob->obmat, verts->x ); } /* no GUI interface yet */ @@ -884,7 +884,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d VECCOPY ( verts->xconst, verts->x ); VECCOPY ( verts->txold, verts->x ); VECCOPY ( verts->tx, verts->x ); - VecMulf ( verts->v, 0.0f ); + mul_v3_fl( verts->v, 0.0f ); verts->impulse_count = 0; VECCOPY ( verts->impulse, tnull ); diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 8c664bc1a57..2ea54ac1f03 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -529,7 +529,7 @@ int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifier // calculate tangential velocity VECCOPY ( temp, collpair->normal ); - VecMulf ( temp, magrelVel ); + mul_v3_fl( temp, magrelVel ); VECSUB ( vrel_t_pre, relativeVelocity, temp ); // Decrease in magnitude of relative tangential velocity due to coulomb friction @@ -539,7 +539,7 @@ int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifier // Apply friction impulse. if ( magtangent > ALMOST_ZERO ) { - Normalize ( vrel_t_pre ); + normalize_v3( vrel_t_pre ); impulse = magtangent / ( 1.0 + w1*w1 + w2*w2 + w3*w3 ); // 2.0 * VECADDMUL ( cloth1->verts[collpair->ap1].impulse, vrel_t_pre, w1 * impulse ); @@ -681,7 +681,7 @@ CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap if ( distance <= ( epsilon1 + epsilon2 + ALMOST_ZERO ) ) { VECCOPY ( collpair->normal, collpair->vector ); - Normalize ( collpair->normal ); + normalize_v3( collpair->normal ); collpair->distance = distance; collpair->flag = 0; @@ -726,6 +726,7 @@ CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap return collpair; } +#if 0 static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair, CollPair *collision_end ) { int result = 0; @@ -778,7 +779,7 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo // calculate tangential velocity VECCOPY ( temp, collpair->normal ); - VecMulf ( temp, magrelVel ); + mul_v3_fl( temp, magrelVel ); VECSUB ( vrel_t_pre, relativeVelocity, temp ); // Decrease in magnitude of relative tangential velocity due to coulomb friction @@ -788,7 +789,7 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo // Apply friction impulse. if ( magtangent > ALMOST_ZERO ) { - Normalize ( vrel_t_pre ); + normalize_v3( vrel_t_pre ); impulse = 2.0 * magtangent / ( 1.0 + w1*w1 + w2*w2 + w3*w3 ); VECADDMUL ( cloth1->verts[collpair->ap1].impulse, vrel_t_pre, w1 * impulse ); @@ -834,6 +835,7 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo } return result; } +#endif static float projectPointOntoLine(float *p, float *a, float *b) { @@ -853,15 +855,15 @@ static void calculateEENormal(float *np1, float *np2, float *np3, float *np4,flo // printf("l1: %f, l1: %f, l2: %f, l2: %f\n", line1[0], line1[1], line2[0], line2[1]); - Crossf(out_normal, line1, line2); + cross_v3_v3v3(out_normal, line1, line2); - length = Normalize(out_normal); + length = normalize_v3(out_normal); if (length <= FLT_EPSILON) { // lines are collinear VECSUB(out_normal, np2, np1); - Normalize(out_normal); + normalize_v3(out_normal); } } @@ -901,7 +903,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float VECSUB(line1, np12, np11); VECSUB(line2, np22, np21); - Crossf(cross, line1, line2); + cross_v3_v3v3(cross, line1, line2); length = INPR(cross, cross); if (length < FLT_EPSILON) @@ -912,7 +914,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float *out_a1 = 0; calculateEENormal(np11, np12, np21, np22, out_normal); VECSUB(temp, np22, np21); - VecMulf(temp, *out_a2); + mul_v3_fl(temp, *out_a2); VECADD(temp2, temp, np21); VECADD(temp2, temp2, np11); return INPR(temp2, temp2); @@ -928,7 +930,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float // return (np22 - (np11 + (np12 - np11) * out_a1)).lengthSquared(); VECSUB(temp, np12, np11); - VecMulf(temp, *out_a1); + mul_v3_fl(temp, *out_a1); VECADD(temp2, temp, np11); VECSUB(temp2, np22, temp2); return INPR(temp2, temp2); @@ -943,7 +945,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float // return (np21 - (np11 + (np12 - np11) * out_a1)).lengthSquared(); VECSUB(temp, np12, np11); - VecMulf(temp, *out_a1); + mul_v3_fl(temp, *out_a1); VECADD(temp2, temp, np11); VECSUB(temp2, np21, temp2); return INPR(temp2, temp2); @@ -991,12 +993,12 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float // p1= np11 + (np12 - np11) * out_a1; VECSUB(temp, np12, np11); - VecMulf(temp, *out_a1); + mul_v3_fl(temp, *out_a1); VECADD(p1, np11, temp); // p2 = np21 + (np22 - np21) * out_a2; VECSUB(temp, np22, np21); - VecMulf(temp, *out_a2); + mul_v3_fl(temp, *out_a2); VECADD(p2, np21, temp); calculateEENormal(np11, np12, np21, np22, out_normal); @@ -1022,7 +1024,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float // p1 = np11 + (np12 - np11) * out_a1; VECSUB(temp, np12, np11); - VecMulf(temp, *out_a1); + mul_v3_fl(temp, *out_a1); VECADD(p1, np11, temp); *out_a2 = projectPointOntoLine(p1, np21, np22); @@ -1032,7 +1034,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float // return (p1 - (np21 + (np22 - np21) * out_a2)).lengthSquared(); VECSUB(temp, np22, np21); - VecMulf(temp, *out_a2); + mul_v3_fl(temp, *out_a2); VECADD(temp, temp, np21); VECSUB(temp, p1, temp); return INPR(temp, temp); @@ -1044,7 +1046,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float // p2 = np21 + (np22 - np21) * out_a2; VECSUB(temp, np22, np21); - VecMulf(temp, *out_a2); + mul_v3_fl(temp, *out_a2); VECADD(p2, np21, temp); *out_a1 = projectPointOntoLine(p2, np11, np12); @@ -1054,7 +1056,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float // return ((np11 + (np12 - np11) * out_a1) - p2).lengthSquared(); VECSUB(temp, np12, np11); - VecMulf(temp, *out_a1); + mul_v3_fl(temp, *out_a1); VECADD(temp, temp, np11); VECSUB(temp, temp, p2); return INPR(temp, temp); @@ -1065,6 +1067,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float return 0; } +#if 0 static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair ) { EdgeCollPair edgecollpair; @@ -1217,16 +1220,16 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi float desiredVn; VECCOPY(vrel_1_to_2, verts1[edgecollpair.p11].tv); - VecMulf(vrel_1_to_2, 1.0 - a); + mul_v3_fl(vrel_1_to_2, 1.0 - a); VECCOPY(temp, verts1[edgecollpair.p12].tv); - VecMulf(temp, a); + mul_v3_fl(temp, a); VECADD(vrel_1_to_2, vrel_1_to_2, temp); VECCOPY(temp, verts1[edgecollpair.p21].tv); - VecMulf(temp, 1.0 - b); + mul_v3_fl(temp, 1.0 - b); VECCOPY(temp2, verts1[edgecollpair.p22].tv); - VecMulf(temp2, b); + mul_v3_fl(temp2, b); VECADD(temp, temp, temp2); VECSUB(vrel_1_to_2, vrel_1_to_2, temp); @@ -1237,7 +1240,7 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi if(out_normalVelocity < 0.0) { out_normalVelocity*= -1.0; - VecNegf(out_normal); + negate_v3(out_normal); } */ /* Inelastic repulsion impulse. */ @@ -1292,6 +1295,7 @@ static int cloth_collision_moving ( ClothModifierData *clmd, CollisionModifierDa return 1; } +#endif // return all collision objects in scene @@ -1707,7 +1711,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl continue; } - length = Normalize ( temp ); + length = normalize_v3( temp ); if ( length < mindistance ) { @@ -1715,17 +1719,17 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) { - VecMulf ( temp, -correction ); + mul_v3_fl( temp, -correction ); VECADD ( verts[j].tx, verts[j].tx, temp ); } else if ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) { - VecMulf ( temp, correction ); + mul_v3_fl( temp, correction ); VECADD ( verts[i].tx, verts[i].tx, temp ); } else { - VecMulf ( temp, -correction*0.5 ); + mul_v3_fl( temp, -correction*0.5 ); VECADD ( verts[j].tx, verts[j].tx, temp ); VECSUB ( verts[i].tx, verts[i].tx, temp ); diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 8cd64ae2ece..f3448a60b5a 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -52,7 +52,7 @@ #include "BKE_utildefines.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_threads.h" #include "IMB_imbuf.h" @@ -462,35 +462,35 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr) if(bezt[0].h2==HD_AUTO) { - hlen= VecLenf(bezt[0].vec[1], bezt[0].vec[2]); /* original handle length */ + hlen= len_v3v3(bezt[0].vec[1], bezt[0].vec[2]); /* original handle length */ /* clip handle point */ VECCOPY(vec, bezt[1].vec[0]); if(vec[0] < bezt[0].vec[1][0]) vec[0]= bezt[0].vec[1][0]; - VecSubf(vec, vec, bezt[0].vec[1]); - nlen= VecLength(vec); + sub_v3_v3v3(vec, vec, bezt[0].vec[1]); + nlen= len_v3(vec); if(nlen>FLT_EPSILON) { - VecMulf(vec, hlen/nlen); - VecAddf(bezt[0].vec[2], vec, bezt[0].vec[1]); - VecSubf(bezt[0].vec[0], bezt[0].vec[1], vec); + mul_v3_fl(vec, hlen/nlen); + add_v3_v3v3(bezt[0].vec[2], vec, bezt[0].vec[1]); + sub_v3_v3v3(bezt[0].vec[0], bezt[0].vec[1], vec); } } a= cuma->totpoint-1; if(bezt[a].h2==HD_AUTO) { - hlen= VecLenf(bezt[a].vec[1], bezt[a].vec[0]); /* original handle length */ + hlen= len_v3v3(bezt[a].vec[1], bezt[a].vec[0]); /* original handle length */ /* clip handle point */ VECCOPY(vec, bezt[a-1].vec[2]); if(vec[0] > bezt[a].vec[1][0]) vec[0]= bezt[a].vec[1][0]; - VecSubf(vec, vec, bezt[a].vec[1]); - nlen= VecLength(vec); + sub_v3_v3v3(vec, vec, bezt[a].vec[1]); + nlen= len_v3(vec); if(nlen>FLT_EPSILON) { - VecMulf(vec, hlen/nlen); - VecAddf(bezt[a].vec[0], vec, bezt[a].vec[1]); - VecSubf(bezt[a].vec[2], bezt[a].vec[1], vec); + mul_v3_fl(vec, hlen/nlen); + add_v3_v3v3(bezt[a].vec[0], vec, bezt[a].vec[1]); + sub_v3_v3v3(bezt[a].vec[2], bezt[a].vec[1], vec); } } } diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index a94fd8f6bd2..c38e61d269a 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -36,7 +36,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "DNA_armature_types.h" @@ -122,12 +122,12 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata, cob->ob = ob; cob->type = datatype; cob->rotOrder = EULER_ORDER_DEFAULT; // TODO: when objects have rotation order too, use that - Mat4CpyMat4(cob->matrix, ob->obmat); + copy_m4_m4(cob->matrix, ob->obmat); } else - Mat4One(cob->matrix); + unit_m4(cob->matrix); - Mat4CpyMat4(cob->startmat, cob->matrix); + copy_m4_m4(cob->startmat, cob->matrix); } break; case CONSTRAINT_OBTYPE_BONE: @@ -148,18 +148,18 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata, } /* matrix in world-space */ - Mat4MulMat4(cob->matrix, cob->pchan->pose_mat, ob->obmat); + mul_m4_m4m4(cob->matrix, cob->pchan->pose_mat, ob->obmat); } else - Mat4One(cob->matrix); + unit_m4(cob->matrix); - Mat4CpyMat4(cob->startmat, cob->matrix); + copy_m4_m4(cob->startmat, cob->matrix); } break; default: /* other types not yet handled */ - Mat4One(cob->matrix); - Mat4One(cob->startmat); + unit_m4(cob->matrix); + unit_m4(cob->startmat); break; } @@ -176,8 +176,8 @@ void constraints_clear_evalob (bConstraintOb *cob) return; /* calculate delta of constraints evaluation */ - Mat4Invert(imat, cob->startmat); - Mat4MulMat4(delta, imat, cob->matrix); + invert_m4_m4(imat, cob->startmat); + mul_m4_m4m4(delta, imat, cob->matrix); /* copy matrices back to source */ switch (cob->type) { @@ -186,10 +186,10 @@ void constraints_clear_evalob (bConstraintOb *cob) /* cob->ob might not exist! */ if (cob->ob) { /* copy new ob-matrix back to owner */ - Mat4CpyMat4(cob->ob->obmat, cob->matrix); + copy_m4_m4(cob->ob->obmat, cob->matrix); /* copy inverse of delta back to owner */ - Mat4Invert(cob->ob->constinv, delta); + invert_m4_m4(cob->ob->constinv, delta); } } break; @@ -198,10 +198,10 @@ void constraints_clear_evalob (bConstraintOb *cob) /* cob->ob or cob->pchan might not exist */ if (cob->ob && cob->pchan) { /* copy new pose-matrix back to owner */ - Mat4MulMat4(cob->pchan->pose_mat, cob->matrix, cob->ob->imat); + mul_m4_m4m4(cob->pchan->pose_mat, cob->matrix, cob->ob->imat); /* copy inverse of delta back to owner */ - Mat4Invert(cob->pchan->constinv, delta); + invert_m4_m4(cob->pchan->constinv, delta); } } break; @@ -235,9 +235,9 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 case CONSTRAINT_SPACE_WORLD: /* ---------- FROM WORLDSPACE ---------- */ { /* world to pose */ - Mat4Invert(imat, ob->obmat); - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, tempmat, imat); + invert_m4_m4(imat, ob->obmat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, imat); /* use pose-space as stepping stone for other spaces... */ if (ELEM(to, CONSTRAINT_SPACE_LOCAL, CONSTRAINT_SPACE_PARLOCAL)) { @@ -250,8 +250,8 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 { /* pose to world */ if (to == CONSTRAINT_SPACE_WORLD) { - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, tempmat, ob->obmat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, ob->obmat); } /* pose to local */ else if (to == CONSTRAINT_SPACE_LOCAL) { @@ -260,7 +260,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 float offs_bone[4][4]; /* construct offs_bone the same way it is done in armature.c */ - Mat4CpyMat3(offs_bone, pchan->bone->bone_mat); + copy_m4_m3(offs_bone, pchan->bone->bone_mat); VECCOPY(offs_bone[3], pchan->bone->head); offs_bone[3][1]+= pchan->bone->parent->length; @@ -269,37 +269,37 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 float tmat[4][4]; /* the rotation of the parent restposition */ - Mat4CpyMat4(tmat, pchan->bone->parent->arm_mat); + copy_m4_m4(tmat, pchan->bone->parent->arm_mat); /* the location of actual parent transform */ VECCOPY(tmat[3], offs_bone[3]); offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f; - Mat4MulVecfl(pchan->parent->pose_mat, tmat[3]); + mul_m4_v3(pchan->parent->pose_mat, tmat[3]); - Mat4MulMat4(diff_mat, offs_bone, tmat); - Mat4Invert(imat, diff_mat); + mul_m4_m4m4(diff_mat, offs_bone, tmat); + invert_m4_m4(imat, diff_mat); } else { /* pose_mat = par_pose_mat * bone_mat * chan_mat */ - Mat4MulMat4(diff_mat, offs_bone, pchan->parent->pose_mat); - Mat4Invert(imat, diff_mat); + mul_m4_m4m4(diff_mat, offs_bone, pchan->parent->pose_mat); + invert_m4_m4(imat, diff_mat); } } else { /* pose_mat = chan_mat * arm_mat */ - Mat4Invert(imat, pchan->bone->arm_mat); + invert_m4_m4(imat, pchan->bone->arm_mat); } - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, tempmat, imat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, imat); } } /* pose to local with parent */ else if (to == CONSTRAINT_SPACE_PARLOCAL) { if (pchan->bone) { - Mat4Invert(imat, pchan->bone->arm_mat); - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, tempmat, imat); + invert_m4_m4(imat, pchan->bone->arm_mat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, imat); } } } @@ -313,7 +313,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 float offs_bone[4][4]; /* construct offs_bone the same way it is done in armature.c */ - Mat4CpyMat3(offs_bone, pchan->bone->bone_mat); + copy_m4_m3(offs_bone, pchan->bone->bone_mat); VECCOPY(offs_bone[3], pchan->bone->head); offs_bone[3][1]+= pchan->bone->parent->length; @@ -322,29 +322,29 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 float tmat[4][4]; /* the rotation of the parent restposition */ - Mat4CpyMat4(tmat, pchan->bone->parent->arm_mat); + copy_m4_m4(tmat, pchan->bone->parent->arm_mat); /* the location of actual parent transform */ VECCOPY(tmat[3], offs_bone[3]); offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f; - Mat4MulVecfl(pchan->parent->pose_mat, tmat[3]); + mul_m4_v3(pchan->parent->pose_mat, tmat[3]); - Mat4MulMat4(diff_mat, offs_bone, tmat); - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, tempmat, diff_mat); + mul_m4_m4m4(diff_mat, offs_bone, tmat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, diff_mat); } else { /* pose_mat = par_pose_mat * bone_mat * chan_mat */ - Mat4MulMat4(diff_mat, offs_bone, pchan->parent->pose_mat); - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, tempmat, diff_mat); + mul_m4_m4m4(diff_mat, offs_bone, pchan->parent->pose_mat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, diff_mat); } } else { - Mat4CpyMat4(diff_mat, pchan->bone->arm_mat); + copy_m4_m4(diff_mat, pchan->bone->arm_mat); - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, tempmat, diff_mat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, diff_mat); } } @@ -359,9 +359,9 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 { /* local + parent to pose */ if (pchan->bone) { - Mat4CpyMat4(diff_mat, pchan->bone->arm_mat); - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, diff_mat, tempmat); + copy_m4_m4(diff_mat, pchan->bone->arm_mat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, diff_mat, tempmat); } /* use pose-space as stepping stone for other spaces */ @@ -379,19 +379,19 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 /* check if object has a parent - otherwise this won't work */ if (ob->parent) { /* 'subtract' parent's effects from owner */ - Mat4MulMat4(diff_mat, ob->parentinv, ob->parent->obmat); - Mat4Invert(imat, diff_mat); - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, tempmat, imat); + mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat); + invert_m4_m4(imat, diff_mat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, imat); } } else if (from==CONSTRAINT_SPACE_LOCAL && to==CONSTRAINT_SPACE_WORLD) { /* check that object has a parent - otherwise this won't work */ if (ob->parent) { /* 'add' parent's effect back to owner */ - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(diff_mat, ob->parentinv, ob->parent->obmat); - Mat4MulMat4(mat, tempmat, diff_mat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat); + mul_m4_m4m4(mat, tempmat, diff_mat); } } } @@ -412,7 +412,7 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f short freeDM = 0; /* initialize target matrix using target matrix */ - Mat4CpyMat4(mat, ob->obmat); + copy_m4_m4(mat, ob->obmat); /* get index of vertex group */ dgroup = get_named_vertexgroup_num(ob, substring); @@ -453,8 +453,8 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f if (dvert[i].dw[j].def_nr == dgroup) { dm->getVertCo(dm, i, co); dm->getVertNo(dm, i, nor); - VecAddf(vec, vec, co); - VecAddf(normal, normal, nor); + add_v3_v3v3(vec, vec, co); + add_v3_v3v3(normal, normal, nor); count++; break; } @@ -465,8 +465,8 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f /* calculate averages of normal and coordinates */ if (count > 0) { - VecMulf(vec, 1.0f / count); - VecMulf(normal, 1.0f / count); + mul_v3_fl(vec, 1.0f / count); + mul_v3_fl(normal, 1.0f / count); } @@ -475,25 +475,25 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f * calc_manipulator_stats, V3D_MANIP_NORMAL case */ /* we need the transpose of the inverse for a normal... */ - Mat3CpyMat4(imat, ob->obmat); + copy_m3_m4(imat, ob->obmat); - Mat3Inv(tmat, imat); - Mat3Transp(tmat); - Mat3MulVecfl(tmat, normal); + invert_m3_m3(tmat, imat); + transpose_m3(tmat); + mul_m3_v3(tmat, normal); - Normalize(normal); + normalize_v3(normal); VECCOPY(plane, tmat[1]); VECCOPY(tmat[2], normal); - Crossf(tmat[0], normal, plane); - Crossf(tmat[1], tmat[2], tmat[0]); + cross_v3_v3v3(tmat[0], normal, plane); + cross_v3_v3v3(tmat[1], tmat[2], tmat[0]); - Mat4CpyMat3(mat, tmat); - Mat4Ortho(mat); + copy_m4_m3(mat, tmat); + normalize_m4(mat); /* apply the average coordinate as the new location */ - VecMat4MulVecfl(tvec, ob->obmat, vec); + mul_v3_m4v3(tvec, ob->obmat, vec); VECCOPY(mat[3], tvec); } } @@ -521,7 +521,7 @@ static void contarget_get_lattice_mat (Object *ob, char *substring, float mat[][ int i, n; /* initialize target matrix using target matrix */ - Mat4CpyMat4(mat, ob->obmat); + copy_m4_m4(mat, ob->obmat); /* get index of vertex group */ dgroup = get_named_vertexgroup_num(ob, substring); @@ -541,7 +541,7 @@ static void contarget_get_lattice_mat (Object *ob, char *substring, float mat[][ else memcpy(tvec, bp->vec, 3*sizeof(float)); - VecAddf(vec, vec, tvec); + add_v3_v3v3(vec, vec, tvec); grouped++; break; @@ -555,8 +555,8 @@ static void contarget_get_lattice_mat (Object *ob, char *substring, float mat[][ /* find average location, then multiply by ob->obmat to find world-space location */ if (grouped) - VecMulf(vec, 1.0f / grouped); - VecMat4MulVecfl(tvec, ob->obmat, vec); + mul_v3_fl(vec, 1.0f / grouped); + mul_v3_m4v3(tvec, ob->obmat, vec); /* copy new location to matrix */ VECCOPY(mat[3], tvec); @@ -568,7 +568,7 @@ static void constraint_target_to_mat4 (Scene *scene, Object *ob, char *substring { /* Case OBJECT */ if (!strlen(substring)) { - Mat4CpyMat4(mat, ob->obmat); + copy_m4_m4(mat, ob->obmat); constraint_mat_convertspace(ob, NULL, mat, from, to); } /* Case VERTEXGROUP */ @@ -600,23 +600,23 @@ static void constraint_target_to_mat4 (Scene *scene, Object *ob, char *substring */ if (headtail < 0.000001) { /* skip length interpolation if set to head */ - Mat4MulMat4(mat, pchan->pose_mat, ob->obmat); + mul_m4_m4m4(mat, pchan->pose_mat, ob->obmat); } else { float tempmat[4][4], loc[3]; /* interpolate along length of bone */ - VecLerpf(loc, pchan->pose_head, pchan->pose_tail, headtail); + interp_v3_v3v3(loc, pchan->pose_head, pchan->pose_tail, headtail); /* use interpolated distance for subtarget */ - Mat4CpyMat4(tempmat, pchan->pose_mat); - VecCopyf(tempmat[3], loc); + copy_m4_m4(tempmat, pchan->pose_mat); + copy_v3_v3(tempmat[3], loc); - Mat4MulMat4(mat, tempmat, ob->obmat); + mul_m4_m4m4(mat, tempmat, ob->obmat); } } else - Mat4CpyMat4(mat, ob->obmat); + copy_m4_m4(mat, ob->obmat); /* convert matrix space as required */ constraint_mat_convertspace(ob, pchan, mat, from, to); @@ -665,7 +665,7 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstrain if (VALID_CONS_TARGET(ct)) constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); else if (ct) - Mat4One(ct->matrix); + unit_m4(ct->matrix); } /* This following macro should be used for all standard single-target *_get_tars functions @@ -771,7 +771,7 @@ static void childof_new_data (void *cdata) data->flag = (CHILDOF_LOCX | CHILDOF_LOCY | CHILDOF_LOCZ | CHILDOF_ROTX |CHILDOF_ROTY | CHILDOF_ROTZ | CHILDOF_SIZEX | CHILDOF_SIZEY | CHILDOF_SIZEZ); - Mat4One(data->invmat); + unit_m4(data->invmat); } static int childof_get_tars (bConstraint *con, ListBase *list) @@ -812,16 +812,16 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta float loco[3], eulo[3], sizo[3]; /* get offset (parent-inverse) matrix */ - Mat4CpyMat4(invmat, data->invmat); + copy_m4_m4(invmat, data->invmat); /* extract components of both matrices */ VECCOPY(loc, ct->matrix[3]); - Mat4ToEulO(ct->matrix, eul, ct->rotOrder); - Mat4ToSize(ct->matrix, size); + mat4_to_eulO( eul, ct->rotOrder,ct->matrix); + mat4_to_size( size,ct->matrix); VECCOPY(loco, invmat[3]); - Mat4ToEulO(invmat, eulo, cob->rotOrder); - Mat4ToSize(invmat, sizo); + mat4_to_eulO( eulo, cob->rotOrder,invmat); + mat4_to_size( sizo,invmat); /* disable channels not enabled */ if (!(data->flag & CHILDOF_LOCX)) loc[0]= loco[0]= 0.0f; @@ -835,19 +835,19 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta if (!(data->flag & CHILDOF_SIZEZ)) size[2]= sizo[2]= 1.0f; /* make new target mat and offset mat */ - LocEulOSizeToMat4(ct->matrix, loc, eul, size, ct->rotOrder); - LocEulOSizeToMat4(invmat, loco, eulo, sizo, cob->rotOrder); + loc_eulO_size_to_mat4(ct->matrix, loc, eul, size, ct->rotOrder); + loc_eulO_size_to_mat4(invmat, loco, eulo, sizo, cob->rotOrder); /* multiply target (parent matrix) by offset (parent inverse) to get * the effect of the parent that will be exherted on the owner */ - Mat4MulMat4(parmat, invmat, ct->matrix); + mul_m4_m4m4(parmat, invmat, ct->matrix); /* now multiply the parent matrix by the owner matrix to get the * the effect of this constraint (i.e. owner is 'parented' to parent) */ - Mat4CpyMat4(tempmat, cob->matrix); - Mat4MulMat4(cob->matrix, tempmat, parmat); + copy_m4_m4(tempmat, cob->matrix); + mul_m4_m4m4(cob->matrix, tempmat, parmat); } } @@ -928,14 +928,14 @@ static void vectomat (float *vec, float *target_up, short axis, short upflag, sh float neg = -1; int right_index; - VecCopyf(n, vec); - if (Normalize(n) == 0.0) { + copy_v3_v3(n, vec); + if (normalize_v3(n) == 0.0) { n[0] = 0.0; n[1] = 0.0; n[2] = 1.0; } if (axis > 2) axis -= 3; - else VecNegf(n); + else negate_v3(n); /* n specifies the transformation of the track axis */ if (flags & TARGET_Z_UP) { @@ -952,19 +952,19 @@ static void vectomat (float *vec, float *target_up, short axis, short upflag, sh } /* project the up vector onto the plane specified by n */ - Projf(proj, u, n); /* first u onto n... */ - VecSubf(proj, u, proj); /* then onto the plane */ + project_v3_v3v3(proj, u, n); /* first u onto n... */ + sub_v3_v3v3(proj, u, proj); /* then onto the plane */ /* proj specifies the transformation of the up axis */ - if (Normalize(proj) == 0.0) { /* degenerate projection */ + if (normalize_v3(proj) == 0.0) { /* degenerate projection */ proj[0] = 0.0; proj[1] = 1.0; proj[2] = 0.0; } /* Normalized cross product of n and proj specifies transformation of the right axis */ - Crossf(right, proj, n); - Normalize(right); + cross_v3_v3v3(right, proj, n); + normalize_v3(right); if (axis != upflag) { right_index = 3 - axis - upflag; @@ -1004,7 +1004,7 @@ static void trackto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta float tmat[4][4]; /* Get size property, since ob->size is only the object's own relative size, not its global one */ - Mat4ToSize(cob->matrix, size); + mat4_to_size( size,cob->matrix); /* Clear the object's rotation */ cob->matrix[0][0]=size[0]; @@ -1020,13 +1020,13 @@ static void trackto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta /* targetmat[2] instead of ownermat[2] is passed to vectomat * for backwards compatability it seems... (Aligorith) */ - VecSubf(vec, cob->matrix[3], ct->matrix[3]); + sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]); vectomat(vec, ct->matrix[2], (short)data->reserved1, (short)data->reserved2, data->flags, totmat); - Mat4CpyMat4(tmat, cob->matrix); - Mat4MulMat34(cob->matrix, totmat, tmat); + copy_m4_m4(tmat, cob->matrix); + mul_m4_m3m4(cob->matrix, totmat, tmat); } } @@ -1097,19 +1097,19 @@ static void kinematic_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstra Object *ob= cob->ob; if (ob == NULL) { - Mat4One(ct->matrix); + unit_m4(ct->matrix); } else { float vec[3]; /* move grabtarget into world space */ VECCOPY(vec, data->grabtarget); - Mat4MulVecfl(ob->obmat, vec); - Mat4CpyMat4(ct->matrix, ob->obmat); + mul_m4_v3(ob->obmat, vec); + copy_m4_m4(ct->matrix, ob->obmat); VECCOPY(ct->matrix[3], vec); } } else - Mat4One(ct->matrix); + unit_m4(ct->matrix); } } @@ -1176,8 +1176,8 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr float totmat[4][4]; float curvetime; - Mat4One(totmat); - Mat4One(ct->matrix); + unit_m4(totmat); + unit_m4(ct->matrix); /* note: when creating constraints that follow path, the curve gets the CU_PATH set now, * currently for paths to work it needs to go through the bevlist/displist system (ton) @@ -1211,34 +1211,34 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr if ( where_on_path(ct->tar, curvetime, vec, dir, NULL, &radius) ) { if (data->followflag & FOLLOWPATH_FOLLOW) { - vectoquat(dir, (short) data->trackflag, (short) data->upflag, quat); + vec_to_quat( quat,dir, (short) data->trackflag, (short) data->upflag); - Normalize(dir); + normalize_v3(dir); q[0]= (float)cos(0.5*vec[3]); x1= (float)sin(0.5*vec[3]); q[1]= -x1*dir[0]; q[2]= -x1*dir[1]; q[3]= -x1*dir[2]; - QuatMul(quat, q, quat); + mul_qt_qtqt(quat, q, quat); - QuatToMat4(quat, totmat); + quat_to_mat4( totmat,quat); } if (data->followflag & FOLLOWPATH_RADIUS) { float tmat[4][4], rmat[4][4]; - Mat4Scale(tmat, radius); - Mat4MulMat4(rmat, totmat, tmat); - Mat4CpyMat4(totmat, rmat); + scale_m4_fl(tmat, radius); + mul_m4_m4m4(rmat, totmat, tmat); + copy_m4_m4(totmat, rmat); } VECCOPY(totmat[3], vec); - Mat4MulSerie(ct->matrix, ct->tar->obmat, totmat, NULL, NULL, NULL, NULL, NULL, NULL); + mul_serie_m4(ct->matrix, ct->tar->obmat, totmat, NULL, NULL, NULL, NULL, NULL, NULL); } } } else if (ct) - Mat4One(ct->matrix); + unit_m4(ct->matrix); } static void followpath_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) @@ -1253,25 +1253,25 @@ static void followpath_evaluate (bConstraint *con, bConstraintOb *cob, ListBase /* get Object local transform (loc/rot/size) to determine transformation from path */ //object_to_mat4(ob, obmat); - Mat4CpyMat4(obmat, cob->matrix); // FIXME!!! + copy_m4_m4(obmat, cob->matrix); // FIXME!!! /* get scaling of object before applying constraint */ - Mat4ToSize(cob->matrix, size); + mat4_to_size( size,cob->matrix); /* apply targetmat - containing location on path, and rotation */ - Mat4MulSerie(cob->matrix, ct->matrix, obmat, NULL, NULL, NULL, NULL, NULL, NULL); + mul_serie_m4(cob->matrix, ct->matrix, obmat, NULL, NULL, NULL, NULL, NULL, NULL); /* un-apply scaling caused by path */ if ((data->followflag & FOLLOWPATH_RADIUS)==0) { /* XXX - assume that scale correction means that radius will have some scale error in it - Campbell */ float obsize[3]; - Mat4ToSize(cob->matrix, obsize); + mat4_to_size( obsize,cob->matrix); if (obsize[0]) - VecMulf(cob->matrix[0], size[0] / obsize[0]); + mul_v3_fl(cob->matrix[0], size[0] / obsize[0]); if (obsize[1]) - VecMulf(cob->matrix[1], size[1] / obsize[1]); + mul_v3_fl(cob->matrix[1], size[1] / obsize[1]); if (obsize[2]) - VecMulf(cob->matrix[2], size[2] / obsize[2]); + mul_v3_fl(cob->matrix[2], size[2] / obsize[2]); } } } @@ -1349,9 +1349,9 @@ static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t float size[3]; VECCOPY(loc, cob->matrix[3]); - Mat4ToSize(cob->matrix, size); + mat4_to_size( size,cob->matrix); - Mat4ToEulO(cob->matrix, eul, cob->rotOrder); + mat4_to_eulO( eul, cob->rotOrder,cob->matrix); /* eulers: radians to degrees! */ eul[0] = (float)(eul[0] / M_PI * 180); @@ -1386,7 +1386,7 @@ static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t eul[1] = (float)(eul[1] / 180 * M_PI); eul[2] = (float)(eul[2] / 180 * M_PI); - LocEulOSizeToMat4(cob->matrix, loc, eul, size, cob->rotOrder); + loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, cob->rotOrder); } static bConstraintTypeInfo CTI_ROTLIMIT = { @@ -1412,8 +1412,8 @@ static void sizelimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * bSizeLimitConstraint *data = con->data; float obsize[3], size[3]; - Mat4ToSize(cob->matrix, size); - Mat4ToSize(cob->matrix, obsize); + mat4_to_size( size,cob->matrix); + mat4_to_size( obsize,cob->matrix); if (data->flag & LIMIT_XMIN) { if (size[0] < data->xmin) @@ -1441,11 +1441,11 @@ static void sizelimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * } if (obsize[0]) - VecMulf(cob->matrix[0], size[0]/obsize[0]); + mul_v3_fl(cob->matrix[0], size[0]/obsize[0]); if (obsize[1]) - VecMulf(cob->matrix[1], size[1]/obsize[1]); + mul_v3_fl(cob->matrix[1], size[1]/obsize[1]); if (obsize[2]) - VecMulf(cob->matrix[2], size[2]/obsize[2]); + mul_v3_fl(cob->matrix[2], size[2]/obsize[2]); } static bConstraintTypeInfo CTI_SIZELIMIT = { @@ -1591,17 +1591,17 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta float size[3]; VECCOPY(loc, cob->matrix[3]); - Mat4ToSize(cob->matrix, size); + mat4_to_size( size,cob->matrix); /* to allow compatible rotations, must get both rotations in the order of the owner... */ - Mat4ToEulO(ct->matrix, eul, cob->rotOrder); - Mat4ToEulO(cob->matrix, obeul, cob->rotOrder); + mat4_to_eulO( eul, cob->rotOrder,ct->matrix); + mat4_to_eulO( obeul, cob->rotOrder,cob->matrix); if ((data->flag & ROTLIKE_X)==0) eul[0] = obeul[0]; else { if (data->flag & ROTLIKE_OFFSET) - eulerO_rot(eul, obeul[0], 'x', cob->rotOrder); + rotate_eulO(eul, cob->rotOrder, 'x', obeul[0]); if (data->flag & ROTLIKE_X_INVERT) eul[0] *= -1; @@ -1611,7 +1611,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta eul[1] = obeul[1]; else { if (data->flag & ROTLIKE_OFFSET) - eulerO_rot(eul, obeul[1], 'y', cob->rotOrder); + rotate_eulO(eul, cob->rotOrder, 'y', obeul[1]); if (data->flag & ROTLIKE_Y_INVERT) eul[1] *= -1; @@ -1621,14 +1621,14 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta eul[2] = obeul[2]; else { if (data->flag & ROTLIKE_OFFSET) - eulerO_rot(eul, obeul[2], 'z', cob->rotOrder); + rotate_eulO(eul, cob->rotOrder, 'z', obeul[2]); if (data->flag & ROTLIKE_Z_INVERT) eul[2] *= -1; } compatible_eul(eul, obeul); - LocEulOSizeToMat4(cob->matrix, loc, eul, size, cob->rotOrder); + loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, cob->rotOrder); } } @@ -1690,32 +1690,32 @@ static void sizelike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t if (VALID_CONS_TARGET(ct)) { float obsize[3], size[3]; - Mat4ToSize(ct->matrix, size); - Mat4ToSize(cob->matrix, obsize); + mat4_to_size( size,ct->matrix); + mat4_to_size( obsize,cob->matrix); if ((data->flag & SIZELIKE_X) && (obsize[0] != 0)) { if (data->flag & SIZELIKE_OFFSET) { size[0] += (obsize[0] - 1.0f); - VecMulf(cob->matrix[0], size[0] / obsize[0]); + mul_v3_fl(cob->matrix[0], size[0] / obsize[0]); } else - VecMulf(cob->matrix[0], size[0] / obsize[0]); + mul_v3_fl(cob->matrix[0], size[0] / obsize[0]); } if ((data->flag & SIZELIKE_Y) && (obsize[1] != 0)) { if (data->flag & SIZELIKE_OFFSET) { size[1] += (obsize[1] - 1.0f); - VecMulf(cob->matrix[1], size[1] / obsize[1]); + mul_v3_fl(cob->matrix[1], size[1] / obsize[1]); } else - VecMulf(cob->matrix[1], size[1] / obsize[1]); + mul_v3_fl(cob->matrix[1], size[1] / obsize[1]); } if ((data->flag & SIZELIKE_Z) && (obsize[2] != 0)) { if (data->flag & SIZELIKE_OFFSET) { size[2] += (obsize[2] - 1.0f); - VecMulf(cob->matrix[2], size[2] / obsize[2]); + mul_v3_fl(cob->matrix[2], size[2] / obsize[2]); } else - VecMulf(cob->matrix[2], size[2] / obsize[2]); + mul_v3_fl(cob->matrix[2], size[2] / obsize[2]); } } } @@ -1816,7 +1816,7 @@ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintT #endif } else if (ct) - Mat4One(ct->matrix); + unit_m4(ct->matrix); } static void pycon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) @@ -1911,7 +1911,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint short axis; /* initialise return matrix */ - Mat4One(ct->matrix); + unit_m4(ct->matrix); /* get the transform matrix of the target */ constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, tempmat, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); @@ -1924,7 +1924,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint */ if (data->type < 10) { /* extract rotation (is in whatever space target should be in) */ - Mat4ToEul(tempmat, vec); + mat4_to_eul( vec,tempmat); vec[0] *= (float)(180.0/M_PI); vec[1] *= (float)(180.0/M_PI); vec[2] *= (float)(180.0/M_PI); @@ -1932,7 +1932,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint } else if (data->type < 20) { /* extract scaling (is in whatever space target should be in) */ - Mat4ToSize(tempmat, vec); + mat4_to_size( vec,tempmat); axis= data->type - 10; } else { @@ -1967,7 +1967,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint /* convert animation to matrices for use here */ chan_calc_mat(tchan); - Mat4CpyMat4(ct->matrix, tchan->chan_mat); + copy_m4_m4(ct->matrix, tchan->chan_mat); /* Clean up */ free_pose(pose); @@ -1997,8 +1997,8 @@ static void actcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *tar /* Nice and simple... we just need to multiply the matrices, as the get_target_matrix * function has already taken care of everything else. */ - Mat4CpyMat4(temp, cob->matrix); - Mat4MulMat4(cob->matrix, ct->matrix, temp); + copy_m4_m4(temp, cob->matrix); + mul_m4_m4m4(cob->matrix, ct->matrix, temp); } } @@ -2067,7 +2067,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * float mdet; /* Vector object -> target */ - VecSubf(vec, ct->matrix[3], cob->matrix[3]); + sub_v3_v3v3(vec, ct->matrix[3], cob->matrix[3]); switch (data->lockflag){ case LOCK_X: /* LOCK X */ { @@ -2075,71 +2075,71 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * case TRACK_Y: /* LOCK X TRACK Y */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[0]); - VecSubf(totmat[1], vec, vec2); - Normalize(totmat[1]); + project_v3_v3v3(vec2, vec, cob->matrix[0]); + sub_v3_v3v3(totmat[1], vec, vec2); + normalize_v3(totmat[1]); /* the x axis is fixed */ totmat[0][0] = cob->matrix[0][0]; totmat[0][1] = cob->matrix[0][1]; totmat[0][2] = cob->matrix[0][2]; - Normalize(totmat[0]); + normalize_v3(totmat[0]); /* the z axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[2], totmat[0], totmat[1]); + cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); } break; case TRACK_Z: /* LOCK X TRACK Z */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[0]); - VecSubf(totmat[2], vec, vec2); - Normalize(totmat[2]); + project_v3_v3v3(vec2, vec, cob->matrix[0]); + sub_v3_v3v3(totmat[2], vec, vec2); + normalize_v3(totmat[2]); /* the x axis is fixed */ totmat[0][0] = cob->matrix[0][0]; totmat[0][1] = cob->matrix[0][1]; totmat[0][2] = cob->matrix[0][2]; - Normalize(totmat[0]); + normalize_v3(totmat[0]); /* the z axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[1], totmat[2], totmat[0]); + cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); } break; case TRACK_nY: /* LOCK X TRACK -Y */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[0]); - VecSubf(totmat[1], vec, vec2); - Normalize(totmat[1]); - VecNegf(totmat[1]); + project_v3_v3v3(vec2, vec, cob->matrix[0]); + sub_v3_v3v3(totmat[1], vec, vec2); + normalize_v3(totmat[1]); + negate_v3(totmat[1]); /* the x axis is fixed */ totmat[0][0] = cob->matrix[0][0]; totmat[0][1] = cob->matrix[0][1]; totmat[0][2] = cob->matrix[0][2]; - Normalize(totmat[0]); + normalize_v3(totmat[0]); /* the z axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[2], totmat[0], totmat[1]); + cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); } break; case TRACK_nZ: /* LOCK X TRACK -Z */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[0]); - VecSubf(totmat[2], vec, vec2); - Normalize(totmat[2]); - VecNegf(totmat[2]); + project_v3_v3v3(vec2, vec, cob->matrix[0]); + sub_v3_v3v3(totmat[2], vec, vec2); + normalize_v3(totmat[2]); + negate_v3(totmat[2]); /* the x axis is fixed */ totmat[0][0] = cob->matrix[0][0]; totmat[0][1] = cob->matrix[0][1]; totmat[0][2] = cob->matrix[0][2]; - Normalize(totmat[0]); + normalize_v3(totmat[0]); /* the z axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[1], totmat[2], totmat[0]); + cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); } break; default: @@ -2158,71 +2158,71 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * case TRACK_X: /* LOCK Y TRACK X */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[1]); - VecSubf(totmat[0], vec, vec2); - Normalize(totmat[0]); + project_v3_v3v3(vec2, vec, cob->matrix[1]); + sub_v3_v3v3(totmat[0], vec, vec2); + normalize_v3(totmat[0]); /* the y axis is fixed */ totmat[1][0] = cob->matrix[1][0]; totmat[1][1] = cob->matrix[1][1]; totmat[1][2] = cob->matrix[1][2]; - Normalize(totmat[1]); + normalize_v3(totmat[1]); /* the z axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[2], totmat[0], totmat[1]); + cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); } break; case TRACK_Z: /* LOCK Y TRACK Z */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[1]); - VecSubf(totmat[2], vec, vec2); - Normalize(totmat[2]); + project_v3_v3v3(vec2, vec, cob->matrix[1]); + sub_v3_v3v3(totmat[2], vec, vec2); + normalize_v3(totmat[2]); /* the y axis is fixed */ totmat[1][0] = cob->matrix[1][0]; totmat[1][1] = cob->matrix[1][1]; totmat[1][2] = cob->matrix[1][2]; - Normalize(totmat[1]); + normalize_v3(totmat[1]); /* the z axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[0], totmat[1], totmat[2]); + cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); } break; case TRACK_nX: /* LOCK Y TRACK -X */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[1]); - VecSubf(totmat[0], vec, vec2); - Normalize(totmat[0]); - VecNegf(totmat[0]); + project_v3_v3v3(vec2, vec, cob->matrix[1]); + sub_v3_v3v3(totmat[0], vec, vec2); + normalize_v3(totmat[0]); + negate_v3(totmat[0]); /* the y axis is fixed */ totmat[1][0] = cob->matrix[1][0]; totmat[1][1] = cob->matrix[1][1]; totmat[1][2] = cob->matrix[1][2]; - Normalize(totmat[1]); + normalize_v3(totmat[1]); /* the z axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[2], totmat[0], totmat[1]); + cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); } break; case TRACK_nZ: /* LOCK Y TRACK -Z */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[1]); - VecSubf(totmat[2], vec, vec2); - Normalize(totmat[2]); - VecNegf(totmat[2]); + project_v3_v3v3(vec2, vec, cob->matrix[1]); + sub_v3_v3v3(totmat[2], vec, vec2); + normalize_v3(totmat[2]); + negate_v3(totmat[2]); /* the y axis is fixed */ totmat[1][0] = cob->matrix[1][0]; totmat[1][1] = cob->matrix[1][1]; totmat[1][2] = cob->matrix[1][2]; - Normalize(totmat[1]); + normalize_v3(totmat[1]); /* the z axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[0], totmat[1], totmat[2]); + cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); } break; default: @@ -2241,71 +2241,71 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * case TRACK_X: /* LOCK Z TRACK X */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[2]); - VecSubf(totmat[0], vec, vec2); - Normalize(totmat[0]); + project_v3_v3v3(vec2, vec, cob->matrix[2]); + sub_v3_v3v3(totmat[0], vec, vec2); + normalize_v3(totmat[0]); /* the z axis is fixed */ totmat[2][0] = cob->matrix[2][0]; totmat[2][1] = cob->matrix[2][1]; totmat[2][2] = cob->matrix[2][2]; - Normalize(totmat[2]); + normalize_v3(totmat[2]); /* the x axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[1], totmat[2], totmat[0]); + cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); } break; case TRACK_Y: /* LOCK Z TRACK Y */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[2]); - VecSubf(totmat[1], vec, vec2); - Normalize(totmat[1]); + project_v3_v3v3(vec2, vec, cob->matrix[2]); + sub_v3_v3v3(totmat[1], vec, vec2); + normalize_v3(totmat[1]); /* the z axis is fixed */ totmat[2][0] = cob->matrix[2][0]; totmat[2][1] = cob->matrix[2][1]; totmat[2][2] = cob->matrix[2][2]; - Normalize(totmat[2]); + normalize_v3(totmat[2]); /* the x axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[0], totmat[1], totmat[2]); + cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); } break; case TRACK_nX: /* LOCK Z TRACK -X */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[2]); - VecSubf(totmat[0], vec, vec2); - Normalize(totmat[0]); - VecNegf(totmat[0]); + project_v3_v3v3(vec2, vec, cob->matrix[2]); + sub_v3_v3v3(totmat[0], vec, vec2); + normalize_v3(totmat[0]); + negate_v3(totmat[0]); /* the z axis is fixed */ totmat[2][0] = cob->matrix[2][0]; totmat[2][1] = cob->matrix[2][1]; totmat[2][2] = cob->matrix[2][2]; - Normalize(totmat[2]); + normalize_v3(totmat[2]); /* the x axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[1], totmat[2], totmat[0]); + cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); } break; case TRACK_nY: /* LOCK Z TRACK -Y */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[2]); - VecSubf(totmat[1], vec, vec2); - Normalize(totmat[1]); - VecNegf(totmat[1]); + project_v3_v3v3(vec2, vec, cob->matrix[2]); + sub_v3_v3v3(totmat[1], vec, vec2); + normalize_v3(totmat[1]); + negate_v3(totmat[1]); /* the z axis is fixed */ totmat[2][0] = cob->matrix[2][0]; totmat[2][1] = cob->matrix[2][1]; totmat[2][2] = cob->matrix[2][2]; - Normalize(totmat[2]); + normalize_v3(totmat[2]); /* the x axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[0], totmat[1], totmat[2]); + cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); } break; default: @@ -2330,18 +2330,18 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * tmpmat[0][0] = cob->matrix[0][0];tmpmat[0][1] = cob->matrix[0][1];tmpmat[0][2] = cob->matrix[0][2]; tmpmat[1][0] = cob->matrix[1][0];tmpmat[1][1] = cob->matrix[1][1];tmpmat[1][2] = cob->matrix[1][2]; tmpmat[2][0] = cob->matrix[2][0];tmpmat[2][1] = cob->matrix[2][1];tmpmat[2][2] = cob->matrix[2][2]; - Normalize(tmpmat[0]); - Normalize(tmpmat[1]); - Normalize(tmpmat[2]); - Mat3Inv(invmat, tmpmat); - Mat3MulMat3(tmpmat, totmat, invmat); + normalize_v3(tmpmat[0]); + normalize_v3(tmpmat[1]); + normalize_v3(tmpmat[2]); + invert_m3_m3(invmat, tmpmat); + mul_m3_m3m3(tmpmat, totmat, invmat); totmat[0][0] = tmpmat[0][0];totmat[0][1] = tmpmat[0][1];totmat[0][2] = tmpmat[0][2]; totmat[1][0] = tmpmat[1][0];totmat[1][1] = tmpmat[1][1];totmat[1][2] = tmpmat[1][2]; totmat[2][0] = tmpmat[2][0];totmat[2][1] = tmpmat[2][1];totmat[2][2] = tmpmat[2][2]; - Mat4CpyMat4(tmat, cob->matrix); + copy_m4_m4(tmat, cob->matrix); - mdet = Det3x3( totmat[0][0],totmat[0][1],totmat[0][2], + mdet = determinant_m3( totmat[0][0],totmat[0][1],totmat[0][2], totmat[1][0],totmat[1][1],totmat[1][2], totmat[2][0],totmat[2][1],totmat[2][2]); if (mdet==0) { @@ -2351,7 +2351,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * } /* apply out transformaton to the object */ - Mat4MulMat34(cob->matrix, totmat, tmat); + mul_m4_m3m4(cob->matrix, totmat, tmat); } } @@ -2416,7 +2416,7 @@ static void distlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * short clamp_surf= 0; /* calculate our current distance from the target */ - dist= VecLenf(cob->matrix[3], ct->matrix[3]); + dist= len_v3v3(cob->matrix[3], ct->matrix[3]); /* set distance (flag is only set when user demands it) */ if (data->dist == 0) @@ -2463,7 +2463,7 @@ static void distlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* clamp to 'surface' (i.e. move owner so that dist == data->dist) */ if (clamp_surf) { /* simply interpolate along line formed by target -> owner */ - VecLerpf(dvec, ct->matrix[3], cob->matrix[3], sfac); + interp_v3_v3v3(dvec, ct->matrix[3], cob->matrix[3], sfac); /* copy new vector onto owner */ VECCOPY(cob->matrix[3], dvec); @@ -2537,27 +2537,27 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * float dist; /* store scaling before destroying obmat */ - Mat4ToSize(cob->matrix, size); + mat4_to_size( size,cob->matrix); /* store X orientation before destroying obmat */ xx[0] = cob->matrix[0][0]; xx[1] = cob->matrix[0][1]; xx[2] = cob->matrix[0][2]; - Normalize(xx); + normalize_v3(xx); /* store Z orientation before destroying obmat */ zz[0] = cob->matrix[2][0]; zz[1] = cob->matrix[2][1]; zz[2] = cob->matrix[2][2]; - Normalize(zz); + normalize_v3(zz); - VecSubf(vec, cob->matrix[3], ct->matrix[3]); + sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]); vec[0] /= size[0]; vec[1] /= size[1]; vec[2] /= size[2]; - dist = Normalize(vec); - //dist = VecLenf( ob->obmat[3], targetmat[3]); + dist = normalize_v3(vec); + //dist = len_v3v3( ob->obmat[3], targetmat[3]); /* data->orglength==0 occurs on first run, and after 'R' button is clicked */ if (data->orglength == 0) @@ -2600,8 +2600,8 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * cob->matrix[2][1]=0; cob->matrix[2][2]=size[2]*scale[2]; - VecSubf(vec, cob->matrix[3], ct->matrix[3]); - Normalize(vec); + sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]); + normalize_v3(vec); /* new Y aligns object target connection*/ totmat[1][0] = -vec[0]; @@ -2611,8 +2611,8 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * case PLANE_X: /* build new Z vector */ /* othogonal to "new Y" "old X! plane */ - Crossf(orth, vec, xx); - Normalize(orth); + cross_v3_v3v3(orth, vec, xx); + normalize_v3(orth); /* new Z*/ totmat[2][0] = orth[0]; @@ -2620,8 +2620,8 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * totmat[2][2] = orth[2]; /* we decided to keep X plane*/ - Crossf(xx, orth, vec); - Normalize(xx); + cross_v3_v3v3(xx, orth, vec); + normalize_v3(xx); totmat[0][0] = xx[0]; totmat[0][1] = xx[1]; totmat[0][2] = xx[2]; @@ -2629,8 +2629,8 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * case PLANE_Z: /* build new X vector */ /* othogonal to "new Y" "old Z! plane */ - Crossf(orth, vec, zz); - Normalize(orth); + cross_v3_v3v3(orth, vec, zz); + normalize_v3(orth); /* new X */ totmat[0][0] = -orth[0]; @@ -2638,16 +2638,16 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * totmat[0][2] = -orth[2]; /* we decided to keep Z */ - Crossf(zz, orth, vec); - Normalize(zz); + cross_v3_v3v3(zz, orth, vec); + normalize_v3(zz); totmat[2][0] = zz[0]; totmat[2][1] = zz[1]; totmat[2][2] = zz[2]; break; } /* switch (data->plane) */ - Mat4CpyMat4(tmat, cob->matrix); - Mat4MulMat34(cob->matrix, totmat, tmat); + copy_m4_m4(tmat, cob->matrix); + mul_m4_m3m4(cob->matrix, totmat, tmat); } } @@ -2715,15 +2715,15 @@ static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *tar float val1, val2; int index; - Mat4CpyMat4(obmat, cob->matrix); - Mat4CpyMat4(tarmat, ct->matrix); + copy_m4_m4(obmat, cob->matrix); + copy_m4_m4(tarmat, ct->matrix); if (data->flag & MINMAX_USEROT) { /* take rotation of target into account by doing the transaction in target's localspace */ - Mat4Invert(imat, tarmat); - Mat4MulMat4(tmat, obmat, imat); - Mat4CpyMat4(obmat, tmat); - Mat4One(tarmat); + invert_m4_m4(imat, tarmat); + mul_m4_m4m4(tmat, obmat, imat); + copy_m4_m4(obmat, tmat); + unit_m4(tarmat); } switch (data->minmaxflag) { @@ -2774,8 +2774,8 @@ static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *tar } if (data->flag & MINMAX_USEROT) { /* get out of localspace */ - Mat4MulMat4(tmat, obmat, ct->matrix); - Mat4CpyMat4(cob->matrix, tmat); + mul_m4_m4m4(tmat, obmat, ct->matrix); + copy_m4_m4(cob->matrix, tmat); } else { VECCOPY(cob->matrix[3], obmat[3]); @@ -2899,7 +2899,7 @@ static void clampto_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstrain * might end up calling this... */ if (ct) - Mat4One(ct->matrix); + unit_m4(ct->matrix); } static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) @@ -2913,8 +2913,8 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta float obmat[4][4], targetMatrix[4][4], ownLoc[3]; float curveMin[3], curveMax[3]; - Mat4CpyMat4(obmat, cob->matrix); - Mat4One(targetMatrix); + copy_m4_m4(obmat, cob->matrix); + unit_m4(targetMatrix); VECCOPY(ownLoc, obmat[3]); INIT_MINMAX(curveMin, curveMax) @@ -2930,7 +2930,7 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta /* 1. determine which axis to sample on? */ if (data->flag == CLAMPTO_AUTO) { float size[3]; - VecSubf(size, curveMax, curveMin); + sub_v3_v3v3(size, curveMax, curveMin); /* find axis along which the bounding box has the greatest * extent. Otherwise, default to the x-axis, as that is quite @@ -3003,10 +3003,10 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta /* 3. position on curve */ if (where_on_path(ct->tar, curvetime, vec, dir, NULL, NULL) ) { - Mat4One(totmat); + unit_m4(totmat); VECCOPY(totmat[3], vec); - Mat4MulSerie(targetMatrix, ct->tar->obmat, totmat, NULL, NULL, NULL, NULL, NULL, NULL); + mul_serie_m4(targetMatrix, ct->tar->obmat, totmat, NULL, NULL, NULL, NULL, NULL, NULL); } } @@ -3081,22 +3081,22 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* obtain target effect */ switch (data->from) { case 2: /* scale */ - Mat4ToSize(ct->matrix, dvec); + mat4_to_size( dvec,ct->matrix); break; case 1: /* rotation (convert to degrees first) */ - Mat4ToEulO(ct->matrix, dvec, cob->rotOrder); + mat4_to_eulO( dvec, cob->rotOrder,ct->matrix); for (i=0; i<3; i++) dvec[i] = (float)(dvec[i] / M_PI * 180); break; default: /* location */ - VecCopyf(dvec, ct->matrix[3]); + copy_v3_v3(dvec, ct->matrix[3]); break; } /* extract components of owner's matrix */ VECCOPY(loc, cob->matrix[3]); - Mat4ToEulO(cob->matrix, eul, cob->rotOrder); - Mat4ToSize(cob->matrix, size); + mat4_to_eulO( eul, cob->rotOrder,cob->matrix); + mat4_to_size( size,cob->matrix); /* determine where in range current transforms lie */ if (data->expo) { @@ -3145,12 +3145,12 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * loc[i]= (data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i]))); /* add original location back on (so that it can still be moved) */ - VecAddf(loc, cob->matrix[3], loc); + add_v3_v3v3(loc, cob->matrix[3], loc); break; } /* apply to matrix */ - LocEulOSizeToMat4(cob->matrix, loc, eul, size, cob->rotOrder); + loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, cob->rotOrder); } } @@ -3222,7 +3222,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr hit.index = -1; hit.dist = 100000.0f; //TODO should use FLT_MAX.. but normal projection doenst yet supports it - Mat4One(ct->matrix); + unit_m4(ct->matrix); if(target != NULL) { @@ -3248,8 +3248,8 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr BLI_bvhtree_find_nearest(treeData.tree, co, &nearest, treeData.nearest_callback, &treeData); - dist = VecLenf(co, nearest.co); - VecLerpf(co, co, nearest.co, (dist - scon->dist)/dist); /* linear interpolation */ + dist = len_v3v3(co, nearest.co); + interp_v3_v3v3(co, co, nearest.co, (dist - scon->dist)/dist); /* linear interpolation */ space_transform_invert(&transform, co); break; @@ -3264,7 +3264,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr break; } - Normalize(no); + normalize_v3(no); bvhtree_from_mesh_faces(&treeData, target, scon->dist, 4, 6); @@ -3294,7 +3294,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr } /* co is in local object coordinates, change it to global and update target position */ - VecMat4MulVecfl(co, cob->matrix, co); + mul_v3_m4v3(co, cob->matrix, co); VECCOPY(ct->matrix[3], co); } } @@ -3378,23 +3378,23 @@ static void damptrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * float rmat[3][3], tmat[4][4]; /* find the (unit) direction that the axis we're interested in currently points - * - Mat4Mul3Vecfl() only takes the 3x3 (rotation+scaling) components of the 4x4 matrix + * - mul_mat3_m4_v3() only takes the 3x3 (rotation+scaling) components of the 4x4 matrix * - the normalisation step at the end should take care of any unwanted scaling * left over in the 3x3 matrix we used */ VECCOPY(obvec, track_dir_vecs[data->trackflag]); - Mat4Mul3Vecfl(cob->matrix, obvec); + mul_mat3_m4_v3(cob->matrix, obvec); - if (Normalize(obvec) == 0.0f) { + if (normalize_v3(obvec) == 0.0f) { /* exceptional case - just use the track vector as appropriate */ VECCOPY(obvec, track_dir_vecs[data->trackflag]); } /* find the (unit) direction vector going from the owner to the target */ VECCOPY(obloc, cob->matrix[3]); - VecSubf(tarvec, ct->matrix[3], obloc); + sub_v3_v3v3(tarvec, ct->matrix[3], obloc); - if (Normalize(tarvec) == 0.0f) { + if (normalize_v3(tarvec) == 0.0f) { /* the target is sitting on the owner, so just make them use the same direction vectors */ // FIXME: or would it be better to use the pure direction vector? VECCOPY(tarvec, obvec); @@ -3409,23 +3409,23 @@ static void damptrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * * - the min/max wrappers around (obvec . tarvec) result (stored temporarily in rangle) * are used to ensure that the smallest angle is chosen */ - Crossf(raxis, obvec, tarvec); + cross_v3_v3v3(raxis, obvec, tarvec); - rangle= Inpf(obvec, tarvec); + rangle= dot_v3v3(obvec, tarvec); rangle= acos( MAX2(-1.0f, MIN2(1.0f, rangle)) ); /* construct rotation matrix from the axis-angle rotation found above * - this call takes care to make sure that the axis provided is a unit vector first */ - AxisAngleToMat3(raxis, rangle, rmat); + axis_angle_to_mat3( rmat,raxis, rangle); /* rotate the owner in the way defined by this rotation matrix, then reapply the location since * we may have destroyed that in the process of multiplying the matrix */ - Mat4One(tmat); - Mat4MulMat34(tmat, rmat, cob->matrix); // m1, m3, m2 + unit_m4(tmat); + mul_m4_m3m4(tmat, rmat, cob->matrix); // m1, m3, m2 - Mat4CpyMat4(cob->matrix, tmat); + copy_m4_m4(cob->matrix, tmat); VECCOPY(cob->matrix[3], obloc); } } @@ -3509,7 +3509,7 @@ static void splineik_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstrai * might end up calling this... */ if (ct) - Mat4One(ct->matrix); + unit_m4(ct->matrix); } static bConstraintTypeInfo CTI_SPLINEIK = { @@ -3771,12 +3771,12 @@ void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n, cob->ob= (Object *)ownerdata; cob->pchan= NULL; if (cob->ob) { - Mat4CpyMat4(cob->matrix, cob->ob->obmat); - Mat4CpyMat4(cob->startmat, cob->matrix); + copy_m4_m4(cob->matrix, cob->ob->obmat); + copy_m4_m4(cob->startmat, cob->matrix); } else { - Mat4One(cob->matrix); - Mat4One(cob->startmat); + unit_m4(cob->matrix); + unit_m4(cob->startmat); } } break; @@ -3785,12 +3785,12 @@ void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n, cob->ob= NULL; /* this might not work at all :/ */ cob->pchan= (bPoseChannel *)ownerdata; if (cob->pchan) { - Mat4CpyMat4(cob->matrix, cob->pchan->pose_mat); - Mat4CpyMat4(cob->startmat, cob->matrix); + copy_m4_m4(cob->matrix, cob->pchan->pose_mat); + copy_m4_m4(cob->startmat, cob->matrix); } else { - Mat4One(cob->matrix); - Mat4One(cob->startmat); + unit_m4(cob->matrix); + unit_m4(cob->startmat); } } break; @@ -3807,7 +3807,7 @@ void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n, if (ct) { if (cti->get_target_matrix) cti->get_target_matrix(con, cob, ct, ctime); - Mat4CpyMat4(mat, ct->matrix); + copy_m4_m4(mat, ct->matrix); } /* free targets + 'constraint-ob' */ @@ -3817,7 +3817,7 @@ void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n, } else { /* invalid constraint - perhaps... */ - Mat4One(mat); + unit_m4(mat); } } @@ -3860,7 +3860,7 @@ void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime) /* move owner matrix into right space */ constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, CONSTRAINT_SPACE_WORLD, con->ownspace); - Mat4CpyMat4(oldmat, cob->matrix); + copy_m4_m4(oldmat, cob->matrix); /* prepare targets for constraint solving */ if (cti->get_constraint_targets) { @@ -3881,7 +3881,7 @@ void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime) } else { for (ct= targets.first; ct; ct= ct->next) - Mat4One(ct->matrix); + unit_m4(ct->matrix); } } @@ -3898,21 +3898,21 @@ void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime) /* Interpolate the enforcement, to blend result of constraint into final owner transform */ /* 1. Remove effects of original matrix from constraint solution ==> delta */ - Mat4Invert(imat, oldmat); - Mat4CpyMat4(solution, cob->matrix); - Mat4MulMat4(delta, solution, imat); + invert_m4_m4(imat, oldmat); + copy_m4_m4(solution, cob->matrix); + mul_m4_m4m4(delta, solution, imat); /* 2. If constraint influence is not full strength, then interpolate * identity_matrix --> delta_matrix to get the effect the constraint actually exerts */ if (enf < 1.0) { float identity[4][4]; - Mat4One(identity); - Mat4BlendMat4(delta, identity, delta, enf); + unit_m4(identity); + blend_m4_m4m4(delta, identity, delta, enf); } /* 3. Now multiply the delta by the matrix in use before the evaluation */ - Mat4MulMat4(cob->matrix, delta, oldmat); + mul_m4_m4m4(cob->matrix, delta, oldmat); /* move owner back into worldspace for next constraint/other business */ if ((con->flag & CONSTRAINT_SPACEONCE) == 0) diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 7f2872c0797..21549f6b147 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -46,6 +46,8 @@ #include "BKE_screen.h" #include "BKE_global.h" +#include "BPY_extern.h" + #include <string.h> /* struct */ @@ -408,16 +410,26 @@ struct bContextDataResult { static int ctx_data_get(bContext *C, const char *member, bContextDataResult *result) { int done= 0, recursion= C->data.recursion; + int ret= 0; memset(result, 0, sizeof(bContextDataResult)); if(CTX_py_dict_get(C)) { - return bpy_context_get(C, member, result); + return BPY_context_get(C, member, result); +// if (BPY_context_get(C, member, result)) +// return 1; } /* we check recursion to ensure that we do not get infinite * loops requesting data from ourselfs in a context callback */ - if(!done && recursion < 1 && C->wm.store) { + + /* Ok, this looks evil... + * if(ret) done= -(-ret | -done); + * + * Values in order of importance + * (0, -1, 1) - Where 1 is highest priority + * */ + if(done!=1 && recursion < 1 && C->wm.store) { bContextStoreEntry *entry; C->data.recursion= 1; @@ -429,21 +441,28 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res } } } - if(!done && recursion < 2 && C->wm.region) { + if(done!=1 && recursion < 2 && C->wm.region) { C->data.recursion= 2; - if(C->wm.region->type && C->wm.region->type->context) - done= C->wm.region->type->context(C, member, result); + if(C->wm.region->type && C->wm.region->type->context) { + ret = C->wm.region->type->context(C, member, result); + if(ret) done= -(-ret | -done); + + } } - if(!done && recursion < 3 && C->wm.area) { + if(done!=1 && recursion < 3 && C->wm.area) { C->data.recursion= 3; - if(C->wm.area->type && C->wm.area->type->context) - done= C->wm.area->type->context(C, member, result); + if(C->wm.area->type && C->wm.area->type->context) { + ret = C->wm.area->type->context(C, member, result); + if(ret) done= -(-ret | -done); + } } - if(!done && recursion < 4 && C->wm.screen) { + if(done!=1 && recursion < 4 && C->wm.screen) { bContextDataCallback cb= C->wm.screen->context; C->data.recursion= 4; - if(cb) - done= cb(C, member, result); + if(cb) { + ret = cb(C, member, result); + if(ret) done= -(-ret | -done); + } } C->data.recursion= recursion; @@ -455,7 +474,7 @@ static void *ctx_data_pointer_get(const bContext *C, const char *member) { bContextDataResult result; - if(C && ctx_data_get((bContext*)C, member, &result)) + if(C && ctx_data_get((bContext*)C, member, &result)==1) return result.ptr.data; return NULL; @@ -465,7 +484,7 @@ static int ctx_data_pointer_verify(const bContext *C, const char *member, void * { bContextDataResult result; - if(ctx_data_get((bContext*)C, member, &result)) { + if(ctx_data_get((bContext*)C, member, &result)==1) { *pointer= result.ptr.data; return 1; } @@ -479,7 +498,7 @@ static int ctx_data_collection_get(const bContext *C, const char *member, ListBa { bContextDataResult result; - if(ctx_data_get((bContext*)C, member, &result)) { + if(ctx_data_get((bContext*)C, member, &result)==1) { *list= result.list; return 1; } @@ -494,7 +513,7 @@ PointerRNA CTX_data_pointer_get(const bContext *C, const char *member) { bContextDataResult result; - if(ctx_data_get((bContext*)C, member, &result)) + if(ctx_data_get((bContext*)C, member, &result)==1) return result.ptr; else return PointerRNA_NULL; @@ -514,7 +533,7 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member) { bContextDataResult result; - if(ctx_data_get((bContext*)C, member, &result)) { + if(ctx_data_get((bContext*)C, member, &result)==1) { return result.list; } else { @@ -524,11 +543,13 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member) } } -void CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb) +/* 1:found, -1:found but not set, 0:not found */ +int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb) { bContextDataResult result; + int ret= ctx_data_get((bContext*)C, member, &result); - if(ctx_data_get((bContext*)C, member, &result)) { + if(ret==1) { *r_ptr= result.ptr; *r_lb= result.list; } @@ -536,6 +557,8 @@ void CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, List memset(r_ptr, 0, sizeof(*r_ptr)); memset(r_lb, 0, sizeof(*r_lb)); } + + return ret; } static void data_dir_add(ListBase *lb, const char *member) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 5580070b922..83e2e0c29d9 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -40,7 +40,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_object_types.h" #include "DNA_curve_types.h" @@ -145,6 +145,7 @@ Curve *add_curve(char *name, int type) cu->fsize= 1.0; cu->ulheight = 0.05; cu->texflag= CU_AUTOSPACE; + cu->twist_mode= CU_TWIST_MINIMUM; // XXX: this one seems to be the best one in most cases, at least for curve deform... cu->bb= unit_boundbox(); @@ -991,7 +992,7 @@ static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float for(i=0; i<3; i++) { p[i]= (-6*t + 6)*p0[i] + (18*t - 12)*p1[i] + (-18*t + 6)*p2[i] + (6*t)*p3[i]; } - Normalize(p); + normalize_v3(p); p = (float *)(((char *)p)+stride); } } @@ -1597,7 +1598,7 @@ static void bevel_list_calc_bisect(BevList *bl) nr= bl->nr; while(nr--) { /* totally simple */ - VecBisect3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec); + bisect_v3_v3v3v3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec); bevp0= bevp1; bevp1= bevp2; @@ -1615,8 +1616,8 @@ static void bevel_list_flip_tangents(BevList *bl) nr= bl->nr; while(nr--) { - if(RAD2DEG(VecAngle2(bevp0->tan, bevp1->tan)) > 90) - VecNegf(bevp1->tan); + if(RAD2DEG(angle_v2v2(bevp0->tan, bevp1->tan)) > 90) + negate_v3(bevp1->tan); bevp0= bevp1; bevp1= bevp2; @@ -1636,9 +1637,9 @@ static void bevel_list_apply_tilt(BevList *bl) nr= bl->nr; while(nr--) { - AxisAngleToQuat(q, bevp1->dir, bevp1->alfa); - QuatMul(bevp1->quat, q, bevp1->quat); - NormalQuat(bevp1->quat); + axis_angle_to_quat(q, bevp1->dir, bevp1->alfa); + mul_qt_qtqt(bevp1->quat, q, bevp1->quat); + normalize_qt(bevp1->quat); bevp0= bevp1; bevp1= bevp2; @@ -1682,18 +1683,18 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter) while(nr--) { /* interpolate quats */ float zaxis[3] = {0,0,1}, cross[3], q2[4]; - QuatInterpol(q, bevp0_quat, bevp2->quat, 0.5); - NormalQuat(q); + interp_qt_qtqt(q, bevp0_quat, bevp2->quat, 0.5); + normalize_qt(q); - QuatMulVecf(q, zaxis); - Crossf(cross, zaxis, bevp1->dir); - AxisAngleToQuat(q2, cross, NormalizedVecAngle2(zaxis, bevp1->dir)); - NormalQuat(q2); + mul_qt_v3(q, zaxis); + cross_v3_v3v3(cross, zaxis, bevp1->dir); + axis_angle_to_quat(q2, cross, angle_normalized_v3v3(zaxis, bevp1->dir)); + normalize_qt(q2); QUATCOPY(bevp0_quat, bevp1->quat); - QuatMul(q, q2, q); - QuatInterpol(bevp1->quat, bevp1->quat, q, 0.5); - NormalQuat(bevp1->quat); + mul_qt_qtqt(q, q2, q); + interp_qt_qtqt(bevp1->quat, bevp1->quat, q, 0.5); + normalize_qt(bevp1->quat); bevp0= bevp1; @@ -1715,8 +1716,8 @@ static void make_bevel_list_3D_zup(BevList *bl) nr= bl->nr; while(nr--) { /* totally simple */ - VecBisect3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec); - vectoquat(bevp1->dir, 5, 1, bevp1->quat); + bisect_v3_v3v3v3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec); + vec_to_quat( bevp1->quat,bevp1->dir, 5, 1); bevp0= bevp1; bevp1= bevp2; @@ -1742,15 +1743,15 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) while(nr--) { if(nr+4 > bl->nr) { /* first time and second time, otherwise first point adjusts last */ - vectoquat(bevp1->dir, 5, 1, bevp1->quat); + vec_to_quat( bevp1->quat,bevp1->dir, 5, 1); } else { - float angle= NormalizedVecAngle2(bevp0->dir, bevp1->dir); + float angle= angle_normalized_v3v3(bevp0->dir, bevp1->dir); if(angle > 0.0f) { /* otherwise we can keep as is */ - Crossf(cross_tmp, bevp0->dir, bevp1->dir); - AxisAngleToQuat(q, cross_tmp, angle); - QuatMul(bevp1->quat, q, bevp0->quat); + cross_v3_v3v3(cross_tmp, bevp0->dir, bevp1->dir); + axis_angle_to_quat(q, cross_tmp, angle); + mul_qt_qtqt(bevp1->quat, q, bevp0->quat); } else { QUATCOPY(bevp1->quat, bevp0->quat); @@ -1787,26 +1788,26 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) bevp_last--; /* quats and vec's are normalized, should not need to re-normalize */ - QuatMulVecf(bevp_first->quat, vec_1); - QuatMulVecf(bevp_last->quat, vec_2); - Normalize(vec_1); - Normalize(vec_2); + mul_qt_v3(bevp_first->quat, vec_1); + mul_qt_v3(bevp_last->quat, vec_2); + normalize_v3(vec_1); + normalize_v3(vec_2); /* align the vector, can avoid this and it looks 98% OK but * better to align the angle quat roll's before comparing */ { - Crossf(cross_tmp, bevp_last->dir, bevp_first->dir); - angle = NormalizedVecAngle2(bevp_first->dir, bevp_last->dir); - AxisAngleToQuat(q, cross_tmp, angle); - QuatMulVecf(q, vec_2); + cross_v3_v3v3(cross_tmp, bevp_last->dir, bevp_first->dir); + angle = angle_normalized_v3v3(bevp_first->dir, bevp_last->dir); + axis_angle_to_quat(q, cross_tmp, angle); + mul_qt_v3(q, vec_2); } - angle= NormalizedVecAngle2(vec_1, vec_2); + angle= angle_normalized_v3v3(vec_1, vec_2); /* flip rotation if needs be */ - Crossf(cross_tmp, vec_1, vec_2); - Normalize(cross_tmp); - if(NormalizedVecAngle2(bevp_first->dir, cross_tmp) < 90/(180.0/M_PI)) + cross_v3_v3v3(cross_tmp, vec_1, vec_2); + normalize_v3(cross_tmp); + if(angle_normalized_v3v3(bevp_first->dir, cross_tmp) < 90/(180.0/M_PI)) angle = -angle; bevp2= (BevPoint *)(bl+1); @@ -1817,8 +1818,8 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) while(nr--) { ang_fac= angle * (1.0f-((float)nr/bl->nr)); /* also works */ - AxisAngleToQuat(q, bevp1->dir, ang_fac); - QuatMul(bevp1->quat, q, bevp1->quat); + axis_angle_to_quat(q, bevp1->dir, ang_fac); + mul_qt_qtqt(bevp1->quat, q, bevp1->quat); bevp0= bevp1; bevp1= bevp2; @@ -1847,9 +1848,9 @@ static void make_bevel_list_3D_tangent(BevList *bl) nr= bl->nr; while(nr--) { - Crossf(cross_tmp, bevp1->tan, bevp1->dir); - Crossf(bevp1->tan, cross_tmp, bevp1->dir); - Normalize(bevp1->tan); + cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir); + cross_v3_v3v3(bevp1->tan, cross_tmp, bevp1->dir); + normalize_v3(bevp1->tan); bevp0= bevp1; bevp1= bevp2; @@ -1871,9 +1872,9 @@ static void make_bevel_list_3D_tangent(BevList *bl) float cross_tmp[3]; float zero[3] = {0,0,0}; - Crossf(cross_tmp, bevp1->tan, bevp1->dir); - Normalize(cross_tmp); - triatoquat(zero, cross_tmp, bevp1->tan, bevp1->quat); /* XXX - could be faster */ + cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir); + normalize_v3(cross_tmp); + tri_to_quat( bevp1->quat,zero, cross_tmp, bevp1->tan); /* XXX - could be faster */ bevp0= bevp1; bevp1= bevp2; @@ -2279,14 +2280,14 @@ void makeBevelList(Object *ob) bevp1= bevp2+1; /* simple quat/dir */ - VecSubf(bevp1->dir, bevp1->vec, bevp2->vec); - Normalize(bevp1->dir); + sub_v3_v3v3(bevp1->dir, bevp1->vec, bevp2->vec); + normalize_v3(bevp1->dir); - vectoquat(bevp1->dir, 5, 1, bevp1->quat); + vec_to_quat( bevp1->quat,bevp1->dir, 5, 1); - AxisAngleToQuat(q, bevp1->dir, bevp1->alfa); - QuatMul(bevp1->quat, q, bevp1->quat); - NormalQuat(bevp1->quat); + axis_angle_to_quat(q, bevp1->dir, bevp1->alfa); + mul_qt_qtqt(bevp1->quat, q, bevp1->quat); + normalize_qt(bevp1->quat); VECCOPY(bevp2->dir, bevp1->dir); QUATCOPY(bevp2->quat, bevp1->quat); } @@ -2420,10 +2421,10 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) if(leftviolate || rightviolate) { /* align left handle */ float h1[3], h2[3]; - VecSubf(h1, p2-3, p2); - VecSubf(h2, p2, p2+3); - len1= Normalize(h1); - len2= Normalize(h2); + sub_v3_v3v3(h1, p2-3, p2); + sub_v3_v3v3(h2, p2, p2+3); + len1= normalize_v3(h1); + len2= normalize_v3(h2); vz= INPR(h1, h2); @@ -2459,8 +2460,8 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) *(p2+5)= *(p2+2)+dz1; } - len2= VecLenf(p2, p2+3); - len1= VecLenf(p2, p2-3); + len2= len_v3v3(p2, p2+3); + len1= len_v3v3(p2, p2-3); if(len1==0.0) len1=1.0; if(len2==0.0) len2=1.0; @@ -2587,18 +2588,18 @@ void autocalchandlesNurb(Nurb *nu, int flag) if(flag==0 || (bezt1->f1 & flag) ) { bezt1->h1= 0; /* distance too short: vectorhandle */ - if( VecLenf( bezt1->vec[1], bezt0->vec[1] ) < 0.0001) { + if( len_v3v3( bezt1->vec[1], bezt0->vec[1] ) < 0.0001) { bezt1->h1= HD_VECT; leftsmall= 1; } else { /* aligned handle? */ - if(DistVL2Dfl(bezt1->vec[1], bezt1->vec[0], bezt1->vec[2]) < 0.0001) { + if(dist_to_line_v2(bezt1->vec[1], bezt1->vec[0], bezt1->vec[2]) < 0.0001) { align= 1; bezt1->h1= HD_ALIGN; } /* or vector handle? */ - if(DistVL2Dfl(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001) + if(dist_to_line_v2(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001) bezt1->h1= HD_VECT; } @@ -2607,7 +2608,7 @@ void autocalchandlesNurb(Nurb *nu, int flag) if(flag==0 || (bezt1->f3 & flag) ) { bezt1->h2= 0; /* distance too short: vectorhandle */ - if( VecLenf( bezt1->vec[1], bezt2->vec[1] ) < 0.0001) { + if( len_v3v3( bezt1->vec[1], bezt2->vec[1] ) < 0.0001) { bezt1->h2= HD_VECT; rightsmall= 1; } @@ -2616,7 +2617,7 @@ void autocalchandlesNurb(Nurb *nu, int flag) if(align) bezt1->h2= HD_ALIGN; /* or vector handle? */ - if(DistVL2Dfl(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001) + if(dist_to_line_v2(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001) bezt1->h2= HD_VECT; } diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 28aaadea9c3..7b754025b6c 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -34,7 +34,7 @@ #include "BKE_customdata.h" #include "BKE_utildefines.h" // CLAMP -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_linklist.h" #include "BLI_mempool.h" @@ -410,21 +410,21 @@ static void mdisps_bilinear(float out[3], float (*disps)[3], int st, float u, fl vrat = v - y; uopp = 1 - urat; - VecCopyf(d[0], disps[y * st + x]); - VecCopyf(d[1], disps[y * st + x2]); - VecCopyf(d[2], disps[y2 * st + x]); - VecCopyf(d[3], disps[y2 * st + x2]); - VecMulf(d[0], uopp); - VecMulf(d[1], urat); - VecMulf(d[2], uopp); - VecMulf(d[3], urat); + copy_v3_v3(d[0], disps[y * st + x]); + copy_v3_v3(d[1], disps[y * st + x2]); + copy_v3_v3(d[2], disps[y2 * st + x]); + copy_v3_v3(d[3], disps[y2 * st + x2]); + mul_v3_fl(d[0], uopp); + mul_v3_fl(d[1], urat); + mul_v3_fl(d[2], uopp); + mul_v3_fl(d[3], urat); - VecAddf(d2[0], d[0], d[1]); - VecAddf(d2[1], d[2], d[3]); - VecMulf(d2[0], 1 - vrat); - VecMulf(d2[1], vrat); + add_v3_v3v3(d2[0], d[0], d[1]); + add_v3_v3v3(d2[1], d[2], d[3]); + mul_v3_fl(d2[0], 1 - vrat); + mul_v3_fl(d2[1], vrat); - VecAddf(out, d2[0], d2[1]); + add_v3_v3v3(out, d2[0], d2[1]); } static void layerSwap_mdisps(void *data, int *ci) @@ -440,7 +440,7 @@ static void layerSwap_mdisps(void *data, int *ci) for(y = 0; y < st; ++y) { for(x = 0; x < st; ++x) { - VecCopyf(d[(st - y - 1) * st + (st - x - 1)], s->disps[y * st + x]); + copy_v3_v3(d[(st - y - 1) * st + (st - x - 1)], s->disps[y * st + x]); } } @@ -462,7 +462,7 @@ static void layerInterp_mdisps(void **sources, float *weights, float *sub_weight /* Initialize the destination */ for(i = 0; i < d->totdisp; ++i) { float z[3] = {0,0,0}; - VecCopyf(d->disps[i], z); + copy_v3_v3(d->disps[i], z); } /* For now, some restrictions on the input */ @@ -493,7 +493,7 @@ static void layerInterp_mdisps(void **sources, float *weights, float *sub_weight float srcdisp[3]; mdisps_bilinear(srcdisp, s->disps, st, mid3[0], mid3[1]); - VecCopyf(d->disps[y * st + x], srcdisp); + copy_v3_v3(d->disps[y * st + x], srcdisp); } } } diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index b7949a6e06f..c1e45243bb5 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -59,7 +59,7 @@ #include "BKE_mesh.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #ifdef HAVE_CONFIG_H #include <config.h> diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 36568ee5667..8b848ac5371 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -34,7 +34,7 @@ #endif #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_anim_types.h" #include "DNA_action_types.h" diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 64af08d6f6a..48fb283c404 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -56,7 +56,7 @@ #include "DNA_key_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_edgehash.h" @@ -220,12 +220,12 @@ void addnormalsDispList(Object *ob, ListBase *lb) for(; b<dl->nr; b++) { - CalcNormFloat4(v1, v3, v4, v2, nor); + normal_quad_v3( nor,v1, v3, v4, v2); - VecAddf(n1, n1, nor); - VecAddf(n2, n2, nor); - VecAddf(n3, n3, nor); - VecAddf(n4, n4, nor); + add_v3_v3v3(n1, n1, nor); + add_v3_v3v3(n2, n2, nor); + add_v3_v3v3(n3, n3, nor); + add_v3_v3v3(n4, n4, nor); v2= v1; v1+= 3; v4= v3; v3+= 3; @@ -236,7 +236,7 @@ void addnormalsDispList(Object *ob, ListBase *lb) a= dl->parts*dl->nr; v1= ndata; while(a--) { - Normalize(v1); + normalize_v3(v1); v1+= 3; } } @@ -475,11 +475,11 @@ static void init_fastshade_for_ob(Render *re, Object *ob, int *need_orco_r, floa init_fastshade_shadeinput(re); RE_DataBase_GetView(re, tmat); - Mat4MulMat4(mat, ob->obmat, tmat); + mul_m4_m4m4(mat, ob->obmat, tmat); - Mat4Invert(tmat, mat); - Mat3CpyMat4(imat, tmat); - if(ob->transflag & OB_NEG_SCALE) Mat3MulFloat((float *)imat, -1.0); + invert_m4_m4(tmat, mat); + copy_m3_m4(imat, tmat); + if(ob->transflag & OB_NEG_SCALE) mul_m3_fl(imat, -1.0); if (need_orco_r) *need_orco_r= 0; for(a=0; a<ob->totcol; a++) { @@ -563,7 +563,7 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un vn[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn; vn[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn; vn[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn; - Normalize(vn); + normalize_v3(vn); } for (i=0; i<totface; i++) { @@ -586,15 +586,15 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un VECCOPY(nor, &nors[i*3]); } else { if (mf->v4) - CalcNormFloat4(mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co, nor); + normal_quad_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co); else - CalcNormFloat(mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, nor); + normal_tri_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co); } n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - Normalize(n1); + normalize_v3(n1); for (j=0; j<nverts; j++) { MVert *mv= &mvert[vidx[j]]; @@ -603,7 +603,7 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un float *vn = (mf->flag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1; VECCOPY(vec, mv->co); - Mat4MulVecfl(mat, vec); + mul_m4_v3(mat, vec); vec[0]+= 0.001*vn[0]; vec[1]+= 0.001*vn[1]; vec[2]+= 0.001*vn[2]; @@ -708,14 +708,14 @@ void shadeDispList(Scene *scene, Base *base) n1[0]= imat[0][0]*dl->nors[0]+imat[0][1]*dl->nors[1]+imat[0][2]*dl->nors[2]; n1[1]= imat[1][0]*dl->nors[0]+imat[1][1]*dl->nors[1]+imat[1][2]*dl->nors[2]; n1[2]= imat[2][0]*dl->nors[0]+imat[2][1]*dl->nors[1]+imat[2][2]*dl->nors[2]; - Normalize(n1); + normalize_v3(n1); fp= dl->verts; a= dl->nr; while(a--) { VECCOPY(vec, fp); - Mat4MulVecfl(mat, vec); + mul_m4_v3(mat, vec); fastshade(vec, n1, fp, ma, (char *)col1, NULL); @@ -731,12 +731,12 @@ void shadeDispList(Scene *scene, Base *base) while(a--) { VECCOPY(vec, fp); - Mat4MulVecfl(mat, vec); + mul_m4_v3(mat, vec); n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - Normalize(n1); + normalize_v3(n1); fastshade(vec, n1, fp, ma, (char *)col1, NULL); @@ -769,13 +769,13 @@ void shadeDispList(Scene *scene, Base *base) a= dl->nr; while(a--) { VECCOPY(vec, fp); - Mat4MulVecfl(mat, vec); + mul_m4_v3(mat, vec); /* transpose ! */ n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - Normalize(n1); + normalize_v3(n1); fastshade(vec, n1, fp, ma, (char *)col1, NULL); @@ -1612,7 +1612,7 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) vec[1]= fp1[2]; vec[2]= 0.0; - QuatMulVecf(bevp->quat, vec); + mul_qt_v3(bevp->quat, vec); data[0]= bevp->vec[0] + fac*vec[0]; data[1]= bevp->vec[1] + fac*vec[1]; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 9b648e2c05c..6d63553396d 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -52,7 +52,7 @@ #include "DNA_texture_types.h" #include "DNA_scene_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_jitter.h" #include "BLI_listbase.h" @@ -221,8 +221,8 @@ static void precalculate_effector(EffectorCache *eff) if(cu->path && cu->path->data) { where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius); - Mat4MulVecfl(eff->ob->obmat, eff->guide_loc); - Mat4Mul3Vecfl(eff->ob->obmat, eff->guide_dir); + mul_m4_v3(eff->ob->obmat, eff->guide_loc); + mul_mat3_m4_v3(eff->ob->obmat, eff->guide_dir); } } } @@ -433,8 +433,8 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect return visibility; VECCOPY(norm, efd->vec_to_point); - VecNegf(norm); - len = Normalize(norm); + negate_v3(norm); + len = normalize_v3(norm); // check all collision objects for(col = colls->first; col; col = col->next) @@ -520,7 +520,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *poi float falloff = weights ? weights->weight[0] * weights->weight[eff->pd->forcefield] : 1.0f; float fac, r_fac; - fac = Inpf(efd->nor, efd->vec_to_point2); + fac = dot_v3v3(efd->nor, efd->vec_to_point2); if(eff->pd->zdir == PFIELD_Z_POS && fac < 0.0f) falloff=0.0f; @@ -537,7 +537,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *poi break; VECADDFAC(temp, efd->vec_to_point, efd->nor, -fac); - r_fac= VecLength(temp); + r_fac= len_v3(temp); falloff*= falloff_func_rad(eff->pd, r_fac); break; case PFIELD_FALL_CONE: @@ -545,7 +545,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *poi if(falloff == 0.0f) break; - r_fac=saacos(fac/VecLength(efd->vec_to_point))*180.0f/(float)M_PI; + r_fac=saacos(fac/len_v3(efd->vec_to_point))*180.0f/(float)M_PI; falloff*= falloff_func_rad(eff->pd, r_fac); break; @@ -574,12 +574,12 @@ int closest_point_on_surface(SurfaceModifierData *surmd, float *co, float *surfa MFace *mface = CDDM_get_face(surmd->dm, nearest.index); VECCOPY(surface_vel, surmd->v[mface->v1].co); - VecAddf(surface_vel, surface_vel, surmd->v[mface->v2].co); - VecAddf(surface_vel, surface_vel, surmd->v[mface->v3].co); + add_v3_v3v3(surface_vel, surface_vel, surmd->v[mface->v2].co); + add_v3_v3v3(surface_vel, surface_vel, surmd->v[mface->v3].co); if(mface->v4) - VecAddf(surface_vel, surface_vel, surmd->v[mface->v4].co); + add_v3_v3v3(surface_vel, surface_vel, surmd->v[mface->v4].co); - VecMulf(surface_vel, mface->v4 ? 0.25f : 0.333f); + mul_v3_fl(surface_vel, mface->v4 ? 0.25f : 0.333f); } return 1; } @@ -596,9 +596,9 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin float vec[3]; /* using velocity corrected location allows for easier sliding over effector surface */ - VecCopyf(vec, point->vel); - VecMulf(vec, point->vel_to_frame); - VecAddf(vec, vec, point->loc); + copy_v3_v3(vec, point->vel); + mul_v3_fl(vec, point->vel_to_frame); + add_v3_v3v3(vec, vec, point->loc); ret = closest_point_on_surface(eff->surmd, vec, efd->loc, efd->nor, real_velocity ? efd->vel : NULL); @@ -612,10 +612,10 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin dm->getVertCo(dm, *efd->index, efd->loc); dm->getVertNo(dm, *efd->index, efd->nor); - Mat4MulVecfl(eff->ob->obmat, efd->loc); - Mat4Mul3Vecfl(eff->ob->obmat, efd->nor); + mul_m4_v3(eff->ob->obmat, efd->loc); + mul_mat3_m4_v3(eff->ob->obmat, efd->nor); - Normalize(efd->nor); + normalize_v3(efd->nor); efd->size = 0.0f; @@ -660,15 +660,15 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin /* use z-axis as normal*/ VECCOPY(efd->nor, ob->obmat[2]); - Normalize(efd->nor); + normalize_v3(efd->nor); /* for vortex the shape chooses between old / new force */ if(eff->pd->shape == PFIELD_SHAPE_PLANE) { /* efd->loc is closes point on effector xy-plane */ float temp[3]; - VecSubf(temp, point->loc, ob->obmat[3]); - Projf(efd->loc, temp, efd->nor); - VecSubf(efd->loc, point->loc, efd->loc); + sub_v3_v3v3(temp, point->loc, ob->obmat[3]); + project_v3_v3v3(efd->loc, temp, efd->nor); + sub_v3_v3v3(efd->loc, point->loc, efd->loc); } else { VECCOPY(efd->loc, ob->obmat[3]); @@ -679,7 +679,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin where_is_object_time(eff->scene, ob, cfra - 1.0); - VecSubf(efd->vel, efd->vel, ob->obmat[3]); + sub_v3_v3v3(efd->vel, efd->vel, ob->obmat[3]); } *eff->ob = obcopy; @@ -690,8 +690,8 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin } if(ret) { - VecSubf(efd->vec_to_point, point->loc, efd->loc); - efd->distance = VecLength(efd->vec_to_point); + sub_v3_v3v3(efd->vec_to_point, point->loc, efd->loc); + efd->distance = len_v3(efd->vec_to_point); if(eff->flag & PE_USE_NORMAL_DATA) { VECCOPY(efd->vec_to_point2, efd->vec_to_point); @@ -699,9 +699,9 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin } else { /* for some effectors we need the object center every time */ - VecSubf(efd->vec_to_point2, point->loc, eff->ob->obmat[3]); + sub_v3_v3v3(efd->vec_to_point2, point->loc, eff->ob->obmat[3]); VECCOPY(efd->nor2, eff->ob->obmat[2]); - Normalize(efd->nor2); + normalize_v3(efd->nor2); } } @@ -764,12 +764,12 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP VECCOPY(tex_co,point->loc); if(eff->pd->flag & PFIELD_TEX_2D) { - float fac=-Inpf(tex_co, efd->nor); + float fac=-dot_v3v3(tex_co, efd->nor); VECADDFAC(tex_co, tex_co, efd->nor, fac); } if(eff->pd->flag & PFIELD_TEX_OBJECT) { - Mat4Mul3Vecfl(eff->ob->obmat, tex_co); + mul_mat3_m4_v3(eff->ob->obmat, tex_co); } hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL,NULL, 1, result); @@ -815,11 +815,11 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP } if(eff->pd->flag & PFIELD_TEX_2D){ - float fac = -Inpf(force, efd->nor); + float fac = -dot_v3v3(force, efd->nor); VECADDFAC(force, force, efd->nor, fac); } - VecAddf(total_force, total_force, force); + add_v3_v3v3(total_force, total_force, force); } void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, float *total_force) { @@ -844,51 +844,51 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint * switch(pd->forcefield){ case PFIELD_WIND: VECCOPY(force, efd->nor); - VecMulf(force, strength * efd->falloff); + mul_v3_fl(force, strength * efd->falloff); break; case PFIELD_FORCE: - Normalize(force); - VecMulf(force, strength * efd->falloff); + normalize_v3(force); + mul_v3_fl(force, strength * efd->falloff); break; case PFIELD_VORTEX: /* old vortex force */ if(pd->shape == PFIELD_SHAPE_POINT) { - Crossf(force, efd->nor, efd->vec_to_point); - Normalize(force); - VecMulf(force, strength * efd->distance * efd->falloff); + cross_v3_v3v3(force, efd->nor, efd->vec_to_point); + normalize_v3(force); + mul_v3_fl(force, strength * efd->distance * efd->falloff); } else { /* new vortex force */ - Crossf(temp, efd->nor2, efd->vec_to_point2); - VecMulf(temp, strength * efd->falloff); + cross_v3_v3v3(temp, efd->nor2, efd->vec_to_point2); + mul_v3_fl(temp, strength * efd->falloff); - Crossf(force, efd->nor2, temp); - VecMulf(force, strength * efd->falloff); + cross_v3_v3v3(force, efd->nor2, temp); + mul_v3_fl(force, strength * efd->falloff); VECADDFAC(temp, temp, point->vel, -point->vel_to_sec); - VecAddf(force, force, temp); + add_v3_v3v3(force, force, temp); } break; case PFIELD_MAGNET: if(eff->pd->shape == PFIELD_SHAPE_POINT) /* magnetic field of a moving charge */ - Crossf(temp, efd->nor, efd->vec_to_point); + cross_v3_v3v3(temp, efd->nor, efd->vec_to_point); else - VecCopyf(temp, efd->nor); + copy_v3_v3(temp, efd->nor); - Normalize(temp); - VecMulf(temp, strength * efd->falloff); - Crossf(force, point->vel, temp); - VecMulf(force, point->vel_to_sec); + normalize_v3(temp); + mul_v3_fl(temp, strength * efd->falloff); + cross_v3_v3v3(force, point->vel, temp); + mul_v3_fl(force, point->vel_to_sec); break; case PFIELD_HARMONIC: - VecMulf(force, -strength * efd->falloff); - VecCopyf(temp, point->vel); - VecMulf(temp, -damp * 2.0f * (float)sqrt(fabs(strength)) * point->vel_to_sec); - VecAddf(force, force, temp); + mul_v3_fl(force, -strength * efd->falloff); + copy_v3_v3(temp, point->vel); + mul_v3_fl(temp, -damp * 2.0f * (float)sqrt(fabs(strength)) * point->vel_to_sec); + add_v3_v3v3(force, force, temp); break; case PFIELD_CHARGE: - VecMulf(force, point->charge * strength * efd->falloff); + mul_v3_fl(force, point->charge * strength * efd->falloff); break; case PFIELD_LENNARDJ: fac = pow((efd->size + point->size) / efd->distance, 6.0); @@ -898,7 +898,7 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint * /* limit the repulsive term drastically to avoid huge forces */ fac = ((fac>2.0) ? 2.0 : fac); - VecMulf(force, strength * fac); + mul_v3_fl(force, strength * fac); break; case PFIELD_BOID: /* Boid field is handled completely in boids code. */ @@ -913,16 +913,16 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint * force[0] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[0], temp[1], temp[2], 2,0,2); force[1] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[1], temp[2], temp[0], 2,0,2); force[2] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[2], temp[0], temp[1], 2,0,2); - VecMulf(force, strength * efd->falloff); + mul_v3_fl(force, strength * efd->falloff); break; case PFIELD_DRAG: VECCOPY(force, point->vel); - fac = Normalize(force) * point->vel_to_sec; + fac = normalize_v3(force) * point->vel_to_sec; strength = MIN2(strength, 2.0f); damp = MIN2(damp, 2.0f); - VecMulf(force, -efd->falloff * fac * (strength * fac + damp)); + mul_v3_fl(force, -efd->falloff * fac * (strength * fac + damp)); break; } @@ -937,12 +937,12 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint * if(pd->flag & PFIELD_DO_ROTATION && point->ave && point->rot) { float xvec[3] = {1.0f, 0.0f, 0.0f}; float dave[3]; - QuatMulVecf(point->rot, xvec); - Crossf(dave, xvec, force); + mul_qt_v3(point->rot, xvec); + cross_v3_v3v3(dave, xvec, force); if(pd->f_flow != 0.0f) { VECADDFAC(dave, dave, point->ave, -pd->f_flow * efd->falloff); } - VecAddf(point->ave, point->ave, dave); + add_v3_v3v3(point->ave, point->ave, dave); } } diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 8827897a509..48a05c2f6a7 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -64,7 +64,7 @@ #include "BKE_utildefines.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BKE_blender.h" @@ -180,7 +180,7 @@ static void mesh_add_normals_flags(Mesh *me) v3= me->mvert+mface->v3; v4= me->mvert+mface->v4; - CalcNormFloat(v1->co, v2->co, v3->co, nor); + normal_tri_v3( nor,v1->co, v2->co, v3->co); sno[0]= 32767.0*nor[0]; sno[1]= 32767.0*nor[1]; sno[2]= 32767.0*nor[2]; @@ -1249,7 +1249,7 @@ static void read_inventor(Scene *scene, char *str, struct ListBase *listb) VECCOPY(bp->vec, data); if(coordtype==4) { bp->vec[3]= data[3]; - VecMulf(bp->vec, 1.0f/data[3]); + mul_v3_fl(bp->vec, 1.0f/data[3]); } else bp->vec[3]= 1.0; data+= coordtype; @@ -1837,7 +1837,7 @@ static void write_vert_stl(Object *ob, MVert *verts, int index, FILE *fpSTL) float vert[3]; VECCOPY(vert, verts[(index)].co); - Mat4MulVecfl(ob->obmat, vert); + mul_m4_v3(ob->obmat, vert); if (ENDIAN_ORDER==B_ENDIAN) { SWITCH_INT(vert[0]); @@ -2174,7 +2174,7 @@ static void write_camera_vrml(FILE *fp, Object *ob) Camera *cam; if(ob==0) return; - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); fprintf(fp, "\tMatrixTransform {\n"); @@ -3031,10 +3031,10 @@ static void dxf_read_line(Scene *scene, int noob) { mvert= &me->mvert[(me->totvert-2)]; - VecSubf(mvert->co, cent, vcenter); + sub_v3_v3v3(mvert->co, cent, vcenter); mvert++; if (vspace) { VECCOPY(mvert->co, epoint); - } else VecSubf(mvert->co, epoint, vcenter); + } else sub_v3_v3v3(mvert->co, epoint, vcenter); mface= &(((MFace*)me->mface)[me->totface-1]); mface->v1= me->totvert-2; @@ -3237,7 +3237,7 @@ static void dxf_read_ellipse(Scene *scene, int noob) if (vspace) { VECCOPY(mvert->co, epoint); } else { - VecSubf(mvert->co, epoint, vcenter); + sub_v3_v3v3(mvert->co, epoint, vcenter); } if (v > 0) { @@ -3360,7 +3360,7 @@ static void dxf_read_arc(Scene *scene, int noob) if (vspace) { VECCOPY(mvert->co, epoint); } else { - VecSubf(mvert->co, epoint, vcenter); + sub_v3_v3v3(mvert->co, epoint, vcenter); } if (v > 0) { @@ -3470,7 +3470,7 @@ static void dxf_read_polyline(Scene *scene, int noob) { mvert= &me->mvert[me->totvert-1]; if (vspace) { VECCOPY(mvert->co, vert); - } else VecSubf(mvert->co, vert, vcenter); + } else sub_v3_v3v3(mvert->co, vert, vcenter); } /* make edges */ @@ -3556,7 +3556,7 @@ static void dxf_read_polyline(Scene *scene, int noob) { mvert= &me->mvert[(me->totvert-1)]; if (vspace) { VECCOPY(mvert->co, vert); - } else VecSubf(mvert->co, vert, vcenter); + } else sub_v3_v3v3(mvert->co, vert, vcenter); } else if (vflags & 128) { if(vids[2]==0) { @@ -3687,7 +3687,7 @@ static void dxf_read_lwpolyline(Scene *scene, int noob) { if (vspace) { VECCOPY(mvert->co, vert); } else { - VecSubf(mvert->co, vert, vcenter); + sub_v3_v3v3(mvert->co, vert, vcenter); } if (v > 0) { @@ -3859,20 +3859,20 @@ static void dxf_read_3dface(Scene *scene, int noob) ftmp=NULL; mvert= &me->mvert[(me->totvert-nverts)]; - VecSubf(mvert->co, cent, vcenter); + sub_v3_v3v3(mvert->co, cent, vcenter); mvert++; if (vspace) { VECCOPY(mvert->co, vert2); - } else VecSubf(mvert->co, vert2, vcenter); + } else sub_v3_v3v3(mvert->co, vert2, vcenter); mvert++; if (vspace) { VECCOPY(mvert->co, vert3); - } else VecSubf(mvert->co, vert3, vcenter); + } else sub_v3_v3v3(mvert->co, vert3, vcenter); if (nverts==4) { mvert++; if (vspace) { VECCOPY(mvert->co, vert4); - } else VecSubf(mvert->co, vert4, vcenter); + } else sub_v3_v3v3(mvert->co, vert4, vcenter); } mface= &(((MFace*)me->mface)[me->totface-1]); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 0ecd1fe912b..a1e6570608f 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -43,7 +43,7 @@ #include "DNA_anim_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_noise.h" #include "BKE_fcurve.h" @@ -924,11 +924,11 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime) } /* use the final posed locations */ - Mat4ToQuat(pchan->pose_mat, q1); - Mat4ToQuat(pchan2->pose_mat, q2); + mat4_to_quat( q1,pchan->pose_mat); + mat4_to_quat( q2,pchan2->pose_mat); - QuatInv(q1); - QuatMul(quat, q1, q2); + invert_qt(q1); + mul_qt_qtqt(quat, q1, q2); angle = 2.0f * (saacos(quat[0])); angle= ABS(angle); @@ -1017,13 +1017,13 @@ static int findzero (float x, float q0, float q1, float q2, float q3, float *o) if (d > 0.0) { t= sqrt(d); - o[0]= (float)(Sqrt3d(-q+t) + Sqrt3d(-q-t) - a); + o[0]= (float)(sqrt3d(-q+t) + sqrt3d(-q-t) - a); if ((o[0] >= SMALL) && (o[0] <= 1.000001)) return 1; else return 0; } else if (d == 0.0) { - t= Sqrt3d(-q); + t= sqrt3d(-q); o[0]= (float)(2*t - a); if ((o[0] >= SMALL) && (o[0] <= 1.000001)) nr++; diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index aa163b821c8..9453c2a0ad1 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -40,7 +40,7 @@ #include "DNA_particle_types.h" #include "DNA_scene_types.h" // N_T -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BKE_cdderivedmesh.h" @@ -563,13 +563,13 @@ void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4], float vec[3]; VECCOPY(vec, mvert[0].co); - Mat4MulVecfl(obmat, vec); + mul_m4_v3(obmat, vec); bbsx = vec[0]; bbsy = vec[1]; bbsz = vec[2]; bbex = vec[0]; bbey = vec[1]; bbez = vec[2]; for(i = 1; i < totvert; i++) { VECCOPY(vec, mvert[i].co); - Mat4MulVecfl(obmat, vec); + mul_m4_v3(obmat, vec); if(vec[0] < bbsx){ bbsx= vec[0]; } if(vec[1] < bbsy){ bbsy= vec[1]; } @@ -626,7 +626,7 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob, verts = MEM_callocN( totvert*3*sizeof(float), "elbeemmesh_vertices"); for(i=0; i<totvert; i++) { VECCOPY( &verts[i*3], mvert[i].co); - if(useGlobalCoords) { Mat4MulVecfl(ob->obmat, &verts[i*3]); } + if(useGlobalCoords) { mul_m4_v3(ob->obmat, &verts[i*3]); } } *vertices = verts; diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 4e79f6238b5..f70de4983e3 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -41,7 +41,7 @@ #include "DNA_anim_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_noise.h" #include "BKE_fcurve.h" diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 4e05bf45d3d..e2dccf02b40 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -41,7 +41,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_vfontdata.h" @@ -968,12 +968,12 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) float minx, maxx, miny, maxy; float timeofs, sizefac; - Mat4Invert(imat, ob->obmat); - Mat3CpyMat4(imat3, imat); + invert_m4_m4(imat, ob->obmat); + copy_m3_m4(imat3, imat); - Mat3CpyMat4(cmat, cu->textoncurve->obmat); - Mat3MulMat3(cmat, cmat, imat3); - sizefac= Normalize(cmat[0])/cu->fsize; + copy_m3_m4(cmat, cu->textoncurve->obmat); + mul_m3_m3m3(cmat, cmat, imat3); + sizefac= normalize_v3(cmat[0])/cu->fsize; minx=miny= 1.0e20f; maxx=maxy= -1.0e20f; @@ -1042,7 +1042,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) where_on_path(cu->textoncurve, ctime, vec, tvec, NULL, NULL); where_on_path(cu->textoncurve, ctime+dtime, tvec, rotvec, NULL, NULL); - VecMulf(vec, sizefac); + mul_v3_fl(vec, sizefac); ct->rot= (float)(M_PI-atan2(rotvec[1], rotvec[0])); @@ -1196,7 +1196,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) vecyo[0] = ct->xof; vecyo[1] = ct->yof; vecyo[2] = 0; - Mat4MulVecfl(ob->obmat, vecyo); + mul_m4_v3(ob->obmat, vecyo); VECCOPY(ob->loc, vecyo); outta = 1; cu->sepchar = 0; diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 43c4137e73e..5023d87cef8 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -36,7 +36,7 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "DNA_listBase.h" diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index efe53f6f8ef..0452b38a2e5 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -61,7 +61,7 @@ #include "DNA_sequence_types.h" #include "DNA_userdef_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_threads.h" diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index de215ae4af9..f2b737fa3c2 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -297,6 +297,7 @@ DO_INLINE void sub_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], f /////////////////////////// // 3x3 matrix /////////////////////////// +#if 0 /* printf 3x3 matrix on console: for debug output */ static void print_fmatrix(float m3[3][3]) { @@ -304,6 +305,7 @@ static void print_fmatrix(float m3[3][3]) printf("%f\t%f\t%f\n",m3[1][0],m3[1][1],m3[1][2]); printf("%f\t%f\t%f\n\n",m3[2][0],m3[2][1],m3[2][2]); } +#endif /* copy 3x3 matrix */ DO_INLINE void cp_fmatrix(float to[3][3], float from[3][3]) @@ -972,6 +974,7 @@ DO_INLINE void BuildPPinv(fmatrix3x3 *lA, fmatrix3x3 *P, fmatrix3x3 *Pinv) } } +#if 0 /* // version 1.3 static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S, fmatrix3x3 *P, fmatrix3x3 *Pinv) @@ -1143,6 +1146,7 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector return iterations<conjgrad_looplimit; } +#endif // outer product is NOT cross product!!! DO_INLINE void dfdx_spring_type1(float to[3][3], float extent[3], float length, float L, float dot, float k) @@ -1550,28 +1554,28 @@ static void cloth_calc_force(ClothModifierData *clmd, float frame, lfVector *lF, CalcFloat(lX[mfaces[i].v1],lX[mfaces[i].v2],lX[mfaces[i].v3],triunnormal); VECCOPY(trinormal, triunnormal); - Normalize(trinormal); + normalize_v3(trinormal); // add wind from v1 VECCOPY(tmp, trinormal); - VecMulf(tmp, calculateVertexWindForce(winvec[mfaces[i].v1], triunnormal)); + mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v1], triunnormal)); VECADDS(lF[mfaces[i].v1], lF[mfaces[i].v1], tmp, factor); // add wind from v2 VECCOPY(tmp, trinormal); - VecMulf(tmp, calculateVertexWindForce(winvec[mfaces[i].v2], triunnormal)); + mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v2], triunnormal)); VECADDS(lF[mfaces[i].v2], lF[mfaces[i].v2], tmp, factor); // add wind from v3 VECCOPY(tmp, trinormal); - VecMulf(tmp, calculateVertexWindForce(winvec[mfaces[i].v3], triunnormal)); + mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v3], triunnormal)); VECADDS(lF[mfaces[i].v3], lF[mfaces[i].v3], tmp, factor); // add wind from v4 if(mfaces[i].v4) { VECCOPY(tmp, trinormal); - VecMulf(tmp, calculateVertexWindForce(winvec[mfaces[i].v4], triunnormal)); + mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v4], triunnormal)); VECADDS(lF[mfaces[i].v4], lF[mfaces[i].v4], tmp, factor); } } @@ -1652,7 +1656,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase if(verts [i].flags & CLOTH_VERT_FLAG_PINNED) { VECSUB(id->V[i], verts[i].xconst, verts[i].xold); - // VecMulf(id->V[i], clmd->sim_parms->stepsPerFrame); + // mul_v3_fl(id->V[i], clmd->sim_parms->stepsPerFrame); } } } @@ -1725,7 +1729,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase VECCOPY(id->Xnew[i], verts[i].tx); VECCOPY(id->Vnew[i], verts[i].tv); - VecMulf(id->Vnew[i], clmd->sim_parms->stepsPerFrame); + mul_v3_fl(id->Vnew[i], clmd->sim_parms->stepsPerFrame); } } diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 5dc26143533..9e9a1719952 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -70,7 +70,7 @@ #include "DNA_world_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_dynstr.h" #include "BKE_utildefines.h" diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 61f51d61e0b..0b067c6ef7b 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1192,11 +1192,11 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, int tot) #endif // XXX old animation system flag= setkeys(ctime, &key->block, k, t, 0); - + if(flag==0) - ; /* do_key(a, a+step, tot, (char *)out, key, k, t, 0); */ + do_key(a, a+step, tot, (char *)out, key, actkb, k, t, 0); else - ; /* cp_key(a, a+step, tot, (char *)out, key, k[2],0); */ + cp_key(a, a+step, tot, (char *)out, key, actkb, k[2], NULL, 0); } } else { diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index c53101299c6..dc548edbb25 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -39,7 +39,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_armature_types.h" #include "DNA_mesh_types.h" @@ -155,10 +155,10 @@ void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) /* prevent using deformed locations */ freedisplist(<Ob->disp); - Mat4CpyMat4(mat, ltOb->obmat); - Mat4One(ltOb->obmat); + copy_m4_m4(mat, ltOb->obmat); + unit_m4(ltOb->obmat); lattice_deform_verts(ltOb, NULL, NULL, vertexCos, uNew*vNew*wNew, NULL); - Mat4CpyMat4(ltOb->obmat, mat); + copy_m4_m4(ltOb->obmat, mat); lt->typeu = typeu; lt->typev = typev; @@ -310,18 +310,18 @@ void init_latt_deform(Object *oblatt, Object *ob) /* for example with a particle system: ob==0 */ if(ob==NULL) { /* in deformspace, calc matrix */ - Mat4Invert(lt->latmat, oblatt->obmat); + invert_m4_m4(lt->latmat, oblatt->obmat); /* back: put in deform array */ - Mat4Invert(imat, lt->latmat); + invert_m4_m4(imat, lt->latmat); } else { /* in deformspace, calc matrix */ - Mat4Invert(imat, oblatt->obmat); - Mat4MulMat4(lt->latmat, ob->obmat, imat); + invert_m4_m4(imat, oblatt->obmat); + mul_m4_m4m4(lt->latmat, ob->obmat, imat); /* back: put in deform array */ - Mat4Invert(imat, lt->latmat); + invert_m4_m4(imat, lt->latmat); } for(w=0,fw=lt->fw; w<lt->pntsw; w++,fw+=lt->dw) { @@ -337,7 +337,7 @@ void init_latt_deform(Object *oblatt, Object *ob) fp[2] = bp->vec[2] - fw; } - Mat4Mul3Vecfl(imat, fp); + mul_mat3_m4_v3(imat, fp); } } } @@ -356,7 +356,7 @@ void calc_latt_deform(Object *ob, float *co, float weight) /* co is in local coords, treat with latmat */ VECCOPY(vec, co); - Mat4MulVecfl(lt->latmat, vec); + mul_m4_v3(lt->latmat, vec); /* u v w coords */ @@ -456,15 +456,15 @@ typedef struct { static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd, int dloc) { - Mat4Invert(ob->imat, ob->obmat); - Mat4MulMat4(cd->objectspace, par->obmat, ob->imat); - Mat4Invert(cd->curvespace, cd->objectspace); - Mat3CpyMat4(cd->objectspace3, cd->objectspace); + invert_m4_m4(ob->imat, ob->obmat); + mul_m4_m4m4(cd->objectspace, par->obmat, ob->imat); + invert_m4_m4(cd->curvespace, cd->objectspace); + copy_m3_m4(cd->objectspace3, cd->objectspace); // offset vector for 'no smear' if(dloc) { - Mat4Invert(par->imat, par->obmat); - VecMat4MulVecfl(cd->dloc, par->imat, ob->obmat[3]); + invert_m4_m4(par->imat, par->obmat); + mul_v3_m4v3(cd->dloc, par->imat, ob->obmat[3]); } else cd->dloc[0]=cd->dloc[1]=cd->dloc[2]= 0.0f; @@ -497,15 +497,15 @@ static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir, float dvec[3]; if(ctime < 0.0) { - VecSubf(dvec, path->data[1].vec, path->data[0].vec); - VecMulf(dvec, ctime*(float)path->len); + sub_v3_v3v3(dvec, path->data[1].vec, path->data[0].vec); + mul_v3_fl(dvec, ctime*(float)path->len); VECADD(vec, vec, dvec); if(quat) QUATCOPY(quat, path->data[0].quat); if(radius) *radius= path->data[0].radius; } else if(ctime > 1.0) { - VecSubf(dvec, path->data[path->len-1].vec, path->data[path->len-2].vec); - VecMulf(dvec, (ctime-1.0)*(float)path->len); + sub_v3_v3v3(dvec, path->data[path->len-1].vec, path->data[path->len-2].vec); + mul_v3_fl(dvec, (ctime-1.0)*(float)path->len); VECADD(vec, vec, dvec); if(quat) QUATCOPY(quat, path->data[path->len-1].quat); if(radius) *radius= path->data[path->len-1].radius; @@ -570,28 +570,28 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C dir[cd->no_rot_axis-1]= 0.0f; /* -1 for compatibility with old track defines */ - vectoquat(dir, axis-1, upflag, quat); + vec_to_quat( quat,dir, axis-1, upflag); /* the tilt */ if(loc[3]!=0.0) { - Normalize(dir); + normalize_v3(dir); q[0]= (float)cos(0.5*loc[3]); fac= (float)sin(0.5*loc[3]); q[1]= -fac*dir[0]; q[2]= -fac*dir[1]; q[3]= -fac*dir[2]; - QuatMul(quat, q, quat); + mul_qt_qtqt(quat, q, quat); } #endif - static float q_x90d[4] = {0.70710676908493, 0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; AxisAngleToQuat(q, rot_axis, 90 * (M_PI / 180)); - static float q_y90d[4] = {0.70710676908493, 0.0, 0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; AxisAngleToQuat(q, rot_axis, 90 * (M_PI / 180)); - static float q_z90d[4] = {0.70710676908493, 0.0, 0.0, 0.70710676908493}; // float rot_axis[3]= {0,0,2}; AxisAngleToQuat(q, rot_axis, 90 * (M_PI / 180)); + static float q_x90d[4] = {0.70710676908493, 0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180)); + static float q_y90d[4] = {0.70710676908493, 0.0, 0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180)); + static float q_z90d[4] = {0.70710676908493, 0.0, 0.0, 0.70710676908493}; // float rot_axis[3]= {0,0,2}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180)); - static float q_nx90d[4] = {0.70710676908493, -0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; AxisAngleToQuat(q, rot_axis, -90 * (M_PI / 180)); - static float q_ny90d[4] = {0.70710676908493, 0.0, -0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; AxisAngleToQuat(q, rot_axis, -90 * (M_PI / 180)); - static float q_nz90d[4] = {0.70710676908493, 0.0, 0.0, -0.70710676908493}; // float rot_axis[3]= {0,0,2}; AxisAngleToQuat(q, rot_axis, -90 * (M_PI / 180)); + static float q_nx90d[4] = {0.70710676908493, -0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180)); + static float q_ny90d[4] = {0.70710676908493, 0.0, -0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180)); + static float q_nz90d[4] = {0.70710676908493, 0.0, 0.0, -0.70710676908493}; // float rot_axis[3]= {0,0,2}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180)); if(cd->no_rot_axis) { /* set by caller */ @@ -602,12 +602,12 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C VECCOPY(dir_flat, dir); dir_flat[cd->no_rot_axis-1]= 0.0f; - Normalize(dir); - Normalize(dir_flat); + normalize_v3(dir); + normalize_v3(dir_flat); - RotationBetweenVectorsToQuat(q, dir, dir_flat); /* Could this be done faster? */ + rotation_between_vecs_to_quat(q, dir, dir_flat); /* Could this be done faster? */ - QuatMul(new_quat, q, new_quat); + mul_qt_qtqt(new_quat, q, new_quat); } @@ -624,14 +624,14 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C switch(axis) { case MOD_CURVE_POSX: - QuatMul(quat, new_quat, q_y90d); + mul_qt_qtqt(quat, new_quat, q_y90d); cent[0]= 0.0; cent[1]= co[2]; cent[2]= co[1]; break; case MOD_CURVE_NEGX: - QuatMul(quat, new_quat, q_ny90d); + mul_qt_qtqt(quat, new_quat, q_ny90d); cent[0]= 0.0; cent[1]= -co[1]; @@ -639,28 +639,28 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C break; case MOD_CURVE_POSY: - QuatMul(quat, new_quat, q_x90d); + mul_qt_qtqt(quat, new_quat, q_x90d); cent[0]= co[2]; cent[1]= 0.0; cent[2]= -co[0]; break; case MOD_CURVE_NEGY: - QuatMul(quat, new_quat, q_nx90d); + mul_qt_qtqt(quat, new_quat, q_nx90d); cent[0]= -co[0]; cent[1]= 0.0; cent[2]= -co[2]; break; case MOD_CURVE_POSZ: - QuatMul(quat, new_quat, q_z90d); + mul_qt_qtqt(quat, new_quat, q_z90d); cent[0]= co[1]; cent[1]= -co[0]; cent[2]= 0.0; break; case MOD_CURVE_NEGZ: - QuatMul(quat, new_quat, q_nz90d); + mul_qt_qtqt(quat, new_quat, q_nz90d); cent[0]= co[0]; cent[1]= -co[1]; @@ -670,11 +670,11 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C /* scale if enabled */ if(cu->flag & CU_PATH_RADIUS) - VecMulf(cent, radius); + mul_v3_fl(cent, radius); /* local rotation */ - NormalQuat(quat); - QuatMulVecf(quat, cent); + normalize_qt(quat); + mul_qt_v3(quat, cent); /* translation */ VECADD(co, cent, loc); @@ -739,7 +739,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh for(j = 0; j < dvert->totweight; j++) { if(dvert->dw[j].def_nr == index) { - Mat4MulVecfl(cd.curvespace, vertexCos[a]); + mul_m4_v3(cd.curvespace, vertexCos[a]); DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax); break; } @@ -754,9 +754,9 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh if(dvert->dw[j].def_nr == index) { VECCOPY(vec, vertexCos[a]); calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL); - VecLerpf(vertexCos[a], vertexCos[a], vec, + interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, dvert->dw[j].weight); - Mat4MulVecfl(cd.objectspace, vertexCos[a]); + mul_m4_v3(cd.objectspace, vertexCos[a]); break; } } @@ -766,13 +766,13 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh INIT_MINMAX(cd.dmin, cd.dmax); for(a = 0; a < numVerts; a++) { - Mat4MulVecfl(cd.curvespace, vertexCos[a]); + mul_m4_v3(cd.curvespace, vertexCos[a]); DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax); } for(a = 0; a < numVerts; a++) { calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL); - Mat4MulVecfl(cd.objectspace, vertexCos[a]); + mul_m4_v3(cd.objectspace, vertexCos[a]); } } cu->flag = flag; @@ -787,7 +787,7 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target, float *orco float quat[4]; if(cuOb->type != OB_CURVE) { - Mat3One(mat); + unit_m3(mat); return; } @@ -797,18 +797,18 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target, float *orco VECCOPY(cd.dmin, orco); VECCOPY(cd.dmax, orco); - Mat4MulVecfl(cd.curvespace, vec); + mul_m4_v3(cd.curvespace, vec); if(calc_curve_deform(scene, cuOb, vec, target->trackflag+1, &cd, quat)) { float qmat[3][3]; - QuatToMat3(quat, qmat); - Mat3MulMat3(mat, qmat, cd.objectspace3); + quat_to_mat3( qmat,quat); + mul_m3_m3m3(mat, qmat, cd.objectspace3); } else - Mat3One(mat); + unit_m3(mat); - Mat4MulVecfl(cd.objectspace, vec); + mul_m4_v3(cd.objectspace, vec); } @@ -939,7 +939,7 @@ void outside_lattice(Lattice *lt) bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1]; bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2]; - VecMulf(bp->vec, 0.3333333f); + mul_v3_fl(bp->vec, 0.3333333f); } } diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index c2260e1e761..a3e0ab04991 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -46,7 +46,7 @@ #include "DNA_userdef_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_animsys.h" #include "BKE_blender.h" diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 3ca7dac4bc9..d731ab4230b 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -47,7 +47,7 @@ #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_utildefines.h" @@ -436,7 +436,7 @@ Object *find_basis_mball(Scene *scene, Object *basis) void calc_mballco(MetaElem *ml, float *vec) { if(ml->mat) { - Mat4MulVecfl((float ( * )[4])ml->mat, vec); + mul_m4_v3((float ( * )[4])ml->mat, vec); } } @@ -448,7 +448,7 @@ float densfunc(MetaElem *ball, float x, float y, float z) vec[0]= x; vec[1]= y; vec[2]= z; - Mat4MulVecfl((float ( * )[4])ball->imat, vec); + mul_m4_v3((float ( * )[4])ball->imat, vec); dx= vec[0]; dy= vec[1]; dz= vec[2]; @@ -1508,8 +1508,8 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ int a, obnr, zero_size=0; char obname[32]; - Mat4CpyMat4(obmat, ob->obmat); /* to cope with duplicators from next_object */ - Mat4Invert(obinv, ob->obmat); + copy_m4_m4(obmat, ob->obmat); /* to cope with duplicators from next_object */ + invert_m4_m4(obinv, ob->obmat); a= 0; splitIDname(ob->id.name+2, obname, &obnr); @@ -1581,15 +1581,15 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ if(ml->s > 10.0) ml->s = 10.0; /* Rotation of MetaElem is stored in quat */ - QuatToMat4(ml->quat, temp3); + quat_to_mat4( temp3,ml->quat); /* Translation of MetaElem */ - Mat4One(temp2); + unit_m4(temp2); temp2[3][0]= ml->x; temp2[3][1]= ml->y; temp2[3][2]= ml->z; - Mat4MulMat4(temp1, temp3, temp2); + mul_m4_m4m4(temp1, temp3, temp2); /* make a copy because of duplicates */ mainb[a]= new_pgn_element(sizeof(MetaElem)); @@ -1600,12 +1600,12 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ imat= new_pgn_element(4*4*sizeof(float)); /* mat is the matrix to transform from mball into the basis-mball */ - Mat4Invert(obinv, obmat); - Mat4MulMat4(temp2, bob->obmat, obinv); + invert_m4_m4(obinv, obmat); + mul_m4_m4m4(temp2, bob->obmat, obinv); /* MetaBall transformation */ - Mat4MulMat4(mat, temp1, temp2); + mul_m4_m4m4(mat, temp1, temp2); - Mat4Invert(imat,mat); + invert_m4_m4(imat,mat); mainb[a]->rad2= ml->rad*ml->rad; @@ -1648,7 +1648,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ /* transformation of Metalem bb */ for(i=0; i<8; i++) - Mat4MulVecfl((float ( * )[4])mat, mainb[a]->bb->vec[i]); + mul_m4_v3((float ( * )[4])mat, mainb[a]->bb->vec[i]); /* find max and min of transformed bb */ for(i=0; i<8; i++){ diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 6ef557ca879..d5c597b802c 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -70,7 +70,7 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_edgehash.h" @@ -1086,7 +1086,7 @@ void mesh_to_curve(Scene *scene, Object *ob) /* add points */ vl= polyline.first; for (i=0, bp=nu->bp; i < totpoly; i++, bp++, vl=(VertLink *)vl->next) { - VecCopyf(bp->vec, mverts[vl->index].co); + copy_v3_v3(bp->vec, mverts[vl->index].co); bp->f1= SELECT; bp->radius = bp->weight = 1.0; } @@ -1146,23 +1146,23 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float *f_no= &fnors[i*3]; if (mf->v4) - CalcNormFloat4(mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, mverts[mf->v4].co, f_no); + normal_quad_v3( f_no,mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, mverts[mf->v4].co); else - CalcNormFloat(mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, f_no); + normal_tri_v3( f_no,mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co); - VecAddf(tnorms[mf->v1], tnorms[mf->v1], f_no); - VecAddf(tnorms[mf->v2], tnorms[mf->v2], f_no); - VecAddf(tnorms[mf->v3], tnorms[mf->v3], f_no); + add_v3_v3v3(tnorms[mf->v1], tnorms[mf->v1], f_no); + add_v3_v3v3(tnorms[mf->v2], tnorms[mf->v2], f_no); + add_v3_v3v3(tnorms[mf->v3], tnorms[mf->v3], f_no); if (mf->v4) - VecAddf(tnorms[mf->v4], tnorms[mf->v4], f_no); + add_v3_v3v3(tnorms[mf->v4], tnorms[mf->v4], f_no); } for (i=0; i<numVerts; i++) { MVert *mv= &mverts[i]; float *no= tnorms[i]; - if (Normalize(no)==0.0) { + if (normalize_v3(no)==0.0) { VECCOPY(no, mv->co); - Normalize(no); + normalize_v3(no); } mv->no[0]= (short)(no[0]*32767.0); @@ -1262,7 +1262,7 @@ UvVertMap *make_uv_vert_map(struct MFace *mface, struct MTFace *tface, unsigned next= iterv->next; uv2= (tf+iterv->f)->uv[iterv->tfindex]; - Vec2Subf(uvdiff, uv2, uv); + sub_v2_v2v2(uvdiff, uv2, uv); if(fabs(uv[0]-uv2[0]) < limit[0] && fabs(uv[1]-uv2[1]) < limit[1]) { diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 1193e8247be..50c907fd1ca 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -41,7 +41,7 @@ #include "float.h" #include "ctype.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_kdopbvh.h" #include "BLI_kdtree.h" @@ -82,7 +82,7 @@ #include "BKE_anim.h" #include "BKE_action.h" #include "BKE_bmesh.h" -// XXX #include "BKE_booleanops.h" +#include "BKE_booleanops.h" #include "BKE_cloth.h" #include "BKE_collision.h" #include "BKE_cdderivedmesh.h" @@ -113,18 +113,12 @@ #include "BKE_shrinkwrap.h" #include "BKE_simple_deform.h" -//XXX #include "LOD_DependKludge.h" #include "LOD_decimation.h" -// XXX -static struct DerivedMesh *NewBooleanDerivedMesh() {return NULL;} - #include "CCGSubSurf.h" #include "RE_shader_ext.h" -//XXX #include "BIF_meshlaplacian.h" - /* Utility */ static int is_last_displist(Object *ob) @@ -1193,7 +1187,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, if(amd->end_cap && amd->end_cap != ob) end_cap = amd->end_cap->derivedFinal; - Mat4One(offset); + unit_m4(offset); indexMap = MEM_callocN(sizeof(*indexMap) * dm->getNumVerts(dm), "indexmap"); @@ -1203,7 +1197,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, maxVerts = dm->getNumVerts(dm); if(amd->offset_type & MOD_ARR_OFF_CONST) - VecAddf(offset[3], offset[3], amd->offset); + add_v3_v3v3(offset[3], offset[3], amd->offset); if(amd->offset_type & MOD_ARR_OFF_RELATIVE) { for(j = 0; j < 3; j++) offset[3][j] += amd->scale[j] * vertarray_size(src_mvert, @@ -1215,14 +1209,14 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, float result_mat[4][4]; if(ob) - Mat4Invert(obinv, ob->obmat); + invert_m4_m4(obinv, ob->obmat); else - Mat4One(obinv); + unit_m4(obinv); - Mat4MulSerie(result_mat, offset, + mul_serie_m4(result_mat, offset, obinv, amd->offset_ob->obmat, NULL, NULL, NULL, NULL, NULL); - Mat4CpyMat4(offset, result_mat); + copy_m4_m4(offset, result_mat); } if(amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob) { @@ -1232,7 +1226,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, float scale; object_to_mat3(amd->curve_ob, tmp_mat); - scale = Mat3ToScalef(tmp_mat); + scale = mat3_to_scale(tmp_mat); if(!cu->path) { cu->flag |= CU_PATH; // needed for path & bevlist @@ -1247,7 +1241,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, prescribed length */ if(amd->fit_type == MOD_ARR_FITLENGTH || amd->fit_type == MOD_ARR_FITCURVE) { - float dist = sqrt(Inpf(offset[3], offset[3])); + float dist = sqrt(dot_v3v3(offset[3], offset[3])); if(dist > 1e-6f) /* this gives length = first copy start to last copy end @@ -1280,11 +1274,11 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, result = CDDM_from_template(dm, finalVerts, finalEdges, finalFaces); /* calculate the offset matrix of the final copy (for merging) */ - Mat4One(final_offset); + unit_m4(final_offset); for(j=0; j < count - 1; j++) { - Mat4MulMat4(tmp_mat, final_offset, offset); - Mat4CpyMat4(final_offset, tmp_mat); + mul_m4_m4m4(tmp_mat, final_offset, offset); + copy_m4_m4(final_offset, tmp_mat); } numVerts = numEdges = numFaces = 0; @@ -1320,7 +1314,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, if((count > 1) && (amd->flags & MOD_ARR_MERGE)) { float tmp_co[3]; VECCOPY(tmp_co, mv->co); - Mat4MulVecfl(offset, tmp_co); + mul_m4_v3(offset, tmp_co); for(j = 0; j < maxVerts; j++) { /* if vertex already merged, don't use it */ @@ -1328,15 +1322,15 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, inMV = &src_mvert[j]; /* if this vert is within merge limit, merge */ - if(VecLenCompare(tmp_co, inMV->co, amd->merge_dist)) { + if(compare_len_v3v3(tmp_co, inMV->co, amd->merge_dist)) { indexMap[i].merge = j; /* test for merging with final copy of merge target */ if(amd->flags & MOD_ARR_MERGEFINAL) { VECCOPY(tmp_co, inMV->co); inMV = &src_mvert[i]; - Mat4MulVecfl(final_offset, tmp_co); - if(VecLenCompare(tmp_co, inMV->co, amd->merge_dist)) + mul_m4_v3(final_offset, tmp_co); + if(compare_len_v3v3(tmp_co, inMV->co, amd->merge_dist)) indexMap[i].merge_final = 1; } break; @@ -1353,7 +1347,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, *mv2 = *mv; numVerts++; - Mat4MulVecfl(offset, co); + mul_m4_v3(offset, co); VECCOPY(mv2->co, co); } } else if(indexMap[i].merge != i && indexMap[i].merge_final) { @@ -1510,7 +1504,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, cap_medge = start_cap->getEdgeArray(start_cap); cap_mface = start_cap->getFaceArray(start_cap); - Mat4Invert(startoffset, offset); + invert_m4_m4(startoffset, offset); vert_map = MEM_callocN(sizeof(*vert_map) * capVerts, "arrayModifier_doArray vert_map"); @@ -1526,12 +1520,12 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, int j; VECCOPY(tmp_co, mv->co); - Mat4MulVecfl(startoffset, tmp_co); + mul_m4_v3(startoffset, tmp_co); for(j = 0; j < maxVerts; j++) { in_mv = &src_mvert[j]; /* if this vert is within merge limit, merge */ - if(VecLenCompare(tmp_co, in_mv->co, amd->merge_dist)) { + if(compare_len_v3v3(tmp_co, in_mv->co, amd->merge_dist)) { vert_map[i] = calc_mapping(indexMap, j, 0); merged = 1; break; @@ -1542,7 +1536,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, if(!merged) { DM_copy_vert_data(start_cap, result, i, numVerts, 1); mvert[numVerts] = *mv; - Mat4MulVecfl(startoffset, mvert[numVerts].co); + mul_m4_v3(startoffset, mvert[numVerts].co); origindex[numVerts] = ORIGINDEX_NONE; vert_map[i] = numVerts; @@ -1611,7 +1605,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, cap_medge = end_cap->getEdgeArray(end_cap); cap_mface = end_cap->getFaceArray(end_cap); - Mat4MulMat4(endoffset, final_offset, offset); + mul_m4_m4m4(endoffset, final_offset, offset); vert_map = MEM_callocN(sizeof(*vert_map) * capVerts, "arrayModifier_doArray vert_map"); @@ -1627,12 +1621,12 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, int j; VECCOPY(tmp_co, mv->co); - Mat4MulVecfl(offset, tmp_co); + mul_m4_v3(offset, tmp_co); for(j = 0; j < maxVerts; j++) { in_mv = &src_mvert[j]; /* if this vert is within merge limit, merge */ - if(VecLenCompare(tmp_co, in_mv->co, amd->merge_dist)) { + if(compare_len_v3v3(tmp_co, in_mv->co, amd->merge_dist)) { vert_map[i] = calc_mapping(indexMap, j, count - 1); merged = 1; break; @@ -1643,7 +1637,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, if(!merged) { DM_copy_vert_data(end_cap, result, i, numVerts, 1); mvert[numVerts] = *mv; - Mat4MulVecfl(endoffset, mvert[numVerts].co); + mul_m4_v3(endoffset, mvert[numVerts].co); origindex[numVerts] = ORIGINDEX_NONE; vert_map[i] = numVerts; @@ -1927,9 +1921,9 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, if (mmd->mirror_ob) { float obinv[4][4]; - Mat4Invert(obinv, mmd->mirror_ob->obmat); - Mat4MulMat4(mtx, ob->obmat, obinv); - Mat4Invert(imtx, mtx); + invert_m4_m4(obinv, mmd->mirror_ob->obmat); + mul_m4_m4m4(mtx, ob->obmat, obinv); + invert_m4_m4(imtx, mtx); } for(i = 0; i < maxVerts; i++) { @@ -1940,10 +1934,10 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, dm->getVert(dm, i, &inMV); - VecCopyf(co, inMV.co); + copy_v3_v3(co, inMV.co); if (mmd->mirror_ob) { - VecMat4MulVecfl(co, mtx, co); + mul_v3_m4v3(co, mtx, co); } isShared = ABS(co[axis])<=tolerance; @@ -1961,9 +1955,9 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, if(isShared) { co[axis] = 0; if (mmd->mirror_ob) { - VecMat4MulVecfl(co, imtx, co); + mul_v3_m4v3(co, imtx, co); } - VecCopyf(mv->co, co); + copy_v3_v3(mv->co, co); mv->flag |= ME_VERT_MERGED; } else { @@ -1975,9 +1969,9 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, co[axis] = -co[axis]; if (mmd->mirror_ob) { - VecMat4MulVecfl(co, imtx, co); + mul_v3_m4v3(co, imtx, co); } - VecCopyf(mv2->co, co); + copy_v3_v3(mv2->co, co); if (mmd->flag & MOD_MIR_VGROUP){ dvert = DM_get_vert_data(result, numVerts, CD_MDEFORMVERT); @@ -2483,12 +2477,12 @@ static SmoothMesh *smoothmesh_from_derivedmesh(DerivedMesh *dm) if(face->edges[2]->verts[1]->oldIndex == mf.v3) face->flip[2] = 1; face->edges[3] = BLI_edgehash_lookup(edges, mf.v4, mf.v1); if(face->edges[3]->verts[1]->oldIndex == mf.v4) face->flip[3] = 1; - CalcNormFloat4(v1.co, v2.co, v3.co, v4.co, face->normal); + normal_quad_v3( face->normal,v1.co, v2.co, v3.co, v4.co); } else { face->edges[2] = BLI_edgehash_lookup(edges, mf.v3, mf.v1); if(face->edges[2]->verts[1]->oldIndex == mf.v3) face->flip[2] = 1; face->edges[3] = NULL; - CalcNormFloat(v1.co, v2.co, v3.co, face->normal); + normal_tri_v3( face->normal,v1.co, v2.co, v3.co); } for(j = 0; j < SMOOTHFACE_MAX_EDGES && face->edges[j]; j++) { @@ -3185,7 +3179,7 @@ static void tag_and_count_extra_edges(SmoothMesh *mesh, float split_angle, /* we know the edge has 2 faces, so check the angle */ SmoothFace *face1 = edge->faces->link; SmoothFace *face2 = edge->faces->next->link; - float edge_angle_cos = Inpf(face1->normal, + float edge_angle_cos = dot_v3v3(face1->normal, face2->normal); if(edge_angle_cos < threshold) { @@ -3581,7 +3575,7 @@ static void get_texture_coords(DisplaceModifierData *dmd, Object *ob, if(texmapping == MOD_DISP_MAP_OBJECT) { if(dmd->map_object) - Mat4Invert(mapob_imat, dmd->map_object->obmat); + invert_m4_m4(mapob_imat, dmd->map_object->obmat); else /* if there is no map object, default to local */ texmapping = MOD_DISP_MAP_LOCAL; } @@ -3647,12 +3641,12 @@ static void get_texture_coords(DisplaceModifierData *dmd, Object *ob, break; case MOD_DISP_MAP_GLOBAL: VECCOPY(*texco, *co); - Mat4MulVecfl(ob->obmat, *texco); + mul_m4_v3(ob->obmat, *texco); break; case MOD_DISP_MAP_OBJECT: VECCOPY(*texco, *co); - Mat4MulVecfl(ob->obmat, *texco); - Mat4MulVecfl(mapob_imat, *texco); + mul_m4_v3(ob->obmat, *texco); + mul_m4_v3(mapob_imat, *texco); break; } } @@ -3923,7 +3917,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, /* convert coords to world space */ for(i = 0, co = coords; i < numVerts; ++i, ++co) - Mat4MulVecfl(ob->obmat, *co); + mul_m4_v3(ob->obmat, *co); /* calculate a projection matrix and normal for each projector */ for(i = 0; i < num_projectors; ++i) { @@ -3931,7 +3925,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, float offsetmat[4][4]; Camera *cam = NULL; /* calculate projection matrix */ - Mat4Invert(projectors[i].projmat, projectors[i].ob->obmat); + invert_m4_m4(projectors[i].projmat, projectors[i].ob->obmat); if(projectors[i].ob->type == OB_CAMERA) { cam = (Camera *)projectors[i].ob->data; @@ -3953,9 +3947,8 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, xmin = -xmax; ymin = -ymax; - i_window(xmin, xmax, ymin, ymax, - cam->clipsta, cam->clipend, perspmat); - Mat4MulMat4(tmpmat, projectors[i].projmat, perspmat); + perspective_m4( perspmat,xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend); + mul_m4_m4m4(tmpmat, projectors[i].projmat, perspmat); } else if(cam->type == CAM_ORTHO) { float orthomat[4][4]; float xmax; @@ -3973,16 +3966,15 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, xmin = -xmax; ymin = -ymax; - i_ortho(xmin, xmax, ymin, ymax, - cam->clipsta, cam->clipend, orthomat); - Mat4MulMat4(tmpmat, projectors[i].projmat, orthomat); + orthographic_m4( orthomat,xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend); + mul_m4_m4m4(tmpmat, projectors[i].projmat, orthomat); } } else { - Mat4CpyMat4(tmpmat, projectors[i].projmat); + copy_m4_m4(tmpmat, projectors[i].projmat); } - Mat4One(offsetmat); - Mat4MulFloat3(offsetmat[0], 0.5); + unit_m4(offsetmat); + mul_mat3_m4_fl(offsetmat, 0.5); offsetmat[3][0] = offsetmat[3][1] = offsetmat[3][2] = 0.5; if (cam) { @@ -3998,19 +3990,19 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, } } - Mat4MulMat4(projectors[i].projmat, tmpmat, offsetmat); + mul_m4_m4m4(projectors[i].projmat, tmpmat, offsetmat); /* calculate worldspace projector normal (for best projector test) */ projectors[i].normal[0] = 0; projectors[i].normal[1] = 0; projectors[i].normal[2] = 1; - Mat4Mul3Vecfl(projectors[i].ob->obmat, projectors[i].normal); + mul_mat3_m4_v3(projectors[i].ob->obmat, projectors[i].normal); } /* if only one projector, project coords to UVs */ if(num_projectors == 1) for(i = 0, co = coords; i < numVerts; ++i, ++co) - Mat4MulVec3Project(projectors[0].projmat, *co); + mul_project_m4_v4(projectors[0].projmat, *co); mface = dm->getFaceArray(dm); numFaces = dm->getNumFaces(dm); @@ -4047,19 +4039,19 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, /* get the untransformed face normal */ if(mf->v4) { VECCOPY(co4, coords[mf->v4]); - CalcNormFloat4(co1, co2, co3, co4, face_no); + normal_quad_v3( face_no,co1, co2, co3, co4); } else { - CalcNormFloat(co1, co2, co3, face_no); + normal_tri_v3( face_no,co1, co2, co3); } /* find the projector which the face points at most directly * (projector normal with largest dot product is best) */ - best_dot = Inpf(projectors[0].normal, face_no); + best_dot = dot_v3v3(projectors[0].normal, face_no); best_projector = &projectors[0]; for(j = 1; j < num_projectors; ++j) { - float tmp_dot = Inpf(projectors[j].normal, + float tmp_dot = dot_v3v3(projectors[j].normal, face_no); if(tmp_dot > best_dot) { best_dot = tmp_dot; @@ -4067,11 +4059,11 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, } } - Mat4MulVec3Project(best_projector->projmat, co1); - Mat4MulVec3Project(best_projector->projmat, co2); - Mat4MulVec3Project(best_projector->projmat, co3); + mul_project_m4_v4(best_projector->projmat, co1); + mul_project_m4_v4(best_projector->projmat, co2); + mul_project_m4_v4(best_projector->projmat, co3); if(mf->v4) - Mat4MulVec3Project(best_projector->projmat, co4); + mul_project_m4_v4(best_projector->projmat, co4); /* apply transformed coords as UVs */ tface->uv[0][0] = co1[0]; @@ -4138,11 +4130,11 @@ static DerivedMesh *decimateModifier_applyModifier( ModifierData *md, Object *ob, DerivedMesh *derivedData, int useRenderParams, int isFinalCalc) { - // DecimateModifierData *dmd = (DecimateModifierData*) md; + DecimateModifierData *dmd = (DecimateModifierData*) md; DerivedMesh *dm = derivedData, *result = NULL; MVert *mvert; MFace *mface; - // LOD_Decimation_Info lod; + LOD_Decimation_Info lod; int totvert, totface; int a, numTris; @@ -4164,8 +4156,6 @@ static DerivedMesh *decimateModifier_applyModifier( goto exit; } - // XXX -#if 0 lod.vertex_buffer= MEM_mallocN(3*sizeof(float)*totvert, "vertices"); lod.vertex_normal_buffer= MEM_mallocN(3*sizeof(float)*totvert, "normals"); lod.triangle_index_buffer= MEM_mallocN(3*sizeof(int)*numTris, "trias"); @@ -4250,10 +4240,6 @@ static DerivedMesh *decimateModifier_applyModifier( MEM_freeN(lod.vertex_buffer); MEM_freeN(lod.vertex_normal_buffer); MEM_freeN(lod.triangle_index_buffer); -#else - modifier_setError(md, "Modifier not working yet in 2.5."); - goto exit; -#endif exit: return result; @@ -4372,11 +4358,11 @@ static void smoothModifier_do( if (uctmp[idx1] < 255) { uctmp[idx1]++; - VecAddf(v1, v1, fvec); + add_v3_v3v3(v1, v1, fvec); } if (uctmp[idx2] < 255) { uctmp[idx2]++; - VecAddf(v2, v2, fvec); + add_v3_v3v3(v2, v2, fvec); } } @@ -4590,14 +4576,14 @@ static void castModifier_sphere_do( * we use its location, transformed to ob's local space */ if (ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4Invert(ctrl_ob->imat, ctrl_ob->obmat); - Mat4MulMat4(mat, ob->obmat, ctrl_ob->imat); - Mat4Invert(imat, mat); + invert_m4_m4(ctrl_ob->imat, ctrl_ob->obmat); + mul_m4_m4m4(mat, ob->obmat, ctrl_ob->imat); + invert_m4_m4(imat, mat); } - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); VECCOPY(center, ctrl_ob->obmat[3]); - Mat4MulVecfl(ob->imat, center); + mul_m4_v3(ob->imat, center); } /* now we check which options the user wants */ @@ -4632,7 +4618,7 @@ static void castModifier_sphere_do( if(len <= 0) { for (i = 0; i < numVerts; i++) { - len += VecLenf(center, vertexCos[i]); + len += len_v3v3(center, vertexCos[i]); } len /= numVerts; @@ -4654,9 +4640,9 @@ static void castModifier_sphere_do( VECCOPY(tmp_co, vertexCos[i]); if(ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4MulVecfl(mat, tmp_co); + mul_m4_v3(mat, tmp_co); } else { - VecSubf(tmp_co, tmp_co, center); + sub_v3_v3v3(tmp_co, tmp_co, center); } } @@ -4666,7 +4652,7 @@ static void castModifier_sphere_do( vec[2] = 0.0f; if (has_radius) { - if (VecLength(vec) > cmd->radius) continue; + if (len_v3(vec) > cmd->radius) continue; } for (j = 0; j < dvert[i].totweight; ++j) { @@ -4680,7 +4666,7 @@ static void castModifier_sphere_do( fac = fac_orig * dw->weight; facm = 1.0f - fac; - Normalize(vec); + normalize_v3(vec); if (flag & MOD_CAST_X) tmp_co[0] = fac*vec[0]*len + facm*tmp_co[0]; @@ -4691,9 +4677,9 @@ static void castModifier_sphere_do( if(ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4MulVecfl(imat, tmp_co); + mul_m4_v3(imat, tmp_co); } else { - VecAddf(tmp_co, tmp_co, center); + add_v3_v3v3(tmp_co, tmp_co, center); } } @@ -4709,9 +4695,9 @@ static void castModifier_sphere_do( VECCOPY(tmp_co, vertexCos[i]); if(ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4MulVecfl(mat, tmp_co); + mul_m4_v3(mat, tmp_co); } else { - VecSubf(tmp_co, tmp_co, center); + sub_v3_v3v3(tmp_co, tmp_co, center); } } @@ -4721,10 +4707,10 @@ static void castModifier_sphere_do( vec[2] = 0.0f; if (has_radius) { - if (VecLength(vec) > cmd->radius) continue; + if (len_v3(vec) > cmd->radius) continue; } - Normalize(vec); + normalize_v3(vec); if (flag & MOD_CAST_X) tmp_co[0] = fac*vec[0]*len + facm*tmp_co[0]; @@ -4735,9 +4721,9 @@ static void castModifier_sphere_do( if(ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4MulVecfl(imat, tmp_co); + mul_m4_v3(imat, tmp_co); } else { - VecAddf(tmp_co, tmp_co, center); + add_v3_v3v3(tmp_co, tmp_co, center); } } @@ -4792,14 +4778,14 @@ static void castModifier_cuboid_do( if (ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4Invert(ctrl_ob->imat, ctrl_ob->obmat); - Mat4MulMat4(mat, ob->obmat, ctrl_ob->imat); - Mat4Invert(imat, mat); + invert_m4_m4(ctrl_ob->imat, ctrl_ob->obmat); + mul_m4_m4m4(mat, ob->obmat, ctrl_ob->imat); + invert_m4_m4(imat, mat); } - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); VECCOPY(center, ctrl_ob->obmat[3]); - Mat4MulVecfl(ob->imat, center); + mul_m4_v3(ob->imat, center); } if((flag & MOD_CAST_SIZE_FROM_RADIUS) && has_radius) { @@ -4828,7 +4814,7 @@ static void castModifier_cuboid_do( DO_MINMAX(center, min, max); for (i = 0; i < numVerts; i++) { - VecSubf(vec, vertexCos[i], center); + sub_v3_v3v3(vec, vertexCos[i], center); DO_MINMAX(vec, min, max); } } @@ -4871,9 +4857,9 @@ static void castModifier_cuboid_do( VECCOPY(tmp_co, vertexCos[i]); if(ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4MulVecfl(mat, tmp_co); + mul_m4_v3(mat, tmp_co); } else { - VecSubf(tmp_co, tmp_co, center); + sub_v3_v3v3(tmp_co, tmp_co, center); } } @@ -4909,7 +4895,7 @@ static void castModifier_cuboid_do( if (tmp_co[2] > 0.0f) octant += 4; /* apex is the bb's vertex at the chosen octant */ - VecCopyf(apex, bb[octant]); + copy_v3_v3(apex, bb[octant]); /* find which bb plane is closest to this vertex ... */ d[0] = tmp_co[0] / apex[0]; @@ -4947,9 +4933,9 @@ static void castModifier_cuboid_do( if(ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4MulVecfl(imat, tmp_co); + mul_m4_v3(imat, tmp_co); } else { - VecAddf(tmp_co, tmp_co, center); + add_v3_v3v3(tmp_co, tmp_co, center); } } @@ -4967,9 +4953,9 @@ static void castModifier_cuboid_do( VECCOPY(tmp_co, vertexCos[i]); if(ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4MulVecfl(mat, tmp_co); + mul_m4_v3(mat, tmp_co); } else { - VecSubf(tmp_co, tmp_co, center); + sub_v3_v3v3(tmp_co, tmp_co, center); } } @@ -4984,7 +4970,7 @@ static void castModifier_cuboid_do( if (tmp_co[1] > 0.0f) octant += 2; if (tmp_co[2] > 0.0f) octant += 4; - VecCopyf(apex, bb[octant]); + copy_v3_v3(apex, bb[octant]); d[0] = tmp_co[0] / apex[0]; d[1] = tmp_co[1] / apex[1]; @@ -5015,9 +5001,9 @@ static void castModifier_cuboid_do( if(ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4MulVecfl(imat, tmp_co); + mul_m4_v3(imat, tmp_co); } else { - VecAddf(tmp_co, tmp_co, center); + add_v3_v3v3(tmp_co, tmp_co, center); } } @@ -5182,7 +5168,7 @@ static void wavemod_get_texture_coords(WaveModifierData *wmd, Object *ob, if(texmapping == MOD_WAV_MAP_OBJECT) { if(wmd->map_object) - Mat4Invert(wmd->map_object->imat, wmd->map_object->obmat); + invert_m4_m4(wmd->map_object->imat, wmd->map_object->obmat); else /* if there is no map object, default to local */ texmapping = MOD_WAV_MAP_LOCAL; } @@ -5248,12 +5234,12 @@ static void wavemod_get_texture_coords(WaveModifierData *wmd, Object *ob, break; case MOD_WAV_MAP_GLOBAL: VECCOPY(*texco, *co); - Mat4MulVecfl(ob->obmat, *texco); + mul_m4_v3(ob->obmat, *texco); break; case MOD_WAV_MAP_OBJECT: VECCOPY(*texco, *co); - Mat4MulVecfl(ob->obmat, *texco); - Mat4MulVecfl(wmd->map_object->imat, *texco); + mul_m4_v3(ob->obmat, *texco); + mul_m4_v3(wmd->map_object->imat, *texco); break; } } @@ -5279,8 +5265,8 @@ static void waveModifier_do(WaveModifierData *md, if(wmd->objectcenter){ float mat[4][4]; /* get the control object's location in local coordinates */ - Mat4Invert(ob->imat, ob->obmat); - Mat4MulMat4(mat, wmd->objectcenter->obmat, ob->imat); + invert_m4_m4(ob->imat, ob->obmat); + mul_m4_m4m4(mat, wmd->objectcenter->obmat, ob->imat); wmd->startx = mat[3][0]; wmd->starty = mat[3][1]; @@ -5669,14 +5655,14 @@ static void hookModifier_deformVerts( /* get world-space matrix of target, corrected for the space the verts are in */ if (hmd->subtarget[0] && pchan) { /* bone target if there's a matching pose-channel */ - Mat4MulMat4(dmat, pchan->pose_mat, hmd->object->obmat); + mul_m4_m4m4(dmat, pchan->pose_mat, hmd->object->obmat); } else { /* just object target */ - Mat4CpyMat4(dmat, hmd->object->obmat); + copy_m4_m4(dmat, hmd->object->obmat); } - Mat4Invert(ob->imat, ob->obmat); - Mat4MulSerie(mat, ob->imat, dmat, hmd->parentinv, + invert_m4_m4(ob->imat, ob->obmat); + mul_serie_m4(mat, ob->imat, dmat, hmd->parentinv, NULL, NULL, NULL, NULL, NULL); /* vertex indices? */ @@ -5706,29 +5692,29 @@ static void hookModifier_deformVerts( if(orig_index == index) { co = vertexCos[j]; if(hmd->falloff != 0.0) { - float len = VecLenf(co, hmd->cent); + float len = len_v3v3(co, hmd->cent); if(len > hmd->falloff) fac = 0.0; else if(len > 0.0) fac *= sqrt(1.0 - len / hmd->falloff); } if(fac != 0.0) { - VecMat4MulVecfl(vec, mat, co); - VecLerpf(co, co, vec, fac); + mul_v3_m4v3(vec, mat, co); + interp_v3_v3v3(co, co, vec, fac); } } } } else { if(hmd->falloff != 0.0) { - float len = VecLenf(co, hmd->cent); + float len = len_v3v3(co, hmd->cent); if(len > hmd->falloff) fac = 0.0; else if(len > 0.0) fac *= sqrt(1.0 - len / hmd->falloff); } if(fac != 0.0) { - VecMat4MulVecfl(vec, mat, co); - VecLerpf(co, co, vec, fac); + mul_v3_m4v3(vec, mat, co); + interp_v3_v3v3(co, co, vec, fac); } } } @@ -5767,14 +5753,14 @@ static void hookModifier_deformVerts( float *co = vertexCos[i]; if(hmd->falloff != 0.0) { - float len = VecLenf(co, hmd->cent); + float len = len_v3v3(co, hmd->cent); if(len > hmd->falloff) fac = 0.0; else if(len > 0.0) fac *= sqrt(1.0 - len / hmd->falloff); } - VecMat4MulVecfl(vec, mat, co); - VecLerpf(co, co, vec, fac); + mul_v3_m4v3(vec, mat, co); + interp_v3_v3v3(co, co, vec, fac); } } } @@ -6110,7 +6096,7 @@ static void collisionModifier_deformVerts( for ( i = 0; i < numverts; i++ ) { // we save global positions - Mat4MulVecfl ( ob->obmat, collmd->x[i].co ); + mul_m4_v3( ob->obmat, collmd->x[i].co ); } collmd->xnew = MEM_dupallocN(collmd->x); // frame end position @@ -6140,7 +6126,7 @@ static void collisionModifier_deformVerts( for ( i = 0; i < numverts; i++ ) { // we save global positions - Mat4MulVecfl ( ob->obmat, collmd->xnew[i].co ); + mul_m4_v3( ob->obmat, collmd->xnew[i].co ); } memcpy(collmd->current_xnew, collmd->x, numverts*sizeof(MVert)); @@ -6286,14 +6272,14 @@ static void surfaceModifier_deformVerts( /* convert to global coordinates and calculate velocity */ for(i = 0, x = surmd->x, v = surmd->v; i<numverts; i++, x++, v++) { vec = CDDM_get_vert(surmd->dm, i)->co; - Mat4MulVecfl(ob->obmat, vec); + mul_m4_v3(ob->obmat, vec); if(init) v->co[0] = v->co[1] = v->co[2] = 0.0f; else - VecSubf(v->co, vec, x->co); + sub_v3_v3v3(v->co, vec, x->co); - VecCopyf(x->co, vec); + copy_v3_v3(x->co, vec); } surmd->cfra = md->scene->r.cfra; @@ -6390,12 +6376,6 @@ static CustomDataMask booleanModifier_requiredDataMask(Object *ob, ModifierData dataMask |= (1 << CD_MDEFORMVERT); - /* particles only need this if they are after a non deform modifier, and - * the modifier stack will only create them in that case. */ -// dataMask |= CD_MASK_ORIGSPACE; - -// dataMask |= CD_MASK_ORCO; - return dataMask; } @@ -6733,7 +6713,7 @@ static DerivedMesh * particleInstanceModifier_applyModifier( psys_get_particle_on_path(&sim, first_particle + i/totvert, &state,1); - Normalize(state.vel); + normalize_v3(state.vel); /* TODO: incremental rotations somehow */ if(state.vel[axis] < -0.9999 || state.vel[axis] > 0.9999) { @@ -6744,10 +6724,10 @@ static DerivedMesh * particleInstanceModifier_applyModifier( float temp[3] = {0.0f,0.0f,0.0f}; temp[axis] = 1.0f; - Crossf(cross, temp, state.vel); + cross_v3_v3v3(cross, temp, state.vel); /* state.vel[axis] is the only component surviving from a dot product with the axis */ - VecRotToQuat(cross,saacos(state.vel[axis]),state.rot); + axis_angle_to_quat(state.rot,cross,saacos(state.vel[axis])); } } @@ -6756,9 +6736,9 @@ static DerivedMesh * particleInstanceModifier_applyModifier( psys_get_particle_state(&sim, first_particle + i/totvert, &state,1); } - QuatMulVecf(state.rot,mv->co); + mul_qt_v3(state.rot,mv->co); if(pimd->flag & eParticleInstanceFlag_UseSize) - VecMulf(mv->co, size[i/totvert]); + mul_v3_fl(mv->co, size[i/totvert]); VECADD(mv->co,mv->co,state.co); } @@ -6921,14 +6901,14 @@ static void explodeModifier_createFacepa(ExplodeModifierData *emd, /* set face-particle-indexes to nearest particle to face center */ for(i=0,fa=mface; i<totface; i++,fa++){ - VecAddf(center,mvert[fa->v1].co,mvert[fa->v2].co); - VecAddf(center,center,mvert[fa->v3].co); + add_v3_v3v3(center,mvert[fa->v1].co,mvert[fa->v2].co); + add_v3_v3v3(center,center,mvert[fa->v3].co); if(fa->v4){ - VecAddf(center,center,mvert[fa->v4].co); - VecMulf(center,0.25); + add_v3_v3v3(center,center,mvert[fa->v4].co); + mul_v3_fl(center,0.25); } else - VecMulf(center,0.3333f); + mul_v3_fl(center,0.3333f); p= BLI_kdtree_find_nearest(tree,center,NULL,NULL); @@ -7100,7 +7080,7 @@ static DerivedMesh * explodeModifier_splitEdges(ExplodeModifierData *emd, Derive mv=CDDM_get_vert(splitdm,i); VECADD(dupve->co,dupve->co,mv->co); - VecMulf(dupve->co,0.5); + mul_v3_fl(dupve->co,0.5); } BLI_edgehashIterator_free(ehi); @@ -7316,7 +7296,7 @@ static DerivedMesh * explodeModifier_splitEdges(ExplodeModifierData *emd, Derive VECADD(dupve->co,dupve->co,mv->co); mv=CDDM_get_vert(splitdm,mf->v4); VECADD(dupve->co,dupve->co,mv->co); - VecMulf(dupve->co,0.25); + mul_v3_fl(dupve->co,0.25); df1=CDDM_get_face(splitdm,curdupface); @@ -7492,7 +7472,7 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd, /*dupvert= CDDM_get_verts(explode);*/ /* getting back to object space */ - Mat4Invert(imat,ob->obmat); + invert_m4_m4(imat,ob->obmat); psmd->psys->lattice = psys_get_lattice(&sim); @@ -7519,23 +7499,23 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd, /* get particle state */ psys_particle_on_emitter(psmd,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc0,nor,0,0,0,0); - Mat4MulVecfl(ob->obmat,loc0); + mul_m4_v3(ob->obmat,loc0); state.time=cfra; psys_get_particle_state(&sim, i, &state, 1); vertco=CDDM_get_vert(explode,v)->co; - Mat4MulVecfl(ob->obmat,vertco); + mul_m4_v3(ob->obmat,vertco); VECSUB(vertco,vertco,loc0); /* apply rotation, size & location */ - QuatMulVecf(state.rot,vertco); - VecMulf(vertco,pa->size); + mul_qt_v3(state.rot,vertco); + mul_v3_fl(vertco,pa->size); VECADD(vertco,vertco,state.co); - Mat4MulVecfl(imat,vertco); + mul_m4_v3(imat,vertco); } } BLI_edgehashIterator_free(ehi); @@ -7866,17 +7846,17 @@ static void meshdeformModifier_do( float (*vertexCos)[3], int numVerts) { MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; - Mesh *me= ob->data; + Mesh *me= (mmd->object)? mmd->object->data: NULL; + EditMesh *em = (me)? BKE_mesh_get_editmesh(me): NULL; DerivedMesh *tmpdm, *cagedm; MDeformVert *dvert = NULL; MDeformWeight *dw; - EditMesh *em = BKE_mesh_get_editmesh(me); MVert *cagemvert; float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4]; float weight, totweight, fac, co[3], *weights, (*dco)[3], (*bindcos)[3]; int a, b, totvert, totcagevert, defgrp_index; - if(!mmd->object || (!mmd->bindcos && !mmd->needbind)) + if(!mmd->object || (!mmd->bindcos && !mmd->bindfunc)) return; /* get cage derivedmesh */ @@ -7901,11 +7881,11 @@ static void meshdeformModifier_do( return; /* compute matrices to go in and out of cage object space */ - Mat4Invert(imat, mmd->object->obmat); - Mat4MulMat4(cagemat, ob->obmat, imat); - Mat4MulMat4(cmat, cagemat, mmd->bindmat); - Mat4Invert(iobmat, cmat); - Mat3CpyMat4(icagemat, iobmat); + invert_m4_m4(imat, mmd->object->obmat); + mul_m4_m4m4(cagemat, ob->obmat, imat); + mul_m4_m4m4(cmat, cagemat, mmd->bindmat); + invert_m4_m4(iobmat, cmat); + copy_m3_m4(icagemat, iobmat); /* bind weights if needed */ if(!mmd->bindcos) { @@ -7914,7 +7894,7 @@ static void meshdeformModifier_do( /* progress bar redraw can make this recursive .. */ if(!recursive) { recursive = 1; - //XXX harmonic_coordinates_bind(mmd, vertexCos, numVerts, cagemat); + mmd->bindfunc(md->scene, mmd, (float*)vertexCos, numVerts, cagemat); recursive = 0; } } @@ -7939,7 +7919,7 @@ static void meshdeformModifier_do( VECCOPY(co, cagemvert[a].co); if(G.rt != 527) { - Mat4MulVecfl(mmd->bindmat, co); + mul_m4_v3(mmd->bindmat, co); /* compute difference with world space bind coord */ VECSUB(dco[a], co, bindcos[a]); } @@ -7993,7 +7973,7 @@ static void meshdeformModifier_do( if(mmd->flag & MOD_MDEF_DYNAMIC_BIND) { /* transform coordinate into cage's local space */ VECCOPY(co, vertexCos[b]); - Mat4MulVecfl(cagemat, co); + mul_m4_v3(cagemat, co); totweight= meshdeform_dynamic_bind(mmd, dco, co); } else { @@ -8010,8 +7990,8 @@ static void meshdeformModifier_do( } if(totweight > 0.0f) { - VecMulf(co, fac/totweight); - Mat3MulVecfl(icagemat, co); + mul_v3_fl(co, fac/totweight); + mul_m3_v3(icagemat, co); if(G.rt != 527) VECADD(vertexCos[b], vertexCos[b], co) else @@ -8102,7 +8082,7 @@ static DerivedMesh *multiresModifier_applyModifier(ModifierData *md, Object *ob, int i; MVert *dst = CDDM_get_verts(final); for(i = 0; i < mmd->undo_verts_tot; ++i) { - VecCopyf(dst[i].co, mmd->undo_verts[i].co); + copy_v3_v3(dst[i].co, mmd->undo_verts[i].co); } CDDM_calc_normals(final); @@ -8383,10 +8363,10 @@ static void shapekeyModifier_deformMatricesEM( int a; if(kb && kb->totelem==numVerts && kb!=key->refkey) { - Mat3Scale(scale, kb->curval); + scale_m3_fl(scale, kb->curval); for(a=0; a<numVerts; a++) - Mat3CpyMat3(defMats[a], scale); + copy_m3_m3(defMats[a], scale); } } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index e1a51a05ca4..47b2914b0f5 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -37,7 +37,7 @@ #include "DNA_scene_types.h" #include "DNA_view3d_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BKE_cdderivedmesh.h" @@ -164,7 +164,7 @@ int multiresModifier_reshape(MultiresModifierData *mmd, Object *dst, Object *src int i; for(i = 0; i < src_me->totvert; ++i) - VecCopyf(mvert[i].co, src_me->mvert[i].co); + copy_v3_v3(mvert[i].co, src_me->mvert[i].co); mrdm->needsFree = 1; MultiresDM_mark_as_modified(mrdm); mrdm->release(mrdm); @@ -178,9 +178,9 @@ int multiresModifier_reshape(MultiresModifierData *mmd, Object *dst, Object *src static void Mat3FromColVecs(float mat[][3], float v1[3], float v2[3], float v3[3]) { - VecCopyf(mat[0], v1); - VecCopyf(mat[1], v2); - VecCopyf(mat[2], v3); + copy_v3_v3(mat[0], v1); + copy_v3_v3(mat[1], v2); + copy_v3_v3(mat[2], v3); } static DerivedMesh *multires_subdisp_pre(DerivedMesh *mrdm, int distance, int simple) @@ -233,7 +233,7 @@ static void multires_subdisp(DerivedMesh *orig, Object *ob, DerivedMesh *final, if(!addverts) { for(i = 0; i < totvert; ++i) { float z[3] = {0,0,0}; - VecCopyf(mvd[i].co, z); + copy_v3_v3(mvd[i].co, z); } } @@ -424,7 +424,7 @@ void multiresModifier_del_levels(struct MultiresModifierData *mmd, struct Object for(j = 0, y = 0; y < st; y += skip) { for(x = 0; x < st; x += skip) { - VecCopyf(disps[j], mdisps[i].disps[y * st + x]); + copy_v3_v3(disps[j], mdisps[i].disps[y * st + x]); ++j; } } @@ -998,27 +998,27 @@ static void calc_disp_mat(MultiresDisplacer *d, float mat[3][3]) if(u < 0) { u = multires_index_at_loc(d->face_index, d->x - 1, d->y, d, &d->edges_primary); - VecSubf(t1, base->co, d->subco[u].co); + sub_v3_v3v3(t1, base->co, d->subco[u].co); } else - VecSubf(t1, d->subco[u].co, base->co); + sub_v3_v3v3(t1, d->subco[u].co, base->co); if(v < 0) { v = multires_index_at_loc(d->face_index, d->x, d->y - 1, d, &d->edges_primary); - VecSubf(t2, base->co, d->subco[v].co); + sub_v3_v3v3(t2, base->co, d->subco[v].co); } else - VecSubf(t2, d->subco[v].co, base->co); + sub_v3_v3v3(t2, d->subco[v].co, base->co); //printf("uu=%d, vv=%d\n", u, v); - Normalize(t1); - Normalize(t2); + normalize_v3(t1); + normalize_v3(t2); Mat3FromColVecs(mat, t1, t2, norm); if(d->invert) { - Mat3Inv(inv, mat); - Mat3CpyMat3(mat, inv); + invert_m3_m3(inv, mat); + copy_m3_m3(mat, inv); } } @@ -1033,23 +1033,23 @@ static void multires_displace(MultiresDisplacer *d, float co[3]) data = d->grid->disps[(d->y * d->spacing) * d->disp_st + (d->x * d->spacing)]; if(d->invert) - VecSubf(disp, co, subco->co); + sub_v3_v3v3(disp, co, subco->co); else - VecCopyf(disp, data); + copy_v3_v3(disp, data); /* Apply ts matrix to displacement */ calc_disp_mat(d, mat); - Mat3MulVecfl(mat, disp); + mul_m3_v3(mat, disp); if(d->invert) { - VecCopyf(data, disp); + copy_v3_v3(data, disp); } else { if(d->type == 4 || d->type == 5) - VecMulf(disp, d->weight); - VecAddf(co, co, disp); + mul_v3_fl(disp, d->weight); + add_v3_v3v3(co, co, disp); } if(d->type == 2) { @@ -1200,7 +1200,7 @@ static void multiresModifier_update(DerivedMesh *dm) /* Subtract the original vertex cos from the new vertex cos */ verts_new = CDDM_get_verts(dm); for(i = 0; i < dm->getNumVerts(dm); ++i) - VecSubf(verts_new[i].co, verts_new[i].co, cur_lvl_orig_verts[i].co); + sub_v3_v3v3(verts_new[i].co, verts_new[i].co, cur_lvl_orig_verts[i].co); final = multires_subdisp_pre(dm, totlvl - lvl, 0); @@ -1579,7 +1579,7 @@ void multires_load_old(DerivedMesh *dm, Multires *mr) /* Transfer verts */ for(i = 0; i < totvert; ++i) - VecCopyf(vdst[i].co, vsrc[vvmap[i]].co); + copy_v3_v3(vdst[i].co, vsrc[vvmap[i]].co); MEM_freeN(vvmap); } diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 2776444c8a0..1b0f1f28d2c 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -32,6 +32,7 @@ #endif #include <stdlib.h> +#include <stddef.h> #include <string.h> #include "DNA_ID.h" @@ -53,7 +54,7 @@ #include "BKE_text.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_rand.h" #include "BLI_threads.h" @@ -903,7 +904,11 @@ void nodeAddSockets(bNode *node, bNodeType *ntype) } } } - +/* Find the first available, non-duplicate name for a given node */ +void nodeUniqueName(bNodeTree *ntree, bNode *node) +{ + BLI_uniquename(&ntree->nodes, node, "Node", '.', offsetof(bNode, name), 32); +} bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup, ID *id) { @@ -937,6 +942,9 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup, ID *id) } else BLI_strncpy(node->name, ntype->name, NODE_MAXSTR); + + nodeUniqueName(ntree, node); + node->type= ntype->type; node->flag= NODE_SELECT|ntype->flag; node->width= ntype->width; @@ -989,6 +997,8 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node, int internal) bNodeSocket *sock, *oldsock; *nnode= *node; + nodeUniqueName(ntree, nnode); + BLI_addtail(&ntree->nodes, nnode); BLI_duplicatelist(&nnode->inputs, &node->inputs); @@ -1054,7 +1064,7 @@ bNodeTree *ntreeAddTree(int type) if(ntree->type==NTREE_SHADER) BLI_strncpy(ntree->id.name, "NTShader Nodetree", sizeof(ntree->id.name)); else if(ntree->type==NTREE_COMPOSIT) - BLI_strncpy(ntree->id.name, "NTComposit Nodetree", sizeof(ntree->id.name)); + BLI_strncpy(ntree->id.name, "NTCompositing Nodetree", sizeof(ntree->id.name)); else if(ntree->type==NTREE_TEXTURE) BLI_strncpy(ntree->id.name, "NTTexture Nodetree", sizeof(ntree->id.name)); @@ -1662,7 +1672,8 @@ void ntreeSocketUseFlags(bNodeTree *ntree) /* tag all thats in use */ for(link= ntree->links.first; link; link= link->next) { link->fromsock->flag |= SOCK_IN_USE; - link->tosock->flag |= SOCK_IN_USE; + if(link->tosock) // FIXME This can be NULL, when dragging a new link in the UI, should probably copy the node tree for preview render - campbell + link->tosock->flag |= SOCK_IN_USE; } } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 6f0749e0fcd..27bfd6f36a3 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -70,7 +70,7 @@ #include "DNA_world_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BKE_utildefines.h" @@ -732,13 +732,13 @@ float dof_camera(Object *ob) return 0.0f; if (cam->dof_ob) { /* too simple, better to return the distance on the view axis only - * return VecLenf(ob->obmat[3], cam->dof_ob->obmat[3]); */ + * return len_v3v3(ob->obmat[3], cam->dof_ob->obmat[3]); */ float mat[4][4], obmat[4][4]; - Mat4CpyMat4(obmat, ob->obmat); - Mat4Ortho(obmat); - Mat4Invert(ob->imat, obmat); - Mat4MulMat4(mat, cam->dof_ob->obmat, ob->imat); + copy_m4_m4(obmat, ob->obmat); + normalize_m4(obmat); + invert_m4_m4(ob->imat, obmat); + mul_m4_m4m4(mat, cam->dof_ob->obmat, ob->imat); return (float)fabs(mat[3][2]); } return cam->YF_dofdist; @@ -957,8 +957,8 @@ Object *add_only_object(int type, char *name) /* ob->transflag= OB_QUAT; */ #if 0 /* not used yet */ - QuatOne(ob->quat); - QuatOne(ob->dquat); + unit_qt(ob->quat); + unit_qt(ob->dquat); #endif ob->col[0]= ob->col[1]= ob->col[2]= 1.0; @@ -968,9 +968,9 @@ Object *add_only_object(int type, char *name) ob->rot[0]= ob->rot[1]= ob->rot[2]= 0.0; ob->size[0]= ob->size[1]= ob->size[2]= 1.0; - Mat4One(ob->constinv); - Mat4One(ob->parentinv); - Mat4One(ob->obmat); + unit_m4(ob->constinv); + unit_m4(ob->parentinv); + unit_m4(ob->obmat); ob->dt= OB_SHADED; ob->empty_drawtype= OB_ARROWS; ob->empty_drawsize= 1.0; @@ -1456,7 +1456,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) } ob->parent= target->parent; /* libdata */ - Mat4CpyMat4(ob->parentinv, target->parentinv); + copy_m4_m4(ob->parentinv, target->parentinv); /* copy animdata stuff - drivers only for now... */ if ((target->adt) && (target->adt->drivers.first)) { @@ -1580,7 +1580,7 @@ void object_scale_to_mat3(Object *ob, float mat[][3]) vec[0]= ob->size[0]+ob->dsize[0]; vec[1]= ob->size[1]+ob->dsize[1]; vec[2]= ob->size[2]+ob->dsize[2]; - SizeToMat3(vec, mat); + size_to_mat3( mat,vec); } // TODO: this should take rotation orders into account later... @@ -1591,29 +1591,29 @@ void object_rot_to_mat3(Object *ob, float mat[][3]) /* initialise the delta-rotation matrix, which will get (pre)multiplied * with the rotation matrix to yield the appropriate rotation */ - Mat3One(dmat); + unit_m3(dmat); /* rotations may either be quats, eulers (with various rotation orders), or axis-angle */ if (ob->rotmode > 0) { /* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */ - EulOToMat3(ob->rot, ob->rotmode, rmat); - EulOToMat3(ob->drot, ob->rotmode, dmat); + eulO_to_mat3( rmat,ob->rot, ob->rotmode); + eulO_to_mat3( dmat,ob->drot, ob->rotmode); } else if (ob->rotmode == ROT_MODE_AXISANGLE) { /* axis-angle - not really that great for 3D-changing orientations */ - AxisAngleToMat3(ob->rotAxis, ob->rotAngle, rmat); - AxisAngleToMat3(ob->drotAxis, ob->drotAngle, dmat); + axis_angle_to_mat3( rmat,ob->rotAxis, ob->rotAngle); + axis_angle_to_mat3( dmat,ob->drotAxis, ob->drotAngle); } else { /* quats are normalised before use to eliminate scaling issues */ - NormalQuat(ob->quat); - QuatToMat3(ob->quat, rmat); - QuatToMat3(ob->dquat, dmat); + normalize_qt(ob->quat); + quat_to_mat3( rmat,ob->quat); + quat_to_mat3( dmat,ob->dquat); } /* combine these rotations */ // XXX is this correct? if errors, change the order of multiplication... - Mat3MulMat3(mat, dmat, rmat); + mul_m3_m3m3(mat, dmat, rmat); } void object_to_mat3(Object *ob, float mat[][3]) /* no parent */ @@ -1627,7 +1627,7 @@ void object_to_mat3(Object *ob, float mat[][3]) /* no parent */ /* rot */ object_rot_to_mat3(ob, rmat); - Mat3MulMat3(mat, rmat, smat); + mul_m3_m3m3(mat, rmat, smat); } void object_to_mat4(Object *ob, float mat[][4]) @@ -1636,7 +1636,7 @@ void object_to_mat4(Object *ob, float mat[][4]) object_to_mat3(ob, tmat); - Mat4CpyMat3(mat, tmat); + copy_m4_m3(mat, tmat); mat[3][0]= ob->loc[0] + ob->dloc[0]; mat[3][1]= ob->loc[1] + ob->dloc[1]; @@ -1651,7 +1651,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) float q[4], vec[4], dir[3], quat[4], radius, x1, ctime; float timeoffs = 0.0, sf_orig = 0.0; - Mat4One(mat); + unit_m4(mat); cu= par->data; if(cu->path==NULL || cu->path->data==NULL) /* only happens on reload file, but violates depsgraph still... fix! */ @@ -1699,25 +1699,25 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) if( where_on_path(par, ctime, vec, dir, NULL, &radius) ) { if(cu->flag & CU_FOLLOW) { - vectoquat(dir, ob->trackflag, ob->upflag, quat); + vec_to_quat( quat,dir, ob->trackflag, ob->upflag); /* the tilt */ - Normalize(dir); + normalize_v3(dir); q[0]= (float)cos(0.5*vec[3]); x1= (float)sin(0.5*vec[3]); q[1]= -x1*dir[0]; q[2]= -x1*dir[1]; q[3]= -x1*dir[2]; - QuatMul(quat, q, quat); + mul_qt_qtqt(quat, q, quat); - QuatToMat4(quat, mat); + quat_to_mat4( mat,quat); } if(cu->flag & CU_PATH_RADIUS) { float tmat[4][4], rmat[4][4]; - Mat4Scale(tmat, radius); - Mat4MulMat4(rmat, mat, tmat); - Mat4CpyMat4(mat, rmat); + scale_m4_fl(tmat, radius); + mul_m4_m4m4(rmat, mat, tmat); + copy_m4_m4(mat, rmat); } VECCOPY(mat[3], vec); @@ -1731,7 +1731,7 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4]) float vec[3]; if (par->type!=OB_ARMATURE) { - Mat4One(mat); + unit_m4(mat); return; } @@ -1739,17 +1739,17 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4]) pchan= get_pose_channel(par->pose, ob->parsubstr); if (!pchan){ printf ("Object %s with Bone parent: bone %s doesn't exist\n", ob->id.name+2, ob->parsubstr); - Mat4One(mat); + unit_m4(mat); return; } /* get bone transform */ - Mat4CpyMat4(mat, pchan->pose_mat); + copy_m4_m4(mat, pchan->pose_mat); /* but for backwards compatibility, the child has to move to the tail */ VECCOPY(vec, mat[1]); - VecMulf(vec, pchan->bone->length); - VecAddf(mat[3], mat[3], vec); + mul_v3_fl(vec, pchan->bone->length); + add_v3_v3v3(mat[3], mat[3], vec); } static void give_parvert(Object *par, int nr, float *vec) @@ -1788,7 +1788,7 @@ static void give_parvert(Object *par, int nr, float *vec) if(vindex == nr) { dm->getVertCo(dm, i, co); - VecAddf(vec, vec, co); + add_v3_v3v3(vec, vec, co); count++; } } @@ -1796,7 +1796,7 @@ static void give_parvert(Object *par, int nr, float *vec) if (count==0) { /* keep as 0,0,0 */ } else if(count > 0) { - VecMulf(vec, 1.0f / count); + mul_v3_fl(vec, 1.0f / count); } else { /* use first index if its out of range */ dm->getVertCo(dm, 0, vec); @@ -1880,7 +1880,7 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4]) float cmat[3][3], v1[3], v2[3], v3[3], q[4]; /* in local ob space */ - Mat4One(mat); + unit_m4(mat); if (ELEM4(par->type, OB_MESH, OB_SURF, OB_CURVE, OB_LATTICE)) { @@ -1888,17 +1888,17 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4]) give_parvert(par, ob->par2, v2); give_parvert(par, ob->par3, v3); - triatoquat(v1, v2, v3, q); - QuatToMat3(q, cmat); - Mat4CpyMat3(mat, cmat); + tri_to_quat( q,v1, v2, v3); + quat_to_mat3( cmat,q); + copy_m4_m3(mat, cmat); if(ob->type==OB_CURVE) { VECCOPY(mat[3], v1); } else { - VecAddf(mat[3], v1, v2); - VecAddf(mat[3], mat[3], v3); - VecMulf(mat[3], 0.3333333f); + add_v3_v3v3(mat[3], v1, v2); + add_v3_v3v3(mat[3], mat[3], v3); + mul_v3_fl(mat[3], 0.3333333f); } } } @@ -1986,8 +1986,8 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime) } /* set negative scale flag in object */ - Crossf(vec, ob->obmat[0], ob->obmat[1]); - if( Inpf(vec, ob->obmat[2]) < 0.0 ) ob->transflag |= OB_NEG_SCALE; + cross_v3_v3v3(vec, ob->obmat[0], ob->obmat[1]); + if( dot_v3v3(vec, ob->obmat[2]) < 0.0 ) ob->transflag |= OB_NEG_SCALE; else ob->transflag &= ~OB_NEG_SCALE; } @@ -2001,7 +2001,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ object_to_mat4(ob, locmat); - if(ob->partype & PARSLOW) Mat4CpyMat4(slowmat, obmat); + if(ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat); switch(ob->partype & PARTYPE) { case PAROBJECT: @@ -2013,43 +2013,43 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ } } - if(ok) Mat4MulSerie(totmat, par->obmat, tmat, + if(ok) mul_serie_m4(totmat, par->obmat, tmat, NULL, NULL, NULL, NULL, NULL, NULL); - else Mat4CpyMat4(totmat, par->obmat); + else copy_m4_m4(totmat, par->obmat); break; case PARBONE: ob_parbone(ob, par, tmat); - Mat4MulSerie(totmat, par->obmat, tmat, + mul_serie_m4(totmat, par->obmat, tmat, NULL, NULL, NULL, NULL, NULL, NULL); break; case PARVERT1: - Mat4One(totmat); + unit_m4(totmat); if (simul){ VECCOPY(totmat[3], par->obmat[3]); } else{ give_parvert(par, ob->par1, vec); - VecMat4MulVecfl(totmat[3], par->obmat, vec); + mul_v3_m4v3(totmat[3], par->obmat, vec); } break; case PARVERT3: ob_parvert3(ob, par, tmat); - Mat4MulSerie(totmat, par->obmat, tmat, + mul_serie_m4(totmat, par->obmat, tmat, NULL, NULL, NULL, NULL, NULL, NULL); break; case PARSKEL: - Mat4CpyMat4(totmat, par->obmat); + copy_m4_m4(totmat, par->obmat); break; } // total - Mat4MulSerie(tmat, totmat, ob->parentinv, + mul_serie_m4(tmat, totmat, ob->parentinv, NULL, NULL, NULL, NULL, NULL, NULL); - Mat4MulSerie(obmat, tmat, locmat, + mul_serie_m4(obmat, tmat, locmat, NULL, NULL, NULL, NULL, NULL, NULL); if (simul) { @@ -2057,7 +2057,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ } else{ // external usable originmat - Mat3CpyMat4(originmat, tmat); + copy_m3_m4(originmat, tmat); // origin, voor help line if( (ob->partype & 15)==PARSKEL ) { @@ -2076,9 +2076,9 @@ void solve_tracking (Object *ob, float targetmat[][4]) float totmat[3][3]; float tmat[4][4]; - VecSubf(vec, ob->obmat[3], targetmat[3]); - vectoquat(vec, ob->trackflag, ob->upflag, quat); - QuatToMat3(quat, totmat); + sub_v3_v3v3(vec, ob->obmat[3], targetmat[3]); + vec_to_quat( quat,vec, ob->trackflag, ob->upflag); + quat_to_mat3( totmat,quat); if(ob->parent && (ob->transflag & OB_POWERTRACK)) { /* 'temporal' : clear parent info */ @@ -2091,9 +2091,9 @@ void solve_tracking (Object *ob, float targetmat[][4]) tmat[3][2]= ob->obmat[3][2]; tmat[3][3]= ob->obmat[3][3]; } - else Mat4CpyMat4(tmat, ob->obmat); + else copy_m4_m4(tmat, ob->obmat); - Mat4MulMat34(ob->obmat, totmat, tmat); + mul_m4_m3m4(ob->obmat, totmat, tmat); } @@ -2165,9 +2165,9 @@ void what_does_parent(Scene *scene, Object *ob, Object *workob) { clear_workob(workob); - Mat4One(workob->obmat); - Mat4One(workob->parentinv); - Mat4One(workob->constinv); + unit_m4(workob->obmat); + unit_m4(workob->parentinv); + unit_m4(workob->constinv); workob->parent= ob->parent; workob->track= ob->track; @@ -2255,7 +2255,7 @@ void minmax_object(Object *ob, float *min, float *max) bb= *(cu->bb); for(a=0; a<8; a++) { - Mat4MulVecfl(ob->obmat, bb.vec[a]); + mul_m4_v3(ob->obmat, bb.vec[a]); DO_MINMAX(bb.vec[a], min, max); } break; @@ -2264,10 +2264,10 @@ void minmax_object(Object *ob, float *min, float *max) bPoseChannel *pchan; for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { VECCOPY(vec, pchan->pose_head); - Mat4MulVecfl(ob->obmat, vec); + mul_m4_v3(ob->obmat, vec); DO_MINMAX(vec, min, max); VECCOPY(vec, pchan->pose_tail); - Mat4MulVecfl(ob->obmat, vec); + mul_m4_v3(ob->obmat, vec); DO_MINMAX(vec, min, max); } break; @@ -2280,7 +2280,7 @@ void minmax_object(Object *ob, float *min, float *max) bb = *mesh_get_bb(ob); for(a=0; a<8; a++) { - Mat4MulVecfl(ob->obmat, bb.vec[a]); + mul_m4_v3(ob->obmat, bb.vec[a]); DO_MINMAX(bb.vec[a], min, max); } } @@ -2292,11 +2292,11 @@ void minmax_object(Object *ob, float *min, float *max) DO_MINMAX(ob->obmat[3], min, max); VECCOPY(vec, ob->obmat[3]); - VecAddf(vec, vec, ob->size); + add_v3_v3v3(vec, vec, ob->size); DO_MINMAX(vec, min, max); VECCOPY(vec, ob->obmat[3]); - VecSubf(vec, vec, ob->size); + sub_v3_v3v3(vec, vec, ob->size); DO_MINMAX(vec, min, max); break; } @@ -2347,11 +2347,11 @@ void object_handle_update(Scene *scene, Object *ob) // printf("ob proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name); if(ob->proxy_from->proxy_group) {/* transform proxy into group space */ Object *obg= ob->proxy_from->proxy_group; - Mat4Invert(obg->imat, obg->obmat); - Mat4MulMat4(ob->obmat, ob->proxy_from->obmat, obg->imat); + invert_m4_m4(obg->imat, obg->obmat); + mul_m4_m4m4(ob->obmat, ob->proxy_from->obmat, obg->imat); } else - Mat4CpyMat4(ob->obmat, ob->proxy_from->obmat); + copy_m4_m4(ob->obmat, ob->proxy_from->obmat); } else where_is_object(scene, ob); @@ -2532,7 +2532,7 @@ int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3 v1 = triangle_indexes[i][0]; v2 = triangle_indexes[i][1]; v3 = triangle_indexes[i][2]; - result = RayIntersectsTriangle(ray_start, ray_normal, bb->vec[v1], bb->vec[v2], bb->vec[v3], &lambda, NULL); + result = isect_ray_tri_v3(ray_start, ray_normal, bb->vec[v1], bb->vec[v2], bb->vec[v3], &lambda, NULL); } return result; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 6bd2a03a628..860533652ad 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -51,7 +51,7 @@ #include "DNA_smoke_types.h" #include "DNA_texture_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" #include "BLI_kdtree.h" @@ -618,12 +618,12 @@ static float psys_render_projected_area(ParticleSystem *psys, float *center, flo /* transform to view space */ VECCOPY(co, center); co[3]= 1.0f; - Mat4MulVec4fl(data->viewmat, co); + mul_m4_v4(data->viewmat, co); /* compute two vectors orthogonal to view vector */ VECCOPY(view, co); - Normalize(view); - VecOrthoBasisf(view, ortho1, ortho2); + normalize_v3(view); + ortho_basis_v3v3_v3( ortho1, ortho2,view); /* compute on screen minification */ w= co[2]*data->winmat[2][3] + data->winmat[3][3]; @@ -637,7 +637,7 @@ static float psys_render_projected_area(ParticleSystem *psys, float *center, flo /* viewport of the screen test */ /* project point on screen */ - Mat4MulVec4fl(data->winmat, co); + mul_m4_v4(data->winmat, co); if(co[3] != 0.0f) { co[0]= 0.5f*data->winx*(1.0f + co[0]/co[3]); co[1]= 0.5f*data->winy*(1.0f + co[1]/co[3]); @@ -698,9 +698,9 @@ void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float psys->pathcachebufs.first = psys->pathcachebufs.last = NULL; psys->childcachebufs.first = psys->childcachebufs.last = NULL; - Mat4CpyMat4(data->winmat, winmat); - Mat4MulMat4(data->viewmat, ob->obmat, viewmat); - Mat4MulMat4(data->mat, data->viewmat, winmat); + copy_m4_m4(data->winmat, winmat); + mul_m4_m4m4(data->viewmat, ob->obmat, viewmat); + mul_m4_m4m4(data->mat, data->viewmat, winmat); data->winx= winx; data->winy= winy; @@ -828,11 +828,11 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) if(mf->v4) { VECCOPY(co4, mvert[mf->v4].co); VECADD(facecenter[b], facecenter[b], co4); - facearea[b] += AreaQ3Dfl(co1, co2, co3, co4); + facearea[b] += area_quad_v3(co1, co2, co3, co4); facetotvert[b] += 4; } else { - facearea[b] += AreaT3Dfl(co1, co2, co3); + facearea[b] += area_tri_v3(co1, co2, co3); facetotvert[b] += 3; } } @@ -840,7 +840,7 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) for(a=0; a<totorigface; a++) if(facetotvert[a] > 0) - VecMulf(facecenter[a], 1.0f/facetotvert[a]); + mul_v3_fl(facecenter[a], 1.0f/facetotvert[a]); /* for conversion from BU area / pixel area to reference screen size */ mesh_get_texspace(me, 0, 0, size); @@ -1007,7 +1007,7 @@ void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, Partic float t[4]; if(type<0) { - VecfCubicInterpol(keys[1].co, keys[1].vel, keys[2].co, keys[2].vel, dt, result->co, result->vel); + interp_cubic_v3( result->co, result->vel,keys[1].co, keys[1].vel, keys[2].co, keys[2].vel, dt); } else { key_curve_position_weights(dt, t, type); @@ -1280,9 +1280,9 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData /* convert velocity to timestep size */ if(pind->keyed || pind->cache || point_vel){ - VecMulf(keys[1].vel, dfra / frs_sec); - VecMulf(keys[2].vel, dfra / frs_sec); - QuatInterpol(result->rot,keys[1].rot,keys[2].rot,keytime); + mul_v3_fl(keys[1].vel, dfra / frs_sec); + mul_v3_fl(keys[2].vel, dfra / frs_sec); + interp_qt_qtqt(result->rot,keys[1].rot,keys[2].rot,keytime); } /* now we should have in chronologiacl order k1<=k2<=t<=k3<=k4 with keytime between [0,1]->[k2,k3] (k1 & k4 used for cardinal & bspline interpolation)*/ @@ -1292,7 +1292,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData /* the velocity needs to be converted back from cubic interpolation */ if(pind->keyed || pind->cache || point_vel) - VecMulf(result->vel, frs_sec / dfra); + mul_v3_fl(result->vel, frs_sec / dfra); } /************************************************/ /* Particles on a dm */ @@ -1312,14 +1312,14 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or VECCOPY(n1,(mvert+mface->v1)->no); VECCOPY(n2,(mvert+mface->v2)->no); VECCOPY(n3,(mvert+mface->v3)->no); - Normalize(n1); - Normalize(n2); - Normalize(n3); + normalize_v3(n1); + normalize_v3(n2); + normalize_v3(n3); if(mface->v4) { v4= (mvert+mface->v4)->co; VECCOPY(n4,(mvert+mface->v4)->no); - Normalize(n4); + normalize_v3(n4); vec[0]= w[0]*v1[0] + w[1]*v2[0] + w[2]*v3[0] + w[3]*v4[0]; vec[1]= w[0]*v1[1] + w[1]*v2[1] + w[2]*v3[1] + w[3]*v4[1]; @@ -1332,7 +1332,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or nor[2]= w[0]*n1[2] + w[1]*n2[2] + w[2]*n3[2] + w[3]*n4[2]; } else - CalcNormFloat4(v1,v2,v3,v4,nor); + normal_quad_v3(nor,v1,v2,v3,v4); } } else { @@ -1347,7 +1347,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or nor[2]= w[0]*n1[2] + w[1]*n2[2] + w[2]*n3[2]; } else - CalcNormFloat(v1,v2,v3,nor); + normal_tri_v3(nor,v1,v2,v3); } } @@ -1361,11 +1361,11 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or } else{ uv1= tuv[0]; uv2= tuv[1]; uv3= tuv[2]; uv4= tuv[3]; - spheremap(v1[0], v1[1], v1[2], uv1, uv1+1); - spheremap(v2[0], v2[1], v2[2], uv2, uv2+1); - spheremap(v3[0], v3[1], v3[2], uv3, uv3+1); + map_to_sphere( uv1, uv1+1,v1[0], v1[1], v1[2]); + map_to_sphere( uv2, uv2+1,v2[0], v2[1], v2[2]); + map_to_sphere( uv3, uv3+1,v3[0], v3[1], v3[2]); if(v4) - spheremap(v4[0], v4[1], v4[2], uv4, uv4+1); + map_to_sphere( uv4, uv4+1,v4[0], v4[1], v4[2]); } if(v4){ @@ -1375,8 +1375,8 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or t1= uv3[1] - uv1[1]; t2= uv4[1] - uv1[1]; - VecSubf(e1, v3, v1); - VecSubf(e2, v4, v1); + sub_v3_v3v3(e1, v3, v1); + sub_v3_v3v3(e2, v4, v1); } else{ s1= uv2[0] - uv1[0]; @@ -1385,8 +1385,8 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or t1= uv2[1] - uv1[1]; t2= uv3[1] - uv1[1]; - VecSubf(e1, v2, v1); - VecSubf(e2, v3, v1); + sub_v3_v3v3(e1, v2, v1); + sub_v3_v3v3(e2, v3, v1); } vtan[0] = (s1*e2[0] - s2*e1[0]); @@ -1411,7 +1411,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or orco[2]= w[0]*o1[2] + w[1]*o2[2] + w[2]*o3[2] + w[3]*o4[2]; if(ornor) - CalcNormFloat4(o1, o2, o3, o4, ornor); + normal_quad_v3( ornor,o1, o2, o3, o4); } else { orco[0]= w[0]*o1[0] + w[1]*o2[0] + w[2]*o3[0]; @@ -1419,7 +1419,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or orco[2]= w[0]*o1[2] + w[1]*o2[2] + w[2]*o3[2]; if(ornor) - CalcNormFloat(o1, o2, o3, ornor); + normal_tri_v3( ornor,o1, o2, o3); } } else { @@ -1517,10 +1517,10 @@ static void psys_origspace_to_w(OrigSpaceFace *osface, int quad, float *w, float if(quad) { v[3][0]= osface->uv[3][0]; v[3][1]= osface->uv[3][1]; v[3][2]= 0.0f; - MeanValueWeights(v, 4, co, neww); + interp_weights_poly_v3( neww,v, 4, co); } else { - MeanValueWeights(v, 3, co, neww); + interp_weights_poly_v3( neww,v, 3, co); neww[3]= 0.0f; } } @@ -1566,10 +1566,10 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, float * /* check that this intersects - Its possible this misses :/ - * could also check its not between */ if(quad) { - if(IsectPQ2Df(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3])) + if(isect_point_quad_v2(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3])) return findex; } - else if(IsectPT2Df(uv, faceuv[0], faceuv[1], faceuv[2])) + else if(isect_point_tri_v2(uv, faceuv[0], faceuv[1], faceuv[2])) return findex; } } @@ -1582,10 +1582,10 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, float * /* check that this intersects - Its possible this misses :/ - * could also check its not between */ if(quad) { - if(IsectPQ2Df(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3])) + if(isect_point_quad_v2(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3])) return findex; } - else if(IsectPT2Df(uv, faceuv[0], faceuv[1], faceuv[2])) + else if(isect_point_tri_v2(uv, faceuv[0], faceuv[1], faceuv[2])) return findex; } } @@ -1678,7 +1678,7 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache if(nor) { dm->getVertNo(dm,mapindex,nor); - Normalize(nor); + normalize_v3(nor); } if(orco) @@ -1686,7 +1686,7 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache if(ornor) { dm->getVertNo(dm,mapindex,nor); - Normalize(nor); + normalize_v3(nor); } if(utan && vtan) { @@ -1711,8 +1711,8 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache if(nor) VECCOPY(nor,tmpnor); - Normalize(tmpnor); - VecMulf(tmpnor,-foffset); + normalize_v3(tmpnor); + mul_v3_fl(tmpnor,-foffset); VECADD(vec,vec,tmpnor); } else @@ -1835,42 +1835,42 @@ static void do_prekink(ParticleKey *state, ParticleKey *par, float *par_rot, flo if(par_rot) QUATCOPY(q2,par_rot) else - vectoquat(par->vel,axis,(axis+1)%3, q2); - QuatMulVecf(q2,vec); - VecMulf(vec,amplitude); + vec_to_quat( q2,par->vel,axis,(axis+1)%3); + mul_qt_v3(q2,vec); + mul_v3_fl(vec,amplitude); VECADD(state->co,state->co,vec); VECSUB(vec,state->co,par->co); if(t!=0.0) - VecRotToQuat(par->vel,t,q1); + axis_angle_to_quat(q1,par->vel,t); - QuatMulVecf(q1,vec); + mul_qt_v3(q1,vec); VECADD(state->co,par->co,vec); break; case PART_KINK_RADIAL: VECSUB(vec,state->co,par->co); - Normalize(vec); - VecMulf(vec,amplitude*(float)sin(t)); + normalize_v3(vec); + mul_v3_fl(vec,amplitude*(float)sin(t)); VECADD(state->co,state->co,vec); break; case PART_KINK_WAVE: vec[axis]=1.0; if(obmat) - Mat4Mul3Vecfl(obmat,vec); + mul_mat3_m4_v3(obmat,vec); if(par_rot) - QuatMulVecf(par_rot,vec); + mul_qt_v3(par_rot,vec); - Projf(q1,vec,par->vel); + project_v3_v3v3(q1,vec,par->vel); VECSUB(vec,vec,q1); - Normalize(vec); + normalize_v3(vec); - VecMulf(vec,amplitude*(float)sin(t)); + mul_v3_fl(vec,amplitude*(float)sin(t)); VECADD(state->co,state->co,vec); break; @@ -1884,46 +1884,46 @@ static void do_prekink(ParticleKey *state, ParticleKey *par, float *par_rot, flo if(par_rot) QUATCOPY(q2,par_rot) else - vectoquat(par->vel,axis,(axis+1)%3,q2); - QuatMulVecf(q2,y_vec); - QuatMulVecf(q2,z_vec); + vec_to_quat(q2,par->vel,axis,(axis+1)%3); + mul_qt_v3(q2,y_vec); + mul_qt_v3(q2,z_vec); VECSUB(vec_from_par,state->co,par->co); VECCOPY(vec_one,vec_from_par); - radius=Normalize(vec_one); + radius=normalize_v3(vec_one); - inp_y=Inpf(y_vec,vec_one); - inp_z=Inpf(z_vec,vec_one); + inp_y=dot_v3v3(y_vec,vec_one); + inp_z=dot_v3v3(z_vec,vec_one); if(inp_y>0.5){ VECCOPY(state_co,y_vec); - VecMulf(y_vec,amplitude*(float)cos(t)); - VecMulf(z_vec,amplitude/2.0f*(float)sin(2.0f*t)); + mul_v3_fl(y_vec,amplitude*(float)cos(t)); + mul_v3_fl(z_vec,amplitude/2.0f*(float)sin(2.0f*t)); } else if(inp_z>0.0){ VECCOPY(state_co,z_vec); - VecMulf(state_co,(float)sin(M_PI/3.0f)); + mul_v3_fl(state_co,(float)sin(M_PI/3.0f)); VECADDFAC(state_co,state_co,y_vec,-0.5f); - VecMulf(y_vec,-amplitude*(float)cos(t + M_PI/3.0f)); - VecMulf(z_vec,amplitude/2.0f*(float)cos(2.0f*t + M_PI/6.0f)); + mul_v3_fl(y_vec,-amplitude*(float)cos(t + M_PI/3.0f)); + mul_v3_fl(z_vec,amplitude/2.0f*(float)cos(2.0f*t + M_PI/6.0f)); } else{ VECCOPY(state_co,z_vec); - VecMulf(state_co,-(float)sin(M_PI/3.0f)); + mul_v3_fl(state_co,-(float)sin(M_PI/3.0f)); VECADDFAC(state_co,state_co,y_vec,-0.5f); - VecMulf(y_vec,amplitude*(float)-sin(t+M_PI/6.0f)); - VecMulf(z_vec,amplitude/2.0f*(float)-sin(2.0f*t+M_PI/3.0f)); + mul_v3_fl(y_vec,amplitude*(float)-sin(t+M_PI/6.0f)); + mul_v3_fl(z_vec,amplitude/2.0f*(float)-sin(2.0f*t+M_PI/3.0f)); } - VecMulf(state_co,amplitude); + mul_v3_fl(state_co,amplitude); VECADD(state_co,state_co,par->co); VECSUB(vec_from_par,state->co,state_co); - length=Normalize(vec_from_par); - VecMulf(vec_from_par,MIN2(length,amplitude/2.0f)); + length=normalize_v3(vec_from_par); + mul_v3_fl(vec_from_par,MIN2(length,amplitude/2.0f)); VECADD(state_co,par->co,y_vec); VECADD(state_co,state_co,z_vec); @@ -1934,7 +1934,7 @@ static void do_prekink(ParticleKey *state, ParticleKey *par, float *par_rot, flo if(t<shape){ shape=t/shape; shape=(float)sqrt((double)shape); - VecLerpf(state->co,state->co,state_co,shape); + interp_v3_v3v3(state->co,state->co,state_co,shape); } else{ VECCOPY(state->co,state_co); @@ -1958,7 +1958,7 @@ static void do_clump(ParticleKey *state, ParticleKey *par, float time, float clu clump = -clumpfac*pa_clump*(float)pow(1.0-(double)time,(double)cpow); else clump = clumpfac*pa_clump*(float)pow((double)time,(double)cpow); - VecLerpf(state->co,state->co,par->co,clump); + interp_v3_v3v3(state->co,state->co,par->co,clump); } } void precalc_guides(ParticleSimulationData *sim, ListBase *effectors) @@ -1990,7 +1990,7 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors) VECSUB(efd.vec_to_point, state.co, eff->guide_loc); VECCOPY(efd.nor, eff->guide_dir); - efd.distance = VecLength(efd.vec_to_point); + efd.distance = len_v3(efd.vec_to_point); VECCOPY(data->vec_to_point, efd.vec_to_point); data->strength = effector_falloff(eff, &efd, &point, weights); @@ -2037,33 +2037,33 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) return 0; } - Mat4MulVecfl(eff->ob->obmat, guidevec); - Mat4Mul3Vecfl(eff->ob->obmat, guidedir); + mul_m4_v3(eff->ob->obmat, guidevec); + mul_mat3_m4_v3(eff->ob->obmat, guidedir); - Normalize(guidedir); + normalize_v3(guidedir); VECCOPY(vec_to_point, data->vec_to_point); if(guidetime != 0.0){ /* curve direction */ - Crossf(temp, eff->guide_dir, guidedir); - angle = Inpf(eff->guide_dir, guidedir)/(VecLength(eff->guide_dir)); + cross_v3_v3v3(temp, eff->guide_dir, guidedir); + angle = dot_v3v3(eff->guide_dir, guidedir)/(len_v3(eff->guide_dir)); angle = saacos(angle); - VecRotToQuat(temp, angle, rot2); - QuatMulVecf(rot2, vec_to_point); + axis_angle_to_quat( rot2,temp, angle); + mul_qt_v3(rot2, vec_to_point); /* curve tilt */ - VecRotToQuat(guidedir, guidevec[3] - eff->guide_loc[3], rot2); - QuatMulVecf(rot2, vec_to_point); + axis_angle_to_quat( rot2,guidedir, guidevec[3] - eff->guide_loc[3]); + mul_qt_v3(rot2, vec_to_point); } /* curve taper */ if(cu->taperobj) - VecMulf(vec_to_point, calc_taper(eff->scene, cu->taperobj, (int)(data->strength*guidetime*100.0), 100)); + mul_v3_fl(vec_to_point, calc_taper(eff->scene, cu->taperobj, (int)(data->strength*guidetime*100.0), 100)); else{ /* curve size*/ if(cu->flag & CU_PATH_RADIUS) { - VecMulf(vec_to_point, radius); + mul_v3_fl(vec_to_point, radius); } } par.co[0] = par.co[1] = par.co[2] = 0.0f; @@ -2081,13 +2081,13 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) if(totstrength != 0.0){ if(totstrength > 1.0) - VecMulf(effect, 1.0f / totstrength); + mul_v3_fl(effect, 1.0f / totstrength); CLAMP(totstrength, 0.0, 1.0); //VECADD(effect,effect,pa_zero); - VecLerpf(state->co, state->co, effect, totstrength); + interp_v3_v3v3(state->co, state->co, effect, totstrength); - Normalize(veffect); - VecMulf(veffect, VecLength(state->vel)); + normalize_v3(veffect); + mul_v3_fl(veffect, len_v3(state->vel)); VECCOPY(state->vel, veffect); return 1; } @@ -2102,7 +2102,7 @@ static void do_rough(float *loc, float mat[4][4], float t, float fac, float size if((float)fabs((float)(-1.5+loc[0]+loc[1]+loc[2]))<1.5f*thres) return; VECCOPY(rco,loc); - VecMulf(rco,t); + mul_v3_fl(rco,t); rough[0]=-1.0f+2.0f*BLI_gTurbulence(size, rco[0], rco[1], rco[2], 2,0,2); rough[1]=-1.0f+2.0f*BLI_gTurbulence(size, rco[1], rco[2], rco[0], 2,0,2); rough[2]=-1.0f+2.0f*BLI_gTurbulence(size, rco[2], rco[0], rco[1], 2,0,2); @@ -2117,10 +2117,10 @@ static void do_rough_end(float *loc, float mat[4][4], float t, float fac, float float roughfac; roughfac=fac*(float)pow((double)t,shape); - Vec2Copyf(rough,loc); + copy_v2_v2(rough,loc); rough[0]=-1.0f+2.0f*rough[0]; rough[1]=-1.0f+2.0f*rough[1]; - Vec2Mulf(rough,roughfac); + mul_v2_fl(rough,roughfac); VECADDFAC(state->co,state->co,mat[0],rough[0]); VECADDFAC(state->co,state->co,mat[1],rough[1]); @@ -2142,23 +2142,23 @@ static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheK pd_point_from_particle(sim, sim->psys->particles+i, &eff_key, &epoint); pdDoEffectors(sim->psys->effectors, sim->colliders, sim->psys->part->effector_weights, &epoint, force, NULL); - VecMulf(force, effector*pow((float)k / (float)steps, 100.0f * sim->psys->part->eff_hair) / (float)steps); + mul_v3_fl(force, effector*pow((float)k / (float)steps, 100.0f * sim->psys->part->eff_hair) / (float)steps); - VecAddf(force, force, vec); + add_v3_v3v3(force, force, vec); - Normalize(force); + normalize_v3(force); VECADDFAC(ca->co, (ca-1)->co, force, *length); if(k < steps) { - VecSubf(vec, (ca+1)->co, ca->co); - *length = VecLength(vec); + sub_v3_v3v3(vec, (ca+1)->co, ca->co); + *length = len_v3(vec); } } static int check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *state, float max_length, float *cur_length, float length, float *dvec) { if(*cur_length + length > max_length){ - VecMulf(dvec, (max_length - *cur_length) / length); + mul_v3_fl(dvec, (max_length - *cur_length) / length); VECADD(state->co, (state - 1)->co, dvec); keys->steps = k; /* something over the maximum step value */ @@ -2172,13 +2172,13 @@ static int check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *st static void offset_child(ChildParticle *cpa, ParticleKey *par, ParticleKey *child, float flat, float radius) { VECCOPY(child->co,cpa->fuv); - VecMulf(child->co,radius); + mul_v3_fl(child->co,radius); child->co[0]*=flat; VECCOPY(child->vel,par->vel); - QuatMulVecf(par->rot,child->co); + mul_qt_v3(par->rot,child->co); QUATCOPY(child->rot,par->rot); @@ -2247,14 +2247,14 @@ static void get_strand_normal(Material *ma, float *surfnor, float surfdist, floa return; if(ma->mode & MA_STR_SURFDIFF) { - Crossf(cross, surfnor, nor); - Crossf(nstrand, nor, cross); + cross_v3_v3v3(cross, surfnor, nor); + cross_v3_v3v3(nstrand, nor, cross); blend= INPR(nstrand, surfnor); CLAMP(blend, 0.0f, 1.0f); - VecLerpf(vnor, nstrand, surfnor, blend); - Normalize(vnor); + interp_v3_v3v3(vnor, nstrand, surfnor, blend); + normalize_v3(vnor); } else VECCOPY(vnor, nor) @@ -2262,8 +2262,8 @@ static void get_strand_normal(Material *ma, float *surfnor, float surfdist, floa if(ma->strand_surfnor > 0.0f) { if(ma->strand_surfnor > surfdist) { blend= (ma->strand_surfnor - surfdist)/ma->strand_surfnor; - VecLerpf(vnor, vnor, surfnor, blend); - Normalize(vnor); + interp_v3_v3v3(vnor, vnor, surfnor, blend); + normalize_v3(vnor); } } @@ -2276,7 +2276,7 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c /* Object *ob= ctx->sim.ob; */ ParticleSystem *psys= ctx->sim.psys; ParticleSettings *part = psys->part; - ParticleEditSettings *pset = &scene->toolsettings->particle; +/* ParticleEditSettings *pset = &scene->toolsettings->particle; */ int totparent=0, between=0; int steps = (int)pow(2.0, (double)part->draw_step); int totchild = psys->totchild; @@ -2440,7 +2440,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle if(part->path_start==0.0f) { /* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */ VECCOPY(cpa_1st,co); - Mat4MulVecfl(ob->obmat,cpa_1st); + mul_m4_v3(ob->obmat,cpa_1st); } pa = psys->particles + cpa->parent; @@ -2538,8 +2538,8 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle do_path_effectors(&ctx->sim, cpa->pa[0], state, k, ctx->steps, keys->co, ptex.effector, 0.0f, ctx->cfra, &eff_length, eff_vec); } else { - VecSubf(eff_vec,(state+1)->co,state->co); - eff_length= VecLength(eff_vec); + sub_v3_v3v3(eff_vec,(state+1)->co,state->co); + eff_length= len_v3(eff_vec); } } } @@ -2599,17 +2599,17 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle // } // if(i<psys->totpart) - // VecLerpf(state->co, (pcache[i] + k)->co, state->co, branchfac); + // interp_v3_v3v3(state->co, (pcache[i] + k)->co, state->co, branchfac); // else // /* this is not threadsafe, but should only happen for // * branching particles particles, which are not threaded */ - // VecLerpf(state->co, (cache[i - psys->totpart] + k)->co, state->co, branchfac); + // interp_v3_v3v3(state->co, (cache[i - psys->totpart] + k)->co, state->co, branchfac); //} /* we have to correct velocity because of kink & clump */ if(k>1){ VECSUB((state-1)->vel,state->co,(state-2)->co); - VecMulf((state-1)->vel,0.5); + mul_v3_fl((state-1)->vel,0.5); if(ctx->ma && (part->draw & PART_DRAW_MAT_COL)) get_strand_normal(ctx->ma, ornor, cur_length, (state-1)->vel); @@ -2841,9 +2841,9 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) /* dynamic hair is in object space */ /* keyed and baked are allready in global space */ if(hair_dm) - Mat4MulVecfl(sim->ob->obmat, result.co); + mul_m4_v3(sim->ob->obmat, result.co); else if(!keyed && !baked && !(psys->flag & PSYS_GLOBAL_HAIR)) - Mat4MulVecfl(hairmat, result.co); + mul_m4_v3(hairmat, result.co); VECCOPY(ca->co, result.co); VECCOPY(ca->col, col); @@ -2851,8 +2851,8 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) /*--modify paths and calculate rotation & velocity--*/ - VecSubf(vec,(cache[p]+1)->co,cache[p]->co); - length = VecLength(vec); + sub_v3_v3v3(vec,(cache[p]+1)->co,cache[p]->co); + length = len_v3(vec); effector= 1.0f; if(vg_effector) @@ -2882,7 +2882,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) /* calculate initial tangent for incremental rotations */ VECSUB(tangent, ca->co, (ca - 1)->co); VECCOPY(prev_tangent, tangent); - Normalize(prev_tangent); + normalize_v3(prev_tangent); /* First rotation is based on emitting face orientation. */ /* This is way better than having flipping rotations resulting */ @@ -2890,13 +2890,13 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) /* It's not an ideal solution though since it disregards the */ /* initial tangent, but taking that in to account will allow */ /* the possibility of flipping again. -jahka */ - Mat3ToQuat_is_ok(rotmat, (ca-1)->rot); + mat3_to_quat_is_ok( (ca-1)->rot,rotmat); } else { VECSUB(tangent, ca->co, (ca - 1)->co); - Normalize(tangent); + normalize_v3(tangent); - cosangle= Inpf(tangent, prev_tangent); + cosangle= dot_v3v3(tangent, prev_tangent); /* note we do the comparison on cosangle instead of * angle, since floating point accuracy makes it give @@ -2906,9 +2906,9 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) } else { angle= saacos(cosangle); - Crossf(normal, prev_tangent, tangent); - VecRotToQuat(normal, angle, q); - QuatMul((ca - 1)->rot, q, (ca - 2)->rot); + cross_v3_v3v3(normal, prev_tangent, tangent); + axis_angle_to_quat( q,normal, angle); + mul_qt_qtqt((ca - 1)->rot, q, (ca - 2)->rot); } VECCOPY(prev_tangent, tangent); @@ -3034,7 +3034,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* non-hair points are allready in global space */ if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { - Mat4MulVecfl(hairmat, result.co); + mul_m4_v3(hairmat, result.co); /* create rotations for proper creation of children */ if(k) { @@ -3044,7 +3044,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* calculate initial tangent for incremental rotations */ VECSUB(tangent, ca->co, (ca - 1)->co); VECCOPY(prev_tangent, tangent); - Normalize(prev_tangent); + normalize_v3(prev_tangent); /* First rotation is based on emitting face orientation. */ /* This is way better than having flipping rotations resulting */ @@ -3052,13 +3052,13 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* It's not an ideal solution though since it disregards the */ /* initial tangent, but taking that in to account will allow */ /* the possibility of flipping again. -jahka */ - Mat3ToQuat_is_ok(rotmat, (ca-1)->rot); + mat3_to_quat_is_ok( (ca-1)->rot,rotmat); } else { VECSUB(tangent, ca->co, (ca - 1)->co); - Normalize(tangent); + normalize_v3(tangent); - cosangle= Inpf(tangent, prev_tangent); + cosangle= dot_v3v3(tangent, prev_tangent); /* note we do the comparison on cosangle instead of * angle, since floating point accuracy makes it give @@ -3068,9 +3068,9 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf } else { angle= saacos(cosangle); - Crossf(normal, prev_tangent, tangent); - VecRotToQuat(normal, angle, q); - QuatMul((ca - 1)->rot, q, (ca - 2)->rot); + cross_v3_v3v3(normal, prev_tangent, tangent); + axis_angle_to_quat( q,normal, angle); + mul_qt_qtqt((ca - 1)->rot, q, (ca - 2)->rot); } VECCOPY(prev_tangent, tangent); @@ -3094,13 +3094,13 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf } else{ keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); - VecLerpf(ca->col, sel_col, nosel_col, keytime); + interp_v3_v3v3(ca->col, sel_col, nosel_col, keytime); } } else{ if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT){ keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); - VecLerpf(ca->col, nosel_col, sel_col, keytime); + interp_v3_v3v3(ca->col, nosel_col, sel_col, keytime); } else{ VECCOPY(ca->col, nosel_col); @@ -3144,12 +3144,12 @@ static void key_from_object(Object *ob, ParticleKey *key){ VECADD(key->vel,key->vel,key->co); - Mat4MulVecfl(ob->obmat,key->co); - Mat4MulVecfl(ob->obmat,key->vel); - Mat4ToQuat(ob->obmat,q); + mul_m4_v3(ob->obmat,key->co); + mul_m4_v3(ob->obmat,key->vel); + mat4_to_quat(q,ob->obmat); VECSUB(key->vel,key->vel,key->co); - QuatMul(key->rot,q,key->rot); + mul_qt_qtqt(key->rot,q,key->rot); } #endif @@ -3161,7 +3161,7 @@ static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat mat[3][3]= 1.0f; /* first axis is the normal */ - CalcNormFloat(v1, v2, v3, mat[2]); + normal_tri_v3( mat[2],v1, v2, v3); /* second axis along (1, 0) in uv space */ if(uv) { @@ -3180,18 +3180,18 @@ static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat mat[1][0]= w1*(v2[0] - v1[0]) + w2*(v3[0] - v1[0]); mat[1][1]= w1*(v2[1] - v1[1]) + w2*(v3[1] - v1[1]); mat[1][2]= w1*(v2[2] - v1[2]) + w2*(v3[2] - v1[2]); - Normalize(mat[1]); + normalize_v3(mat[1]); } else mat[1][0]= mat[1][1]= mat[1][2]= 0.0f; } else { - VecSubf(mat[1], v2, v1); - Normalize(mat[1]); + sub_v3_v3v3(mat[1], v2, v1); + normalize_v3(mat[1]); } /* third as a cross product */ - Crossf(mat[0], mat[1], mat[2]); + cross_v3_v3v3(mat[0], mat[1], mat[2]); } static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float mat[][4], int orco) @@ -3203,7 +3203,7 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m int i = pa->num_dmcache==DMCACHE_NOTFOUND ? pa->num : pa->num_dmcache; - if (i==-1 || i >= dm->getNumFaces(dm)) { Mat4One(mat); return; } + if (i==-1 || i >= dm->getNumFaces(dm)) { unit_m4(mat); return; } mface=dm->getFaceData(dm,i,CD_MFACE); osface=dm->getFaceData(dm,i,CD_ORIGSPACE); @@ -3252,8 +3252,8 @@ void psys_vec_rot_to_face(DerivedMesh *dm, ParticleData *pa, float *vec) float mat[4][4]; psys_face_mat(0, dm, pa, mat, 0); - Mat4Transp(mat); /* cheap inverse for rotation matrix */ - Mat4Mul3Vecfl(mat, vec); + transpose_m4(mat); /* cheap inverse for rotation matrix */ + mul_mat3_m4_v3(mat, vec); } void psys_mat_hair_to_global(Object *ob, DerivedMesh *dm, short from, ParticleData *pa, float hairmat[][4]) @@ -3262,7 +3262,7 @@ void psys_mat_hair_to_global(Object *ob, DerivedMesh *dm, short from, ParticleDa psys_mat_hair_to_object(ob, dm, from, pa, facemat); - Mat4MulMat4(hairmat, facemat, ob->obmat); + mul_m4_m4m4(hairmat, facemat, ob->obmat); } /************************************************/ @@ -3334,6 +3334,8 @@ void object_remove_particle_system(Scene *scene, Object *ob) if(ob->particlesystem.first) ((ParticleSystem *) ob->particlesystem.first)->flag |= PSYS_CURRENT; + else + ob->mode &= ~OB_MODE_PARTICLE_EDIT; DAG_scene_sort(scene); DAG_id_flush_update(&ob->id, OB_RECALC_DATA); @@ -3847,8 +3849,8 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * if(!keyed && !cached) { if((pa->flag & PARS_REKEY)==0) { psys_mat_hair_to_global(sim->ob, sim->psmd->dm, part->from, pa, hairmat); - Mat4MulVecfl(hairmat, state->co); - Mat4Mul3Vecfl(hairmat, state->vel); + mul_m4_v3(hairmat, state->co); + mul_mat3_m4_v3(hairmat, state->vel); if(sim->psys->effectors && (part->flag & PART_CHILD_GUIDE)==0) { do_guides(sim->psys->effectors, state, p, state->time); @@ -3861,7 +3863,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * } } else if(totchild){ - //Mat4Invert(imat,ob->obmat); + //invert_m4_m4(imat,ob->obmat); cpa=psys->child+p-totpart; @@ -3900,7 +3902,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * /* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */ //VECCOPY(cpa_1st,co); - //Mat4MulVecfl(ob->obmat,cpa_1st); + //mul_m4_v3(ob->obmat,cpa_1st); pa = psys->particles + cpa->parent; @@ -3977,22 +3979,22 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * /* try to estimate correct velocity */ if(vel){ ParticleKey tstate; - float length = VecLength(state->vel); + float length = len_v3(state->vel); if(t>=0.001f){ tstate.time=t-0.001f; psys_get_particle_on_path(sim,p,&tstate,0); VECSUB(state->vel,state->co,tstate.co); - Normalize(state->vel); + normalize_v3(state->vel); } else{ tstate.time=t+0.001f; psys_get_particle_on_path(sim,p,&tstate,0); VECSUB(state->vel,tstate.co,state->co); - Normalize(state->vel); + normalize_v3(state->vel); } - VecMulf(state->vel, length); + mul_v3_fl(state->vel, length); } } } @@ -4099,16 +4101,16 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta keytime = (state->time - keys[1].time) / dfra; /* convert velocity to timestep size */ - VecMulf(keys[1].vel, dfra * timestep); - VecMulf(keys[2].vel, dfra * timestep); + mul_v3_fl(keys[1].vel, dfra * timestep); + mul_v3_fl(keys[2].vel, dfra * timestep); psys_interpolate_particle(-1, keys, keytime, state, 1); /* convert back to real velocity */ - VecMulf(state->vel, 1.0f / (dfra * timestep)); + mul_v3_fl(state->vel, 1.0f / (dfra * timestep)); - VecLerpf(state->ave, keys[1].ave, keys[2].ave, keytime); - QuatInterpol(state->rot, keys[1].rot, keys[2].rot, keytime); + interp_v3_v3v3(state->ave, keys[1].ave, keys[2].ave, keytime); + interp_qt_qtqt(state->rot, keys[1].rot, keys[2].rot, keytime); } } else { @@ -4182,8 +4184,8 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa float loc[3], nor[3], vec[3], side[3], len, obrotmat[4][4], qmat[4][4]; float xvec[3] = {-1.0, 0.0, 0.0}, q[4]; - VecSubf(vec, (cache+cache->steps-1)->co, cache->co); - len= Normalize(vec); + sub_v3_v3v3(vec, (cache+cache->steps-1)->co, cache->co); + len= normalize_v3(vec); if(pa) psys_particle_on_emitter(psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,nor,0,0,0,0); @@ -4196,17 +4198,17 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa if(!pa) pa= psys->particles+cpa->pa[0]; - vectoquat(xvec, ob->trackflag, ob->upflag, q); - QuatToMat4(q, obrotmat); + vec_to_quat( q,xvec, ob->trackflag, ob->upflag); + quat_to_mat4( obrotmat,q); obrotmat[3][3]= 1.0f; - QuatToMat4(pa->state.rot, qmat); - Mat4MulMat4(mat, obrotmat, qmat); + quat_to_mat4( qmat,pa->state.rot); + mul_m4_m4m4(mat, obrotmat, qmat); } else { /* make sure that we get a proper side vector */ - if(fabs(Inpf(nor,vec))>0.999999) { - if(fabs(Inpf(nor,xvec))>0.999999) { + if(fabs(dot_v3v3(nor,vec))>0.999999) { + if(fabs(dot_v3v3(nor,xvec))>0.999999) { nor[0] = 0.0f; nor[1] = 1.0f; nor[2] = 0.0f; @@ -4217,11 +4219,11 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa nor[2] = 0.0f; } } - Crossf(side, nor, vec); - Normalize(side); - Crossf(nor, vec, side); + cross_v3_v3v3(side, nor, vec); + normalize_v3(side); + cross_v3_v3v3(nor, vec, side); - Mat4One(mat); + unit_m4(mat); VECCOPY(mat[0], vec); VECCOPY(mat[1], side); VECCOPY(mat[2], nor); @@ -4242,62 +4244,62 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3] if(bb->lock && (bb->align == PART_BB_VIEW)) { VECCOPY(xvec, bb->ob->obmat[0]); - Normalize(xvec); + normalize_v3(xvec); VECCOPY(yvec, bb->ob->obmat[1]); - Normalize(yvec); + normalize_v3(yvec); VECCOPY(zvec, bb->ob->obmat[2]); - Normalize(zvec); + normalize_v3(zvec); } else if(bb->align == PART_BB_VEL) { float temp[3]; VECCOPY(temp, bb->vel); - Normalize(temp); + normalize_v3(temp); VECSUB(zvec, bb->ob->obmat[3], bb->vec); if(bb->lock) { - float fac = -Inpf(zvec, temp); + float fac = -dot_v3v3(zvec, temp); VECADDFAC(zvec, zvec, temp, fac); } - Normalize(zvec); + normalize_v3(zvec); - Crossf(xvec,temp,zvec); - Normalize(xvec); + cross_v3_v3v3(xvec,temp,zvec); + normalize_v3(xvec); - Crossf(yvec,zvec,xvec); + cross_v3_v3v3(yvec,zvec,xvec); } else { VECSUB(zvec, bb->ob->obmat[3], bb->vec); if(bb->lock) zvec[bb->align] = 0.0f; - Normalize(zvec); + normalize_v3(zvec); if(bb->align < PART_BB_VIEW) - Crossf(xvec, onevec, zvec); + cross_v3_v3v3(xvec, onevec, zvec); else - Crossf(xvec, bb->ob->obmat[1], zvec); - Normalize(xvec); + cross_v3_v3v3(xvec, bb->ob->obmat[1], zvec); + normalize_v3(xvec); - Crossf(yvec,zvec,xvec); + cross_v3_v3v3(yvec,zvec,xvec); } VECCOPY(tvec, xvec); VECCOPY(tvec2, yvec); - VecMulf(xvec, cos(bb->tilt * (float)M_PI)); - VecMulf(tvec2, sin(bb->tilt * (float)M_PI)); + mul_v3_fl(xvec, cos(bb->tilt * (float)M_PI)); + mul_v3_fl(tvec2, sin(bb->tilt * (float)M_PI)); VECADD(xvec, xvec, tvec2); - VecMulf(yvec, cos(bb->tilt * (float)M_PI)); - VecMulf(tvec, -sin(bb->tilt * (float)M_PI)); + mul_v3_fl(yvec, cos(bb->tilt * (float)M_PI)); + mul_v3_fl(tvec, -sin(bb->tilt * (float)M_PI)); VECADD(yvec, yvec, tvec); - VecMulf(xvec, bb->size); - VecMulf(yvec, bb->size); + mul_v3_fl(xvec, bb->size); + mul_v3_fl(yvec, bb->size); VECADDFAC(center, bb->vec, xvec, bb->offset[0]); VECADDFAC(center, center, yvec, bb->offset[1]); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index d66c990cbe1..075c6f6207f 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -54,7 +54,7 @@ #include "BLI_rand.h" #include "BLI_jitter.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_kdtree.h" #include "BLI_kdopbvh.h" @@ -405,7 +405,7 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) min[2]-=d/2.0f; for(i=0,mv=mvert; i<totvert; i++,mv++){ - VecSubf(vec,mv->co,min); + sub_v3_v3v3(vec,mv->co,min); vec[0]/=delta[0]; vec[1]/=delta[1]; vec[2]/=delta[2]; @@ -447,7 +447,7 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) VECCOPY(v2,mvert[mface->v2].co); VECCOPY(v3,mvert[mface->v3].co); - if(AxialLineIntersectsTriangle(a,co1, co2, v2, v3, v1, &lambda)){ + if(isect_axial_line_tri_v3(a,co1, co2, v2, v3, v1, &lambda)){ if(from==PART_FROM_FACE) (pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST; else /* store number of intersections */ @@ -457,7 +457,7 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) if(mface->v4){ VECCOPY(v4,mvert[mface->v4].co); - if(AxialLineIntersectsTriangle(a,co1, co2, v4, v1, v3, &lambda)){ + if(isect_axial_line_tri_v3(a,co1, co2, v4, v1, v3, &lambda)){ if(from==PART_FROM_FACE) (pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST; else @@ -577,10 +577,10 @@ static void psys_uv_to_w(float u, float v, int quad, float *w) if(quad) { vert[3][0]= 0.0f; vert[3][1]= 1.0f; vert[3][2]= 0.0f; - MeanValueWeights(vert, 4, co, w); + interp_weights_poly_v3( w,vert, 4, co); } else { - MeanValueWeights(vert, 3, co, w); + interp_weights_poly_v3( w,vert, 3, co); w[3]= 0.0f; } } @@ -669,8 +669,8 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData psys_interpolate_face(mvert,mface,0,0,pa->fuv,co1,nor,0,0,0,0); - Normalize(nor); - VecMulf(nor,-100.0); + normalize_v3(nor); + mul_v3_fl(nor,-100.0); VECADD(co2,co1,nor); @@ -684,7 +684,7 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData v2=mvert[mface->v2].co; v3=mvert[mface->v3].co; - if(LineIntersectsTriangle(co1, co2, v2, v3, v1, &cur_d, 0)){ + if(isect_line_tri_v3(co1, co2, v2, v3, v1, &cur_d, 0)){ if(cur_d<min_d){ min_d=cur_d; pa->foffset=cur_d*50.0f; /* to the middle of volume */ @@ -694,7 +694,7 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData if(mface->v4){ v4=mvert[mface->v4].co; - if(LineIntersectsTriangle(co1, co2, v4, v1, v3, &cur_d, 0)){ + if(isect_line_tri_v3(co1, co2, v4, v1, v3, &cur_d, 0)){ if(cur_d<min_d){ min_d=cur_d; pa->foffset=cur_d*50.0f; /* to the middle of volume */ @@ -776,18 +776,18 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData // int min_seam=0, near_vert=0; // /* find closest seam */ // for(i=0; i<ctx->totseam; i++, seam++){ - // VecSubf(temp,co1,seam->v0); - // inp=Inpf(temp,seam->dir)/seam->length2; + // sub_v3_v3v3(temp,co1,seam->v0); + // inp=dot_v3v3(temp,seam->dir)/seam->length2; // if(inp<0.0f){ - // cur_len=VecLenf(co1,seam->v0); + // cur_len=len_v3v3(co1,seam->v0); // } // else if(inp>1.0f){ - // cur_len=VecLenf(co1,seam->v1); + // cur_len=len_v3v3(co1,seam->v1); // } // else{ - // VecCopyf(temp2,seam->dir); - // VecMulf(temp2,inp); - // cur_len=VecLenf(temp,temp2); + // copy_v3_v3(temp2,seam->dir); + // mul_v3_fl(temp2,inp); + // cur_len=len_v3v3(temp,temp2); // } // if(cur_len<min_len){ // min_len=cur_len; @@ -799,27 +799,27 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData // } // seam=ctx->seams+min_seam; // - // VecCopyf(temp,seam->v0); + // copy_v3_v3(temp,seam->v0); // // if(near_vert){ // if(near_vert==-1) - // VecSubf(tan,co1,seam->v0); + // sub_v3_v3v3(tan,co1,seam->v0); // else{ - // VecSubf(tan,co1,seam->v1); - // VecCopyf(temp,seam->v1); + // sub_v3_v3v3(tan,co1,seam->v1); + // copy_v3_v3(temp,seam->v1); // } - // Normalize(tan); + // normalize_v3(tan); // } // else{ - // VecCopyf(tan,seam->tan); - // VecSubf(temp2,co1,temp); - // if(Inpf(tan,temp2)<0.0f) - // VecNegf(tan); + // copy_v3_v3(tan,seam->tan); + // sub_v3_v3v3(temp2,co1,temp); + // if(dot_v3v3(tan,temp2)<0.0f) + // negate_v3(tan); // } // for(w=0; w<maxw; w++){ - // VecSubf(temp2,ptn[w].co,temp); - // if(Inpf(tan,temp2)<0.0f){ + // sub_v3_v3v3(temp2,ptn[w].co,temp); + // if(dot_v3v3(tan,temp2)<0.0f){ // parent[w]=-1; // pweight[w]=0.0f; // } @@ -989,12 +989,12 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene, // for(p=0, ed=medge; p<totedge; p++,ed++){ // if(ed->flag&ME_SEAM){ - // VecCopyf(cur_seam->v0,(mvert+ed->v1)->co); - // VecCopyf(cur_seam->v1,(mvert+ed->v2)->co); + // copy_v3_v3(cur_seam->v0,(mvert+ed->v1)->co); + // copy_v3_v3(cur_seam->v1,(mvert+ed->v2)->co); - // VecSubf(cur_seam->dir,cur_seam->v1,cur_seam->v0); + // sub_v3_v3v3(cur_seam->dir,cur_seam->v1,cur_seam->v0); - // cur_seam->length2=VecLength(cur_seam->dir); + // cur_seam->length2=len_v3(cur_seam->dir); // cur_seam->length2*=cur_seam->length2; // temp[0]=(float)((mvert+ed->v1)->no[0]); @@ -1004,12 +1004,12 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene, // temp2[1]=(float)((mvert+ed->v2)->no[1]); // temp2[2]=(float)((mvert+ed->v2)->no[2]); - // VecAddf(cur_seam->nor,temp,temp2); - // Normalize(cur_seam->nor); + // add_v3_v3v3(cur_seam->nor,temp,temp2); + // normalize_v3(cur_seam->nor); - // Crossf(cur_seam->tan,cur_seam->dir,cur_seam->nor); + // cross_v3_v3v3(cur_seam->tan,cur_seam->dir,cur_seam->nor); - // Normalize(cur_seam->tan); + // normalize_v3(cur_seam->tan); // cur_seam++; // } @@ -1035,7 +1035,7 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene, cpa->fuv[0]=2.0f*BLI_frand()-1.0f; cpa->fuv[1]=2.0f*BLI_frand()-1.0f; cpa->fuv[2]=2.0f*BLI_frand()-1.0f; - length=VecLength(cpa->fuv); + length=len_v3(cpa->fuv); } cpa->num=-1; @@ -1176,10 +1176,10 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene, v4= (MVert*)dm->getVertData(dm,mf->v4,CD_MVERT); VECCOPY(co4, v4->co); } - cur= AreaQ3Dfl(co1, co2, co3, co4); + cur= area_quad_v3(co1, co2, co3, co4); } else - cur= AreaT3Dfl(co1, co2, co3); + cur= area_tri_v3(co1, co2, co3); if(cur>maxweight) maxweight=cur; @@ -1682,7 +1682,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, r_rot[1] = 2.0f * (PSYS_FRAND(p + 17) - 0.5f); r_rot[2] = 2.0f * (PSYS_FRAND(p + 18) - 0.5f); r_rot[3] = 2.0f * (PSYS_FRAND(p + 19) - 0.5f); - NormalQuat(r_rot); + normalize_qt(r_rot); r_phase = PSYS_FRAND(p + 20); @@ -1699,15 +1699,15 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, psys_get_particle_state(&tsim, pa->num, &state, 1); psys_get_from_key(&state, loc, nor, rot, 0); - QuatMulVecf(rot, vtan); - QuatMulVecf(rot, utan); + mul_qt_v3(rot, vtan); + mul_qt_v3(rot, utan); VECCOPY(p_vel, state.vel); - speed=Normalize(p_vel); - VecMulf(p_vel, Inpf(r_vel, p_vel)); + speed=normalize_v3(p_vel); + mul_v3_fl(p_vel, dot_v3v3(r_vel, p_vel)); VECSUB(p_vel, r_vel, p_vel); - Normalize(p_vel); - VecMulf(p_vel, speed); + normalize_v3(p_vel); + mul_v3_fl(p_vel, speed); VECCOPY(pa->fuv, loc); /* abusing pa->fuv (not used for "from particle") for storing emit location */ } @@ -1731,46 +1731,46 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* particles live in global space so */ /* let's convert: */ /* -location */ - Mat4MulVecfl(ob->obmat,loc); + mul_m4_v3(ob->obmat,loc); /* -normal */ - Mat4Mul3Vecfl(ob->obmat,nor); - Normalize(nor); + mul_mat3_m4_v3(ob->obmat,nor); + normalize_v3(nor); /* -tangent */ if(part->tanfac!=0.0){ //float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_rot)-0.5f):0.0f; float phase=0.0f; - VecMulf(vtan,-(float)cos(M_PI*(part->tanphase+phase))); + mul_v3_fl(vtan,-(float)cos(M_PI*(part->tanphase+phase))); fac=-(float)sin(M_PI*(part->tanphase+phase)); VECADDFAC(vtan,vtan,utan,fac); - Mat4Mul3Vecfl(ob->obmat,vtan); + mul_mat3_m4_v3(ob->obmat,vtan); VECCOPY(utan,nor); - VecMulf(utan,Inpf(vtan,nor)); + mul_v3_fl(utan,dot_v3v3(vtan,nor)); VECSUB(vtan,vtan,utan); - Normalize(vtan); + normalize_v3(vtan); } /* -velocity */ if(part->randfac!=0.0){ - Mat4Mul3Vecfl(ob->obmat,r_vel); - Normalize(r_vel); + mul_mat3_m4_v3(ob->obmat,r_vel); + normalize_v3(r_vel); } /* -angular velocity */ if(part->avemode==PART_AVE_RAND){ - Mat4Mul3Vecfl(ob->obmat,r_ave); - Normalize(r_ave); + mul_mat3_m4_v3(ob->obmat,r_ave); + normalize_v3(r_ave); } /* -rotation */ if(part->randrotfac != 0.0f){ - Mat4ToQuat(ob->obmat,rot); - QuatMul(r_rot,r_rot,rot); + mat4_to_quat(rot,ob->obmat); + mul_qt_qtqt(r_rot,r_rot,rot); } } @@ -1785,8 +1785,8 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* boids store direction in ave */ if(fabs(nor[2])==1.0f) { - VecSubf(pa->state.ave, loc, ob->obmat[3]); - Normalize(pa->state.ave); + sub_v3_v3v3(pa->state.ave, loc, ob->obmat[3]); + normalize_v3(pa->state.ave); } else { VECCOPY(pa->state.ave, nor); @@ -1799,17 +1799,17 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, bpa->gravity[2] = sim->scene->physics_settings.gravity[2]; /* calculate rotation matrix */ - Projf(dvec, r_vel, pa->state.ave); - VecSubf(mat[0], pa->state.ave, dvec); - Normalize(mat[0]); + project_v3_v3v3(dvec, r_vel, pa->state.ave); + sub_v3_v3v3(mat[0], pa->state.ave, dvec); + normalize_v3(mat[0]); VECCOPY(mat[2], r_vel); - VecMulf(mat[2], -1.0f); - Normalize(mat[2]); - Crossf(mat[1], mat[2], mat[0]); + mul_v3_fl(mat[2], -1.0f); + normalize_v3(mat[2]); + cross_v3_v3v3(mat[1], mat[2], mat[0]); /* apply rotation */ - Mat3ToQuat_is_ok(mat, q); - QuatCopy(pa->state.rot, q); + mat3_to_quat_is_ok( q,mat); + copy_qt_qt(pa->state.rot, q); bpa->data.health = part->boids->health; bpa->data.mode = eBoidMode_InAir; @@ -1828,7 +1828,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* *emitter velocity */ if(dtime!=0.0 && part->obfac!=0.0){ VECSUB(vel,loc,pa->state.co); - VecMulf(vel,part->obfac/dtime); + mul_v3_fl(vel,part->obfac/dtime); } /* *emitter normal */ @@ -1843,17 +1843,17 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* *emitter object orientation */ if(part->ob_vel[0]!=0.0) { VECCOPY(vec, ob->obmat[0]); - Normalize(vec); + normalize_v3(vec); VECADDFAC(vel, vel, vec, part->ob_vel[0]); } if(part->ob_vel[1]!=0.0) { VECCOPY(vec, ob->obmat[1]); - Normalize(vec); + normalize_v3(vec); VECADDFAC(vel, vel, vec, part->ob_vel[1]); } if(part->ob_vel[2]!=0.0) { VECCOPY(vec, ob->obmat[2]); - Normalize(vec); + normalize_v3(vec); VECADDFAC(vel, vel, vec, part->ob_vel[2]); } @@ -1874,7 +1874,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, // ptex.ivel*=icu->curval; //} - VecMulf(vel,ptex.ivel); + mul_v3_fl(vel,ptex.ivel); VECCOPY(pa->state.vel,vel); @@ -1889,10 +1889,10 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* create vector into which rotation is aligned */ switch(part->rotmode){ case PART_ROT_NOR: - VecCopyf(rot_vec, nor); + copy_v3_v3(rot_vec, nor); break; case PART_ROT_VEL: - VecCopyf(rot_vec, vel); + copy_v3_v3(rot_vec, vel); break; case PART_ROT_GLOB_X: case PART_ROT_GLOB_Y: @@ -1902,28 +1902,28 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, case PART_ROT_OB_X: case PART_ROT_OB_Y: case PART_ROT_OB_Z: - VecCopyf(rot_vec, ob->obmat[part->rotmode - PART_ROT_OB_X]); + copy_v3_v3(rot_vec, ob->obmat[part->rotmode - PART_ROT_OB_X]); break; } /* create rotation quat */ - VecNegf(rot_vec); - vectoquat(rot_vec, OB_POSX, OB_POSZ, q2); + negate_v3(rot_vec); + vec_to_quat( q2,rot_vec, OB_POSX, OB_POSZ); /* randomize rotation quat */ if(part->randrotfac!=0.0f) - QuatInterpol(rot, q2, r_rot, part->randrotfac); + interp_qt_qtqt(rot, q2, r_rot, part->randrotfac); else - QuatCopy(rot,q2); + copy_qt_qt(rot,q2); /* rotation phase */ phasefac = part->phasefac; if(part->randphasefac != 0.0f) phasefac += part->randphasefac * r_phase; - VecRotToQuat(x_vec, phasefac*(float)M_PI, q_phase); + axis_angle_to_quat( q_phase,x_vec, phasefac*(float)M_PI); /* combine base rotation & phase */ - QuatMul(pa->state.rot, rot, q_phase); + mul_qt_qtqt(pa->state.rot, rot, q_phase); } /* -angular velocity */ @@ -1939,13 +1939,13 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, VECCOPY(pa->state.ave,r_ave); break; } - Normalize(pa->state.ave); - VecMulf(pa->state.ave,part->avefac); + normalize_v3(pa->state.ave); + mul_v3_fl(pa->state.ave,part->avefac); //icu=find_ipocurve(psys->part->ipo,PART_EMIT_AVE); //if(icu){ // calc_icu(icu,100*((pa->time-part->sta)/(part->end-part->sta))); - // VecMulf(pa->state.ave,icu->curval); + // mul_v3_fl(pa->state.ave,icu->curval); //} } } @@ -2157,7 +2157,7 @@ static void set_keyed_keys(ParticleSimulationData *sim) // } // } // else{ -// dist=VecLenf(pa->state.co, re->state.co); +// dist=len_v3v3(pa->state.co, re->state.co); // if(dist <= re->size){ // if(pa->alive==PARS_UNBORN){ // pa->time=re->time; @@ -2168,12 +2168,12 @@ static void set_keyed_keys(ParticleSimulationData *sim) // float vec[3]; // VECSUB(vec,pa->state.co, re->state.co); // if(birth==0) -// VecMulf(vec,(float)pow(1.0f-dist/re->size,part->reactshape)); +// mul_v3_fl(vec,(float)pow(1.0f-dist/re->size,part->reactshape)); // VECADDFAC(pa->state.vel,pa->state.vel,vec,part->reactfac); // VECADDFAC(pa->state.vel,pa->state.vel,re->state.vel,part->partfac); // } // if(birth) -// VecMulf(pa->state.vel,(float)pow(1.0f-dist/re->size,part->reactshape)); +// mul_v3_fl(pa->state.vel,(float)pow(1.0f-dist/re->size,part->reactshape)); // } // } // } @@ -2301,7 +2301,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra /* calculate air-particle interaction */ if(part->dragfac!=0.0f){ - fac=-part->dragfac*pa->size*pa->size*VecLength(states[i].vel); + fac=-part->dragfac*pa->size*pa->size*len_v3(states[i].vel); VECADDFAC(force,force,states[i].vel,fac); } @@ -2313,7 +2313,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra } /* force to acceleration*/ - VecMulf(force,1.0f/pa_mass); + mul_v3_fl(force,1.0f/pa_mass); /* add global acceleration (gravitation) */ if(sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY @@ -2321,7 +2321,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra && (part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR)) { float gravity[3]; VECCOPY(gravity, sim->scene->physics_settings.gravity); - VecMulf(gravity, part->effector_weights->global_gravity); + mul_v3_fl(gravity, part->effector_weights->global_gravity); VECADD(force,force,gravity); } @@ -2348,9 +2348,9 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra switch(i){ case 0: VECCOPY(dx[0],states->vel); - VecMulf(dx[0],dtime); + mul_v3_fl(dx[0],dtime); VECCOPY(dv[0],force); - VecMulf(dv[0],dtime); + mul_v3_fl(dv[0],dtime); VECADDFAC(states[1].co,states->co,dx[0],0.5f); VECADDFAC(states[1].vel,states->vel,dv[0],0.5f); @@ -2358,18 +2358,18 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra break; case 1: VECADDFAC(dx[1],states->vel,dv[0],0.5f); - VecMulf(dx[1],dtime); + mul_v3_fl(dx[1],dtime); VECCOPY(dv[1],force); - VecMulf(dv[1],dtime); + mul_v3_fl(dv[1],dtime); VECADDFAC(states[2].co,states->co,dx[1],0.5f); VECADDFAC(states[2].vel,states->vel,dv[1],0.5f); break; case 2: VECADDFAC(dx[2],states->vel,dv[1],0.5f); - VecMulf(dx[2],dtime); + mul_v3_fl(dx[2],dtime); VECCOPY(dv[2],force); - VecMulf(dv[2],dtime); + mul_v3_fl(dv[2],dtime); VECADD(states[3].co,states->co,dx[2]); VECADD(states[3].vel,states->vel,dv[2]); @@ -2377,9 +2377,9 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra break; case 3: VECADD(dx[3],states->vel,dv[2]); - VecMulf(dx[3],dtime); + mul_v3_fl(dx[3],dtime); VECCOPY(dv[3],force); - VecMulf(dv[3],dtime); + mul_v3_fl(dv[3],dtime); VECADDFAC(pa->state.co,states->co,dx[0],1.0f/6.0f); VECADDFAC(pa->state.co,pa->state.co,dx[1],1.0f/3.0f); @@ -2397,7 +2397,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra /* damp affects final velocity */ if(part->dampfac!=0.0) - VecMulf(pa->state.vel,1.0f-part->dampfac); + mul_v3_fl(pa->state.vel,1.0f-part->dampfac); VECCOPY(pa->state.ave, states->ave); @@ -2414,7 +2414,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra VECCOPY(pa->state.co,tkey.co); /* guides don't produce valid velocity */ VECSUB(pa->state.vel,tkey.co,pa->prev_state.co); - VecMulf(pa->state.vel,1.0f/dtime); + mul_v3_fl(pa->state.vel,1.0f/dtime); pa->state.time=tkey.time; } } @@ -2426,35 +2426,35 @@ static void rotate_particle(ParticleSettings *part, ParticleData *pa, float dfra if((part->flag & PART_ROT_DYN)==0){ if(part->avemode==PART_AVE_SPIN){ float angle; - float len1 = VecLength(pa->prev_state.vel); - float len2 = VecLength(pa->state.vel); + float len1 = len_v3(pa->prev_state.vel); + float len2 = len_v3(pa->state.vel); if(len1==0.0f || len2==0.0f) pa->state.ave[0]=pa->state.ave[1]=pa->state.ave[2]=0.0f; else{ - Crossf(pa->state.ave,pa->prev_state.vel,pa->state.vel); - Normalize(pa->state.ave); - angle=Inpf(pa->prev_state.vel,pa->state.vel)/(len1*len2); - VecMulf(pa->state.ave,saacos(angle)/dtime); + cross_v3_v3v3(pa->state.ave,pa->prev_state.vel,pa->state.vel); + normalize_v3(pa->state.ave); + angle=dot_v3v3(pa->prev_state.vel,pa->state.vel)/(len1*len2); + mul_v3_fl(pa->state.ave,saacos(angle)/dtime); } - VecRotToQuat(pa->state.vel,dtime*part->avefac,rot2); + axis_angle_to_quat(rot2,pa->state.vel,dtime*part->avefac); } } - rotfac=VecLength(pa->state.ave); - if(rotfac==0.0){ /* QuatOne (in VecRotToQuat) doesn't give unit quat [1,0,0,0]?? */ + rotfac=len_v3(pa->state.ave); + if(rotfac==0.0){ /* unit_qt(in VecRotToQuat) doesn't give unit quat [1,0,0,0]?? */ rot1[0]=1.0; rot1[1]=rot1[2]=rot1[3]=0; } else{ - VecRotToQuat(pa->state.ave,rotfac*dtime,rot1); + axis_angle_to_quat(rot1,pa->state.ave,rotfac*dtime); } - QuatMul(pa->state.rot,rot1,pa->prev_state.rot); - QuatMul(pa->state.rot,rot2,pa->state.rot); + mul_qt_qtqt(pa->state.rot,rot1,pa->prev_state.rot); + mul_qt_qtqt(pa->state.rot,rot2,pa->state.rot); /* keep rotation quat in good health */ - NormalQuat(pa->state.rot); + normalize_qt(pa->state.rot); } /* convert from triangle barycentric weights to quad mean value weights */ @@ -2471,7 +2471,7 @@ static void intersect_dm_quad_weights(float *v1, float *v2, float *v3, float *v4 co[1]= v1[1]*w[0] + v2[1]*w[1] + v3[1]*w[2] + v4[1]*w[3]; co[2]= v1[2]*w[0] + v2[2]*w[1] + v3[2]*w[2] + v4[2]*w[3]; - MeanValueWeights(vert, 4, co, w); + interp_weights_poly_v3( w,vert, 4, co); } /* check intersection with a derivedmesh */ @@ -2537,18 +2537,18 @@ int psys_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, float *vert_cos DO_MINMAX(v3,min,max); if(mface->v4) DO_MINMAX(v4,min,max) - if(AabbIntersectAabb(min,max,p_min,p_max)==0) + if(isect_aabb_aabb_v3(min,max,p_min,p_max)==0) continue; } else{ VECCOPY(min, face_minmax+6*i); VECCOPY(max, face_minmax+6*i+3); - if(AabbIntersectAabb(min,max,p_min,p_max)==0) + if(isect_aabb_aabb_v3(min,max,p_min,p_max)==0) continue; } if(radius>0.0f){ - if(SweepingSphereIntersectsTriangleUV(co1, co2, radius, v2, v3, v1, &cur_d, cur_ipoint)){ + if(isect_sweeping_sphere_tri_v3(co1, co2, radius, v2, v3, v1, &cur_d, cur_ipoint)){ if(cur_d<*min_d){ *min_d=cur_d; VECCOPY(ipoint,cur_ipoint); @@ -2557,7 +2557,7 @@ int psys_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, float *vert_cos } } if(mface->v4){ - if(SweepingSphereIntersectsTriangleUV(co1, co2, radius, v4, v1, v3, &cur_d, cur_ipoint)){ + if(isect_sweeping_sphere_tri_v3(co1, co2, radius, v4, v1, v3, &cur_d, cur_ipoint)){ if(cur_d<*min_d){ *min_d=cur_d; VECCOPY(ipoint,cur_ipoint); @@ -2568,7 +2568,7 @@ int psys_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, float *vert_cos } } else{ - if(LineIntersectsTriangle(co1, co2, v1, v2, v3, &cur_d, cur_uv)){ + if(isect_line_tri_v3(co1, co2, v1, v2, v3, &cur_d, cur_uv)){ if(cur_d<*min_d){ *min_d=cur_d; min_w[0]= 1.0 - cur_uv[0] - cur_uv[1]; @@ -2582,7 +2582,7 @@ int psys_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, float *vert_cos } } if(mface->v4){ - if(LineIntersectsTriangle(co1, co2, v1, v3, v4, &cur_d, cur_uv)){ + if(isect_line_tri_v3(co1, co2, v1, v3, v4, &cur_d, cur_uv)){ if(cur_d<*min_d){ *min_d=cur_d; min_w[0]= 1.0 - cur_uv[0] - cur_uv[1]; @@ -2618,7 +2618,7 @@ void particle_intersect_face(void *userdata, int index, const BVHTreeRay *ray, B VECCOPY(vel, v[ face->v1 ].co); VECADD(vel, vel, v[ face->v2 ].co); VECADD(vel, vel, v[ face->v3 ].co); - VecMulf(vel, 0.33334f); + mul_v3_fl(vel, 0.33334f); /* substract face velocity, in other words convert to a coordinate system where only the particle moves */ @@ -2628,16 +2628,16 @@ void particle_intersect_face(void *userdata, int index, const BVHTreeRay *ray, B do { if(ray->radius == 0.0f) { - if(LineIntersectsTriangle(co1, co2, t0, t1, t2, &t, uv)) { + if(isect_line_tri_v3(co1, co2, t0, t1, t2, &t, uv)) { if(t >= 0.0f && t < hit->dist/col->ray_len) { hit->dist = col->ray_len * t; hit->index = index; /* calculate normal that's facing the particle */ - CalcNormFloat(t0, t1, t2, col->nor); + normal_tri_v3( col->nor,t0, t1, t2); VECSUB(temp, co2, co1); - if(Inpf(col->nor, temp) > 0.0f) - VecNegf(col->nor); + if(dot_v3v3(col->nor, temp) > 0.0f) + negate_v3(col->nor); VECCOPY(col->vel,vel); @@ -2647,15 +2647,15 @@ void particle_intersect_face(void *userdata, int index, const BVHTreeRay *ray, B } } else { - if(SweepingSphereIntersectsTriangleUV(co1, co2, ray->radius, t0, t1, t2, &t, ipoint)) { + if(isect_sweeping_sphere_tri_v3(co1, co2, ray->radius, t0, t1, t2, &t, ipoint)) { if(t >=0.0f && t < hit->dist/col->ray_len) { hit->dist = col->ray_len * t; hit->index = index; - VecLerpf(temp, co1, co2, t); + interp_v3_v3v3(temp, co1, co2, t); VECSUB(col->nor, temp, ipoint); - Normalize(col->nor); + normalize_v3(col->nor); VECCOPY(col->vel,vel); @@ -2706,7 +2706,7 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo VECSUB(ray_dir, col.co2, col.co1); hit.index = -1; - hit.dist = col.ray_len = VecLength(ray_dir); + hit.dist = col.ray_len = len_v3(ray_dir); /* even if particle is stationary we want to check for moving colliders */ /* if hit.dist is zero the bvhtree_ray_cast will just ignore everything */ @@ -2738,10 +2738,10 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo float t = hit.dist/col.ray_len; /* time of collision between this iteration */ float dt = col.t + t * (1.0f - col.t); /* time of collision between frame change*/ - VecLerpf(co, col.co1, col.co2, t); + interp_v3_v3v3(co, col.co1, col.co2, t); VECSUB(vec, col.co2, col.co1); - VecMulf(col.vel, 1.0f-col.t); + mul_v3_fl(col.vel, 1.0f-col.t); /* particle dies in collision */ if(through == 0 && (part->flag & PART_DIE_ON_COL || pd->flag & PDEFLE_KILL_PART)) { @@ -2752,9 +2752,9 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo VECADDFAC(co, co, col.nor, (through ? -0.0001f : 0.0001f)); VECCOPY(pa->state.co, co); - VecLerpf(pa->state.vel, pa->prev_state.vel, pa->state.vel, dt); - QuatInterpol(pa->state.rot, pa->prev_state.rot, pa->state.rot, dt); - VecLerpf(pa->state.ave, pa->prev_state.ave, pa->state.ave, dt); + interp_v3_v3v3(pa->state.vel, pa->prev_state.vel, pa->state.vel, dt); + interp_qt_qtqt(pa->state.rot, pa->prev_state.rot, pa->state.rot, dt); + interp_v3_v3v3(pa->state.ave, pa->prev_state.ave, pa->state.ave, dt); /* particle is dead so we don't need to calculate further */ deflections=max_deflections; @@ -2772,13 +2772,13 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo CLAMP(frict,0.0,1.0); /* treat normal & tangent components separately */ - inp = Inpf(col.nor, vec); - inp_v = Inpf(col.nor, col.vel); + inp = dot_v3v3(col.nor, vec); + inp_v = dot_v3v3(col.nor, col.vel); VECADDFAC(tan_vec, vec, col.nor, -inp); VECADDFAC(tan_vel, col.vel, col.nor, -inp_v); if((part->flag & PART_ROT_DYN)==0) - VecLerpf(tan_vec, tan_vec, tan_vel, frict); + interp_v3_v3v3(tan_vec, tan_vec, tan_vel, frict); VECCOPY(nor_vec, col.nor); inp *= 1.0f - damp; @@ -2788,9 +2788,9 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo /* special case for object hitting the particle from behind */ if(through==0 && ((inp_v>0 && inp>0 && inp_v>inp) || (inp_v<0 && inp<0 && inp_v<inp))) - VecMulf(nor_vec, inp_v); + mul_v3_fl(nor_vec, inp_v); else - VecMulf(nor_vec, inp_v + (through ? 1.0f : -1.0f) * inp); + mul_v3_fl(nor_vec, inp_v + (through ? 1.0f : -1.0f) * inp); /* angular <-> linear velocity - slightly more physical and looks even nicer than before */ if(part->flag & PART_ROT_DYN) { @@ -2800,37 +2800,37 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo VECSUB(surface_vel, tan_vec, tan_vel); /* direction of rolling friction */ - Crossf(rot_vel, pa->state.ave, col.nor); + cross_v3_v3v3(rot_vel, pa->state.ave, col.nor); /* convert to current dt */ - VecMulf(rot_vel, (timestep*dfra) * (1.0f - col.t)); - VecMulf(rot_vel, pa->size); + mul_v3_fl(rot_vel, (timestep*dfra) * (1.0f - col.t)); + mul_v3_fl(rot_vel, pa->size); /* apply sliding friction */ VECSUB(surface_vel, surface_vel, rot_vel); VECCOPY(friction, surface_vel); - VecMulf(surface_vel, 1.0 - frict); - VecMulf(friction, frict); + mul_v3_fl(surface_vel, 1.0 - frict); + mul_v3_fl(friction, frict); /* sliding changes angular velocity */ - Crossf(dave, col.nor, friction); - VecMulf(dave, 1.0f/MAX2(pa->size, 0.001)); + cross_v3_v3v3(dave, col.nor, friction); + mul_v3_fl(dave, 1.0f/MAX2(pa->size, 0.001)); /* we assume rolling friction is around 0.01 of sliding friction */ - VecMulf(rot_vel, 1.0 - frict*0.01); + mul_v3_fl(rot_vel, 1.0 - frict*0.01); /* change in angular velocity has to be added to the linear velocity too */ - Crossf(dvel, dave, col.nor); - VecMulf(dvel, pa->size); + cross_v3_v3v3(dvel, dave, col.nor); + mul_v3_fl(dvel, pa->size); VECADD(rot_vel, rot_vel, dvel); VECADD(surface_vel, surface_vel, rot_vel); VECADD(tan_vec, surface_vel, tan_vel); /* convert back to normal time */ - VecMulf(dave, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001)); + mul_v3_fl(dave, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001)); - VecMulf(pa->state.ave, 1.0 - frict*0.01); + mul_v3_fl(pa->state.ave, 1.0 - frict*0.01); VECADD(pa->state.ave, pa->state.ave, dave); } @@ -2839,7 +2839,7 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo /* calculate velocity from collision vector */ VECCOPY(vel, vec); - VecMulf(vel, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001)); + mul_v3_fl(vel, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001)); /* make sure we don't hit the current face again */ VECADDFAC(co, co, col.nor, (through ? -0.0001f : 0.0001f)); @@ -2854,15 +2854,15 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo /* store state for reactors */ //VECCOPY(reaction_state.co, co); - //VecLerpf(reaction_state.vel, pa->prev_state.vel, pa->state.vel, dt); - //QuatInterpol(reaction_state.rot, pa->prev_state.rot, pa->state.rot, dt); + //interp_v3_v3v3(reaction_state.vel, pa->prev_state.vel, pa->state.vel, dt); + //interp_qt_qtqt(reaction_state.rot, pa->prev_state.rot, pa->state.rot, dt); /* set coordinates for next iteration */ VECCOPY(col.co1, co); VECADDFAC(col.co2, co, vec, 1.0f - t); col.t = dt; - if(VecLength(vec) < 0.001 && VecLength(pa->state.vel) < 0.001) { + if(len_v3(vec) < 0.001 && len_v3(pa->state.vel) < 0.001) { /* kill speed to stop slipping */ VECCOPY(pa->state.vel,zerovec); VECCOPY(pa->state.co, co); @@ -3011,7 +3011,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim) VECSUB(temp, key->co, (key+1)->co); VECCOPY(mvert->co, key->co); VECADD(mvert->co, mvert->co, temp); - Mat4MulVecfl(hairmat, mvert->co); + mul_m4_v3(hairmat, mvert->co); mvert++; medge->v1 = pa->hair_index - 1; @@ -3030,7 +3030,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim) } VECCOPY(mvert->co, key->co); - Mat4MulVecfl(hairmat, mvert->co); + mul_m4_v3(hairmat, mvert->co); mvert++; if(k) { @@ -3105,7 +3105,7 @@ static void save_hair(ParticleSimulationData *sim, float cfra){ PARTICLE_P; int totpart; - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); psys->lattice= psys_get_lattice(sim); @@ -3125,8 +3125,8 @@ static void save_hair(ParticleSimulationData *sim, float cfra){ key += pa->totkey; /* convert from global to geometry space */ - VecCopyf(key->co, pa->state.co); - Mat4MulVecfl(ob->imat, key->co); + copy_v3_v3(key->co, pa->state.co); + mul_m4_v3(ob->imat, key->co); if(pa->totkey) { VECSUB(key->co, key->co, root->co); @@ -3941,6 +3941,6 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) system_step(&sim, cfra); /* save matrix for duplicators */ - Mat4Invert(psys->imat, ob->obmat); + invert_m4_m4(psys->imat, ob->obmat); } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 68f0e33a98f..c2798b4a746 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -170,12 +170,12 @@ static void ptcache_interpolate_softbody(int index, void *soft_v, void **data, f dfra = cfra2 - cfra1; - VecMulf(keys[1].vel, dfra); - VecMulf(keys[2].vel, dfra); + mul_v3_fl(keys[1].vel, dfra); + mul_v3_fl(keys[2].vel, dfra); psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, keys, 1); - VecMulf(keys->vel, 1.0f / dfra); + mul_v3_fl(keys->vel, 1.0f / dfra); VECCOPY(bp->pos, keys->co); VECCOPY(bp->vec, keys->vel); @@ -255,18 +255,18 @@ static void ptcache_read_particle(int index, void *psys_v, void **data, float fr /* determine velocity from previous location */ if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) { if(cfra > pa->prev_state.time) { - VecSubf(pa->state.vel, pa->state.co, pa->prev_state.co); - VecMulf(pa->state.vel, (cfra - pa->prev_state.time) / frs_sec); + sub_v3_v3v3(pa->state.vel, pa->state.co, pa->prev_state.co); + mul_v3_fl(pa->state.vel, (cfra - pa->prev_state.time) / frs_sec); } else { - VecSubf(pa->state.vel, pa->prev_state.co, pa->state.co); - VecMulf(pa->state.vel, (pa->prev_state.time - cfra) / frs_sec); + sub_v3_v3v3(pa->state.vel, pa->prev_state.co, pa->state.co); + mul_v3_fl(pa->state.vel, (pa->prev_state.time - cfra) / frs_sec); } } /* determine rotation from velocity */ if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) { - vectoquat(pa->state.vel, OB_NEGX, OB_POSZ, pa->state.rot); + vec_to_quat( pa->state.rot,pa->state.vel, OB_NEGX, OB_POSZ); } } static void ptcache_interpolate_particle(int index, void *psys_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data) @@ -292,18 +292,18 @@ static void ptcache_interpolate_particle(int index, void *psys_v, void **data, f /* determine velocity from previous location */ if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) { if(keys[1].time > keys[2].time) { - VecSubf(keys[2].vel, keys[1].co, keys[2].co); - VecMulf(keys[2].vel, (keys[1].time - keys[2].time) / frs_sec); + sub_v3_v3v3(keys[2].vel, keys[1].co, keys[2].co); + mul_v3_fl(keys[2].vel, (keys[1].time - keys[2].time) / frs_sec); } else { - VecSubf(keys[2].vel, keys[2].co, keys[1].co); - VecMulf(keys[2].vel, (keys[2].time - keys[1].time) / frs_sec); + sub_v3_v3v3(keys[2].vel, keys[2].co, keys[1].co); + mul_v3_fl(keys[2].vel, (keys[2].time - keys[1].time) / frs_sec); } } /* determine rotation from velocity */ if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) { - vectoquat(keys[2].vel, OB_NEGX, OB_POSZ, keys[2].rot); + vec_to_quat( keys[2].rot,keys[2].vel, OB_NEGX, OB_POSZ); } if(cfra > pa->time) @@ -311,13 +311,13 @@ static void ptcache_interpolate_particle(int index, void *psys_v, void **data, f dfra = cfra2 - cfra1; - VecMulf(keys[1].vel, dfra / frs_sec); - VecMulf(keys[2].vel, dfra / frs_sec); + mul_v3_fl(keys[1].vel, dfra / frs_sec); + mul_v3_fl(keys[2].vel, dfra / frs_sec); psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, &pa->state, 1); - QuatInterpol(pa->state.rot, keys[1].rot, keys[2].rot, (cfra - cfra1) / dfra); + interp_qt_qtqt(pa->state.rot, keys[1].rot, keys[2].rot, (cfra - cfra1) / dfra); - VecMulf(pa->state.vel, frs_sec / dfra); + mul_v3_fl(pa->state.vel, frs_sec / dfra); pa->state.time = cfra; } @@ -425,18 +425,18 @@ static int ptcache_totwrite_particle(void *psys_v) // /* determine velocity from previous location */ // if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) { // if(cfra > pa->prev_state.time) { -// VecSubf(pa->state.vel, pa->state.co, pa->prev_state.co); -// VecMulf(pa->state.vel, (cfra - pa->prev_state.time) / frs_sec); +// sub_v3_v3v3(pa->state.vel, pa->state.co, pa->prev_state.co); +// mul_v3_fl(pa->state.vel, (cfra - pa->prev_state.time) / frs_sec); // } // else { -// VecSubf(pa->state.vel, pa->prev_state.co, pa->state.co); -// VecMulf(pa->state.vel, (pa->prev_state.time - cfra) / frs_sec); +// sub_v3_v3v3(pa->state.vel, pa->prev_state.co, pa->state.co); +// mul_v3_fl(pa->state.vel, (pa->prev_state.time - cfra) / frs_sec); // } // } // // /* determine rotation from velocity */ // if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) { -// vectoquat(pa->state.vel, OB_POSX, OB_POSZ, pa->state.rot); +// vec_to_quat( pa->state.rot,pa->state.vel, OB_POSX, OB_POSZ); // } //} //static void ptcache_interpolate_particle_stream(int index, void *psys_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data) @@ -461,13 +461,13 @@ static int ptcache_totwrite_particle(void *psys_v) // // dfra = cfra2 - cfra1; // -// VecMulf(keys[1].vel, dfra / frs_sec); -// VecMulf(keys[2].vel, dfra / frs_sec); +// mul_v3_fl(keys[1].vel, dfra / frs_sec); +// mul_v3_fl(keys[2].vel, dfra / frs_sec); // // psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, &pa->state, 1); -// QuatInterpol(pa->state.rot, keys[1].rot,keys[2].rot, (cfra - cfra1) / dfra); +// interp_qt_qtqt(pa->state.rot, keys[1].rot,keys[2].rot, (cfra - cfra1) / dfra); // -// VecMulf(pa->state.vel, frs_sec / dfra); +// mul_v3_fl(pa->state.vel, frs_sec / dfra); // // pa->state.time = cfra; //} @@ -525,12 +525,12 @@ static void ptcache_interpolate_cloth(int index, void *cloth_v, void **data, flo dfra = cfra2 - cfra1; - VecMulf(keys[1].vel, dfra); - VecMulf(keys[2].vel, dfra); + mul_v3_fl(keys[1].vel, dfra); + mul_v3_fl(keys[2].vel, dfra); psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, keys, 1); - VecMulf(keys->vel, 1.0f / dfra); + mul_v3_fl(keys->vel, 1.0f / dfra); VECCOPY(vert->x, keys->co); VECCOPY(vert->v, keys->vel); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 4f72ca96f5f..91fd0bac400 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -89,7 +89,7 @@ #include "BPY_extern.h" #endif -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" //XXX #include "nla.h" @@ -323,6 +323,7 @@ Scene *add_scene(char *name) sce->r.cfra= 1; sce->r.sfra= 1; sce->r.efra= 250; + sce->r.frame_step= 1; sce->r.xsch= 1920; sce->r.ysch= 1080; sce->r.xasp= 1; @@ -653,7 +654,7 @@ int next_object(Scene *scene, int val, Base **base, Object **ob) /* handle dupli's */ if(dupob) { - Mat4CpyMat4(dupob->ob->obmat, dupob->mat); + copy_m4_m4(dupob->ob->obmat, dupob->mat); (*base)->flag |= OB_FROMDUPLI; *ob= dupob->ob; @@ -666,7 +667,7 @@ int next_object(Scene *scene, int val, Base **base, Object **ob) (*base)->flag &= ~OB_FROMDUPLI; for(dupob= duplilist->first; dupob; dupob= dupob->next) { - Mat4CpyMat4(dupob->ob->obmat, dupob->omat); + copy_m4_m4(dupob->ob->obmat, dupob->omat); } free_object_duplilist(duplilist); diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 078258092f7..a175ddf975a 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -38,7 +38,7 @@ #include "DNA_sequence_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_global.h" #include "BKE_plugin_types.h" diff --git a/source/blender/blenkernel/intern/sequence.c b/source/blender/blenkernel/intern/sequence.c index 1ab085f5fa8..a986e9d7a94 100644 --- a/source/blender/blenkernel/intern/sequence.c +++ b/source/blender/blenkernel/intern/sequence.c @@ -63,8 +63,8 @@ /* **** XXX ******** */ static int seqrectx= 0; /* bad bad global! */ static int seqrecty= 0; -static void waitcursor(int val) {} -static int blender_test_break() {return 0;} +//static void waitcursor(int val) {} +//static int blender_test_break() {return 0;} /* **** XXX ******** */ @@ -1230,6 +1230,7 @@ static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, in } } +#if 0 static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int cfra, int build_proxy_run, int render_size); @@ -1360,6 +1361,7 @@ static void seq_proxy_rebuild(Scene *scene, Sequence * seq) } waitcursor(0); } +#endif /* ********************************************************************** @@ -2631,6 +2633,7 @@ ImBuf *give_ibuf_seq(Scene *scene, int rectx, int recty, int cfra, int chanshown return i; } +#if 0 /* check used when we need to change seq->blend_mode but not to effect or audio strips */ static int seq_can_blend(Sequence *seq) { @@ -2640,6 +2643,7 @@ static int seq_can_blend(Sequence *seq) return 0; } } +#endif /* *********************** threading api ******************* */ @@ -2651,8 +2655,8 @@ static pthread_mutex_t queue_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t wakeup_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t wakeup_cond = PTHREAD_COND_INITIALIZER; -static pthread_mutex_t prefetch_ready_lock = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t prefetch_ready_cond = PTHREAD_COND_INITIALIZER; +//static pthread_mutex_t prefetch_ready_lock = PTHREAD_MUTEX_INITIALIZER; +//static pthread_cond_t prefetch_ready_cond = PTHREAD_COND_INITIALIZER; static pthread_mutex_t frame_done_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t frame_done_cond = PTHREAD_COND_INITIALIZER; @@ -2685,6 +2689,7 @@ typedef struct PrefetchQueueElem { struct ImBuf * ibuf; } PrefetchQueueElem; +#if 0 static void *seq_prefetch_thread(void * This_) { PrefetchThread * This = This_; @@ -2833,6 +2838,7 @@ static void seq_stop_threads() /* deinit malloc mutex */ BLI_end_threads(0); } +#endif void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, int render_size) @@ -2859,6 +2865,7 @@ void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, pthread_mutex_unlock(&wakeup_lock); } +#if 0 static void seq_wait_for_prefetch_ready() { PrefetchThread *tslot; @@ -2887,6 +2894,7 @@ static void seq_wait_for_prefetch_ready() fprintf(stderr, "SEQ-THREAD: prefetch done\n"); } +#endif ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size) { @@ -2993,6 +3001,7 @@ static void free_anim_seq(Sequence *seq) } } +#if 0 static void free_imbuf_seq_except(Scene *scene, int cfra) { Editing *ed= seq_give_editing(scene, FALSE); @@ -3042,6 +3051,7 @@ static void free_imbuf_seq_except(Scene *scene, int cfra) } SEQ_END } +#endif void free_imbuf_seq(ListBase * seqbase, int check_mem_usage) { @@ -3187,6 +3197,7 @@ void free_imbuf_seq() } #endif +#if 0 // XXX old animation system static void free_imbuf_seq_with_ipo(Scene *scene, struct Ipo *ipo) { /* force update of all sequences with this ipo, on ipo changes */ @@ -3206,6 +3217,7 @@ static void free_imbuf_seq_with_ipo(Scene *scene, struct Ipo *ipo) } SEQ_END } +#endif /* seq funcs's for transforming internally notice the difference between start/end and left/right. diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index efb7db04029..c9bf29ed29c 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -51,7 +51,7 @@ #include "BKE_mesh.h" #include "BKE_subsurf.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_kdtree.h" #include "BLI_kdopbvh.h" #include "BLI_editVert.h" @@ -116,31 +116,31 @@ DerivedMesh *object_get_derived_final(struct Scene *scene, Object *ob, CustomDat void space_transform_from_matrixs(SpaceTransform *data, float local[4][4], float target[4][4]) { float itarget[4][4]; - Mat4Invert(itarget, target); - Mat4MulSerie(data->local2target, itarget, local, 0, 0, 0, 0, 0, 0); - Mat4Invert(data->target2local, data->local2target); + invert_m4_m4(itarget, target); + mul_serie_m4(data->local2target, itarget, local, 0, 0, 0, 0, 0, 0); + invert_m4_m4(data->target2local, data->local2target); } void space_transform_apply(const SpaceTransform *data, float *co) { - VecMat4MulVecfl(co, ((SpaceTransform*)data)->local2target, co); + mul_v3_m4v3(co, ((SpaceTransform*)data)->local2target, co); } void space_transform_invert(const SpaceTransform *data, float *co) { - VecMat4MulVecfl(co, ((SpaceTransform*)data)->target2local, co); + mul_v3_m4v3(co, ((SpaceTransform*)data)->target2local, co); } static void space_transform_apply_normal(const SpaceTransform *data, float *no) { - Mat4Mul3Vecfl( ((SpaceTransform*)data)->local2target, no); - Normalize(no); // TODO: could we just determine de scale value from the matrix? + mul_mat3_m4_v3( ((SpaceTransform*)data)->local2target, no); + normalize_v3(no); // TODO: could we just determine de scale value from the matrix? } static void space_transform_invert_normal(const SpaceTransform *data, float *no) { - Mat4Mul3Vecfl(((SpaceTransform*)data)->target2local, no); - Normalize(no); // TODO: could we just determine de scale value from the matrix? + mul_mat3_m4_v3(((SpaceTransform*)data)->target2local, no); + normalize_v3(no); // TODO: could we just determine de scale value from the matrix? } /* @@ -223,7 +223,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) VECCOPY(tmp_co, nearest.co); space_transform_invert(&calc->local2target, tmp_co); - VecLerpf(co, co, tmp_co, weight); //linear interpolation + interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation } } @@ -258,7 +258,7 @@ int normal_projection_project_vertex(char options, const float *vert, const floa space_transform_apply_normal( transf, tmp_no ); no = tmp_no; - hit_tmp.dist *= Mat4ToScalef( ((SpaceTransform*)transf)->local2target ); + hit_tmp.dist *= mat4_to_scale( ((SpaceTransform*)transf)->local2target ); } else { @@ -285,7 +285,7 @@ int normal_projection_project_vertex(char options, const float *vert, const floa space_transform_invert( transf, hit_tmp.co ); space_transform_invert_normal( transf, hit_tmp.no ); - hit_tmp.dist = VecLenf( (float*)vert, hit_tmp.co ); + hit_tmp.dist = len_v3v3( (float*)vert, hit_tmp.co ); } memcpy(hit, &hit_tmp, sizeof(hit_tmp) ); @@ -331,7 +331,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S if(calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) proj_axis[1] = 1.0f; if(calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS) proj_axis[2] = 1.0f; - Normalize(proj_axis); + normalize_v3(proj_axis); //Invalid projection direction if(INPR(proj_axis, proj_axis) < FLT_EPSILON) @@ -364,7 +364,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S { VECCOPY(tmp_co, calc->vert[i].co); if(calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) - NormalShortToFloat(tmp_no, calc->vert[i].no); + normal_short_to_float_v3(tmp_no, calc->vert[i].no); else VECCOPY(tmp_no, proj_axis); } @@ -403,7 +403,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S if(hit.index != -1) { - VecLerpf(co, co, hit.co, weight); + interp_v3_v3v3(co, co, hit.co, weight); } } } @@ -486,14 +486,14 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) //Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position float dist = sasqrt( nearest.dist ); if(dist > FLT_EPSILON) - VecLerpf(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist)/dist); //linear interpolation + interp_v3_v3v3(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist)/dist); //linear interpolation else VECCOPY( tmp_co, nearest.co ); } //Convert the coordinates back to mesh coordinates space_transform_invert(&calc->local2target, tmp_co); - VecLerpf(co, co, tmp_co, weight); //linear interpolation + interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation } } diff --git a/source/blender/blenkernel/intern/simple_deform.c b/source/blender/blenkernel/intern/simple_deform.c index 2978a6f7f01..b2920615f5a 100644 --- a/source/blender/blenkernel/intern/simple_deform.c +++ b/source/blender/blenkernel/intern/simple_deform.c @@ -35,7 +35,7 @@ #include "BKE_lattice.h" #include "BKE_deform.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_shrinkwrap.h" #include <string.h> @@ -171,8 +171,8 @@ void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, s } else { - Mat4CpyMat4(transf->local2target, smd->origin->obmat); - Mat4Invert(transf->target2local, transf->local2target); + copy_m4_m4(transf->local2target, smd->origin->obmat); + invert_m4_m4(transf->target2local, transf->local2target); } } @@ -246,7 +246,7 @@ void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, s axis_limit(limit_axis, smd_limit, co, dcut); simpleDeform_callback(smd_factor, dcut, co); //Apply deform - VecLerpf(vertexCos[i], vertexCos[i], co, weight); //Use vertex weight has coef of linear interpolation + interp_v3_v3v3(vertexCos[i], vertexCos[i], co, weight); //Use vertex weight has coef of linear interpolation if(transf) space_transform_invert(transf, vertexCos[i]); } diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c index 8deae7e8e10..a41c7747b1a 100644 --- a/source/blender/blenkernel/intern/sketch.c +++ b/source/blender/blenkernel/intern/sketch.c @@ -30,7 +30,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_sketch.h" #include "BKE_utildefines.h" @@ -73,7 +73,7 @@ void sk_initPoint(SK_Point *pt, SK_DrawData *dd, float *no) if (no) { VECCOPY(pt->no, no); - Normalize(pt->no); + normalize_v3(pt->no); } else { @@ -235,7 +235,7 @@ void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], f total = end - start; - VecSubf(delta_p, p_end, p_start); + sub_v3_v3v3(delta_p, p_end, p_start); prev = stk->points + start; next = stk->points + end; @@ -259,8 +259,8 @@ void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], f float *p = stk->points[start + 1 + i].p; VECCOPY(p, delta_p); - VecMulf(p, delta); - VecAddf(p, p, p_start); + mul_v3_fl(p, delta); + add_v3_v3v3(p, p, p_start); } } @@ -320,9 +320,9 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end) VECCOPY(normal, stk->points[start].no); - VecSubf(distance, stk->points[end].p, stk->points[start].p); - Projf(normal, distance, normal); - limit = Normalize(normal); + sub_v3_v3v3(distance, stk->points[end].p, stk->points[start].p); + project_v3_v3v3(normal, distance, normal); + limit = normalize_v3(normal); for (i = 1; i < total - 1; i++) { @@ -330,14 +330,14 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end) float offset[3]; float *p = stk->points[start + i].p; - VecSubf(distance, p, stk->points[start].p); - Projf(distance, distance, normal); + sub_v3_v3v3(distance, p, stk->points[start].p); + project_v3_v3v3(distance, distance, normal); VECCOPY(offset, normal); - VecMulf(offset, d); + mul_v3_fl(offset, d); - VecSubf(p, p, distance); - VecAddf(p, p, offset); + sub_v3_v3v3(p, p, distance); + add_v3_v3v3(p, p, offset); } } diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index b7fe0bdfc98..0a106b1920d 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -44,7 +44,7 @@ #include "BLI_rand.h" #include "BLI_jitter.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_edgehash.h" #include "BLI_kdtree.h" #include "BLI_kdopbvh.h" @@ -150,7 +150,7 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive float tmp[3]; VECCOPY(tmp, verts[i].co); - Mat4MulVecfl(ob->obmat, tmp); + mul_m4_v3(ob->obmat, tmp); // min BB min[0] = MIN2(min[0], tmp[0]); @@ -262,8 +262,8 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive // bvhtree_from_mesh_faces(smd->flow->bvh, dm, 0.0, 2, 6); // copy obmat - // Mat4CpyMat4(smd->flow->mat, ob->obmat); - // Mat4CpyMat4(smd->flow->mat_old, ob->obmat); + // copy_m4_m4(smd->flow->mat, ob->obmat); + // copy_m4_m4(smd->flow->mat_old, ob->obmat); } */ @@ -283,8 +283,8 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive SmokeCollSettings *scs = smd->coll; // copy obmat - Mat4CpyMat4(scs->mat, ob->obmat); - Mat4CpyMat4(scs->mat_old, ob->obmat); + copy_m4_m4(scs->mat, ob->obmat); + copy_m4_m4(scs->mat_old, ob->obmat); fill_scs_points(ob, dm, scs); } @@ -332,7 +332,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) { float tmpvec[3]; VECCOPY(tmpvec, mvert[i].co); - Mat4MulVecfl (ob->obmat, tmpvec); + mul_m4_v3(ob->obmat, tmpvec); VECCOPY(&scs->points[i * 3], tmpvec); } @@ -358,10 +358,10 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) VECSUB(side2, mvert[ mface[i].v3 ].co, mvert[ mface[i].v1 ].co); } - Crossf(trinormorg, side1, side2); - Normalize(trinormorg); + cross_v3_v3v3(trinormorg, side1, side2); + normalize_v3(trinormorg); VECCOPY(trinorm, trinormorg); - VecMulf(trinorm, 0.25 * cell_len); + mul_v3_fl(trinorm, 0.25 * cell_len); for(j = 0; j <= divs1; j++) { @@ -390,9 +390,9 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) VECCOPY(p3, mvert[ mface[i].v3 ].co); } - VecMulf(p1, (1.0-uf-vf)); - VecMulf(p2, uf); - VecMulf(p3, vf); + mul_v3_fl(p1, (1.0-uf-vf)); + mul_v3_fl(p2, uf); + mul_v3_fl(p3, vf); VECADD(p, p1, p2); VECADD(p, p, p3); @@ -403,7 +403,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) // mMovPoints.push_back(p + trinorm); VECCOPY(tmpvec, p); VECADD(tmpvec, tmpvec, trinorm); - Mat4MulVecfl (ob->obmat, tmpvec); + mul_m4_v3(ob->obmat, tmpvec); VECCOPY(&scs->points[3 * (dm->getNumVerts(dm) + newdivs)], tmpvec); newdivs++; @@ -413,7 +413,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) // mMovPoints.push_back(p - trinorm); VECCOPY(tmpvec, p); VECSUB(tmpvec, tmpvec, trinorm); - Mat4MulVecfl (ob->obmat, tmpvec); + mul_m4_v3(ob->obmat, tmpvec); VECCOPY(&scs->points[3 * (dm->getNumVerts(dm) + newdivs)], tmpvec); newdivs++; } @@ -466,11 +466,11 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int int divs1=0, divs2=0, divs3=0; VECCOPY(p0, verts[faces[i].v1].co); - Mat4MulVecfl (ob->obmat, p0); + mul_m4_v3(ob->obmat, p0); VECCOPY(p1, verts[faces[i].v2].co); - Mat4MulVecfl (ob->obmat, p1); + mul_m4_v3(ob->obmat, p1); VECCOPY(p2, verts[faces[i].v3].co); - Mat4MulVecfl (ob->obmat, p2); + mul_m4_v3(ob->obmat, p2); VECSUB(side1, p1, p0); VECSUB(side2, p2, p0); @@ -478,12 +478,12 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int if(INPR(side1, side1) > fsTri*fsTri) { - float tmp = Normalize(side1); + float tmp = normalize_v3(side1); divs1 = (int)ceil(tmp/fsTri); } if(INPR(side2, side2) > fsTri*fsTri) { - float tmp = Normalize(side2); + float tmp = normalize_v3(side2); divs2 = (int)ceil(tmp/fsTri); /* @@ -505,11 +505,11 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int facecounter++; VECCOPY(p0, verts[faces[i].v3].co); - Mat4MulVecfl (ob->obmat, p0); + mul_m4_v3(ob->obmat, p0); VECCOPY(p1, verts[faces[i].v4].co); - Mat4MulVecfl (ob->obmat, p1); + mul_m4_v3(ob->obmat, p1); VECCOPY(p2, verts[faces[i].v1].co); - Mat4MulVecfl (ob->obmat, p2); + mul_m4_v3(ob->obmat, p2); VECSUB(side1, p1, p0); VECSUB(side2, p2, p0); @@ -517,12 +517,12 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int if(INPR(side1, side1) > fsTri*fsTri) { - float tmp = Normalize(side1); + float tmp = normalize_v3(side1); divs1 = (int)ceil(tmp/fsTri); } if(INPR(side2, side2) > fsTri*fsTri) { - float tmp = Normalize(side2); + float tmp = normalize_v3(side2); divs2 = (int)ceil(tmp/fsTri); } @@ -849,7 +849,7 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) else if(pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0) continue; else if(pa->flag & (PARS_UNEXIST+PARS_NO_DISP)) continue; // VECCOPY(pos, pa->state.co); - // Mat4MulVecfl (ob->imat, pos); + // mul_m4_v3(ob->imat, pos); // 1. get corresponding cell get_cell(smd->domain->p0, smd->domain->res, smd->domain->dx, pa->state.co, cell, 0); // check if cell is valid (in the domain boundary) @@ -1105,8 +1105,8 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM // rigid movement support /* - Mat4CpyMat4(smd->flow->mat_old, smd->flow->mat); - Mat4CpyMat4(smd->flow->mat, ob->obmat); + copy_m4_m4(smd->flow->mat_old, smd->flow->mat); + copy_m4_m4(smd->flow->mat, ob->obmat); */ } else if(scene->r.cfra < smd->time) @@ -1131,8 +1131,8 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM smd->coll->dm = CDDM_copy(dm); // rigid movement support - Mat4CpyMat4(smd->coll->mat_old, smd->coll->mat); - Mat4CpyMat4(smd->coll->mat, ob->obmat); + copy_m4_m4(smd->coll->mat_old, smd->coll->mat); + copy_m4_m4(smd->coll->mat, ob->obmat); } else if(scene->r.cfra < smd->time) { @@ -1378,7 +1378,7 @@ static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int float tmp[3]; VECSUB(tmp, pos, p0); - VecMulf(tmp, 1.0 / dx); + mul_v3_fl(tmp, 1.0 / dx); if(correct) { diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 6e986325f55..34071b0034c 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -66,7 +66,7 @@ variables on the UI for now #include "DNA_scene_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_ghash.h" #include "BLI_threads.h" @@ -265,7 +265,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) /* ah yeah, put the verices to global coords once */ /* and determine the ortho BB on the fly */ for(i=0; i < pccd_M->totvert; i++){ - Mat4MulVecfl(ob->obmat, pccd_M->mvert[i].co); + mul_m4_v3(ob->obmat, pccd_M->mvert[i].co); /* evaluate limits */ VECCOPY(v,pccd_M->mvert[i].co); @@ -362,7 +362,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) /* ah yeah, put the verices to global coords once */ /* and determine the ortho BB on the fly */ for(i=0; i < pccd_M->totvert; i++){ - Mat4MulVecfl(ob->obmat, pccd_M->mvert[i].co); + mul_m4_v3(ob->obmat, pccd_M->mvert[i].co); /* evaluate limits */ VECCOPY(v,pccd_M->mvert[i].co); @@ -593,7 +593,7 @@ static void add_mesh_quad_diag_springs(Object *ob) if (ob->soft){ int nofquads; - float s_shear = ob->soft->shearstiff*ob->soft->shearstiff; + //float s_shear = ob->soft->shearstiff*ob->soft->shearstiff; nofquads = count_mesh_quads(me); if (nofquads) { @@ -1059,8 +1059,8 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa /* calculate face normal once again SIGH */ VECSUB(edge1, face_v1, face_v2); VECSUB(edge2, face_v3, face_v2); - Crossf(d_nvect, edge2, edge1); - Normalize(d_nvect); + cross_v3_v3v3(d_nvect, edge2, edge1); + normalize_v3(d_nvect); hash = vertexowner->soft->scratch->colliderhash; @@ -1103,14 +1103,14 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa while(a){ VECCOPY(nv1,mvert[a-1].co); if(mprevvert){ - VecMulf(nv1,time); + mul_v3_fl(nv1,time); Vec3PlusStVec(nv1,(1.0f-time),mprevvert[a-1].co); } /* origin to face_v2*/ VECSUB(nv1, nv1, face_v2); - facedist = Inpf(nv1,d_nvect); + facedist = dot_v3v3(nv1,d_nvect); if (ABS(facedist)<outerfacethickness){ - if (point_in_tri_prism(nv1, face_v1,face_v2,face_v3) ){ + if (isect_point_tri_prism_v3(nv1, face_v1,face_v2,face_v3) ){ float df; if (facedist > 0){ df = (outerfacethickness-facedist)/outerfacethickness; @@ -1218,17 +1218,17 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa VECCOPY(nv4,mvert[mface->v4].co); } if (mprevvert){ - VecMulf(nv1,time); + mul_v3_fl(nv1,time); Vec3PlusStVec(nv1,(1.0f-time),mprevvert[mface->v1].co); - VecMulf(nv2,time); + mul_v3_fl(nv2,time); Vec3PlusStVec(nv2,(1.0f-time),mprevvert[mface->v2].co); - VecMulf(nv3,time); + mul_v3_fl(nv3,time); Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co); if (mface->v4){ - VecMulf(nv4,time); + mul_v3_fl(nv4,time); Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co); } } @@ -1237,12 +1237,12 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa /* switch origin to be nv2*/ VECSUB(edge1, nv1, nv2); VECSUB(edge2, nv3, nv2); - Crossf(d_nvect, edge2, edge1); - Normalize(d_nvect); + cross_v3_v3v3(d_nvect, edge2, edge1); + normalize_v3(d_nvect); if ( - LineIntersectsTriangle(nv1, nv2, face_v1, face_v2, face_v3, &t, NULL) || - LineIntersectsTriangle(nv2, nv3, face_v1, face_v2, face_v3, &t, NULL) || - LineIntersectsTriangle(nv3, nv1, face_v1, face_v2, face_v3, &t, NULL) ){ + isect_line_tri_v3(nv1, nv2, face_v1, face_v2, face_v3, &t, NULL) || + isect_line_tri_v3(nv2, nv3, face_v1, face_v2, face_v3, &t, NULL) || + isect_line_tri_v3(nv3, nv1, face_v1, face_v2, face_v3, &t, NULL) ){ Vec3PlusStVec(force,-0.5f,d_nvect); *damp=tune*ob->pd->pdef_sbdamp; deflected = 2; @@ -1251,13 +1251,13 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa /* switch origin to be nv4 */ VECSUB(edge1, nv3, nv4); VECSUB(edge2, nv1, nv4); - Crossf(d_nvect, edge2, edge1); - Normalize(d_nvect); + cross_v3_v3v3(d_nvect, edge2, edge1); + normalize_v3(d_nvect); if ( - /* LineIntersectsTriangle(nv1, nv3, face_v1, face_v2, face_v3, &t, NULL) || + /* isect_line_tri_v3(nv1, nv3, face_v1, face_v2, face_v3, &t, NULL) || we did that edge allready */ - LineIntersectsTriangle(nv3, nv4, face_v1, face_v2, face_v3, &t, NULL) || - LineIntersectsTriangle(nv4, nv1, face_v1, face_v2, face_v3, &t, NULL) ){ + isect_line_tri_v3(nv3, nv4, face_v1, face_v2, face_v3, &t, NULL) || + isect_line_tri_v3(nv4, nv1, face_v1, face_v2, face_v3, &t, NULL) ){ Vec3PlusStVec(force,-0.5f,d_nvect); *damp=tune*ob->pd->pdef_sbdamp; deflected = 2; @@ -1380,7 +1380,7 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa aabbmax[1] = MAX2(edge_v1[1],edge_v2[1]); aabbmax[2] = MAX2(edge_v1[2],edge_v2[2]); - el = VecLenf(edge_v1,edge_v2); + el = len_v3v3(edge_v1,edge_v2); hash = vertexowner->soft->scratch->colliderhash; ihash = BLI_ghashIterator_new(hash); @@ -1446,17 +1446,17 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa VECCOPY(nv4,mvert[mface->v4].co); } if (mprevvert){ - VecMulf(nv1,time); + mul_v3_fl(nv1,time); Vec3PlusStVec(nv1,(1.0f-time),mprevvert[mface->v1].co); - VecMulf(nv2,time); + mul_v3_fl(nv2,time); Vec3PlusStVec(nv2,(1.0f-time),mprevvert[mface->v2].co); - VecMulf(nv3,time); + mul_v3_fl(nv3,time); Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co); if (mface->v4){ - VecMulf(nv4,time); + mul_v3_fl(nv4,time); Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co); } } @@ -1466,15 +1466,15 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa VECSUB(edge1, nv1, nv2); VECSUB(edge2, nv3, nv2); - Crossf(d_nvect, edge2, edge1); - Normalize(d_nvect); - if ( LineIntersectsTriangle(edge_v1, edge_v2, nv1, nv2, nv3, &t, NULL)){ + cross_v3_v3v3(d_nvect, edge2, edge1); + normalize_v3(d_nvect); + if ( isect_line_tri_v3(edge_v1, edge_v2, nv1, nv2, nv3, &t, NULL)){ float v1[3],v2[3]; float intrusiondepth,i1,i2; VECSUB(v1, edge_v1, nv2); VECSUB(v2, edge_v2, nv2); - i1 = Inpf(v1,d_nvect); - i2 = Inpf(v2,d_nvect); + i1 = dot_v3v3(v1,d_nvect); + i2 = dot_v3v3(v2,d_nvect); intrusiondepth = -MIN2(i1,i2)/el; Vec3PlusStVec(force,intrusiondepth,d_nvect); *damp=ob->pd->pdef_sbdamp; @@ -1485,15 +1485,15 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa VECSUB(edge1, nv3, nv4); VECSUB(edge2, nv1, nv4); - Crossf(d_nvect, edge2, edge1); - Normalize(d_nvect); - if (LineIntersectsTriangle( edge_v1, edge_v2,nv1, nv3, nv4, &t, NULL)){ + cross_v3_v3v3(d_nvect, edge2, edge1); + normalize_v3(d_nvect); + if (isect_line_tri_v3( edge_v1, edge_v2,nv1, nv3, nv4, &t, NULL)){ float v1[3],v2[3]; float intrusiondepth,i1,i2; VECSUB(v1, edge_v1, nv4); VECSUB(v2, edge_v2, nv4); - i1 = Inpf(v1,d_nvect); - i2 = Inpf(v2,d_nvect); + i1 = dot_v3v3(v1,d_nvect); + i2 = dot_v3v3(v2,d_nvect); intrusiondepth = -MIN2(i1,i2)/el; @@ -1531,7 +1531,7 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, if (ob->softflag & OB_SB_EDGECOLL){ if ( sb_detect_edge_collisionCached (sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos, &damp,feedback,ob->lay,ob,timenow)){ - VecAddf(bs->ext_force,bs->ext_force,feedback); + add_v3_v3v3(bs->ext_force,bs->ext_force,feedback); bs->flag |= BSF_INTERSECT; //bs->cf=damp; bs->cf=sb->choke*0.01f; @@ -1550,30 +1550,30 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, EffectedPoint epoint; float speed[3]={0.0f,0.0f,0.0f}; float pos[3]; - VecMidf(pos, sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos); - VecMidf(vel, sb->bpoint[bs->v1].vec , sb->bpoint[bs->v2].vec); + mid_v3_v3v3(pos, sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos); + mid_v3_v3v3(vel, sb->bpoint[bs->v1].vec , sb->bpoint[bs->v2].vec); pd_point_from_soft(scene, pos, vel, -1, &epoint); pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); - VecMulf(speed,windfactor); - VecAddf(vel,vel,speed); + mul_v3_fl(speed,windfactor); + add_v3_v3v3(vel,vel,speed); } /* media in rest */ else{ VECADD(vel, sb->bpoint[bs->v1].vec , sb->bpoint[bs->v2].vec); } - f = Normalize(vel); + f = normalize_v3(vel); f = -0.0001f*f*f*sb->aeroedge; /* (todo) add a nice angle dependant function done for now BUT */ /* still there could be some nice drag/lift function, but who needs it */ VECSUB(sp, sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos); - Projf(pr,vel,sp); + project_v3_v3v3(pr,vel,sp); VECSUB(vel,vel,pr); - Normalize(vel); + normalize_v3(vel); if (ob->softflag & OB_SB_AERO_ANGLE){ - Normalize(sp); - Vec3PlusStVec(bs->ext_force,f*(1.0f-ABS(Inpf(vel,sp))),vel); + normalize_v3(sp); + Vec3PlusStVec(bs->ext_force,f*(1.0f-ABS(dot_v3v3(vel,sp))),vel); } else{ Vec3PlusStVec(bs->ext_force,f,vel); // to keep compatible with 2.45 release files @@ -1671,15 +1671,15 @@ static int choose_winner(float*w, float* pos,float*a,float*b,float*c,float*ca,fl { float mindist,cp; int winner =1; - mindist = ABS(Inpf(pos,a)); + mindist = ABS(dot_v3v3(pos,a)); - cp = ABS(Inpf(pos,b)); + cp = ABS(dot_v3v3(pos,b)); if ( mindist < cp ){ mindist = cp; winner =2; } - cp = ABS(Inpf(pos,c)); + cp = ABS(dot_v3v3(pos,c)); if (mindist < cp ){ mindist = cp; winner =3; @@ -1805,17 +1805,17 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], VECSUB(vv4,nv4,mprevvert[mface->v4].co); } - VecMulf(nv1,time); + mul_v3_fl(nv1,time); Vec3PlusStVec(nv1,(1.0f-time),mprevvert[mface->v1].co); - VecMulf(nv2,time); + mul_v3_fl(nv2,time); Vec3PlusStVec(nv2,(1.0f-time),mprevvert[mface->v2].co); - VecMulf(nv3,time); + mul_v3_fl(nv3,time); Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co); if (mface->v4){ - VecMulf(nv4,time); + mul_v3_fl(nv4,time); Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co); } } @@ -1826,14 +1826,14 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], VECSUB(edge2, nv3, nv2); VECSUB(dv1,opco,nv2); /* abuse dv1 to have vertex in question at *origin* of triangle */ - Crossf(d_nvect, edge2, edge1); - n_mag = Normalize(d_nvect); - facedist = Inpf(dv1,d_nvect); + cross_v3_v3v3(d_nvect, edge2, edge1); + n_mag = normalize_v3(d_nvect); + facedist = dot_v3v3(dv1,d_nvect); // so rules are // if ((facedist > innerfacethickness) && (facedist < outerfacethickness)){ - if (point_in_tri_prism(opco, nv1, nv2, nv3) ){ + if (isect_point_tri_prism_v3(opco, nv1, nv2, nv3) ){ force_mag_norm =(float)exp(-ee*facedist); if (facedist > outerfacethickness*ff) force_mag_norm =(float)force_mag_norm*fa*(facedist - outerfacethickness)*(facedist - outerfacethickness); @@ -1863,12 +1863,12 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], VECSUB(edge2, nv1, nv4); VECSUB(dv1,opco,nv4); /* abuse dv1 to have vertex in question at *origin* of triangle */ - Crossf(d_nvect, edge2, edge1); - n_mag = Normalize(d_nvect); - facedist = Inpf(dv1,d_nvect); + cross_v3_v3v3(d_nvect, edge2, edge1); + n_mag = normalize_v3(d_nvect); + facedist = dot_v3v3(dv1,d_nvect); if ((facedist > innerfacethickness) && (facedist < outerfacethickness)){ - if (point_in_tri_prism(opco, nv1, nv3, nv4) ){ + if (isect_point_tri_prism_v3(opco, nv1, nv3, nv4) ){ force_mag_norm =(float)exp(-ee*facedist); if (facedist > outerfacethickness*ff) force_mag_norm =(float)force_mag_norm*fa*(facedist - outerfacethickness)*(facedist - outerfacethickness); @@ -1898,45 +1898,45 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], { // see if 'outer' hits an edge float dist; - PclosestVL3Dfl(ve, opco, nv1, nv2); + closest_to_line_segment_v3(ve, opco, nv1, nv2); VECSUB(ve,opco,ve); - dist = Normalize(ve); + dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); mindistedge = dist, deflected=1; } - PclosestVL3Dfl(ve, opco, nv2, nv3); + closest_to_line_segment_v3(ve, opco, nv2, nv3); VECSUB(ve,opco,ve); - dist = Normalize(ve); + dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); mindistedge = dist, deflected=1; } - PclosestVL3Dfl(ve, opco, nv3, nv1); + closest_to_line_segment_v3(ve, opco, nv3, nv1); VECSUB(ve,opco,ve); - dist = Normalize(ve); + dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); mindistedge = dist, deflected=1; } if (mface->v4){ /* quad */ - PclosestVL3Dfl(ve, opco, nv3, nv4); + closest_to_line_segment_v3(ve, opco, nv3, nv4); VECSUB(ve,opco,ve); - dist = Normalize(ve); + dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); mindistedge = dist, deflected=1; } - PclosestVL3Dfl(ve, opco, nv1, nv4); + closest_to_line_segment_v3(ve, opco, nv1, nv4); VECSUB(ve,opco,ve); - dist = Normalize(ve); + dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); mindistedge = dist, @@ -1974,12 +1974,12 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], } BLI_ghashIterator_free(ihash); - if (cavel) VecMulf(avel,1.0f/(float)cavel); + if (cavel) mul_v3_fl(avel,1.0f/(float)cavel); VECCOPY(vel,avel); if (ci) *intrusion /= ci; if (deflected){ VECCOPY(facenormal,force); - Normalize(facenormal); + normalize_v3(facenormal); } return deflected; } @@ -2060,8 +2060,8 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float fo } /* do bp1 <--> bp2 elastic */ - VecSubf(dir,bp1->pos,bp2->pos); - distance = Normalize(dir); + sub_v3_v3v3(dir,bp1->pos,bp2->pos); + distance = normalize_v3(dir); if (bs->len < distance) iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */ else @@ -2092,10 +2092,10 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float fo Vec3PlusStVec(bp1->force,(bs->len - distance)*forcefactor,dir); /* do bp1 <--> bp2 viscous */ - VecSubf(dvel,bp1->vec,bp2->vec); + sub_v3_v3v3(dvel,bp1->vec,bp2->vec); kd = sb->infrict * sb_fric_force_scale(ob); - absvel = Normalize(dvel); - projvel = Inpf(dir,dvel); + absvel = normalize_v3(dvel); + projvel = dot_v3v3(dir,dvel); kd *= absvel * projvel; Vec3PlusStVec(bp1->force,-kd,dir); @@ -2169,11 +2169,11 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo for(c=sb->totpoint, obp= sb->bpoint; c>=ifirst+bb; c--, obp++) { compare = (obp->colball + bp->colball); - VecSubf(def, bp->pos, obp->pos); + sub_v3_v3v3(def, bp->pos, obp->pos); /* rather check the AABBoxes before ever calulating the real distance */ /* mathematically it is completly nuts, but performace is pretty much (3) times faster */ if ((ABS(def[0]) > compare) || (ABS(def[1]) > compare) || (ABS(def[2]) > compare)) continue; - distance = Normalize(def); + distance = normalize_v3(def); if (distance < compare ){ /* exclude body points attached with a spring */ attached = 0; @@ -2186,16 +2186,16 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo if (!attached){ float f = bstune/(distance) + bstune/(compare*compare)*distance - 2.0f*bstune/compare ; - VecMidf(velcenter, bp->vec, obp->vec); - VecSubf(dvel,velcenter,bp->vec); - VecMulf(dvel,bp->mass); + mid_v3_v3v3(velcenter, bp->vec, obp->vec); + sub_v3_v3v3(dvel,velcenter,bp->vec); + mul_v3_fl(dvel,bp->mass); Vec3PlusStVec(bp->force,f*(1.0f-sb->balldamp),def); Vec3PlusStVec(bp->force,sb->balldamp,dvel); /* exploit force(a,b) == -force(b,a) part2/2 */ - VecSubf(dvel,velcenter,obp->vec); - VecMulf(dvel,bp->mass); + sub_v3_v3v3(dvel,velcenter,obp->vec); + mul_v3_fl(dvel,bp->mass); Vec3PlusStVec(obp->force,sb->balldamp,dvel); Vec3PlusStVec(obp->force,-f*(1.0f-sb->balldamp),def); @@ -2213,16 +2213,16 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo if(ob->softflag & OB_SB_GOAL) { /* true elastic goal */ float ks,kd; - VecSubf(auxvect,bp->pos,bp->origT); + sub_v3_v3v3(auxvect,bp->pos,bp->origT); ks = 1.0f/(1.0f- bp->goal*sb->goalspring)-1.0f ; bp->force[0]+= -ks*(auxvect[0]); bp->force[1]+= -ks*(auxvect[1]); bp->force[2]+= -ks*(auxvect[2]); /* calulate damping forces generated by goals*/ - VecSubf(velgoal,bp->origS, bp->origE); + sub_v3_v3v3(velgoal,bp->origS, bp->origE); kd = sb->goalfrict * sb_fric_force_scale(ob) ; - VecAddf(auxvect,velgoal,bp->vec); + add_v3_v3v3(auxvect,velgoal,bp->vec); if (forcetime > 0.0 ) { /* make sure friction does not become rocket motor on time reversal */ bp->force[0]-= kd * (auxvect[0]); @@ -2241,8 +2241,8 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo if (sb && scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY){ float gravity[3]; VECCOPY(gravity, scene->physics_settings.gravity); - VecMulf(gravity, sb_grav_force_scale(ob)*bp->mass*sb->effector_weights->global_gravity); /* individual mass of node here */ - VecAddf(bp->force, bp->force, gravity); + mul_v3_fl(gravity, sb_grav_force_scale(ob)*bp->mass*sb->effector_weights->global_gravity); /* individual mass of node here */ + add_v3_v3v3(bp->force, bp->force, gravity); } /* particle field & vortex */ @@ -2256,7 +2256,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); /* apply forcefield*/ - VecMulf(force,fieldfactor* eval_sb_fric_force_scale); + mul_v3_fl(force,fieldfactor* eval_sb_fric_force_scale); VECADD(bp->force, bp->force, force); /* BP friction in moving media */ @@ -2309,7 +2309,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo for(b=bp->nofsprings;b>0;b--){ bs = sb->bspring + bp->springs[b-1]; if (do_springcollision || do_aero){ - VecAddf(bp->force,bp->force,bs->ext_force); + add_v3_v3v3(bp->force,bp->force,bs->ext_force); if (bs->flag & BSF_INTERSECT) bp->choke = bs->cf; @@ -2478,7 +2478,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY){ VECCOPY(gravity, scene->physics_settings.gravity); - VecMulf(gravity, sb_grav_force_scale(ob)*sb->effector_weights->global_gravity); + mul_v3_fl(gravity, sb_grav_force_scale(ob)*sb->effector_weights->global_gravity); } /* check conditions for various options */ @@ -2538,13 +2538,13 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa //if ((bp->octantflag & obp->octantflag) == 0) continue; compare = (obp->colball + bp->colball); - VecSubf(def, bp->pos, obp->pos); + sub_v3_v3v3(def, bp->pos, obp->pos); /* rather check the AABBoxes before ever calulating the real distance */ /* mathematically it is completly nuts, but performace is pretty much (3) times faster */ if ((ABS(def[0]) > compare) || (ABS(def[1]) > compare) || (ABS(def[2]) > compare)) continue; - distance = Normalize(def); + distance = normalize_v3(def); if (distance < compare ){ /* exclude body points attached with a spring */ attached = 0; @@ -2557,9 +2557,9 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa if (!attached){ float f = tune/(distance) + tune/(compare*compare)*distance - 2.0f*tune/compare ; - VecMidf(velcenter, bp->vec, obp->vec); - VecSubf(dvel,velcenter,bp->vec); - VecMulf(dvel,bp->mass); + mid_v3_v3v3(velcenter, bp->vec, obp->vec); + sub_v3_v3v3(dvel,velcenter,bp->vec); + mul_v3_fl(dvel,bp->mass); Vec3PlusStVec(bp->force,f*(1.0f-sb->balldamp),def); Vec3PlusStVec(bp->force,sb->balldamp,dvel); @@ -2589,8 +2589,8 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa } /* exploit force(a,b) == -force(b,a) part2/2 */ - VecSubf(dvel,velcenter,obp->vec); - VecMulf(dvel,(bp->mass+obp->mass)/2.0f); + sub_v3_v3v3(dvel,velcenter,obp->vec); + mul_v3_fl(dvel,(bp->mass+obp->mass)/2.0f); Vec3PlusStVec(obp->force,sb->balldamp,dvel); Vec3PlusStVec(obp->force,-f*(1.0f-sb->balldamp),def); @@ -2609,7 +2609,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* do goal stuff */ if(ob->softflag & OB_SB_GOAL) { /* true elastic goal */ - VecSubf(auxvect,bp->pos,bp->origT); + sub_v3_v3v3(auxvect,bp->pos,bp->origT); ks = 1.0f/(1.0f- bp->goal*sb->goalspring)-1.0f ; bp->force[0]+= -ks*(auxvect[0]); bp->force[1]+= -ks*(auxvect[1]); @@ -2624,9 +2624,9 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* calulate damping forces generated by goals*/ - VecSubf(velgoal,bp->origS, bp->origE); + sub_v3_v3v3(velgoal,bp->origS, bp->origE); kd = sb->goalfrict * sb_fric_force_scale(ob) ; - VecAddf(auxvect,velgoal,bp->vec); + add_v3_v3v3(auxvect,velgoal,bp->vec); if (forcetime > 0.0 ) { /* make sure friction does not become rocket motor on time reversal */ bp->force[0]-= kd * (auxvect[0]); @@ -2634,7 +2634,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa bp->force[2]-= kd * (auxvect[2]); if(nl_flags & NLF_BUILD){ //int ia =3*(sb->totpoint-a); - Normalize(auxvect); + normalize_v3(auxvect); /* depending on my vel */ //dfdv_goal(ia,ia,kd*forcetime); } @@ -2663,7 +2663,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); /* apply forcefield*/ - VecMulf(force,fieldfactor* eval_sb_fric_force_scale); + mul_v3_fl(force,fieldfactor* eval_sb_fric_force_scale); VECADD(bp->force, bp->force, force); /* BP friction in moving media */ @@ -2750,7 +2750,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa for(b=bp->nofsprings;b>0;b--){ bs = sb->bspring + bp->springs[b-1]; if (do_springcollision || do_aero){ - VecAddf(bp->force,bp->force,bs->ext_force); + add_v3_v3v3(bp->force,bp->force,bs->ext_force); if (bs->flag & BSF_INTERSECT) bp->choke = bs->cf; @@ -2882,7 +2882,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * /* the ( ... )' operator denotes derivate respective time */ /* the euler step for velocity then becomes */ /* v(t + dt) = v(t) + a(t) * dt */ - VecMulf(bp->force,timeovermass);/* individual mass of node here */ + mul_v3_fl(bp->force,timeovermass);/* individual mass of node here */ /* some nasty if's to have heun in here too */ VECCOPY(dv,bp->force); @@ -2909,17 +2909,17 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * /* so here is (x)'= v(elocity) */ /* the euler step for location then becomes */ /* x(t + dt) = x(t) + v(t~) * dt */ - VecMulf(dx,forcetime); + mul_v3_fl(dx,forcetime); /* the freezer coming sooner or later */ /* - if ((Inpf(dx,dx)<freezeloc )&&(Inpf(bp->force,bp->force)<freezeforce )){ + if ((dot_v3v3(dx,dx)<freezeloc )&&(dot_v3v3(bp->force,bp->force)<freezeforce )){ bp->frozen /=2; } else{ bp->frozen =MIN2(bp->frozen*1.05f,1.0f); } - VecMulf(dx,bp->frozen); + mul_v3_fl(dx,bp->frozen); */ /* again some nasty if's to have heun in here too */ if (mode ==1){ @@ -2940,10 +2940,10 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * we don't want to end up in deep space so we add some <viscosity> to balance that out */ if (bp->choke2 > 0.0f){ - VecMulf(bp->vec,(1.0f - bp->choke2)); + mul_v3_fl(bp->vec,(1.0f - bp->choke2)); } if (bp->choke > 0.0f){ - VecMulf(bp->vec,(1.0f - bp->choke)); + mul_v3_fl(bp->vec,(1.0f - bp->choke)); } } @@ -2959,7 +2959,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * if (bp->flag & SBF_DOFUZZY) fuzzy =1; } /*for*/ - if (sb->totpoint) VecMulf(cm,1.0f/sb->totpoint); + if (sb->totpoint) mul_v3_fl(cm,1.0f/sb->totpoint); if (sb->scratch){ VECCOPY(sb->scratch->aabbmin,aabbmin); VECCOPY(sb->scratch->aabbmax,aabbmax); @@ -3100,7 +3100,7 @@ static void apply_spring_memory(Object *ob) bs = &sb->bspring[a]; bp1 =&sb->bpoint[bs->v1]; bp2 =&sb->bpoint[bs->v2]; - l = VecLenf(bp1->pos,bp2->pos); + l = len_v3v3(bp1->pos,bp2->pos); r = bs->len/l; if (( r > 1.05f) || (r < 0.95)){ bs->len = ((100.0f - b) * bs->len + b*l)/100.0f; @@ -3192,7 +3192,7 @@ static void springs_from_mesh(Object *ob) bp= ob->soft->bpoint; for(a=0; a<me->totvert; a++, bp++) { VECCOPY(bp->origS, me->mvert[a].co); - Mat4MulVecfl(ob->obmat, bp->origS); + mul_m4_v3(ob->obmat, bp->origS); } } @@ -3203,7 +3203,7 @@ static void springs_from_mesh(Object *ob) } for(a=0; a<sb->totspring; a++) { BodySpring *bs = &sb->bspring[a]; - bs->len= scale*VecLenf(sb->bpoint[bs->v1].origS, sb->bpoint[bs->v2].origS); + bs->len= scale*len_v3v3(sb->bpoint[bs->v1].origS, sb->bpoint[bs->v2].origS); } } } @@ -3341,10 +3341,10 @@ static float globallen(float *v1,float *v2,Object *ob) { float p1[3],p2[3]; VECCOPY(p1,v1); - Mat4MulVecfl(ob->obmat, p1); + mul_m4_v3(ob->obmat, p1); VECCOPY(p2,v2); - Mat4MulVecfl(ob->obmat, p2); - return VecLenf(p1,p2); + mul_m4_v3(ob->obmat, p2); + return len_v3v3(p1,p2); } static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object *ob) @@ -3573,12 +3573,12 @@ static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts, int a; /* inverse matrix is not uptodate... */ - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); for(a=0; a<numVerts; a++, bp++) { VECCOPY(vertexCos[a], bp->pos); if(local==0) - Mat4MulVecfl(ob->imat, vertexCos[a]); /* softbody is in global coords, baked optionally not */ + mul_m4_v3(ob->imat, vertexCos[a]); /* softbody is in global coords, baked optionally not */ } } @@ -3706,7 +3706,7 @@ static void softbody_update_positions(Object *ob, SoftBody *sb, float (*vertexCo /* copy the position of the goals at desired end time */ VECCOPY(bp->origE, vertexCos[a]); /* vertexCos came from local world, go global */ - Mat4MulVecfl(ob->obmat, bp->origE); + mul_m4_v3(ob->obmat, bp->origE); /* just to be save give bp->origT a defined value will be calulated in interpolate_exciter()*/ VECCOPY(bp->origT, bp->origE); @@ -3720,7 +3720,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int for(a=0,bp=sb->bpoint; a<numVerts; a++, bp++) { VECCOPY(bp->pos, vertexCos[a]); - Mat4MulVecfl(ob->obmat, bp->pos); /* yep, sofbody is global coords*/ + mul_m4_v3(ob->obmat, bp->pos); /* yep, sofbody is global coords*/ VECCOPY(bp->origS, bp->pos); VECCOPY(bp->origE, bp->pos); VECCOPY(bp->origT, bp->pos); diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 125c8a0c464..7197437bfd4 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -54,7 +54,7 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_linklist.h" #include "BLI_memarena.h" #include "BLI_edgehash.h" @@ -561,7 +561,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh, } DM_interp_vert_data(dm, result, vertIdx, weight[0][0], numVerts, i); - VecCopyf(mvert->co, ccgSubSurf_getFaceCenterData(f)); + copy_v3_v3(mvert->co, ccgSubSurf_getFaceCenterData(f)); *origIndex = ORIGINDEX_NONE; ++mvert; ++origIndex; @@ -579,7 +579,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh, w[nextS] = weight[x][0][2]; w[otherS] = weight[x][0][3]; DM_interp_vert_data(dm, result, vertIdx, w, numVerts, i); - VecCopyf(mvert->co, + copy_v3_v3(mvert->co, ccgSubSurf_getFaceGridEdgeData(ss, f, S, x)); *origIndex = ORIGINDEX_NONE; @@ -602,7 +602,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh, w[nextS] = weight[y * gridFaces + x][0][2]; w[otherS] = weight[y * gridFaces + x][0][3]; DM_interp_vert_data(dm, result, vertIdx, w, numVerts, i); - VecCopyf(mvert->co, + copy_v3_v3(mvert->co, ccgSubSurf_getFaceGridData(ss, f, S, x, y)); *origIndex = ORIGINDEX_NONE; ++mvert; @@ -633,7 +633,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh, w[1] = (float) x / (edgeSize - 1); w[0] = 1 - w[1]; DM_interp_vert_data(dm, result, vertIdx, w, 2, i); - VecCopyf(mvert->co, ccgSubSurf_getEdgeData(ss, e, x)); + copy_v3_v3(mvert->co, ccgSubSurf_getEdgeData(ss, e, x)); *origIndex = ORIGINDEX_NONE; ++mvert; ++origIndex; @@ -651,7 +651,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh, vertIdx = GET_INT_FROM_POINTER(ccgSubSurf_getVertVertHandle(v)); DM_copy_vert_data(dm, result, vertIdx, i, 1); - VecCopyf(mvert->co, ccgSubSurf_getVertData(ss, v)); + copy_v3_v3(mvert->co, ccgSubSurf_getVertData(ss, v)); *((int*)ccgSubSurf_getVertUserData(ss, v)) = i; *origIndex = ccgDM_getVertMapIndex(ss, v); @@ -1016,19 +1016,19 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv) offset = vertNum - ccgdm->faceMap[i].startVert; if(offset < 1) { - VecCopyf(mv->co, ccgSubSurf_getFaceCenterData(f)); + copy_v3_v3(mv->co, ccgSubSurf_getFaceCenterData(f)); } else if(offset < gridSideEnd) { offset -= 1; grid = offset / gridSideVerts; x = offset % gridSideVerts + 1; - VecCopyf(mv->co, ccgSubSurf_getFaceGridEdgeData(ss, f, grid, x)); + copy_v3_v3(mv->co, ccgSubSurf_getFaceGridEdgeData(ss, f, grid, x)); } else if(offset < gridInternalEnd) { offset -= gridSideEnd; grid = offset / gridInternalVerts; offset %= gridInternalVerts; y = offset / gridSideVerts + 1; x = offset % gridSideVerts + 1; - VecCopyf(mv->co, ccgSubSurf_getFaceGridData(ss, f, grid, x, y)); + copy_v3_v3(mv->co, ccgSubSurf_getFaceGridData(ss, f, grid, x, y)); } } else if((vertNum < ccgdm->vertMap[0].startVert) && (ccgSubSurf_getNumEdges(ss) > 0)) { /* this vert comes from edge data */ @@ -1043,14 +1043,14 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv) e = ccgdm->edgeMap[i].edge; x = vertNum - ccgdm->edgeMap[i].startVert + 1; - VecCopyf(mv->co, ccgSubSurf_getEdgeData(ss, e, x)); + copy_v3_v3(mv->co, ccgSubSurf_getEdgeData(ss, e, x)); } else { /* this vert comes from vert data */ CCGVert *v; i = vertNum - ccgdm->vertMap[0].startVert; v = ccgdm->vertMap[i].vert; - VecCopyf(mv->co, ccgSubSurf_getVertData(ss, v)); + copy_v3_v3(mv->co, ccgSubSurf_getVertData(ss, v)); } } @@ -1188,11 +1188,11 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) CCGFace *f = ccgdm->faceMap[index].face; int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f); - VecCopyf(mvert[i++].co, ccgSubSurf_getFaceCenterData(f)); + copy_v3_v3(mvert[i++].co, ccgSubSurf_getFaceCenterData(f)); for(S = 0; S < numVerts; S++) { for(x = 1; x < gridSize - 1; x++) { - VecCopyf(mvert[i++].co, + copy_v3_v3(mvert[i++].co, ccgSubSurf_getFaceGridEdgeData(ss, f, S, x)); } } @@ -1200,7 +1200,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) for(S = 0; S < numVerts; S++) { for(y = 1; y < gridSize - 1; y++) { for(x = 1; x < gridSize - 1; x++) { - VecCopyf(mvert[i++].co, + copy_v3_v3(mvert[i++].co, ccgSubSurf_getFaceGridData(ss, f, S, x, y)); } } @@ -1213,7 +1213,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) int x; for(x = 1; x < edgeSize - 1; x++) { - VecCopyf(mvert[i++].co, ccgSubSurf_getEdgeData(ss, e, x)); + copy_v3_v3(mvert[i++].co, ccgSubSurf_getEdgeData(ss, e, x)); } } @@ -1221,7 +1221,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) for(index = 0; index < totvert; index++) { CCGVert *v = ccgdm->vertMap[index].vert; - VecCopyf(mvert[i].co, ccgSubSurf_getVertData(ss, v)); + copy_v3_v3(mvert[i].co, ccgSubSurf_getVertData(ss, v)); i++; } @@ -1397,18 +1397,18 @@ static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3]) { CCGFace *f = faceMap2[index]; int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f); - VecCopyf(cos[i++], ccgSubSurf_getFaceCenterData(f)); + copy_v3_v3(cos[i++], ccgSubSurf_getFaceCenterData(f)); for (S=0; S<numVerts; S++) { for (x=1; x<gridSize-1; x++) { - VecCopyf(cos[i++], ccgSubSurf_getFaceGridEdgeData(ss, f, S, x)); + copy_v3_v3(cos[i++], ccgSubSurf_getFaceGridEdgeData(ss, f, S, x)); } } for (S=0; S<numVerts; S++) { for (y=1; y<gridSize-1; y++) { for (x=1; x<gridSize-1; x++) { - VecCopyf(cos[i++], ccgSubSurf_getFaceGridData(ss, f, S, x, y)); + copy_v3_v3(cos[i++], ccgSubSurf_getFaceGridData(ss, f, S, x, y)); } } } @@ -1419,13 +1419,13 @@ static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3]) { int x; for (x=1; x<edgeSize-1; x++) { - VecCopyf(cos[i++], ccgSubSurf_getEdgeData(ss, e, x)); + copy_v3_v3(cos[i++], ccgSubSurf_getEdgeData(ss, e, x)); } } for (index=0; index<totvert; index++) { CCGVert *v = vertMap2[index]; - VecCopyf(cos[i++], ccgSubSurf_getVertData(ss, v)); + copy_v3_v3(cos[i++], ccgSubSurf_getVertData(ss, v)); } MEM_freeN(vertMap2); @@ -2709,17 +2709,17 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]) for (i=0; i<N; i++) { CCGEdge *e = ccgSubSurf_getVertEdge(v, i); - VecAddf(edge_sum, edge_sum, ccgSubSurf_getEdgeData(ss, e, 1)); + add_v3_v3v3(edge_sum, edge_sum, ccgSubSurf_getEdgeData(ss, e, 1)); } for (i=0; i<numFaces; i++) { CCGFace *f = ccgSubSurf_getVertFace(v, i); - VecAddf(face_sum, face_sum, ccgSubSurf_getFaceCenterData(f)); + add_v3_v3v3(face_sum, face_sum, ccgSubSurf_getFaceCenterData(f)); } /* ad-hoc correction for boundary vertices, to at least avoid them moving completely out of place (brecht) */ if(numFaces && numFaces != N) - VecMulf(face_sum, (float)N/(float)numFaces); + mul_v3_fl(face_sum, (float)N/(float)numFaces); co = ccgSubSurf_getVertData(ss, v); positions_r[idx][0] = (co[0]*N*N + edge_sum[0]*4 + face_sum[0])/(N*(N+5)); diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 14460423999..0171c58f2c6 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -41,7 +41,7 @@ #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BLI_kdopbvh.h" @@ -215,7 +215,7 @@ TexMapping *add_mapping(void) texmap->size[0]= texmap->size[1]= texmap->size[2]= 1.0f; texmap->max[0]= texmap->max[1]= texmap->max[2]= 1.0f; - Mat4One(texmap->mat); + unit_m4(texmap->mat); return texmap; } @@ -224,16 +224,16 @@ void init_mapping(TexMapping *texmap) { float eul[3], smat[3][3], rmat[3][3], mat[3][3]; - SizeToMat3(texmap->size, smat); + size_to_mat3( smat,texmap->size); eul[0]= (M_PI/180.0f)*texmap->rot[0]; eul[1]= (M_PI/180.0f)*texmap->rot[1]; eul[2]= (M_PI/180.0f)*texmap->rot[2]; - EulToMat3(eul, rmat); + eul_to_mat3( rmat,eul); - Mat3MulMat3(mat, rmat, smat); + mul_m3_m3m3(mat, rmat, smat); - Mat4CpyMat3(texmap->mat, mat); + copy_m4_m3(texmap->mat, mat); VECCOPY(texmap->mat[3], texmap->loc); } diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index c75c9272e5c..b5f8bc81b81 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -42,7 +42,7 @@ #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_utildefines.h" |