diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-11-10 23:43:45 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-11-10 23:43:45 +0300 |
commit | 37e4a311b0ad9da7177e50620efc3561e2dd7045 (patch) | |
tree | 8aea2cc851ab828ee040d601ed4c776283fd639a /source/blender/render | |
parent | 4617bb68ba4b1c5ab459673fffd98bf7203bb4f2 (diff) |
Math Lib
* Convert all code to use new functions.
* Branch maintainers may want to skip this commit, and run this
conversion script instead, if they use a lot of math functions
in new code:
http://www.pasteall.org/9052/python
Diffstat (limited to 'source/blender/render')
29 files changed, 663 insertions, 663 deletions
diff --git a/source/blender/render/intern/raytrace/rayobject.cpp b/source/blender/render/intern/raytrace/rayobject.cpp index 8aff7a38317..869405e0fbc 100644 --- a/source/blender/render/intern/raytrace/rayobject.cpp +++ b/source/blender/render/intern/raytrace/rayobject.cpp @@ -29,7 +29,7 @@ #include <assert.h> #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_material_types.h" #include "RE_raytrace.h" @@ -170,8 +170,8 @@ static inline int rayface_check_cullface(RayFace *face, Isect *is) float nor[3]; /* don't intersect if the ray faces along the face normal */ - if(face->quad) CalcNormFloat4(face->v1, face->v2, face->v3, face->v4, nor); - else CalcNormFloat(face->v1, face->v2, face->v3, nor); + if(face->quad) normal_quad_v3( nor,face->v1, face->v2, face->v3, face->v4); + else normal_tri_v3( nor,face->v1, face->v2, face->v3); return (INPR(nor, is->vec) < 0); } @@ -376,7 +376,7 @@ int RE_rayobject_raycast(RayObject *r, Isect *isec) RE_RC_COUNT(isec->raycounter->raycast.test); /* Setup vars used on raycast */ - isec->dist = VecLength(isec->vec); + isec->dist = len_v3(isec->vec); for(i=0; i<3; i++) { @@ -435,11 +435,11 @@ int RE_rayobject_intersect(RayObject *r, Isect *i) if(face->ob->transform_primitives) { - Mat4MulVecfl(face->ob->mat, nface.v1); - Mat4MulVecfl(face->ob->mat, nface.v2); - Mat4MulVecfl(face->ob->mat, nface.v3); + mul_m4_v3(face->ob->mat, nface.v1); + mul_m4_v3(face->ob->mat, nface.v2); + mul_m4_v3(face->ob->mat, nface.v3); if(RE_rayface_isQuad(&nface)) - Mat4MulVecfl(face->ob->mat, nface.v4); + mul_m4_v3(face->ob->mat, nface.v4); } return intersect_rayface(r, &nface, i); diff --git a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp index a16499d4f91..09026929829 100644 --- a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp +++ b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp @@ -33,7 +33,7 @@ #include "rayobject_rtbuild.h" #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_utildefines.h" static bool selected_node(RTBuilder::Object *node) diff --git a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp index 11f04c04141..4a2a56fa8ef 100644 --- a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp @@ -38,7 +38,7 @@ int tot_hints = 0; #include "BLI_memarena.h" #include "MEM_guardedalloc.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "reorganize.h" #include "bvh.h" diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 072083e58a7..cbb15558a3d 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -35,7 +35,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_rand.h" #include "BLI_memarena.h" @@ -191,8 +191,8 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), if (re) re->flag |= R_HALO; else stargrid *= 1.0; /* then it draws fewer */ - if(re) Mat4Invert(mat, re->viewmat); - else Mat4One(mat); + if(re) invert_m4_m4(mat, re->viewmat); + else unit_m4(mat); /* BOUNDING BOX CALCULATION * bbox goes from z = loc_near_var | loc_far_var, @@ -240,7 +240,7 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), done++; } else { - Mat4MulVecfl(re->viewmat, vec); + mul_m4_v3(re->viewmat, vec); /* in vec are global coordinates * calculate distance to camera @@ -372,7 +372,7 @@ static int check_vnormal(float *n, float *veno) static void calc_edge_stress_add(float *accum, VertRen *v1, VertRen *v2) { - float len= VecLenf(v1->co, v2->co)/VecLenf(v1->orco, v2->orco); + float len= len_v3v3(v1->co, v2->co)/len_v3v3(v1->orco, v2->orco); float *acc; acc= accum + 2*v1->index; @@ -459,11 +459,11 @@ static void calc_tangent_vector(ObjectRen *obr, VertexTangent **vtangents, MemAr } else if(v1->orco) { uv1= uv[0]; uv2= uv[1]; uv3= uv[2]; uv4= uv[3]; - spheremap(v1->orco[0], v1->orco[1], v1->orco[2], &uv[0][0], &uv[0][1]); - spheremap(v2->orco[0], v2->orco[1], v2->orco[2], &uv[1][0], &uv[1][1]); - spheremap(v3->orco[0], v3->orco[1], v3->orco[2], &uv[2][0], &uv[2][1]); + map_to_sphere( &uv[0][0], &uv[0][1],v1->orco[0], v1->orco[1], v1->orco[2]); + map_to_sphere( &uv[1][0], &uv[1][1],v2->orco[0], v2->orco[1], v2->orco[2]); + map_to_sphere( &uv[2][0], &uv[2][1],v3->orco[0], v3->orco[1], v3->orco[2]); if(v4) - spheremap(v4->orco[0], v4->orco[1], v4->orco[2], &uv[3][0], &uv[3][1]); + map_to_sphere( &uv[3][0], &uv[3][1],v4->orco[0], v4->orco[1], v4->orco[2]); } else return; @@ -539,23 +539,23 @@ static void calc_vertexnormals(Render *re, ObjectRen *obr, int do_tangent, int d if(re->flag & R_GLOB_NOPUNOFLIP) vlr->flag |= R_NOPUNOFLIP; - VecSubf(n1, v2->co, v1->co); - Normalize(n1); - VecSubf(n2, v3->co, v2->co); - Normalize(n2); + sub_v3_v3v3(n1, v2->co, v1->co); + normalize_v3(n1); + sub_v3_v3v3(n2, v3->co, v2->co); + normalize_v3(n2); if(v4==NULL) { - VecSubf(n3, v1->co, v3->co); - Normalize(n3); + sub_v3_v3v3(n3, v1->co, v3->co); + normalize_v3(n3); fac1= saacos(-n1[0]*n3[0]-n1[1]*n3[1]-n1[2]*n3[2]); fac2= saacos(-n1[0]*n2[0]-n1[1]*n2[1]-n1[2]*n2[2]); fac3= saacos(-n2[0]*n3[0]-n2[1]*n3[1]-n2[2]*n3[2]); } else { - VecSubf(n3, v4->co, v3->co); - Normalize(n3); - VecSubf(n4, v1->co, v4->co); - Normalize(n4); + sub_v3_v3v3(n3, v4->co, v3->co); + normalize_v3(n3); + sub_v3_v3v3(n4, v1->co, v4->co); + normalize_v3(n4); fac1= saacos(-n4[0]*n1[0]-n4[1]*n1[1]-n4[2]*n1[2]); fac2= saacos(-n1[0]*n2[0]-n1[1]*n2[1]-n1[2]*n2[2]); @@ -622,17 +622,17 @@ static void calc_vertexnormals(Render *re, ObjectRen *obr, int do_tangent, int d vtang= find_vertex_tangent(vtangents[v1->index], tface->uv[0]); VECCOPY(ftang, vtang); - Normalize(ftang); + normalize_v3(ftang); vtang= find_vertex_tangent(vtangents[v2->index], tface->uv[1]); VECCOPY(ftang+3, vtang); - Normalize(ftang+3); + normalize_v3(ftang+3); vtang= find_vertex_tangent(vtangents[v3->index], tface->uv[2]); VECCOPY(ftang+6, vtang); - Normalize(ftang+6); + normalize_v3(ftang+6); if(v4) { vtang= find_vertex_tangent(vtangents[v4->index], tface->uv[3]); VECCOPY(ftang+9, vtang); - Normalize(ftang+9); + normalize_v3(ftang+9); } } } @@ -641,7 +641,7 @@ static void calc_vertexnormals(Render *re, ObjectRen *obr, int do_tangent, int d /* normalize vertex normals */ for(a=0; a<obr->totvert; a++) { VertRen *ver= RE_findOrAddVert(obr, a); - Normalize(ver->n); + normalize_v3(ver->n); if(do_tangent) { float *tav= RE_vertren_get_tangent(obr, ver, 0); if (tav) { @@ -650,7 +650,7 @@ static void calc_vertexnormals(Render *re, ObjectRen *obr, int do_tangent, int d tav[0] -= ver->n[0]*tdn; tav[1] -= ver->n[1]*tdn; tav[2] -= ver->n[2]*tdn; - Normalize(tav); + normalize_v3(tav); } } } @@ -829,7 +829,7 @@ static void autosmooth(Render *re, ObjectRen *obr, float mat[][4], int degr) /* rotate vertices and calculate normal of faces */ for(a=0; a<obr->totvert; a++) { ver= RE_findOrAddVert(obr, a); - Mat4MulVecfl(mat, ver->co); + mul_m4_v3(mat, ver->co); } for(a=0; a<obr->totvlak; a++) { vlr= RE_findOrAddVlak(obr, a); @@ -837,9 +837,9 @@ static void autosmooth(Render *re, ObjectRen *obr, float mat[][4], int degr) /* skip wire faces */ if(vlr->v2 != vlr->v3) { if(vlr->v4) - CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); else - CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co); } } } @@ -982,9 +982,9 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par int flag, i; static int second=0; - VecSubf(nor, vec, vec1); - Normalize(nor); // nor needed as tangent - Crossf(cross, vec, nor); + sub_v3_v3v3(nor, vec, vec1); + normalize_v3(nor); // nor needed as tangent + cross_v3_v3v3(cross, vec, nor); /* turn cross in pixelsize */ w= vec[2]*re->winmat[2][3] + re->winmat[3][3]; @@ -1006,19 +1006,19 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par /* use actual Blender units for strand width and fall back to minimum width */ if(ma->mode & MA_STR_B_UNITS){ - crosslen= VecLength(cross); + crosslen= len_v3(cross); w= 2.0f*crosslen*ma->strand_min/w; if(width < w) width= w; /*cross is the radius of the strand so we want it to be half of full width */ - VecMulf(cross,0.5/crosslen); + mul_v3_fl(cross,0.5/crosslen); } else width/=w; - VecMulf(cross, width); + mul_v3_fl(cross, width); } else width= 1.0f; @@ -1041,30 +1041,30 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par vlr->v4= RE_findOrAddVert(obr, obr->totvert++); VECCOPY(vlr->v1->co, vec); - VecAddf(vlr->v1->co, vlr->v1->co, cross); + add_v3_v3v3(vlr->v1->co, vlr->v1->co, cross); VECCOPY(vlr->v1->n, nor); vlr->v1->orco= sd->orco; vlr->v1->accum= -1.0f; // accum abuse for strand texco VECCOPY(vlr->v2->co, vec); - VecSubf(vlr->v2->co, vlr->v2->co, cross); + sub_v3_v3v3(vlr->v2->co, vlr->v2->co, cross); VECCOPY(vlr->v2->n, nor); vlr->v2->orco= sd->orco; vlr->v2->accum= vlr->v1->accum; VECCOPY(vlr->v4->co, vec1); - VecAddf(vlr->v4->co, vlr->v4->co, cross); + add_v3_v3v3(vlr->v4->co, vlr->v4->co, cross); VECCOPY(vlr->v4->n, nor); vlr->v4->orco= sd->orco; vlr->v4->accum= 1.0f; // accum abuse for strand texco VECCOPY(vlr->v3->co, vec1); - VecSubf(vlr->v3->co, vlr->v3->co, cross); + sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross); VECCOPY(vlr->v3->n, nor); vlr->v3->orco= sd->orco; vlr->v3->accum= vlr->v4->accum; - CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); vlr->mat= ma; vlr->ec= ME_V2V3; @@ -1115,13 +1115,13 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par v2= RE_findOrAddVert(obr, obr->totvert++); VECCOPY(v1->co, vec); - VecAddf(v1->co, v1->co, cross); + add_v3_v3v3(v1->co, v1->co, cross); VECCOPY(v1->n, nor); v1->orco= sd->orco; v1->accum= -1.0f; // accum abuse for strand texco VECCOPY(v2->co, vec); - VecSubf(v2->co, v2->co, cross); + sub_v3_v3v3(v2->co, v2->co, cross); VECCOPY(v2->n, nor); v2->orco= sd->orco; v2->accum= v1->accum; @@ -1149,15 +1149,15 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par } else if(sd->adapt){ float dvec[3],pvec[3]; - VecSubf(dvec,avec,vec); - Projf(pvec,dvec,vec); - VecSubf(dvec,dvec,pvec); + sub_v3_v3v3(dvec,avec,vec); + project_v3_v3v3(pvec,dvec,vec); + sub_v3_v3v3(dvec,dvec,pvec); w= vec[2]*re->winmat[2][3] + re->winmat[3][3]; dx= re->winx*dvec[0]*re->winmat[0][0]/w; dy= re->winy*dvec[1]*re->winmat[1][1]/w; w= sqrt(dx*dx + dy*dy); - if(Inpf(anor,nor)<sd->adapt_angle && w>sd->adapt_pix){ + if(dot_v3v3(anor,nor)<sd->adapt_angle && w>sd->adapt_pix){ vlr= RE_findOrAddVlak(obr, obr->totvlak++); vlr->flag= flag; vlr->v1= v1; @@ -1177,18 +1177,18 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par } VECCOPY(vlr->v4->co, vec); - VecAddf(vlr->v4->co, vlr->v4->co, cross); + add_v3_v3v3(vlr->v4->co, vlr->v4->co, cross); VECCOPY(vlr->v4->n, nor); vlr->v4->orco= sd->orco; vlr->v4->accum= -1.0f + 2.0f*sd->time; // accum abuse for strand texco VECCOPY(vlr->v3->co, vec); - VecSubf(vlr->v3->co, vlr->v3->co, cross); + sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross); VECCOPY(vlr->v3->n, nor); vlr->v3->orco= sd->orco; vlr->v3->accum= vlr->v4->accum; - CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); vlr->mat= ma; vlr->ec= ME_V2V3; @@ -1244,8 +1244,8 @@ static void static_particle_wire(ObjectRen *obr, Material *ma, float *vec, float VECCOPY(vlr->v1->co, vec); VECCOPY(vlr->v2->co, vec1); - VecSubf(vlr->n, vec, vec1); - Normalize(vlr->n); + sub_v3_v3v3(vlr->n, vec, vec1); + normalize_v3(vlr->n); VECCOPY(vlr->v1->n, vlr->n); VECCOPY(vlr->v2->n, vlr->n); @@ -1267,8 +1267,8 @@ static void static_particle_wire(ObjectRen *obr, Material *ma, float *vec, float v1= vlr->v2; // cycle VECCOPY(v1->co, vec); - VecSubf(vlr->n, vec, vec1); - Normalize(vlr->n); + sub_v3_v3v3(vlr->n, vec, vec1); + normalize_v3(vlr->n); VECCOPY(v1->n, vlr->n); vlr->mat= ma; @@ -1307,21 +1307,21 @@ static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Particl VECADD(vlr->v1->co, bb_center, xvec); VECADD(vlr->v1->co, vlr->v1->co, yvec); - Mat4MulVecfl(re->viewmat, vlr->v1->co); + mul_m4_v3(re->viewmat, vlr->v1->co); VECSUB(vlr->v2->co, bb_center, xvec); VECADD(vlr->v2->co, vlr->v2->co, yvec); - Mat4MulVecfl(re->viewmat, vlr->v2->co); + mul_m4_v3(re->viewmat, vlr->v2->co); VECSUB(vlr->v3->co, bb_center, xvec); VECSUB(vlr->v3->co, vlr->v3->co, yvec); - Mat4MulVecfl(re->viewmat, vlr->v3->co); + mul_m4_v3(re->viewmat, vlr->v3->co); VECADD(vlr->v4->co, bb_center, xvec); VECSUB(vlr->v4->co, vlr->v4->co, yvec); - Mat4MulVecfl(re->viewmat, vlr->v4->co); + mul_m4_v3(re->viewmat, vlr->v4->co); - CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); VECCOPY(vlr->v1->n,vlr->n); VECCOPY(vlr->v2->n,vlr->n); VECCOPY(vlr->v3->n,vlr->n); @@ -1352,10 +1352,10 @@ static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Particl axis2[(bb->align + 2) % 3] = 1.0f; if(bb->lock == 0) { zvec[bb->align] = 0.0f; - Normalize(zvec); + normalize_v3(zvec); } - time = saacos(Inpf(zvec, axis1)) / (float)M_PI; - if(Inpf(zvec, axis2) < 0.0f) + time = saacos(dot_v3v3(zvec, axis1)) / (float)M_PI; + if(dot_v3v3(zvec, axis2) < 0.0f) time = 1.0f - time / 2.0f; else time = time / 2.0f; @@ -1419,7 +1419,7 @@ static void particle_normal_ren(short ren_as, ParticleSettings *part, Render *re VECCOPY(loc, state->co); if(ren_as != PART_DRAW_BB) - Mat4MulVecfl(re->viewmat, loc); + mul_m4_v3(re->viewmat, loc); switch(ren_as) { case PART_DRAW_LINE: @@ -1428,11 +1428,11 @@ static void particle_normal_ren(short ren_as, ParticleSettings *part, Render *re sd->size = hasize; VECCOPY(vel, state->vel); - Mat4Mul3Vecfl(re->viewmat, vel); - Normalize(vel); + mul_mat3_m4_v3(re->viewmat, vel); + normalize_v3(vel); if(part->draw & PART_DRAW_VEL_LENGTH) - VecMulf(vel, VecLength(state->vel)); + mul_v3_fl(vel, len_v3(state->vel)); VECADDFAC(loc0, loc, vel, -part->draw_line[0]); VECADDFAC(loc1, loc, vel, part->draw_line[1]); @@ -1651,10 +1651,10 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem // } /* 2.5 setup matrices */ - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); /* need to be that way, for imat texture */ - Mat3CpyMat4(nmat, ob->imat); - Mat3Transp(nmat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); /* need to be that way, for imat texture */ + copy_m3_m4(nmat, ob->imat); + transpose_m3(nmat); /* 2.6 setup strand rendering */ if(part->ren_as == PART_DRAW_PATH && psys->pathcache){ @@ -1677,7 +1677,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem strandbuf= RE_addStrandBuffer(obr, (totpart+totchild)*(path_nbr+1)); strandbuf->ma= ma; strandbuf->lay= ob->lay; - Mat4CpyMat4(strandbuf->winmat, re->winmat); + copy_m4_m4(strandbuf->winmat, re->winmat); strandbuf->winx= re->winx; strandbuf->winy= re->winy; strandbuf->maxdepth= 2; @@ -1861,7 +1861,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem /* surface normal shading setup */ if(ma->mode_l & MA_STR_SURFDIFF) { - Mat3MulVecfl(nmat, nor); + mul_m3_v3(nmat, nor); sd.surfnor= nor; } else @@ -1916,7 +1916,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem curlen= 0.0f; for(k=1; k<=path_nbr; k++) if(k<=max_k) - strandlen += VecLenf((cache+k-1)->co, (cache+k)->co); + strandlen += len_v3v3((cache+k-1)->co, (cache+k)->co); } if(path_nbr) { @@ -1930,11 +1930,11 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem continue; if(k > 0) - curlen += VecLenf((cache+k-1)->co, (cache+k)->co); + curlen += len_v3v3((cache+k-1)->co, (cache+k)->co); time= curlen/strandlen; VECCOPY(loc,state.co); - Mat4MulVecfl(re->viewmat,loc); + mul_m4_v3(re->viewmat,loc); if(strandbuf) { VECCOPY(svert->co, loc); @@ -1985,7 +1985,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem psys_get_particle_on_path(&sim,a,&state,1); if(psys->parent) - Mat4MulVecfl(psys->parent->obmat, state.co); + mul_m4_v3(psys->parent->obmat, state.co); if(part->ren_as == PART_DRAW_BB) { bb.random = random; @@ -2005,7 +2005,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem continue; if(psys->parent) - Mat4MulVecfl(psys->parent->obmat, state.co); + mul_m4_v3(psys->parent->obmat, state.co); if(part->ren_as == PART_DRAW_BB) { bb.random = random; @@ -2076,8 +2076,8 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *me, int totvert, float vec[3], hasize, mat[4][4], imat[3][3]; int a, ok, seed= ma->seed1; - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat3CpyMat4(imat, ob->imat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + copy_m3_m4(imat, ob->imat); re->flag |= R_HALO; @@ -2088,7 +2088,7 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *me, int totvert, hasize= ma->hasize; VECCOPY(vec, mvert->co); - Mat4MulVecfl(mat, vec); + mul_m4_v3(mat, vec); if(ma->mode & MA_HALOPUNO) { xn= mvert->no[0]; @@ -2099,10 +2099,10 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *me, int totvert, nor[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn; nor[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn; nor[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn; - Normalize(nor); + normalize_v3(nor); VECCOPY(view, vec); - Normalize(view); + normalize_v3(view); zn= nor[0]*view[0]+nor[1]*view[1]+nor[2]*view[2]; if(zn>=0.0) hasize= 0.0; @@ -2183,7 +2183,7 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve VECCOPY(shi->vn, vr->n); if(mat) - Mat4MulVecfl(mat, shi->co); + mul_m4_v3(mat, shi->co); if(imat) { shi->vn[0]= imat[0][0]*vr->n[0]+imat[0][1]*vr->n[1]+imat[0][2]*vr->n[2]; @@ -2221,7 +2221,7 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve } if (texco & TEXCO_GLOB) { VECCOPY(shi->gl, shi->co); - Mat4MulVecfl(re->viewinv, shi->gl); + mul_m4_v3(re->viewinv, shi->gl); } if (texco & TEXCO_NORM) { VECCOPY(shi->orn, shi->vn); @@ -2242,7 +2242,7 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve displace[2]= shi->displace[2] * scale[2]; if(mat) - Mat3MulVecfl(imat, displace); + mul_m3_v3(imat, displace); /* 0.5 could become button once? */ vr->co[0] += displace[0]; @@ -2306,10 +2306,10 @@ static void displace_render_face(Render *re, ObjectRen *obr, VlakRen *vlr, float /* Recalculate the face normal - if flipped before, flip now */ if(vlr->v4) { - CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); } else { - CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co); } } @@ -2325,7 +2325,7 @@ static void do_displacement(Render *re, ObjectRen *obr, float mat[][4], float im /* Object Size with parenting */ obt=obr->ob; while(obt){ - VecAddf(temp, obt->size, obt->dsize); + add_v3_v3v3(temp, obt->size, obt->dsize); scale[0]*=temp[0]; scale[1]*=temp[1]; scale[2]*=temp[2]; obt=obt->parent; } @@ -2362,9 +2362,9 @@ static void init_render_mball(Render *re, ObjectRen *obr) if (ob!=find_basis_mball(re->scene, ob)) return; - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); - Mat3CpyMat4(imat, ob->imat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); + copy_m3_m4(imat, ob->imat); ma= give_render_material(re, ob, 1); @@ -2385,7 +2385,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) ver= RE_findOrAddVert(obr, obr->totvert++); VECCOPY(ver->co, data); - Mat4MulVecfl(mat, ver->co); + mul_m4_v3(mat, ver->co); /* render normals are inverted */ xn= -nors[0]; @@ -2396,8 +2396,8 @@ static void init_render_mball(Render *re, ObjectRen *obr) ver->n[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn; ver->n[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn; ver->n[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn; - Normalize(ver->n); - //if(ob->transflag & OB_NEG_SCALE) VecMulf(ver->n. -1.0); + normalize_v3(ver->n); + //if(ob->transflag & OB_NEG_SCALE) mul_v3_fl(ver->n. -1.0); if(need_orco) ver->orco= orco; } @@ -2412,9 +2412,9 @@ static void init_render_mball(Render *re, ObjectRen *obr) vlr->v4= 0; if(ob->transflag & OB_NEG_SCALE) - CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->n); + normal_tri_v3( vlr->n,vlr->v1->co, vlr->v2->co, vlr->v3->co); else - CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co); vlr->mat= ma; vlr->flag= ME_SMOOTH+R_NOPUNOFLIP; @@ -2429,9 +2429,9 @@ static void init_render_mball(Render *re, ObjectRen *obr) vlr1->v2= vlr1->v3; vlr1->v3= RE_findOrAddVert(obr, index[3]); if(ob->transflag & OB_NEG_SCALE) - CalcNormFloat(vlr1->v1->co, vlr1->v2->co, vlr1->v3->co, vlr1->n); + normal_tri_v3( vlr1->n,vlr1->v1->co, vlr1->v2->co, vlr1->v3->co); else - CalcNormFloat(vlr1->v3->co, vlr1->v2->co, vlr1->v1->co, vlr1->n); + normal_tri_v3( vlr1->n,vlr1->v3->co, vlr1->v2->co, vlr1->v1->co); } } @@ -2469,7 +2469,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, if(orco) { v1->orco= orco; orco+= 3; orcoret++; } - Mat4MulVecfl(mat, v1->co); + mul_m4_v3(mat, v1->co); for (v = 1; v < sizev; v++) { ver= RE_findOrAddVert(obr, obr->totvert++); @@ -2477,7 +2477,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, if(orco) { ver->orco= orco; orco+= 3; orcoret++; } - Mat4MulVecfl(mat, ver->co); + mul_m4_v3(mat, ver->co); } /* if V-cyclic, add extra vertices at end of the row */ if (dl->flag & DL_CYCL_U) { @@ -2525,7 +2525,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, vlr= RE_findOrAddVlak(obr, obr->totvlak++); vlr->v1= v1; vlr->v2= v2; vlr->v3= v3; vlr->v4= v4; - CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, n1); + normal_quad_v3( n1,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); VECCOPY(vlr->n, n1); @@ -2536,10 +2536,10 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, vlr->flag |= R_NOPUNOFLIP; } - VecAddf(v1->n, v1->n, n1); - VecAddf(v2->n, v2->n, n1); - VecAddf(v3->n, v3->n, n1); - VecAddf(v4->n, v4->n, n1); + add_v3_v3v3(v1->n, v1->n, n1); + add_v3_v3v3(v2->n, v2->n, n1); + add_v3_v3v3(v3->n, v3->n, n1); + add_v3_v3v3(v4->n, v4->n, n1); p1++; p2++; p3++; p4++; } @@ -2553,10 +2553,10 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, /* optimize! :*/ vlr= RE_findOrAddVlak(obr, UVTOINDEX(sizeu - 1, v)); vlr1= RE_findOrAddVlak(obr, UVTOINDEX(0, v)); - VecAddf(vlr1->v1->n, vlr1->v1->n, vlr->n); - VecAddf(vlr1->v2->n, vlr1->v2->n, vlr->n); - VecAddf(vlr->v3->n, vlr->v3->n, vlr1->n); - VecAddf(vlr->v4->n, vlr->v4->n, vlr1->n); + add_v3_v3v3(vlr1->v1->n, vlr1->v1->n, vlr->n); + add_v3_v3v3(vlr1->v2->n, vlr1->v2->n, vlr->n); + add_v3_v3v3(vlr->v3->n, vlr->v3->n, vlr1->n); + add_v3_v3v3(vlr->v4->n, vlr->v4->n, vlr1->n); } } if (dl->flag & DL_CYCL_U) { @@ -2566,10 +2566,10 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, /* optimize! :*/ vlr= RE_findOrAddVlak(obr, UVTOINDEX(u, 0)); vlr1= RE_findOrAddVlak(obr, UVTOINDEX(u, sizev-1)); - VecAddf(vlr1->v2->n, vlr1->v2->n, vlr->n); - VecAddf(vlr1->v3->n, vlr1->v3->n, vlr->n); - VecAddf(vlr->v1->n, vlr->v1->n, vlr1->n); - VecAddf(vlr->v4->n, vlr->v4->n, vlr1->n); + add_v3_v3v3(vlr1->v2->n, vlr1->v2->n, vlr->n); + add_v3_v3v3(vlr1->v3->n, vlr1->v3->n, vlr->n); + add_v3_v3v3(vlr->v1->n, vlr->v1->n, vlr1->n); + add_v3_v3v3(vlr->v4->n, vlr->v4->n, vlr1->n); } } /* last vertex is an extra case: @@ -2593,11 +2593,11 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, { vlr= RE_findOrAddVlak(obr, UVTOINDEX(sizeu - 1, sizev - 1)); /* (m,n) */ vlr1= RE_findOrAddVlak(obr, UVTOINDEX(0,0)); /* (0,0) */ - VecAddf(n1, vlr->n, vlr1->n); + add_v3_v3v3(n1, vlr->n, vlr1->n); vlr2= RE_findOrAddVlak(obr, UVTOINDEX(0, sizev-1)); /* (0,n) */ - VecAddf(n1, n1, vlr2->n); + add_v3_v3v3(n1, n1, vlr2->n); vlr3= RE_findOrAddVlak(obr, UVTOINDEX(sizeu-1, 0)); /* (m,0) */ - VecAddf(n1, n1, vlr3->n); + add_v3_v3v3(n1, n1, vlr3->n); VECCOPY(vlr->v3->n, n1); VECCOPY(vlr1->v1->n, n1); VECCOPY(vlr2->v2->n, n1); @@ -2605,7 +2605,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, } for(a = startvert; a < obr->totvert; a++) { ver= RE_findOrAddVert(obr, a); - Normalize(ver->n); + normalize_v3(ver->n); } @@ -2627,8 +2627,8 @@ static void init_render_surf(Render *re, ObjectRen *obr) nu= cu->nurb.first; if(nu==0) return; - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); /* material array */ totmat= ob->totcol+1; @@ -2688,8 +2688,8 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) dl= cu->disp.first; if(cu->disp.first==NULL) return; - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); /* material array */ totmat= ob->totcol+1; @@ -2715,7 +2715,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) n[0]= ob->imat[0][2]; n[1]= ob->imat[1][2]; n[2]= ob->imat[2][2]; - Normalize(n); + normalize_v3(n); for(a=0; a<dl->nr; a++, data+=3) { ver= RE_findOrAddVert(obr, obr->totvert++); @@ -2731,7 +2731,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) ver->flag = 0; } - Mat4MulVecfl(mat, ver->co); + mul_m4_v3(mat, ver->co); if (orco) { ver->orco = orco; @@ -2783,7 +2783,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) ver= RE_findOrAddVert(obr, obr->totvert++); VECCOPY(ver->co, fp); - Mat4MulVecfl(mat, ver->co); + mul_m4_v3(mat, ver->co); fp+= 3; if (orco) { @@ -2824,9 +2824,9 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) */ if(frontside) - CalcNormFloat(vlr->v2->co, vlr->v3->co, vlr->v4->co, vlr->n); + normal_tri_v3( vlr->n,vlr->v2->co, vlr->v3->co, vlr->v4->co); else - CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->n); + normal_tri_v3( vlr->n,vlr->v1->co, vlr->v2->co, vlr->v3->co); vlr->mat= matar[ dl->col ]; @@ -2847,14 +2847,14 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) for(a= startvlak; a<obr->totvlak; a++) { vlr= RE_findOrAddVlak(obr, a); - VecAddf(vlr->v1->n, vlr->v1->n, vlr->n); - VecAddf(vlr->v3->n, vlr->v3->n, vlr->n); - VecAddf(vlr->v2->n, vlr->v2->n, vlr->n); - VecAddf(vlr->v4->n, vlr->v4->n, vlr->n); + add_v3_v3v3(vlr->v1->n, vlr->v1->n, vlr->n); + add_v3_v3v3(vlr->v3->n, vlr->v3->n, vlr->n); + add_v3_v3v3(vlr->v2->n, vlr->v2->n, vlr->n); + add_v3_v3v3(vlr->v4->n, vlr->v4->n, vlr->n); } for(a=startvert; a<obr->totvert; a++) { ver= RE_findOrAddVert(obr, a); - len= Normalize(ver->n); + len= normalize_v3(ver->n); if(len==0.0) ver->flag= 1; /* flag abuse, its only used in zbuf now */ else ver->flag= 0; } @@ -3080,9 +3080,9 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) me= ob->data; - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); - Mat3CpyMat4(imat, ob->imat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); + copy_m3_m4(imat, ob->imat); if(me->totvert==0) return; @@ -3163,7 +3163,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) ver= RE_findOrAddVert(obr, obr->totvert++); VECCOPY(ver->co, mvert->co); if(do_autosmooth==0) /* autosmooth on original unrotated data to prevent differences between frames */ - Mat4MulVecfl(mat, ver->co); + mul_m4_v3(mat, ver->co); if(orco) { ver->orco= orco; @@ -3236,15 +3236,15 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) MVert *mv= me->mvert; if(vlr->v4) - len= CalcNormFloat4( mv[mf->v4].co, mv[mf->v3].co, mv[mf->v2].co, mv[mf->v1].co, vlr->n); + len= normal_quad_v3( vlr->n, mv[mf->v4].co, mv[mf->v3].co, mv[mf->v2].co, mv[mf->v1].co); else - len= CalcNormFloat(mv[mf->v3].co, mv[mf->v2].co, mv[mf->v1].co, vlr->n); + len= normal_tri_v3( vlr->n,mv[mf->v3].co, mv[mf->v2].co, mv[mf->v1].co); } else { if(vlr->v4) - len= CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + len= normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); else - len= CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + len= normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co); } vlr->mat= ma; @@ -3318,7 +3318,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) vlr->n[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn; vlr->n[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn; vlr->n[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn; - Normalize(vlr->n); + normalize_v3(vlr->n); vlr->mat= ma; vlr->flag= 0; @@ -3384,13 +3384,13 @@ static void initshadowbuf(Render *re, LampRen *lar, float mat[][4]) shb->soft= lar->soft; shb->shadhalostep= lar->shadhalostep; - Mat4Ortho(mat); - Mat4Invert(shb->winmat, mat); /* winmat is temp */ + normalize_m4(mat); + invert_m4_m4(shb->winmat, mat); /* winmat is temp */ /* matrix: combination of inverse view and lampmat */ /* calculate again: the ortho-render has no correct viewinv */ - Mat4Invert(viewinv, re->viewmat); - Mat4MulMat4(shb->viewmat, viewinv, shb->winmat); + invert_m4_m4(viewinv, re->viewmat); + mul_m4_m4m4(shb->viewmat, viewinv, shb->winmat); /* projection */ shb->d= lar->clipsta; @@ -3469,11 +3469,11 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) BLI_addtail(&re->lampren, lar); go->lampren= lar; - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); - Mat3CpyMat4(lar->mat, mat); - Mat3CpyMat4(lar->imat, ob->imat); + copy_m3_m4(lar->mat, mat); + copy_m3_m4(lar->imat, ob->imat); lar->bufsize = la->bufsize; lar->samp = la->samp; @@ -3498,7 +3498,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) lar->vec[0]= -mat[2][0]; lar->vec[1]= -mat[2][1]; lar->vec[2]= -mat[2][2]; - Normalize(lar->vec); + normalize_v3(lar->vec); lar->co[0]= mat[3][0]; lar->co[1]= mat[3][1]; lar->co[2]= mat[3][2]; @@ -3577,7 +3577,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) lar->sunsky->effect_type = la->sun_effect_type; VECCOPY(vec,ob->obmat[2]); - Normalize(vec); + normalize_v3(vec); InitSunSky(lar->sunsky, la->atm_turbidity, vec, la->horizon_brightness, la->spread, la->sun_brightness, la->sun_size, la->backscattered_light, @@ -3607,9 +3607,9 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) if(lar->type==LA_SPOT) { - Normalize(lar->imat[0]); - Normalize(lar->imat[1]); - Normalize(lar->imat[2]); + normalize_v3(lar->imat[0]); + normalize_v3(lar->imat[1]); + normalize_v3(lar->imat[2]); xn= saacos(lar->spotsi); xn= sin(xn)/cos(xn); @@ -3630,7 +3630,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) lar->sh_invcampos[0]= -lar->co[0]; lar->sh_invcampos[1]= -lar->co[1]; lar->sh_invcampos[2]= -lar->co[2]; - Mat3MulVecfl(lar->imat, lar->sh_invcampos); + mul_m3_v3(lar->imat, lar->sh_invcampos); /* z factor, for a normalized volume */ angle= saacos(lar->spotsi); @@ -3677,7 +3677,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) else if (la->type==LA_SPOT && (lar->mode & LA_SHAD_BUF) ) { /* Per lamp, one shadow buffer is made. */ lar->bufflag= la->bufflag; - Mat4CpyMat4(mat, ob->obmat); + copy_m4_m4(mat, ob->obmat); initshadowbuf(re, lar, mat); // mat is altered } @@ -3792,8 +3792,8 @@ void init_render_world(Render *re) cp[3]= 1; VECCOPY(re->grvec, re->viewmat[2]); - Normalize(re->grvec); - Mat3CpyMat4(re->imat, re->viewinv); + normalize_v3(re->grvec); + copy_m3_m4(re->imat, re->viewinv); for(a=0; a<MAX_MTEX; a++) if(re->wrld.mtex[a] && re->wrld.mtex[a]->tex) re->wrld.skytype |= WO_SKYTEX; @@ -3946,8 +3946,8 @@ static void split_quads(ObjectRen *obr, int dir) vlr->v4 = vlr1->v4 = NULL; /* new normals */ - CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); - CalcNormFloat(vlr1->v3->co, vlr1->v2->co, vlr1->v1->co, vlr1->n); + normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co); + normal_tri_v3( vlr1->n,vlr1->v3->co, vlr1->v2->co, vlr1->v1->co); } /* clear the flag when not divided */ else vlr->flag &= ~R_DIVIDE_24; @@ -4011,8 +4011,8 @@ static void check_non_flat_quads(ObjectRen *obr) /* 1---2 1---2 0 = orig face, 1 = new face */ /* render normals are inverted in render! we calculate normal of single tria here */ - flen= CalcNormFloat(vlr->v4->co, vlr->v3->co, vlr->v1->co, nor); - if(flen==0.0) CalcNormFloat(vlr->v4->co, vlr->v2->co, vlr->v1->co, nor); + flen= normal_tri_v3( nor,vlr->v4->co, vlr->v3->co, vlr->v1->co); + if(flen==0.0) normal_tri_v3( nor,vlr->v4->co, vlr->v2->co, vlr->v1->co); xn= nor[0]*vlr->n[0] + nor[1]*vlr->n[1] + nor[2]*vlr->n[2]; @@ -4024,10 +4024,10 @@ static void check_non_flat_quads(ObjectRen *obr) vlr1->flag |= R_FACE_SPLIT; /* split direction based on vnorms */ - CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, nor); + normal_tri_v3( nor,vlr->v1->co, vlr->v2->co, vlr->v3->co); d1= nor[0]*vlr->v1->n[0] + nor[1]*vlr->v1->n[1] + nor[2]*vlr->v1->n[2]; - CalcNormFloat(vlr->v2->co, vlr->v3->co, vlr->v4->co, nor); + normal_tri_v3( nor,vlr->v2->co, vlr->v3->co, vlr->v4->co); d2= nor[0]*vlr->v2->n[0] + nor[1]*vlr->v2->n[1] + nor[2]*vlr->v2->n[2]; if( fabs(d1) < fabs(d2) ) vlr->flag |= R_DIVIDE_24; @@ -4053,8 +4053,8 @@ static void check_non_flat_quads(ObjectRen *obr) vlr->v4 = vlr1->v4 = NULL; /* new normals */ - CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); - CalcNormFloat(vlr1->v3->co, vlr1->v2->co, vlr1->v1->co, vlr1->n); + normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co); + normal_tri_v3( vlr1->n,vlr1->v3->co, vlr1->v2->co, vlr1->v1->co); } /* clear the flag when not divided */ else vlr->flag &= ~R_DIVIDE_24; @@ -4143,8 +4143,8 @@ static void find_dupli_instances(Render *re, ObjectRen *obr) float imat[4][4], obmat[4][4], obimat[4][4], nmat[3][3]; int first = 1; - Mat4MulMat4(obmat, obr->obmat, re->viewmat); - Mat4Invert(imat, obmat); + mul_m4_m4m4(obmat, obr->obmat, re->viewmat); + invert_m4_m4(imat, obmat); /* for objects instanced by dupliverts/faces/particles, we go over the * list of instances to find ones that instance obr, and setup their @@ -4155,12 +4155,12 @@ static void find_dupli_instances(Render *re, ObjectRen *obr) /* compute difference between object matrix and * object matrix with dupli transform, in viewspace */ - Mat4CpyMat4(obimat, obi->mat); - Mat4MulMat4(obi->mat, imat, obimat); + copy_m4_m4(obimat, obi->mat); + mul_m4_m4m4(obi->mat, imat, obimat); - Mat3CpyMat4(nmat, obi->mat); - Mat3Inv(obi->nmat, nmat); - Mat3Transp(obi->nmat); + copy_m3_m4(nmat, obi->mat); + invert_m3_m3(obi->nmat, nmat); + transpose_m3(obi->nmat); if(!first) { re->totvert += obr->totvert; @@ -4178,19 +4178,19 @@ static void assign_dupligroup_dupli(Render *re, ObjectInstanceRen *obi, ObjectRe { float imat[4][4], obmat[4][4], obimat[4][4], nmat[3][3]; - Mat4MulMat4(obmat, obr->obmat, re->viewmat); - Mat4Invert(imat, obmat); + mul_m4_m4m4(obmat, obr->obmat, re->viewmat); + invert_m4_m4(imat, obmat); obi->obr= obr; /* compute difference between object matrix and * object matrix with dupli transform, in viewspace */ - Mat4CpyMat4(obimat, obi->mat); - Mat4MulMat4(obi->mat, imat, obimat); + copy_m4_m4(obimat, obi->mat); + mul_m4_m4m4(obi->mat, imat, obimat); - Mat3CpyMat4(nmat, obi->mat); - Mat3Inv(obi->nmat, nmat); - Mat3Transp(obi->nmat); + copy_m3_m4(nmat, obi->mat); + invert_m3_m3(obi->nmat, nmat); + transpose_m3(obi->nmat); re->totvert += obr->totvert; re->totvlak += obr->totvlak; @@ -4253,8 +4253,8 @@ static void set_dupli_tex_mat(Render *re, ObjectInstanceRen *obi, DupliObject *d float imat[4][4]; obi->duplitexmat= BLI_memarena_alloc(re->memArena, sizeof(float)*4*4); - Mat4Invert(imat, dob->mat); - Mat4MulSerie(obi->duplitexmat, re->viewmat, dob->omat, imat, re->viewinv, 0, 0, 0, 0); + invert_m4_m4(imat, dob->mat); + mul_serie_m4(obi->duplitexmat, re->viewmat, dob->omat, imat, re->viewinv, 0, 0, 0, 0); } } @@ -4325,7 +4325,7 @@ static void add_render_object(Render *re, Object *ob, Object *par, DupliObject * obr= RE_addRenderObject(re, ob, par, index, 0, ob->lay); if((dob && !dob->animated) || (ob->transflag & OB_RENDER_DUPLI)) { obr->flag |= R_INSTANCEABLE; - Mat4CpyMat4(obr->obmat, ob->obmat); + copy_m4_m4(obr->obmat, ob->obmat); } if(obr->lay & vectorlay) obr->flag |= R_NEED_VECTORS; @@ -4353,7 +4353,7 @@ static void add_render_object(Render *re, Object *ob, Object *par, DupliObject * obr= RE_addRenderObject(re, ob, par, index, psysindex, ob->lay); if((dob && !dob->animated) || (ob->transflag & OB_RENDER_DUPLI)) { obr->flag |= R_INSTANCEABLE; - Mat4CpyMat4(obr->obmat, ob->obmat); + copy_m4_m4(obr->obmat, ob->obmat); } if(obr->lay & vectorlay) obr->flag |= R_NEED_VECTORS; @@ -4384,8 +4384,8 @@ static void init_render_object(Render *re, Object *ob, Object *par, DupliObject else if(render_object_type(ob->type)) add_render_object(re, ob, par, dob, timeoffset, vectorlay); else { - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); } time= PIL_check_seconds_timer(); @@ -4635,8 +4635,8 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp for(SETLOOPER(re->scene, base)) { ob= base->object; /* imat objects has to be done here, since displace can have texture using Object map-input */ - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); /* each object should only be rendered once */ ob->flag &= ~OB_DONE; ob->transflag &= ~OB_RENDER_DUPLI; @@ -4681,7 +4681,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp for(dob= lb->first; dob; dob= dob->next) { Object *obd= dob->ob; - Mat4CpyMat4(obd->obmat, dob->mat); + copy_m4_m4(obd->obmat, dob->mat); /* group duplis need to set ob matrices correct, for deform. so no_draw is part handled */ if(!(obd->transflag & OB_RENDER_DUPLI) && dob->no_draw) @@ -4706,7 +4706,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp * this is a duplivert/face/particle, or it is a non-animated object in * a dupligroup that has already been created before */ if(dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, 0))) { - Mat4MulMat4(mat, dob->mat, re->viewmat); + mul_m4_m4m4(mat, dob->mat, re->viewmat); obi= RE_addRenderInstance(re, NULL, obd, ob, dob->index, 0, mat, obd->lay); /* fill in instance variables for texturing */ @@ -4782,8 +4782,8 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp if(redoimat) { for(SETLOOPER(re->scene, base)) { ob= base->object; - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); } } @@ -4827,8 +4827,8 @@ void RE_Database_FromScene(Render *re, Scene *scene, int use_camera_view) /* if no camera, viewmat should have been set! */ if(use_camera_view && re->scene->camera) { - Mat4Ortho(re->scene->camera->obmat); - Mat4Invert(mat, re->scene->camera->obmat); + normalize_m4(re->scene->camera->obmat); + invert_m4_m4(mat, re->scene->camera->obmat); RE_SetView(re, mat); re->scene->camera->recalc= OB_RECALC_OB; /* force correct matrix for scaled cameras */ } @@ -4948,7 +4948,7 @@ void RE_DataBase_ApplyWindow(Render *re) void RE_DataBase_GetView(Render *re, float mat[][4]) { - Mat4CpyMat4(mat, re->viewmat); + copy_m4_m4(mat, re->viewmat); } /* ------------------------------------------------------------------------- */ @@ -4982,8 +4982,8 @@ static void database_fromscene_vectors(Render *re, Scene *scene, int timeoffset) /* if no camera, viewmat should have been set! */ if(re->scene->camera) { - Mat4Ortho(re->scene->camera->obmat); - Mat4Invert(mat, re->scene->camera->obmat); + normalize_m4(re->scene->camera->obmat); + invert_m4_m4(mat, re->scene->camera->obmat); RE_SetView(re, mat); } @@ -5091,9 +5091,9 @@ static float *calculate_strandsurface_speedvectors(Render *re, ObjectInstanceRen if(mesh->co && mesh->prevco && mesh->nextco) { if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(winmat, obi->mat, re->winmat); + mul_m4_m4m4(winmat, obi->mat, re->winmat); else - Mat4CpyMat4(winmat, re->winmat); + copy_m4_m4(winmat, re->winmat); winspeed= MEM_callocN(sizeof(float)*4*mesh->totvert, "StrandSurfWin"); @@ -5128,9 +5128,9 @@ static void calculate_speedvectors(Render *re, ObjectInstanceRen *obi, float *ve int a, *face, *index; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(winmat, obi->mat, re->winmat); + mul_m4_m4m4(winmat, obi->mat, re->winmat); else - Mat4CpyMat4(winmat, re->winmat); + copy_m4_m4(winmat, re->winmat); if(obr->vertnodes) { for(a=0; a<obr->totvert; a++, vectors+=2) { @@ -5168,7 +5168,7 @@ static void calculate_speedvectors(Render *re, ObjectInstanceRen *obi, float *ve co3= mesh->co[face[2]]; co4= (face[3])? mesh->co[face[3]]: NULL; - InterpWeightsQ3Dfl(co1, co2, co3, co4, strand->vert->co, w); + interp_weights_face_v3( w,co1, co2, co3, co4, strand->vert->co); speed[0]= speed[1]= speed[2]= speed[3]= 0.0f; QUATADDFAC(speed, speed, winspeed[face[0]], w[0]); @@ -5208,8 +5208,8 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * else return 0; - Mat4CpyMat4(mat, re->viewmat); - Mat4Invert(imat, mat); + copy_m4_m4(mat, re->viewmat); + invert_m4_m4(imat, mat); /* set first vertex OK */ if(!fss->meshSurfNormals) return 0; @@ -5222,9 +5222,9 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * velarray = (float *)fss->meshSurfNormals; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(winmat, obi->mat, re->winmat); + mul_m4_m4m4(winmat, obi->mat, re->winmat); else - Mat4CpyMat4(winmat, re->winmat); + copy_m4_m4(winmat, re->winmat); /* (bad) HACK calculate average velocity */ /* better solution would be fixing getVelocityAt() in intern/elbeem/intern/solver_util.cpp @@ -5312,9 +5312,9 @@ static void copy_dbase_object_vectors(Render *re, ListBase *lb) vec= obilb->vectors= MEM_mallocN(2*sizeof(float)*totvector, "vector array"); if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(winmat, obi->mat, re->winmat); + mul_m4_m4m4(winmat, obi->mat, re->winmat); else - Mat4CpyMat4(winmat, re->winmat); + copy_m4_m4(winmat, re->winmat); for(a=0; a<obr->totvert; a++, vec+=2) { if((a & 255)==0) ver= obr->vertnodes[a>>8].vert; @@ -5513,12 +5513,12 @@ void RE_Database_Baking(Render *re, Scene *scene, int type, Object *actob) /* if no camera, set unit */ if(re->scene->camera) { - Mat4Ortho(re->scene->camera->obmat); - Mat4Invert(mat, re->scene->camera->obmat); + normalize_m4(re->scene->camera->obmat); + invert_m4_m4(mat, re->scene->camera->obmat); RE_SetView(re, mat); } else { - Mat4One(mat); + unit_m4(mat); RE_SetView(re, mat); } @@ -5601,8 +5601,8 @@ void RE_make_sticky(Scene *scene, View3D *v3d) RE_SetCamera(re, scene->camera); /* and set view matrix */ - Mat4Ortho(scene->camera->obmat); - Mat4Invert(mat, scene->camera->obmat); + normalize_m4(scene->camera->obmat); + invert_m4_m4(mat, scene->camera->obmat); RE_SetView(re, mat); for(base= FIRSTBASE; base; base= base->next) { @@ -5618,12 +5618,12 @@ void RE_make_sticky(Scene *scene, View3D *v3d) CD_CALLOC, NULL, me->totvert); where_is_object(scene, ob); - Mat4MulMat4(mat, ob->obmat, re->viewmat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); ms= me->msticky; for(a=0; a<me->totvert; a++, ms++, mvert++) { VECCOPY(ho, mvert->co); - Mat4MulVecfl(mat, ho); + mul_m4_v3(mat, ho); projectverto(ho, re->winmat, ho); ms->co[0]= ho[0]/ho[3]; ms->co[1]= ho[1]/ho[3]; diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index b5774d11799..323eb6a9500 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -31,7 +31,7 @@ /* external modules: */ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_threads.h" @@ -211,9 +211,9 @@ static void envmap_transmatrix(float mat[][4], int part) eul[2]= -M_PI/2.0; } - Mat4CpyMat4(tmat, mat); - EulToMat4(eul, rotmat); - Mat4MulSerie(mat, tmat, rotmat, + copy_m4_m4(tmat, mat); + eul_to_mat4( rotmat,eul); + mul_serie_m4(mat, tmat, rotmat, 0, 0, 0, 0, 0, 0); } @@ -231,28 +231,28 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode) int a; if(mode==0) { - Mat4Invert(tmat, mat); - Mat3CpyMat4(imat, tmat); + invert_m4_m4(tmat, mat); + copy_m3_m4(imat, tmat); } else { - Mat4CpyMat4(tmat, mat); - Mat3CpyMat4(imat, mat); + copy_m4_m4(tmat, mat); + copy_m3_m4(imat, mat); } for(obi=re->instancetable.first; obi; obi=obi->next) { /* append or set matrix depending on dupli */ if(obi->flag & R_DUPLI_TRANSFORMED) { - Mat4CpyMat4(tmpmat, obi->mat); - Mat4MulMat4(obi->mat, tmpmat, tmat); + copy_m4_m4(tmpmat, obi->mat); + mul_m4_m4m4(obi->mat, tmpmat, tmat); } else if(mode==1) - Mat4CpyMat4(obi->mat, tmat); + copy_m4_m4(obi->mat, tmat); else - Mat4One(obi->mat); + unit_m4(obi->mat); - Mat3CpyMat4(cmat, obi->mat); - Mat3Inv(obi->nmat, cmat); - Mat3Transp(obi->nmat); + copy_m3_m4(cmat, obi->mat); + invert_m3_m3(obi->nmat, cmat); + transpose_m3(obi->nmat); /* indicate the renderer has to use transform matrices */ if(mode==0) @@ -267,7 +267,7 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode) if((a & 255)==0) har= obr->bloha[a>>8]; else har++; - Mat4MulVecfl(tmat, har->co); + mul_m4_v3(tmat, har->co); } } @@ -277,25 +277,25 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode) /* removed here some horrible code of someone in NaN who tried to fix prototypes... just solved by introducing a correct cmat[3][3] instead of using smat. this works, check square spots in reflections (ton) */ - Mat3CpyMat3(cmat, lar->imat); - Mat3MulMat3(lar->imat, cmat, imat); + copy_m3_m3(cmat, lar->imat); + mul_m3_m3m3(lar->imat, cmat, imat); - Mat3MulVecfl(imat, lar->vec); - Mat4MulVecfl(tmat, lar->co); + mul_m3_v3(imat, lar->vec); + mul_m4_v3(tmat, lar->co); lar->sh_invcampos[0]= -lar->co[0]; lar->sh_invcampos[1]= -lar->co[1]; lar->sh_invcampos[2]= -lar->co[2]; - Mat3MulVecfl(lar->imat, lar->sh_invcampos); + mul_m3_v3(lar->imat, lar->sh_invcampos); lar->sh_invcampos[2]*= lar->sh_zfac; if(lar->shb) { if(mode==1) { - Mat4Invert(pmat, mat); - Mat4MulMat4(smat, pmat, lar->shb->viewmat); - Mat4MulMat4(lar->shb->persmat, smat, lar->shb->winmat); + invert_m4_m4(pmat, mat); + mul_m4_m4m4(smat, pmat, lar->shb->viewmat); + mul_m4_m4m4(lar->shb->persmat, smat, lar->shb->winmat); } - else Mat4MulMat4(lar->shb->persmat, lar->shb->viewmat, lar->shb->winmat); + else mul_m4_m4m4(lar->shb->persmat, lar->shb->viewmat, lar->shb->winmat); } } @@ -373,8 +373,8 @@ static void env_set_imats(Render *re) base= re->scene->base.first; while(base) { - Mat4MulMat4(mat, base->object->obmat, re->viewmat); - Mat4Invert(base->object->imat, mat); + mul_m4_m4m4(mat, base->object->obmat, re->viewmat); + invert_m4_m4(base->object->imat, mat); base= base->next; } @@ -393,18 +393,18 @@ static void render_envmap(Render *re, EnvMap *env) short part; /* need a recalc: ortho-render has no correct viewinv */ - Mat4Invert(oldviewinv, re->viewmat); + invert_m4_m4(oldviewinv, re->viewmat); envre= envmap_render_copy(re, env); /* precalc orthmat for object */ - Mat4CpyMat4(orthmat, env->object->obmat); - Mat4Ortho(orthmat); + copy_m4_m4(orthmat, env->object->obmat); + normalize_m4(orthmat); /* need imat later for texture imat */ - Mat4MulMat4(mat, orthmat, re->viewmat); - Mat4Invert(tmat, mat); - Mat3CpyMat4(env->obimat, tmat); + mul_m4_m4m4(mat, orthmat, re->viewmat); + invert_m4_m4(tmat, mat); + copy_m3_m4(env->obimat, tmat); for(part=0; part<6; part++) { if(env->type==ENV_PLANE && part!=1) @@ -412,17 +412,17 @@ static void render_envmap(Render *re, EnvMap *env) re->display_clear(re->dch, envre->result); - Mat4CpyMat4(tmat, orthmat); + copy_m4_m4(tmat, orthmat); envmap_transmatrix(tmat, part); - Mat4Invert(mat, tmat); + invert_m4_m4(mat, tmat); /* mat now is the camera 'viewmat' */ - Mat4CpyMat4(envre->viewmat, mat); - Mat4CpyMat4(envre->viewinv, tmat); + copy_m4_m4(envre->viewmat, mat); + copy_m4_m4(envre->viewinv, tmat); /* we have to correct for the already rotated vertexcoords */ - Mat4MulMat4(tmat, oldviewinv, envre->viewmat); - Mat4Invert(env->imat, tmat); + mul_m4_m4m4(tmat, oldviewinv, envre->viewmat); + invert_m4_m4(env->imat, tmat); env_rotate_scene(envre, tmat, 1); init_render_world(envre); @@ -503,13 +503,13 @@ void make_envmaps(Render *re) float orthmat[4][4], mat[4][4], tmat[4][4]; /* precalc orthmat for object */ - Mat4CpyMat4(orthmat, env->object->obmat); - Mat4Ortho(orthmat); + copy_m4_m4(orthmat, env->object->obmat); + normalize_m4(orthmat); /* need imat later for texture imat */ - Mat4MulMat4(mat, orthmat, re->viewmat); - Mat4Invert(tmat, mat); - Mat3CpyMat4(env->obimat, tmat); + mul_m4_m4m4(mat, orthmat, re->viewmat); + invert_m4_m4(tmat, mat); + copy_m3_m4(env->obimat, tmat); } else { @@ -678,20 +678,20 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe /* rotate to envmap space, if object is set */ VECCOPY(vec, texvec); - if(env->object) Mat3MulVecfl(env->obimat, vec); - else Mat4Mul3Vecfl(R.viewinv, vec); + if(env->object) mul_m3_v3(env->obimat, vec); + else mul_mat3_m4_v3(R.viewinv, vec); face= envcube_isect(env, vec, sco); ibuf= env->cube[face]; if(osatex) { if(env->object) { - Mat3MulVecfl(env->obimat, dxt); - Mat3MulVecfl(env->obimat, dyt); + mul_m3_v3(env->obimat, dxt); + mul_m3_v3(env->obimat, dyt); } else { - Mat4Mul3Vecfl(R.viewinv, dxt); - Mat4Mul3Vecfl(R.viewinv, dyt); + mul_mat3_m4_v3(R.viewinv, dxt); + mul_mat3_m4_v3(R.viewinv, dyt); } set_dxtdyt(dxts, dyts, dxt, dyt, face); imagewraposa(tex, NULL, ibuf, sco, dxts, dyts, texres); @@ -703,9 +703,9 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe texr1.nor= texr2.nor= NULL; - VecAddf(vec, vec, dxt); + add_v3_v3v3(vec, vec, dxt); face1= envcube_isect(env, vec, sco); - VecSubf(vec, vec, dxt); + sub_v3_v3v3(vec, vec, dxt); if(face!=face1) { ibuf= env->cube[face1]; @@ -716,9 +716,9 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe /* here was the nasty bug! results were not zero-ed. FPE! */ - VecAddf(vec, vec, dyt); + add_v3_v3v3(vec, vec, dyt); face1= envcube_isect(env, vec, sco); - VecSubf(vec, vec, dyt); + sub_v3_v3v3(vec, vec, dyt); if(face!=face1) { ibuf= env->cube[face1]; diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 01131f09b96..3d46fdfaaee 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -48,7 +48,7 @@ #include "DNA_scene_types.h" #include "DNA_texture_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_threads.h" diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index d388e81a745..abff8bf2655 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -37,7 +37,7 @@ #include "PIL_time.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_jitter.h" @@ -562,7 +562,7 @@ void RE_GetCameraWindow(struct Render *re, struct Object *camera, int frame, flo { re->r.cfra= frame; RE_SetCamera(re, camera); - Mat4CpyMat4(mat, re->winmat); + copy_m4_m4(mat, re->winmat); } /* ~~~~~~~~~~~~~~~~ part (tile) calculus ~~~~~~~~~~~~~~~~~~~~~~ */ diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index a15377a8c6d..f62668b84c0 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -36,7 +36,7 @@ #include "DNA_material_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_memarena.h" #include "BLI_threads.h" @@ -165,7 +165,7 @@ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, /* set up view vector */ VECCOPY(shi->view, shi->co); - Normalize(shi->view); + normalize_v3(shi->view); /* cache for shadow */ shi->samplenr++; @@ -181,8 +181,8 @@ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, /* not a pretty solution, but fixes common cases */ if(shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) { - VecNegf(shi->vn); - VecNegf(shi->vno); + negate_v3(shi->vn); + negate_v3(shi->vno); } /* init material vars */ @@ -311,12 +311,12 @@ static void occ_face(const OccFace *face, float *co, float *normal, float *area) if(co) { if(vlr->v4) - VecLerpf(co, vlr->v1->co, vlr->v3->co, 0.5f); + interp_v3_v3v3(co, vlr->v1->co, vlr->v3->co, 0.5f); else - CalcCent3f(co, vlr->v1->co, vlr->v2->co, vlr->v3->co); + cent_tri_v3(co, vlr->v1->co, vlr->v2->co, vlr->v3->co); if(obi->flag & R_TRANSFORMED) - Mat4MulVecfl(obi->mat, co); + mul_m4_v3(obi->mat, co); } if(normal) { @@ -325,7 +325,7 @@ static void occ_face(const OccFace *face, float *co, float *normal, float *area) normal[2]= -vlr->n[2]; if(obi->flag & R_TRANSFORMED) - Mat3MulVecfl(obi->nmat, normal); + mul_m3_v3(obi->nmat, normal); } if(area) { @@ -335,17 +335,17 @@ static void occ_face(const OccFace *face, float *co, float *normal, float *area) if(vlr->v4) VECCOPY(v4, vlr->v4->co); if(obi->flag & R_TRANSFORMED) { - Mat4MulVecfl(obi->mat, v1); - Mat4MulVecfl(obi->mat, v2); - Mat4MulVecfl(obi->mat, v3); - if(vlr->v4) Mat4MulVecfl(obi->mat, v4); + mul_m4_v3(obi->mat, v1); + mul_m4_v3(obi->mat, v2); + mul_m4_v3(obi->mat, v3); + if(vlr->v4) mul_m4_v3(obi->mat, v4); } /* todo: correct area for instances */ if(vlr->v4) - *area= AreaQ3Dfl(v1, v2, v3, v4); + *area= area_quad_v3(v1, v2, v3, v4); else - *area= AreaT3Dfl(v1, v2, v3); + *area= area_tri_v3(v1, v2, v3); } } @@ -591,7 +591,7 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i } if(node->area != 0.0f) - VecMulf(node->co, 1.0f/node->area); + mul_v3_fl(node->co, 1.0f/node->area); /* compute maximum distance from center */ node->dco= 0.0f; @@ -1116,10 +1116,10 @@ static float occ_quad_form_factor(float *p, float *n, float *q0, float *q1, floa normalizef(r2); normalizef(r3); - Crossf(g0, r1, r0); normalizef(g0); - Crossf(g1, r2, r1); normalizef(g1); - Crossf(g2, r3, r2); normalizef(g2); - Crossf(g3, r0, r3); normalizef(g3); + cross_v3_v3v3(g0, r1, r0); normalizef(g0); + cross_v3_v3v3(g1, r2, r1); normalizef(g1); + cross_v3_v3v3(g2, r3, r2); normalizef(g2); + cross_v3_v3v3(g3, r0, r3); normalizef(g3); a1= saacosf(INPR(r0, r1)); a2= saacosf(INPR(r1, r2)); @@ -1151,9 +1151,9 @@ static float occ_form_factor(OccFace *face, float *p, float *n) VECCOPY(v3, vlr->v3->co); if(obi->flag & R_TRANSFORMED) { - Mat4MulVecfl(obi->mat, v1); - Mat4MulVecfl(obi->mat, v2); - Mat4MulVecfl(obi->mat, v3); + mul_m4_v3(obi->mat, v1); + mul_m4_v3(obi->mat, v2); + mul_m4_v3(obi->mat, v3); } if(occ_visible_quad(p, n, v1, v2, v3, q0, q1, q2, q3)) @@ -1162,7 +1162,7 @@ static float occ_form_factor(OccFace *face, float *p, float *n) if(vlr->v4) { VECCOPY(v4, vlr->v4->co); if(obi->flag & R_TRANSFORMED) - Mat4MulVecfl(obi->mat, v4); + mul_m4_v3(obi->mat, v4); if(occ_visible_quad(p, n, v1, v3, v4, q0, q1, q2, q3)) contrib += occ_quad_form_factor(p, n, q0, q1, q2, q3); @@ -1269,7 +1269,7 @@ static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, float } if(occ) *occ= resultocc; - if(bentn) Normalize(bentn); + if(bentn) normalize_v3(bentn); } static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass) @@ -1282,7 +1282,7 @@ static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass) for(pass=0; pass<totpass; pass++) { for(i=0; i<tree->totface; i++) { occ_face(&tree->face[i], co, n, NULL); - VecNegf(n); + negate_v3(n); VECADDFAC(co, co, n, 1e-8f); occ_lookup(tree, 0, &tree->face[i], co, n, &occ[i], NULL); @@ -1315,7 +1315,7 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f aocolor= WO_AOPLAIN; VECCOPY(nn, n); - VecNegf(nn); + negate_v3(nn); occ_lookup(tree, thread, exclude, co, nn, &occ, (aocolor)? bn: NULL); @@ -1347,7 +1347,7 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f } #endif - VecMulf(skycol, occlusion); + mul_v3_fl(skycol, occlusion); } else { skycol[0]= occlusion; @@ -1477,7 +1477,7 @@ static void sample_occ_surface(ShadeInput *shi) co3= mesh->co[face[2]]; co4= (face[3])? mesh->co[face[3]]: NULL; - InterpWeightsQ3Dfl(co1, co2, co3, co4, strand->vert->co, w); + interp_weights_face_v3( w,co1, co2, co3, co4, strand->vert->co); shi->ao[0]= shi->ao[1]= shi->ao[2]= 0.0f; VECADDFAC(shi->ao, shi->ao, mesh->col[face[0]], w[0]); @@ -1512,14 +1512,14 @@ static void *exec_strandsurface_sample(void *data) if(face[3]) { co4= mesh->co[face[3]]; - VecLerpf(co, co1, co3, 0.5f); - CalcNormFloat4(co1, co2, co3, co4, n); + interp_v3_v3v3(co, co1, co3, 0.5f); + normal_quad_v3( n,co1, co2, co3, co4); } else { - CalcCent3f(co, co1, co2, co3); - CalcNormFloat(co1, co2, co3, n); + cent_tri_v3(co, co1, co2, co3); + normal_tri_v3( n,co1, co2, co3); } - VecNegf(n); + negate_v3(n); sample_occ_tree(re, re->occlusiontree, NULL, co, n, othread->thread, 0, col); VECCOPY(othread->facecol[a], col); @@ -1597,7 +1597,7 @@ void make_occ_tree(Render *re) for(a=0; a<mesh->totvert; a++) if(count[a]) - VecMulf(mesh->col[a], 1.0f/count[a]); + mul_v3_fl(mesh->col[a], 1.0f/count[a]); MEM_freeN(count); MEM_freeN(facecol); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 86bbdb8534e..9c4c83a82f9 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -53,7 +53,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_rand.h" #include "BLI_threads.h" @@ -1264,7 +1264,7 @@ void RE_SetWindow(Render *re, rctf *viewplane, float clipsta, float clipend) re->clipend= clipend; re->r.mode &= ~R_ORTHO; - i_window(re->viewplane.xmin, re->viewplane.xmax, re->viewplane.ymin, re->viewplane.ymax, re->clipsta, re->clipend, re->winmat); + perspective_m4( re->winmat,re->viewplane.xmin, re->viewplane.xmax, re->viewplane.ymin, re->viewplane.ymax, re->clipsta, re->clipend); } @@ -1277,14 +1277,14 @@ void RE_SetOrtho(Render *re, rctf *viewplane, float clipsta, float clipend) re->clipend= clipend; re->r.mode |= R_ORTHO; - i_ortho(re->viewplane.xmin, re->viewplane.xmax, re->viewplane.ymin, re->viewplane.ymax, re->clipsta, re->clipend, re->winmat); + orthographic_m4( re->winmat,re->viewplane.xmin, re->viewplane.xmax, re->viewplane.ymin, re->viewplane.ymax, re->clipsta, re->clipend); } void RE_SetView(Render *re, float mat[][4]) { /* re->ok flag? */ - Mat4CpyMat4(re->viewmat, mat); - Mat4Invert(re->viewinv, re->viewmat); + copy_m4_m4(re->viewmat, mat); + invert_m4_m4(re->viewinv, re->viewmat); } /* image and movie output has to move to either imbuf or kernel */ @@ -1511,7 +1511,7 @@ static RenderPart *find_next_pano_slice(Render *re, int *minx, rctf *viewplane) R.viewplane.xmin = viewplane->xmin + R.panodxv; R.viewplane.xmax = viewplane->xmax + R.panodxv; RE_SetWindow(re, &R.viewplane, R.clipsta, R.clipend); - Mat4CpyMat4(R.winmat, re->winmat); + copy_m4_m4(R.winmat, re->winmat); /* rotate database according to part coordinates */ project_renderdata(re, projectverto, 1, -R.panodxp*phi, 1); diff --git a/source/blender/render/intern/source/pixelblending.c b/source/blender/render/intern/source/pixelblending.c index 0e453d461ab..da9a698291c 100644 --- a/source/blender/render/intern/source/pixelblending.c +++ b/source/blender/render/intern/source/pixelblending.c @@ -34,7 +34,7 @@ #include <string.h> /* global includes */ -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" /* own includes */ diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index de3a50acddf..d4b7c403f50 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -27,7 +27,7 @@ #include <float.h> #include <math.h> #include <string.h> -#include "BLI_arithb.h" +#include "BLI_math.h" /* External modules: */ #include "IMB_imbuf_types.h" @@ -155,7 +155,7 @@ static void render_lighting_halo(HaloRen *har, float *colf) /* rotate view to lampspace */ VECCOPY(lvrot, lv); - Mat3MulVecfl(lar->imat, lvrot); + mul_m3_v3(lar->imat, lvrot); x= MAX2(fabs(lvrot[0]/lvrot[2]) , fabs(lvrot[1]/lvrot[2])); /* 1.0/(sqrt(1+x*x)) is equivalent to cos(atan(x)) */ @@ -553,7 +553,7 @@ void shadeSkyView(float *colf, float *rco, float *view, float *dxyview, short th VECCOPY(lo, view); if(R.wrld.skytype & WO_SKYREAL) { - Mat3MulVecfl(R.imat, lo); + mul_m3_v3(R.imat, lo); SWAP(float, lo[1], lo[2]); @@ -594,11 +594,11 @@ void shadeSunView(float *colf, float *view) if(do_init) { VECCOPY(sview, view); - Normalize(sview); - Mat3MulVecfl(R.imat, sview); + normalize_v3(sview); + mul_m3_v3(R.imat, sview); if (sview[2] < 0.0) sview[2] = 0.0; - Normalize(sview); + normalize_v3(sview); do_init= 0; } @@ -654,7 +654,7 @@ void shadeSkyPixel(float *collector, float fx, float fy, short thread) } else { calc_view_vector(view, fx, fy); - fac= Normalize(view); + fac= normalize_v3(view); if(R.wrld.skytype & WO_SKYTEX) { dxyview[0]= -R.viewdx/fac; @@ -677,8 +677,8 @@ void shadeAtmPixel(struct SunSky *sunsky, float *collector, float fx, float fy, float view[3]; calc_view_vector(view, fx, fy); - Normalize(view); - /*Mat3MulVecfl(R.imat, view);*/ + normalize_v3(view); + /*mul_m3_v3(R.imat, view);*/ AtmospherePixleShader(sunsky, view, distance, collector); } diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 2b3e6047af4..e808d70da33 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -29,7 +29,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_kdopbvh.h" @@ -106,7 +106,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa /* init everything */ if (!psys || !ob || !pd) return; - Mat4MulMat4(obview, re->viewinv, ob->obmat); + mul_m4_m4m4(obview, re->viewinv, ob->obmat); /* Just to create a valid rendering context for particles */ psys_render_set(ob, psys, re->viewmat, re->winmat, re->winx, re->winy, 0); @@ -119,7 +119,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa } /* in case ob->imat isn't up-to-date */ - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); total_particles = psys->totpart+psys->totchild; psys->lattice=psys_get_lattice(&sim); @@ -140,11 +140,11 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa VECCOPY(partco, state.co); if (pd->psys_cache_space == TEX_PD_OBJECTSPACE) - Mat4MulVecfl(ob->imat, partco); + mul_m4_v3(ob->imat, partco); else if (pd->psys_cache_space == TEX_PD_OBJECTLOC) { float obloc[3]; VECCOPY(obloc, ob->loc); - VecSubf(partco, partco, obloc); + sub_v3_v3v3(partco, partco, obloc); } else { /* TEX_PD_WORLDSPACE */ } @@ -209,12 +209,12 @@ static void pointdensity_cache_object(Render *re, PointDensity *pd, Object *ob) case TEX_PD_OBJECTSPACE: break; case TEX_PD_OBJECTLOC: - Mat4MulVecfl(ob->obmat, co); - VecSubf(co, co, ob->loc); + mul_m4_v3(ob->obmat, co); + sub_v3_v3v3(co, co, ob->loc); break; case TEX_PD_WORLDSPACE: default: - Mat4MulVecfl(ob->obmat, co); + mul_m4_v3(ob->obmat, co); break; } @@ -391,7 +391,7 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres) num = BLI_bvhtree_range_query(pd->point_tree, co, pd->radius, accum_density, &pdr); if (num > 0) { age /= num; - VecMulf(vec, 1.0f/num); + mul_v3_fl(vec, 1.0f/num); } /* reset */ @@ -424,7 +424,7 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres) num = BLI_bvhtree_range_query(pd->point_tree, co, pd->radius, accum_density, &pdr); if (num > 0) { age /= num; - VecMulf(vec, 1.0f/num); + mul_v3_fl(vec, 1.0f/num); } texres->tin = density; @@ -448,7 +448,7 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres) break; case TEX_PD_COLOR_PARTSPEED: { - float speed = VecLength(vec) * pd->speed_scale; + float speed = len_v3(vec) * pd->speed_scale; if (pd->coba) { if (do_colorband(pd->coba, speed, col)) { @@ -462,7 +462,7 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres) } case TEX_PD_COLOR_PARTVEL: texres->talpha= 1; - VecMulf(vec, pd->speed_scale); + mul_v3_fl(vec, pd->speed_scale); VECCOPY(&texres->tr, vec); texres->ta = texres->tin; break; diff --git a/source/blender/render/intern/source/rayobject_blibvh.c b/source/blender/render/intern/source/rayobject_blibvh.c index 3fd71862f54..3579eb9007f 100644 --- a/source/blender/render/intern/source/rayobject_blibvh.c +++ b/source/blender/render/intern/source/rayobject_blibvh.c @@ -31,7 +31,7 @@ #include "MEM_guardedalloc.h" #include "BKE_utildefines.h" #include "BLI_kdopbvh.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "RE_raytrace.h" #include "render_types.h" #include "rayobject.h" @@ -120,7 +120,7 @@ static int RE_rayobject_blibvh_intersect(RayObject *o, Isect *isec) data.leafs = obj->leafs; VECCOPY(dir, isec->vec); - Normalize(dir); + normalize_v3(dir); hit.index = 0; hit.dist = isec->labda*isec->dist; diff --git a/source/blender/render/intern/source/rayobject_instance.c b/source/blender/render/intern/source/rayobject_instance.c index e2f4dc5a9dd..9ed184e532c 100644 --- a/source/blender/render/intern/source/rayobject_instance.c +++ b/source/blender/render/intern/source/rayobject_instance.c @@ -30,7 +30,7 @@ #include "MEM_guardedalloc.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "RE_raytrace.h" #include "rayobject.h" @@ -79,8 +79,8 @@ RayObject *RE_rayobject_instance_create(RayObject *target, float transform[][4], obj->ob = ob; obj->target_ob = target_ob; - Mat4CpyMat4(obj->target2global, transform); - Mat4Invert(obj->global2target, obj->target2global); + copy_m4_m4(obj->target2global, transform); + invert_m4_m4(obj->global2target, obj->target2global); return RE_rayobject_unalignRayAPI((RayObject*) obj); } @@ -111,10 +111,10 @@ static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec) //Transform to target coordinates system VECADD( isec->vec, isec->vec, isec->start ); - Mat4MulVecfl(obj->global2target, isec->start); - Mat4MulVecfl(obj->global2target, isec->vec ); + mul_m4_v3(obj->global2target, isec->start); + mul_m4_v3(obj->global2target, isec->vec ); - isec->dist = VecLenf( isec->start, isec->vec ); + isec->dist = len_v3v3( isec->start, isec->vec ); VECSUB( isec->vec, isec->vec, isec->start ); isec->labda *= isec->dist / dist; @@ -194,7 +194,7 @@ static void RE_rayobject_instance_bb(RayObject *o, float *min, float *max) for(i=0; i<8; i++) { for(j=0; j<3; j++) t[j] = i&(1<<j) ? M[j] : m[j]; - Mat4MulVecfl(obj->target2global, t); + mul_m4_v3(obj->target2global, t); DO_MINMAX(t, min, max); } } diff --git a/source/blender/render/intern/source/rayobject_octree.c b/source/blender/render/intern/source/rayobject_octree.c index 2f0a1a3f53b..7c29db6a4bb 100644 --- a/source/blender/render/intern/source/rayobject_octree.c +++ b/source/blender/render/intern/source/rayobject_octree.c @@ -40,7 +40,7 @@ #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "rayobject.h" @@ -226,7 +226,7 @@ static int face_in_node(RayFace *face, short x, short y, short z, float rtf[][3] // init static vars if(face) { - CalcNormFloat(rtf[0], rtf[1], rtf[2], nor); + normal_tri_v3( nor,rtf[0], rtf[1], rtf[2]); d= -nor[0]*rtf[0][0] - nor[1]*rtf[0][1] - nor[2]*rtf[0][2]; return 0; } diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index 7043837166a..85442480a9c 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -41,7 +41,7 @@ #include "BKE_node.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_jitter.h" #include "BLI_rand.h" @@ -397,11 +397,11 @@ static void makeraytree_single(Render *re) RE_rayface_from_vlak(face, obi, vlr); if((obi->flag & R_TRANSFORMED)) { - Mat4MulVecfl(obi->mat, face->v1); - Mat4MulVecfl(obi->mat, face->v2); - Mat4MulVecfl(obi->mat, face->v3); + mul_m4_v3(obi->mat, face->v1); + mul_m4_v3(obi->mat, face->v2); + mul_m4_v3(obi->mat, face->v3); if(RE_rayface_isQuad(face)) - Mat4MulVecfl(obi->mat, face->v4); + mul_m4_v3(obi->mat, face->v4); } RE_rayobject_add( raytree, RE_rayobject_unalignRayFace(face) ); @@ -481,7 +481,7 @@ void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr) shi->co[1]= is->start[1]+is->labda*(shi->view[1]); shi->co[2]= is->start[2]+is->labda*(shi->view[2]); - Normalize(shi->view); + normalize_v3(shi->view); shi->obi= obi; shi->obr= obi->obr; @@ -674,7 +674,7 @@ static void ray_fadeout_endcolor(float *col, ShadeInput *origshi, ShadeInput *sh VECCOPY(col, shr->combined); } else if (origshi->mat->fadeto_mir == MA_RAYMIR_FADETOSKY) { VECCOPY(shi->view, vec); - Normalize(shi->view); + normalize_v3(shi->view); shadeSkyView(col, isec->start, shi->view, NULL, shi->thread); shadeSunView(col, shi->view); @@ -686,7 +686,7 @@ static void ray_fadeout(Isect *is, ShadeInput *shi, float *col, float *blendcol, /* if fading out, linear blend against fade color */ float blendfac; - blendfac = 1.0 - VecLenf(shi->co, is->start)/dist_mir; + blendfac = 1.0 - len_v3v3(shi->co, is->start)/dist_mir; col[0] = col[0]*blendfac + (1.0 - blendfac)*blendcol[0]; col[1] = col[1]*blendfac + (1.0 - blendfac)*blendcol[1]; @@ -1297,15 +1297,15 @@ static void trace_refract(float *col, ShadeInput *shi, ShadeResult *shr) /* get a quasi-random vector from a phong-weighted disc */ QMC_samplePhong(samp3d, qsa, shi->thread, samples, blur); - VecOrthoBasisf(v_refract, orthx, orthy); - VecMulf(orthx, samp3d[0]); - VecMulf(orthy, samp3d[1]); + ortho_basis_v3v3_v3( orthx, orthy,v_refract); + mul_v3_fl(orthx, samp3d[0]); + mul_v3_fl(orthy, samp3d[1]); /* and perturb the refraction vector in it */ - VecAddf(v_refract_new, v_refract, orthx); - VecAddf(v_refract_new, v_refract_new, orthy); + add_v3_v3v3(v_refract_new, v_refract, orthx); + add_v3_v3v3(v_refract_new, v_refract_new, orthy); - Normalize(v_refract_new); + normalize_v3(v_refract_new); } else { /* no blurriness, use the original normal */ VECCOPY(v_refract_new, v_refract); @@ -1384,20 +1384,20 @@ static void trace_reflect(float *col, ShadeInput *shi, ShadeResult *shr, float f /* find the normal's perpendicular plane, blurring along tangents * if tangent shading enabled */ if (shi->mat->mode & (MA_TANGENT_V)) { - Crossf(orthx, shi->vn, shi->tang); // bitangent + cross_v3_v3v3(orthx, shi->vn, shi->tang); // bitangent VECCOPY(orthy, shi->tang); - VecMulf(orthx, samp3d[0]); - VecMulf(orthy, samp3d[1]*aniso); + mul_v3_fl(orthx, samp3d[0]); + mul_v3_fl(orthy, samp3d[1]*aniso); } else { - VecOrthoBasisf(shi->vn, orthx, orthy); - VecMulf(orthx, samp3d[0]); - VecMulf(orthy, samp3d[1]); + ortho_basis_v3v3_v3( orthx, orthy,shi->vn); + mul_v3_fl(orthx, samp3d[0]); + mul_v3_fl(orthy, samp3d[1]); } /* and perturb the normal in it */ - VecAddf(v_nor_new, shi->vn, orthx); - VecAddf(v_nor_new, v_nor_new, orthy); - Normalize(v_nor_new); + add_v3_v3v3(v_nor_new, shi->vn, orthx); + add_v3_v3v3(v_nor_new, v_nor_new, orthy); + normalize_v3(v_nor_new); } else { /* no blurriness, use the original normal */ VECCOPY(v_nor_new, shi->vn); @@ -1706,7 +1706,7 @@ static void DS_energy(float *sphere, int tot, float *vec) res[0]= res[1]= res[2]= 0.0f; for(a=0, fp=sphere; a<tot; a++, fp+=3) { - VecSubf(force, vec, fp); + sub_v3_v3v3(force, vec, fp); fac= force[0]*force[0] + force[1]*force[1] + force[2]*force[2]; if(fac!=0.0f) { fac= 1.0f/fac; @@ -1716,9 +1716,9 @@ static void DS_energy(float *sphere, int tot, float *vec) } } - VecMulf(res, 0.5); - VecAddf(vec, vec, res); - Normalize(vec); + mul_v3_fl(res, 0.5); + add_v3_v3v3(vec, vec, res); + normalize_v3(vec); } @@ -1881,7 +1881,7 @@ static void ray_ao_qmc(ShadeInput *shi, float *shadfac) VECCOPY(nrm, shi->facenor); } - VecOrthoBasisf(nrm, up, side); + ortho_basis_v3v3_v3( up, side,nrm); /* sampling init */ if (R.wrld.ao_samp_method==WO_AOSAMP_HALTON) { @@ -1908,7 +1908,7 @@ static void ray_ao_qmc(ShadeInput *shi, float *shadfac) dir[1] = (samp3d[0]*up[1] + samp3d[1]*side[1] + samp3d[2]*nrm[1]); dir[2] = (samp3d[0]*up[2] + samp3d[1]*side[2] + samp3d[2]*nrm[2]); - Normalize(dir); + normalize_v3(dir); isec.vec[0] = -dir[0]; isec.vec[1] = -dir[1]; @@ -1928,7 +1928,7 @@ static void ray_ao_qmc(ShadeInput *shi, float *shadfac) view[0]= -dir[0]; view[1]= -dir[1]; view[2]= -dir[2]; - Normalize(view); + normalize_v3(view); if(aocolor==WO_AOSKYCOL) { skyfac= 0.5*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]); @@ -2064,7 +2064,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float *shadfac) view[0]= -vec[0]; view[1]= -vec[1]; view[2]= -vec[2]; - Normalize(view); + normalize_v3(view); if(aocolor==WO_AOSKYCOL) { fac= 0.5*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]); @@ -2230,8 +2230,8 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, float *lampco, float * v[0] = co[0] - lampco[0]; v[1] = co[1] - lampco[1]; v[2] = co[2] - lampco[2]; - Normalize(v); - VecOrthoBasisf(v, ru, rv); + normalize_v3(v); + ortho_basis_v3v3_v3( ru, rv,v); /* sampling, returns quasi-random vector in area_size disc */ QMC_sampleDisc(samp3d, qsa, shi->thread, samples,lar->area_size); @@ -2248,7 +2248,7 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, float *lampco, float * QMC_sampleRect(samp3d, qsa, shi->thread, samples, lar->area_size, lar->area_sizey); /* align samples to lamp vector */ - Mat3MulVecfl(lar->mat, samp3d); + mul_m3_v3(lar->mat, samp3d); } end[0] = vec[0]+samp3d[0]; end[1] = vec[1]+samp3d[1]; @@ -2259,11 +2259,11 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, float *lampco, float * if(shi->strand) { /* bias away somewhat to avoid self intersection */ - float jitbias= 0.5f*(VecLength(shi->dxco) + VecLength(shi->dyco)); + float jitbias= 0.5f*(len_v3(shi->dxco) + len_v3(shi->dyco)); float v[3]; VECSUB(v, co, end); - Normalize(v); + normalize_v3(v); co[0] -= jitbias*v[0]; co[1] -= jitbias*v[1]; @@ -2274,7 +2274,7 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, float *lampco, float * isec->vec[0] = end[0]-isec->start[0]; isec->vec[1] = end[1]-isec->start[1]; isec->vec[2] = end[2]-isec->start[2]; - isec->labda = 1.0f; // * Normalize(isec->vec); + isec->labda = 1.0f; // * normalize_v3(isec->vec); /* trace the ray */ if(isec->mode==RE_RAY_SHADOW_TRA) { @@ -2370,7 +2370,7 @@ static void ray_shadow_jitter(ShadeInput *shi, LampRen *lar, float *lampco, floa vec[0]= jitlamp[0]; vec[1]= jitlamp[1]; vec[2]= 0.0f; - Mat3MulVecfl(lar->mat, vec); + mul_m3_v3(lar->mat, vec); /* set start and vec */ isec->vec[0] = vec[0]+lampco[0]-isec->start[0]; @@ -2537,7 +2537,7 @@ static void ray_translucent(ShadeInput *shi, LampRen *lar, float *distfac, float co[1]= isec.start[1]+isec.labda*(isec.vec[1]); co[2]= isec.start[2]+isec.labda*(isec.vec[2]); - *distfac= VecLength(isec.vec); + *distfac= len_v3(isec.vec); } else *distfac= 0.0f; diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 6c18592b8d2..cae6c640f8b 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -36,7 +36,7 @@ /* External modules: */ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_jitter.h" #include "BLI_rand.h" @@ -1498,13 +1498,13 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRe VECCOPY(nor, shi->facenor); calc_view_vector(shi->facenor, sx, sy); - Normalize(shi->facenor); + normalize_v3(shi->facenor); shade_input_set_viewco(shi, x, y, sx, sy, z); - orthoarea= VecLength(shi->dxco)*VecLength(shi->dyco); + orthoarea= len_v3(shi->dxco)*len_v3(shi->dyco); VECCOPY(shi->facenor, nor); shade_input_set_viewco(shi, x, y, sx, sy, z); - *area= VecLength(shi->dxco)*VecLength(shi->dyco); + *area= len_v3(shi->dxco)*len_v3(shi->dyco); *area= MIN2(*area, 2.0f*orthoarea); shade_input_set_uv(shi); @@ -1516,8 +1516,8 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRe /* not a pretty solution, but fixes common cases */ if(shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) { - VecNegf(shi->vn); - VecNegf(shi->vno); + negate_v3(shi->vn); + negate_v3(shi->vno); } /* if nodetree, use the material that we are currently preprocessing @@ -2148,24 +2148,24 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int quad, int /* bitangent */ if(tvn && ttang) { VECCOPY(mat[0], ttang); - Crossf(mat[1], tvn, ttang); + cross_v3_v3v3(mat[1], tvn, ttang); VECCOPY(mat[2], tvn); } else { VECCOPY(mat[0], shi->nmaptang); - Crossf(mat[1], shi->vn, shi->nmaptang); + cross_v3_v3v3(mat[1], shi->vn, shi->nmaptang); VECCOPY(mat[2], shi->vn); } - Mat3Inv(imat, mat); - Mat3MulVecfl(imat, nor); + invert_m3_m3(imat, mat); + mul_m3_v3(imat, nor); } else if(R.r.bake_normal_space == R_BAKE_SPACE_OBJECT) - Mat4Mul3Vecfl(ob->imat, nor); /* ob->imat includes viewinv! */ + mul_mat3_m4_v3(ob->imat, nor); /* ob->imat includes viewinv! */ else if(R.r.bake_normal_space == R_BAKE_SPACE_WORLD) - Mat4Mul3Vecfl(R.viewinv, nor); + mul_mat3_m4_v3(R.viewinv, nor); - Normalize(nor); /* in case object has scaling */ + normalize_v3(nor); /* in case object has scaling */ shr.combined[0]= nor[0]/2.0f + 0.5f; shr.combined[1]= 0.5f - nor[1]/2.0f; @@ -2278,7 +2278,7 @@ static int bake_intersect_tree(RayObject* raytree, Isect* isect, float *start, f hitco[1] = isect->start[1] + isect->labda*isect->vec[1]; hitco[2] = isect->start[2] + isect->labda*isect->vec[2]; - *dist= VecLenf(start, hitco); + *dist= len_v3v3(start, hitco); } return hit; @@ -2330,8 +2330,8 @@ static void bake_set_vlr_dxyco(BakeShade *bs, float *uv1, float *uv2, float *uv3 } if(bs->obi->flag & R_TRANSFORMED) { - Mat3MulVecfl(bs->obi->nmat, bs->dxco); - Mat3MulVecfl(bs->obi->nmat, bs->dyco); + mul_m3_v3(bs->obi->nmat, bs->dxco); + mul_m3_v3(bs->obi->nmat, bs->dyco); } } @@ -2370,7 +2370,7 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v) shi->co[2]= l*v3[2]+u*v1[2]+v*v2[2]; if(obi->flag & R_TRANSFORMED) - Mat4MulVecfl(obi->mat, shi->co); + mul_m4_v3(obi->mat, shi->co); VECCOPY(shi->dxco, bs->dxco); VECCOPY(shi->dyco, bs->dyco); @@ -2406,7 +2406,7 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v) isec.userdata= bs; if(bake_intersect_tree(R.raytree, &isec, shi->co, shi->vn, sign, co, &dist)) { - if(!hit || VecLenf(shi->co, co) < VecLenf(shi->co, minco)) { + if(!hit || len_v3v3(shi->co, co) < len_v3v3(shi->co, minco)) { minisec= isec; mindist= dist; VECCOPY(minco, co); diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index 54863ef3295..75e58648cd5 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -60,7 +60,7 @@ #include "MEM_guardedalloc.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_memarena.h" @@ -448,8 +448,8 @@ int RE_vlakren_get_normal(Render *re, ObjectInstanceRen *obi, VlakRen *vlr, floa if(obi->flag & R_TRANSFORMED) { VECCOPY(nor, vlr->n); - Mat3MulVecfl(nmat, nor); - Normalize(nor); + mul_m3_v3(nmat, nor); + normalize_v3(nor); } else VECCOPY(nor, vlr->n); @@ -462,7 +462,7 @@ int RE_vlakren_get_normal(Render *re, ObjectInstanceRen *obi, VlakRen *vlr, floa else { VECCOPY(v1, vlr->v1->co); if(obi->flag & R_TRANSFORMED) - Mat4MulVecfl(obi->mat, v1); + mul_m4_v3(obi->mat, v1); if(INPR(v1, nor) < 0.0f) { flipped= 1; } @@ -995,12 +995,12 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f har->sin= sin(zn); har->cos= cos(zn); - zn= VecLenf(vec1, vec); + zn= len_v3v3(vec1, vec); har->hasize= vectsize*zn + (1.0-vectsize)*hasize; - VecSubf(har->no, vec, vec1); - Normalize(har->no); + sub_v3_v3v3(har->no, vec, vec1); + normalize_v3(har->no); } if(ma->mode & MA_HALO_XALPHA) har->type |= HA_XALPHA; @@ -1035,7 +1035,7 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f /* texvec[0]+= imatbase->ivec[0]; */ /* texvec[1]+= imatbase->ivec[1]; */ /* texvec[2]+= imatbase->ivec[2]; */ - /* Mat3MulVecfl(imatbase->imat, texvec); */ + /* mul_m3_v3(imatbase->imat, texvec); */ } else { if(orco) { @@ -1108,12 +1108,12 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater har->sin= sin(zn); har->cos= cos(zn); - zn= VecLenf(vec1, vec)*0.5; + zn= len_v3v3(vec1, vec)*0.5; har->hasize= vectsize*zn + (1.0-vectsize)*hasize; - VecSubf(har->no, vec, vec1); - Normalize(har->no); + sub_v3_v3v3(har->no, vec, vec1); + normalize_v3(har->no); } if(ma->mode & MA_HALO_XALPHA) har->type |= HA_XALPHA; @@ -1149,13 +1149,13 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater if(mtex->object){ float imat[4][4]; /* imat should really be cached somewhere before this */ - Mat4Invert(imat,mtex->object->obmat); - Mat4MulVecfl(imat,texvec); + invert_m4_m4(imat,mtex->object->obmat); + mul_m4_v3(imat,texvec); } /* texvec[0]+= imatbase->ivec[0]; */ /* texvec[1]+= imatbase->ivec[1]; */ /* texvec[2]+= imatbase->ivec[2]; */ - /* Mat3MulVecfl(imatbase->imat, texvec); */ + /* mul_m3_v3(imatbase->imat, texvec); */ } else if(mtex->texco & TEXCO_GLOB){ VECCOPY(texvec,vec); @@ -1349,10 +1349,10 @@ ObjectInstanceRen *RE_addRenderInstance(Render *re, ObjectRen *obr, Object *ob, obi->lay= lay; if(mat) { - Mat4CpyMat4(obi->mat, mat); - Mat3CpyMat4(mat3, mat); - Mat3Inv(obi->nmat, mat3); - Mat3Transp(obi->nmat); + copy_m4_m4(obi->mat, mat); + copy_m3_m4(mat3, mat); + invert_m3_m3(obi->nmat, mat3); + transpose_m3(obi->nmat); obi->flag |= R_DUPLI_TRANSFORMED; } @@ -1395,14 +1395,14 @@ int clip_render_object(float boundbox[][3], float *bounds, float winmat[][4]) float mat[4][4], vec[4]; int a, fl, flag= -1; - Mat4CpyMat4(mat, winmat); + copy_m4_m4(mat, winmat); for(a=0; a<8; a++) { vec[0]= (a & 1)? boundbox[0][0]: boundbox[1][0]; vec[1]= (a & 2)? boundbox[0][1]: boundbox[1][1]; vec[2]= (a & 4)? boundbox[0][2]: boundbox[1][2]; vec[3]= 1.0; - Mat4MulVec4fl(mat, vec); + mul_m4_v4(mat, vec); fl= 0; if(bounds) { diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index 50e0321a6eb..f8428680135 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -37,7 +37,7 @@ #include "BKE_scene.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_jitter.h" #include "BLI_memarena.h" @@ -613,7 +613,7 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar) char *clipflag; minz= 1.0e30f; maxz= -1.0e30f; - Mat4CpyMat4(viewmat, lar->shb->viewmat); + copy_m4_m4(viewmat, lar->shb->viewmat); if(lar->mode & (LA_LAYER|LA_LAYER_SHADOW)) lay= lar->lay; @@ -628,9 +628,9 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar) obr= obi->obr; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(obviewmat, obi->mat, viewmat); + mul_m4_m4m4(obviewmat, obi->mat, viewmat); else - Mat4CpyMat4(obviewmat, viewmat); + copy_m4_m4(obviewmat, viewmat); memset(clipflag, 0, sizeof(char)*obr->totvert); @@ -661,7 +661,7 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar) if(clipflag[a]) { VECCOPY(vec, ver->co); - Mat4MulVecfl(obviewmat, vec); + mul_m4_v3(obviewmat, vec); /* Z on visible side of lamp space */ if(vec[2] < 0.0f) { float inpr, z= -vec[2]; @@ -669,7 +669,7 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar) /* since vec is rotated in lampspace, this is how to get the cosine of angle */ /* precision is set 20% larger */ vec[2]*= 1.2f; - Normalize(vec); + normalize_v3(vec); inpr= - vec[2]; if(inpr>=lar->spotsi) { @@ -764,8 +764,8 @@ void makeshadowbuf(Render *re, LampRen *lar) shb->pixsize= (shb->d)/temp; wsize= shb->pixsize*(shb->size/2.0); - i_window(-wsize, wsize, -wsize, wsize, shb->d, shb->clipend, shb->winmat); - Mat4MulMat4(shb->persmat, shb->viewmat, shb->winmat); + perspective_m4( shb->winmat,-wsize, wsize, -wsize, wsize, shb->d, shb->clipend); + mul_m4_m4m4(shb->persmat, shb->viewmat, shb->winmat); if(ELEM3(lar->buftype, LA_SHADBUF_REGULAR, LA_SHADBUF_HALFWAY, LA_SHADBUF_DEEP)) { shb->totbuf= lar->buffers; @@ -1107,7 +1107,7 @@ float testshadowbuf(Render *re, ShadBuf *shb, float *rco, float *dxco, float *dy VECCOPY(co, rco); co[3]= 1.0f; - Mat4MulVec4fl(shb->persmat, co); /* rational hom co */ + mul_m4_v4(shb->persmat, co); /* rational hom co */ xs1= siz*(1.0f+co[0]/co[3]); ys1= siz*(1.0f+co[1]/co[3]); @@ -1148,7 +1148,7 @@ float testshadowbuf(Render *re, ShadBuf *shb, float *rco, float *dxco, float *dy co[1]= rco[1]+dxco[1]; co[2]= rco[2]+dxco[2]; co[3]= 1.0; - Mat4MulVec4fl(shb->persmat,co); /* rational hom co */ + mul_m4_v4(shb->persmat,co); /* rational hom co */ dx[0]= xs1- siz*(1.0+co[0]/co[3]); dx[1]= ys1- siz*(1.0+co[1]/co[3]); @@ -1156,7 +1156,7 @@ float testshadowbuf(Render *re, ShadBuf *shb, float *rco, float *dxco, float *dy co[1]= rco[1]+dyco[1]; co[2]= rco[2]+dyco[2]; co[3]= 1.0; - Mat4MulVec4fl(shb->persmat,co); /* rational hom co */ + mul_m4_v4(shb->persmat,co); /* rational hom co */ dy[0]= xs1- siz*(1.0+co[0]/co[3]); dy[1]= ys1- siz*(1.0+co[1]/co[3]); @@ -1292,7 +1292,7 @@ float shadow_halo(LampRen *lar, float *p1, float *p2) co[1]= p1[1]; co[2]= p1[2]/lar->sh_zfac; co[3]= 1.0; - Mat4MulVec4fl(shb->winmat, co); /* rational hom co */ + mul_m4_v4(shb->winmat, co); /* rational hom co */ xf1= siz*(1.0+co[0]/co[3]); yf1= siz*(1.0+co[1]/co[3]); zf1= (co[2]/co[3]); @@ -1302,7 +1302,7 @@ float shadow_halo(LampRen *lar, float *p1, float *p2) co[1]= p2[1]; co[2]= p2[2]/lar->sh_zfac; co[3]= 1.0; - Mat4MulVec4fl(shb->winmat, co); /* rational hom co */ + mul_m4_v4(shb->winmat, co); /* rational hom co */ xf2= siz*(1.0+co[0]/co[3]); yf2= siz*(1.0+co[1]/co[3]); zf2= (co[2]/co[3]); @@ -1635,9 +1635,9 @@ static void bspface_init_strand(BSPFace *face) face->radline= 0.5f*VecLen2f(face->v1, face->v2); - VecMidf(face->vec1, face->v1, face->v2); + mid_v3_v3v3(face->vec1, face->v1, face->v2); if(face->v4) - VecMidf(face->vec2, face->v3, face->v4); + mid_v3_v3v3(face->vec2, face->v3, face->v4); else VECCOPY(face->vec2, face->v3); @@ -1659,7 +1659,7 @@ static int point_behind_strand(float *p, BSPFace *face) /* v1 - v2 is radius, v1 - v3 length */ float dist, rc[2], pt[2]; - /* using code from PdistVL2Dfl(), distance vec to line-piece */ + /* using code from dist_to_line_segment_v2(), distance vec to line-piece */ if(face->len==0.0f) { rc[0]= p[0]-face->vec1[0]; @@ -1977,9 +1977,9 @@ static void isb_bsp_fillfaces(Render *re, LampRen *lar, ISBBranch *root) obr= obi->obr; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(winmat, obi->mat, shb->persmat); + mul_m4_m4m4(winmat, obi->mat, shb->persmat); else - Mat4CpyMat4(winmat, shb->persmat); + copy_m4_m4(winmat, shb->persmat); for(a=0; a<obr->totvlak; a++) { @@ -2055,7 +2055,7 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v RE_vlakren_get_normal(&R, obi, vlr, nor); VECCOPY(v1, vlr->v1->co); if(obi->flag & R_TRANSFORMED) - Mat4MulVecfl(obi->mat, v1); + mul_m4_v3(obi->mat, v1); /* from shadepixel() */ dface= v1[0]*nor[0] + v1[1]*nor[1] + v1[2]*nor[2]; @@ -2093,7 +2093,7 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v } /* move 3d vector to lampbuf */ - Mat4MulVec4fl(shb->persmat, hoco); /* rational hom co */ + mul_m4_v4(shb->persmat, hoco); /* rational hom co */ /* clip We can test for -1.0/1.0 because of the properties of the * coordinate transformations. */ diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index 79ee6c89460..396c713cfb7 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -30,7 +30,7 @@ #include <string.h> -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "DNA_curve_types.h" @@ -212,7 +212,7 @@ void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr) if(R.r.mode & R_ORTHO) shr->mist= mistfactor(-shi->co[2], shi->co); else - shr->mist= mistfactor(VecLength(shi->co), shi->co); + shr->mist= mistfactor(len_v3(shi->co), shi->co); } else shr->mist= 0.0f; @@ -227,7 +227,7 @@ void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr) shr->combined[3]= fac; if (shi->mat->material_type!= MA_TYPE_VOLUME) - VecMulf(shr->combined, fac); + mul_v3_fl(shr->combined, fac); } else shr->combined[3]= 1.0f; @@ -314,9 +314,9 @@ void shade_input_set_triangle_i(ShadeInput *shi, ObjectInstanceRen *obi, VlakRen VECCOPY(shi->n3, shi->v3->n); if(obi->flag & R_TRANSFORMED) { - Mat3MulVecfl(obi->nmat, shi->n1); - Mat3MulVecfl(obi->nmat, shi->n2); - Mat3MulVecfl(obi->nmat, shi->n3); + mul_m3_v3(obi->nmat, shi->n1); + mul_m3_v3(obi->nmat, shi->n2); + mul_m3_v3(obi->nmat, shi->n3); } if(!(vlr->flag & (R_NOPUNOFLIP|R_TANGENT))) { @@ -384,7 +384,7 @@ void shade_input_set_strand(ShadeInput *shi, StrandRen *strand, StrandPoint *spo /* shade_input_set_viewco equivalent */ VECCOPY(shi->co, spoint->co); VECCOPY(shi->view, shi->co); - Normalize(shi->view); + normalize_v3(shi->view); shi->xs= (int)spoint->x; shi->ys= (int)spoint->y; @@ -407,12 +407,12 @@ void shade_input_set_strand(ShadeInput *shi, StrandRen *strand, StrandPoint *spo else { float cross[3]; - Crossf(cross, spoint->co, spoint->tan); - Crossf(shi->vn, cross, spoint->tan); - Normalize(shi->vn); + cross_v3_v3v3(cross, spoint->co, spoint->tan); + cross_v3_v3v3(shi->vn, cross, spoint->tan); + normalize_v3(shi->vn); if(INPR(shi->vn, shi->view) < 0.0f) - VecNegf(shi->vn); + negate_v3(shi->vn); } VECCOPY(shi->vno, shi->vn); @@ -450,8 +450,8 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert if(shi->mat->strand_surfnor > 0.0f) { shi->surfdist= 0.0f; for(sv=strand->vert; sv!=svert; sv++) - shi->surfdist+=VecLenf(sv->co, (sv+1)->co); - shi->surfdist += spoint->t*VecLenf(sv->co, (sv+1)->co); + shi->surfdist+=len_v3v3(sv->co, (sv+1)->co); + shi->surfdist += spoint->t*len_v3v3(sv->co, (sv+1)->co); } } @@ -474,13 +474,13 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert if(texco & TEXCO_GLOB) { VECCOPY(shi->gl, shi->co); - Mat4MulVecfl(R.viewinv, shi->gl); + mul_m4_v3(R.viewinv, shi->gl); if(shi->osatex) { VECCOPY(shi->dxgl, shi->dxco); - Mat3MulVecfl(R.imat, shi->dxco); + mul_m3_v3(R.imat, shi->dxco); VECCOPY(shi->dygl, shi->dyco); - Mat3MulVecfl(R.imat, shi->dyco); + mul_m3_v3(R.imat, shi->dyco); } } @@ -652,7 +652,7 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float * VECCOPY(v1, shi->v1->co); if(shi->obi->flag & R_TRANSFORMED) - Mat4MulVecfl(shi->obi->mat, v1); + mul_m4_v3(shi->obi->mat, v1); dface= v1[0]*shi->facenor[0]+v1[1]*shi->facenor[1]+v1[2]*shi->facenor[2]; @@ -731,7 +731,7 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float * shi->camera_co[0] = shi->camera_co[1] = shi->camera_co[2] = 0.0f; /* cannot normalize earlier, code above needs it at viewplane level */ - Normalize(view); + normalize_v3(view); } /* from scanline pixel coordinates to 3d coordinates, requires set_triangle */ @@ -773,17 +773,17 @@ void shade_input_set_uv(ShadeInput *shi) VECCOPY(v3, shi->v3->co); if(shi->obi->flag & R_TRANSFORMED) { - Mat4MulVecfl(shi->obi->mat, v1); - Mat4MulVecfl(shi->obi->mat, v2); - Mat4MulVecfl(shi->obi->mat, v3); + mul_m4_v3(shi->obi->mat, v1); + mul_m4_v3(shi->obi->mat, v2); + mul_m4_v3(shi->obi->mat, v3); } /* exception case for wire render of edge */ if(vlr->v2==vlr->v3) { float lend, lenc; - lend= VecLenf(v2, v1); - lenc= VecLenf(shi->co, v1); + lend= len_v3v3(v2, v1); + lenc= len_v3v3(shi->co, v1); if(lend==0.0f) { shi->u=shi->v= 0.0f; @@ -851,7 +851,7 @@ void shade_input_set_normals(ShadeInput *shi) shi->vn[1]= l*n3[1]-u*n1[1]-v*n2[1]; shi->vn[2]= l*n3[2]-u*n1[2]-v*n2[2]; - Normalize(shi->vn); + normalize_v3(shi->vn); } else VECCOPY(shi->vn, shi->facenor); @@ -939,9 +939,9 @@ void shade_input_set_shade_texco(ShadeInput *shi) shi->tang[2]= (tl*s3[2] - tu*s1[2] - tv*s2[2]); if(obi->flag & R_TRANSFORMED) - Mat3MulVecfl(obi->nmat, shi->tang); + mul_m3_v3(obi->nmat, shi->tang); - Normalize(shi->tang); + normalize_v3(shi->tang); VECCOPY(shi->nmaptang, shi->tang); } } @@ -963,9 +963,9 @@ void shade_input_set_shade_texco(ShadeInput *shi) shi->nmaptang[2]= (tl*s3[2] - tu*s1[2] - tv*s2[2]); if(obi->flag & R_TRANSFORMED) - Mat3MulVecfl(obi->nmat, shi->nmaptang); + mul_m3_v3(obi->nmat, shi->nmaptang); - Normalize(shi->nmaptang); + normalize_v3(shi->nmaptang); } } } @@ -976,7 +976,7 @@ void shade_input_set_shade_texco(ShadeInput *shi) if(surfnor) { VECCOPY(shi->surfnor, surfnor) if(obi->flag & R_TRANSFORMED) - Mat3MulVecfl(obi->nmat, shi->surfnor); + mul_m3_v3(obi->nmat, shi->surfnor); } else VECCOPY(shi->surfnor, shi->vn) @@ -1037,15 +1037,15 @@ void shade_input_set_shade_texco(ShadeInput *shi) if(texco & TEXCO_GLOB) { VECCOPY(shi->gl, shi->co); - Mat4MulVecfl(R.viewinv, shi->gl); + mul_m4_v3(R.viewinv, shi->gl); if(shi->osatex) { VECCOPY(shi->dxgl, shi->dxco); // TXF: bug was here, but probably should be in convertblender.c, R.imat only valid if there is a world - //Mat3MulVecfl(R.imat, shi->dxco); - Mat4Mul3Vecfl(R.viewinv, shi->dxco); + //mul_m3_v3(R.imat, shi->dxco); + mul_mat3_m4_v3(R.viewinv, shi->dxco); VECCOPY(shi->dygl, shi->dyco); - //Mat3MulVecfl(R.imat, shi->dyco); - Mat4Mul3Vecfl(R.viewinv, shi->dyco); + //mul_m3_v3(R.imat, shi->dyco); + mul_mat3_m4_v3(R.viewinv, shi->dyco); } } @@ -1242,9 +1242,9 @@ void shade_input_set_shade_texco(ShadeInput *shi) zbuf_make_winmat(&R, winmat); if(shi->obi->flag & R_TRANSFORMED) - Mat4MulMat4(obwinmat, obi->mat, winmat); + mul_m4_m4m4(obwinmat, obi->mat, winmat); else - Mat4CpyMat4(obwinmat, winmat); + copy_m4_m4(obwinmat, winmat); zbuf_render_project(obwinmat, v1->co, ho1); zbuf_render_project(obwinmat, v2->co, ho2); diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index aa0bbd575a7..f167122f497 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -31,7 +31,7 @@ #include <string.h> -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_colortools.h" #include "BKE_material.h" @@ -168,7 +168,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) p1[0]= shi->co[0]-lar->co[0]; p1[1]= shi->co[1]-lar->co[1]; p1[2]= -lar->co[2]; - Mat3MulVecfl(lar->imat, p1); + mul_m3_v3(lar->imat, p1); VECCOPY(npos, p1); // npos is double! /* pre-scale */ @@ -180,7 +180,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) /* rotate view */ VECCOPY(nray, shi->view); - Mat3MulVecd(lar->imat, nray); + mul_m3_v3_double(lar->imat, nray); if(R.wrld.mode & WO_MIST) { /* patchy... */ @@ -311,7 +311,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) a= sqrt(p1[0]*p1[0]+p1[1]*p1[1]+p1[2]*p1[2]); b= sqrt(p2[0]*p2[0]+p2[1]*p2[1]+p2[2]*p2[2]); - c= VecLenf(p1, p2); + c= len_v3v3(p1, p2); a/= ladist; a= sqrt(a); @@ -489,7 +489,7 @@ static float area_lamp_energy_multisample(LampRen *lar, float *co, float *vn) vec[0]= jitlamp[0]; vec[1]= jitlamp[1]; vec[2]= 0.0f; - Mat3MulVecfl(lar->mat, vec); + mul_m3_v3(lar->mat, vec); VECADD(area[0], lar->area[0], vec); VECADD(area[1], lar->area[1], vec); @@ -553,7 +553,7 @@ static float Phong_Spec( float *n, float *l, float *v, int hard, int tangent ) h[0] = l[0] + v[0]; h[1] = l[1] + v[1]; h[2] = l[2] + v[2]; - Normalize(h); + normalize_v3(h); rslt = h[0]*n[0] + h[1]*n[1] + h[2]*n[2]; if(tangent) rslt= sasqrt(1.0f - rslt*rslt); @@ -573,7 +573,7 @@ static float CookTorr_Spec(float *n, float *l, float *v, int hard, int tangent) h[0]= v[0]+l[0]; h[1]= v[1]+l[1]; h[2]= v[2]+l[2]; - Normalize(h); + normalize_v3(h); nh= n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; if(tangent) nh= sasqrt(1.0f - nh*nh); @@ -606,7 +606,7 @@ static float Blinn_Spec(float *n, float *l, float *v, float refrac, float spec_p h[0]= v[0]+l[0]; h[1]= v[1]+l[1]; h[2]= v[2]+l[2]; - Normalize(h); + normalize_v3(h); nh= n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; /* Dot product between surface normal and half-way vector */ if(tangent) nh= sasqrt(1.0f - nh*nh); @@ -653,7 +653,7 @@ static float Toon_Spec( float *n, float *l, float *v, float size, float smooth, h[0] = l[0] + v[0]; h[1] = l[1] + v[1]; h[2] = l[2] + v[2]; - Normalize(h); + normalize_v3(h); rslt = h[0]*n[0] + h[1]*n[1] + h[2]*n[2]; if(tangent) rslt = sasqrt(1.0f - rslt*rslt); @@ -677,7 +677,7 @@ static float WardIso_Spec( float *n, float *l, float *v, float rms, int tangent) h[0] = l[0] + v[0]; h[1] = l[1] + v[1]; h[2] = l[2] + v[2]; - Normalize(h); + normalize_v3(h); nh = n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; /* Dot product between surface normal and half-way vector */ if(tangent) nh = sasqrt(1.0f - nh*nh); @@ -728,7 +728,7 @@ static float OrenNayar_Diff(float nl, float *n, float *l, float *v, float rough h[0]= v[0]+l[0]; h[1]= v[1]+l[1]; h[2]= v[2]+l[2]; - Normalize(h); + normalize_v3(h); nh= n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; /* Dot product between surface normal and half-way vector */ if(nh<0.0f) nh = 0.0f; @@ -749,12 +749,12 @@ static float OrenNayar_Diff(float nl, float *n, float *l, float *v, float rough Lit_B[0] = l[0] - (realnl * n[0]); Lit_B[1] = l[1] - (realnl * n[1]); Lit_B[2] = l[2] - (realnl * n[2]); - Normalize( Lit_B ); + normalize_v3( Lit_B ); View_B[0] = v[0] - (nv * n[0]); View_B[1] = v[1] - (nv * n[1]); View_B[2] = v[2] - (nv * n[2]); - Normalize( View_B ); + normalize_v3( View_B ); t = Lit_B[0]*View_B[0] + Lit_B[1]*View_B[1] + Lit_B[2]*View_B[2]; if( t < 0 ) t = 0; @@ -1143,7 +1143,7 @@ float lamp_get_visibility(LampRen *lar, float *co, float *lv, float *dist) /* rotate view to lampspace */ VECCOPY(lvrot, lv); - Mat3MulVecfl(lar->imat, lvrot); + mul_m3_v3(lar->imat, lvrot); x= MAX2(fabs(lvrot[0]/lvrot[2]) , fabs(lvrot[1]/lvrot[2])); /* 1.0f/(sqrt(1+x*x)) is equivalent to cos(atan(x)) */ @@ -1235,27 +1235,27 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int float cross[3], nstrand[3], blend; if(ma->mode & MA_STR_SURFDIFF) { - Crossf(cross, shi->surfnor, vn); - Crossf(nstrand, vn, cross); + cross_v3_v3v3(cross, shi->surfnor, vn); + cross_v3_v3v3(nstrand, vn, cross); blend= INPR(nstrand, shi->surfnor); blend= 1.0f - blend; CLAMP(blend, 0.0f, 1.0f); - VecLerpf(vnor, nstrand, shi->surfnor, blend); - Normalize(vnor); + interp_v3_v3v3(vnor, nstrand, shi->surfnor, blend); + normalize_v3(vnor); } else { - Crossf(cross, lv, vn); - Crossf(vnor, cross, vn); - Normalize(vnor); + cross_v3_v3v3(cross, lv, vn); + cross_v3_v3v3(vnor, cross, vn); + normalize_v3(vnor); } if(ma->strand_surfnor > 0.0f) { if(ma->strand_surfnor > shi->surfdist) { blend= (ma->strand_surfnor - shi->surfdist)/ma->strand_surfnor; - VecLerpf(vnor, vnor, shi->surfnor, blend); - Normalize(vnor); + interp_v3_v3v3(vnor, vnor, shi->surfnor, blend); + normalize_v3(vnor); } } @@ -1264,9 +1264,9 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int } else if (ma->mode & MA_TANGENT_V) { float cross[3]; - Crossf(cross, lv, shi->tang); - Crossf(vnor, cross, shi->tang); - Normalize(vnor); + cross_v3_v3v3(cross, lv, shi->tang); + cross_v3_v3v3(vnor, cross, shi->tang); + normalize_v3(vnor); vnor[0]= -vnor[0];vnor[1]= -vnor[1];vnor[2]= -vnor[2]; vn= vnor; } @@ -1404,7 +1404,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int lv[1]+= view[1]; lv[2]+= view[2]; - Normalize(lv); + normalize_v3(lv); t= vn[0]*lv[0]+vn[1]*lv[1]+vn[2]*lv[2]; @@ -1662,15 +1662,15 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) if(texfac==0.0f) { VECCOPY(col, shr->col); - VecMulf(col, invalpha); + mul_v3_fl(col, invalpha); } else if(texfac==1.0f) { col[0]= col[1]= col[2]= 1.0f; - VecMulf(col, invalpha); + mul_v3_fl(col, invalpha); } else { VECCOPY(col, shr->col); - VecMulf(col, invalpha); + mul_v3_fl(col, invalpha); col[0]= pow(col[0], 1.0f-texfac); col[1]= pow(col[1], 1.0f-texfac); col[2]= pow(col[2], 1.0f-texfac); diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c index a416c2d2764..25cfc0f1253 100644 --- a/source/blender/render/intern/source/sss.c +++ b/source/blender/render/intern/source/sss.c @@ -47,7 +47,7 @@ /* external modules: */ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_memarena.h" @@ -443,8 +443,8 @@ static void compute_radiance(ScatterTree *tree, float *co, float *rad) of the mesh not visible from the camera. this can not only make it darker, but also lead to ugly color shifts */ - VecMulf(result.rad, tree->ss[0]->frontweight); - VecMulf(result.backrad, tree->ss[0]->backweight); + mul_v3_fl(result.rad, tree->ss[0]->frontweight); + mul_v3_fl(result.backrad, tree->ss[0]->backweight); VECCOPY(rad, result.rad); VECADD(backrad, result.rad, result.backrad); @@ -760,7 +760,7 @@ ScatterTree *scatter_tree_new(ScatterSettings *ss[3], float scale, float error, points[i].area= fabs(area[i])/(tree->scale*tree->scale); points[i].back= (area[i] < 0.0f); - VecMulf(points[i].co, 1.0f/tree->scale); + mul_v3_fl(points[i].co, 1.0f/tree->scale); DO_MINMAX(points[i].co, tree->min, tree->max); refpoints[i]= points + i; @@ -813,7 +813,7 @@ void scatter_tree_sample(ScatterTree *tree, float *co, float *color) float sco[3]; VECCOPY(sco, co); - VecMulf(sco, 1.0f/tree->scale); + mul_v3_fl(sco, 1.0f/tree->scale); compute_radiance(tree, sco, color); } diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index 61080c7d807..47a7c052b18 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -37,7 +37,7 @@ #include "DNA_material_types.h" #include "DNA_meshdata_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_memarena.h" @@ -99,10 +99,10 @@ void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint) VECCOPY(p[3], sseg->v[3]->co); if(sseg->obi->flag & R_TRANSFORMED) { - Mat4MulVecfl(sseg->obi->mat, p[0]); - Mat4MulVecfl(sseg->obi->mat, p[1]); - Mat4MulVecfl(sseg->obi->mat, p[2]); - Mat4MulVecfl(sseg->obi->mat, p[3]); + mul_m4_v3(sseg->obi->mat, p[0]); + mul_m4_v3(sseg->obi->mat, p[1]); + mul_m4_v3(sseg->obi->mat, p[2]); + mul_m4_v3(sseg->obi->mat, p[3]); } if(t == 0.0f) { @@ -135,11 +135,11 @@ void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint) spoint->dtco[2]= data[0]*p[0][2] + data[1]*p[1][2] + data[2]*p[2][2] + data[3]*p[3][2]; VECCOPY(spoint->tan, spoint->dtco); - Normalize(spoint->tan); + normalize_v3(spoint->tan); VECCOPY(spoint->nor, spoint->co); VECMUL(spoint->nor, -1.0f); - Normalize(spoint->nor); + normalize_v3(spoint->nor); spoint->width= strand_eval_width(ma, spoint->strandco); @@ -148,7 +148,7 @@ void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint) spoint->alpha= (simplify)? simplify[1]: 1.0f; /* outer points */ - Crossf(cross, spoint->co, spoint->tan); + cross_v3_v3v3(cross, spoint->co, spoint->tan); w= spoint->co[2]*strandbuf->winmat[2][3] + strandbuf->winmat[3][3]; dx= strandbuf->winx*cross[0]*strandbuf->winmat[0][0]/w; @@ -157,7 +157,7 @@ void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint) if(w > 0.0f) { if(strandbuf->flag & R_STRAND_B_UNITS) { - crosslen= VecLength(cross); + crosslen= len_v3(cross); w= 2.0f*crosslen*strandbuf->minwidth/w; if(spoint->width < w) { @@ -169,14 +169,14 @@ void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint) /* squared because we only change width, not length */ spoint->width *= simplify[0]*simplify[0]; - VecMulf(cross, spoint->width*0.5f/crosslen); + mul_v3_fl(cross, spoint->width*0.5f/crosslen); } else - VecMulf(cross, spoint->width/w); + mul_v3_fl(cross, spoint->width/w); } - VecSubf(spoint->co1, spoint->co, cross); - VecAddf(spoint->co2, spoint->co, cross); + sub_v3_v3v3(spoint->co1, spoint->co, cross); + add_v3_v3v3(spoint->co2, spoint->co, cross); VECCOPY(spoint->dsco, cross); } @@ -220,7 +220,7 @@ void interpolate_shade_result(ShadeResult *shr1, ShadeResult *shr2, float t, Sha interpolate_vec4(shr1->col, shr2->col, t, negt, shr->col); if(addpassflag & SCE_PASS_NORMAL) { interpolate_vec3(shr1->nor, shr2->nor, t, negt, shr->nor); - Normalize(shr->nor); + normalize_v3(shr->nor); } if(addpassflag & SCE_PASS_DIFFUSE) interpolate_vec3(shr1->diff, shr2->diff, t, negt, shr->diff); @@ -825,9 +825,9 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa /* compute matrix and try clipping whole object */ if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(obwinmat, obi->mat, winmat); + mul_m4_m4m4(obwinmat, obi->mat, winmat); else - Mat4CpyMat4(obwinmat, winmat); + copy_m4_m4(obwinmat, winmat); if(clip_render_object(obi->obr->boundbox, bounds, winmat)) continue; @@ -903,9 +903,9 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa obr= obi->obr; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(obwinmat, obi->mat, winmat); + mul_m4_m4m4(obwinmat, obi->mat, winmat); else - Mat4CpyMat4(obwinmat, winmat); + copy_m4_m4(obwinmat, winmat); sseg.obi= obi; sseg.strand= RE_findOrAddStrand(obr, sortseg->strand); @@ -975,7 +975,7 @@ StrandSurface *cache_strand_surface(Render *re, ObjectRen *obr, DerivedMesh *dm, mvert= dm->getVertArray(dm); for(a=0; a<mesh->totvert; a++, mvert++) { VECCOPY(co[a], mvert->co); - Mat4MulVecfl(mat, co[a]); + mul_m4_v3(mat, co[a]); } mface= dm->getFaceArray(dm); diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c index 2b490e71142..54032833196 100644 --- a/source/blender/render/intern/source/sunsky.c +++ b/source/blender/render/intern/source/sunsky.c @@ -21,7 +21,7 @@ #include "sunsky.h" #include "math.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_global.h" /** @@ -289,12 +289,12 @@ void GetSkyXYZRadiancef(struct SunSky* sunsky, const float varg[3], float color_ float theta, phi; float v[3]; - VecCopyf(v, (float*)varg); - Normalize(v); + copy_v3_v3(v, (float*)varg); + normalize_v3(v); if (v[2] < 0.001){ v[2] = 0.001; - Normalize(v); + normalize_v3(v); } DirectionToThetaPhi(v, &theta, &phi); @@ -448,7 +448,7 @@ void AtmospherePixleShader( struct SunSky* sunSky, float view[3], float s, float sunDirection[1] = sunSky->toSun[1]; sunDirection[2] = sunSky->toSun[2]; - costheta = Inpf(view, sunDirection); // cos(theta) + costheta = dot_v3v3(view, sunDirection); // cos(theta) Phase_1 = 1 + (costheta * costheta); // Phase_1 vec3opf(sunSky->atm_BetaRay, sunSky->atm_BetaRay, *, sunSky->atm_BetaRayMultiplier); @@ -461,7 +461,7 @@ void AtmospherePixleShader( struct SunSky* sunSky, float view[3], float s, float E1[1] = exp(E1[1]); E1[2] = exp(E1[2]); - VecCopyf(E, E1); + copy_v3_v3(E, E1); //Phase2(theta) = (1-g^2)/(1+g-2g*cos(theta))^(3/2) fTemp = 1 + sunSky->atm_HGg - 2 * sunSky->atm_HGg * costheta; diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index a74bd3e8041..d2e36a7a286 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -33,7 +33,7 @@ #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "DNA_texture_types.h" @@ -832,7 +832,7 @@ static int cubemap_glob(float *n, float x, float y, float z, float *adr1, float else { VECCOPY(nor, n); } - Mat4Mul3Vecfl(R.viewinv, nor); + mul_mat3_m4_v3(R.viewinv, nor); x1= fabs(nor[0]); y1= fabs(nor[1]); @@ -871,7 +871,7 @@ static int cubemap(MTex *mtex, VlakRen *vlr, float *n, float x, float y, float z /* test for v1, vlr can be faked for baking */ if(vlr->v1 && vlr->v1->orco) { float nor[3]; - CalcNormFloat(vlr->v1->orco, vlr->v2->orco, vlr->v3->orco, nor); + normal_tri_v3( nor,vlr->v1->orco, vlr->v2->orco, vlr->v3->orco); if( fabs(nor[0])<fabs(nor[2]) && fabs(nor[1])<fabs(nor[2]) ) vlr->puno |= ME_PROJXY; else if( fabs(nor[0])<fabs(nor[1]) && fabs(nor[2])<fabs(nor[1]) ) vlr->puno |= ME_PROJXZ; @@ -925,7 +925,7 @@ static int cubemap_ob(Object *ob, float *n, float x, float y, float z, float *ad if(n==NULL) return 0; VECCOPY(nor, n); - if(ob) Mat4Mul3Vecfl(ob->imat, nor); + if(ob) mul_mat3_m4_v3(ob->imat, nor); x1= fabs(nor[0]); y1= fabs(nor[1]); @@ -970,8 +970,8 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d fx = (t[0] + 1.0) / 2.0; fy = (t[1] + 1.0) / 2.0; } - else if(wrap==MTEX_TUBE) tubemap(t[0], t[1], t[2], &fx, &fy); - else if(wrap==MTEX_SPHERE) spheremap(t[0], t[1], t[2], &fx, &fy); + else if(wrap==MTEX_TUBE) map_to_tube( &fx, &fy,t[0], t[1], t[2]); + else if(wrap==MTEX_SPHERE) map_to_sphere( &fx, &fy,t[0], t[1], t[2]); else { if(texco==TEXCO_OBJECT) cubemap_ob(ob, n, t[0], t[1], t[2], &fx, &fy); else if(texco==TEXCO_GLOB) cubemap_glob(n, t[0], t[1], t[2], &fx, &fy); @@ -1042,20 +1042,20 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d } if(ok) { if(wrap==MTEX_TUBE) { - tubemap(t[0], t[1], t[2], area, area+1); - tubemap(t[0]+dxt[0], t[1]+dxt[1], t[2]+dxt[2], area+2, area+3); - tubemap(t[0]+dyt[0], t[1]+dyt[1], t[2]+dyt[2], area+4, area+5); + map_to_tube( area, area+1,t[0], t[1], t[2]); + map_to_tube( area+2, area+3,t[0]+dxt[0], t[1]+dxt[1], t[2]+dxt[2]); + map_to_tube( area+4, area+5,t[0]+dyt[0], t[1]+dyt[1], t[2]+dyt[2]); } else { - spheremap(t[0], t[1], t[2],area,area+1); - spheremap(t[0]+dxt[0], t[1]+dxt[1], t[2]+dxt[2], area+2, area+3); - spheremap(t[0]+dyt[0], t[1]+dyt[1], t[2]+dyt[2], area+4, area+5); + map_to_sphere(area,area+1,t[0], t[1], t[2]); + map_to_sphere( area+2, area+3,t[0]+dxt[0], t[1]+dxt[1], t[2]+dxt[2]); + map_to_sphere( area+4, area+5,t[0]+dyt[0], t[1]+dyt[1], t[2]+dyt[2]); } areaflag= 1; } else { - if(wrap==MTEX_TUBE) tubemap(t[0], t[1], t[2], &fx, &fy); - else spheremap(t[0], t[1], t[2], &fx, &fy); + if(wrap==MTEX_TUBE) map_to_tube( &fx, &fy,t[0], t[1], t[2]); + else map_to_sphere( &fx, &fy,t[0], t[1], t[2]); dxt[0]/= 2.0; dxt[1]/= 2.0; dyt[0]/= 2.0; @@ -1230,7 +1230,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, * artificer: added the use of tmpvec to avoid scaling texvec */ VECCOPY(tmpvec, texvec); - VecMulf(tmpvec, 1.0/tex->noisesize); + mul_v3_fl(tmpvec, 1.0/tex->noisesize); switch(tex->stype) { case TEX_MFRACTAL: @@ -1252,7 +1252,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, * artificer: added the use of tmpvec to avoid scaling texvec */ VECCOPY(tmpvec, texvec); - VecMulf(tmpvec, 1.0/tex->noisesize); + mul_v3_fl(tmpvec, 1.0/tex->noisesize); retval= voronoiTex(tex, tmpvec, texres); break; @@ -1261,7 +1261,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, * artificer: added the use of tmpvec to avoid scaling texvec */ VECCOPY(tmpvec, texvec); - VecMulf(tmpvec, 1.0/tex->noisesize); + mul_v3_fl(tmpvec, 1.0/tex->noisesize); retval= mg_distNoiseTex(tex, tmpvec, texres); break; @@ -1675,13 +1675,13 @@ void do_material_tex(ShadeInput *shi) VECCOPY(tempvec, shi->co); if(mtex->texflag & MTEX_OB_DUPLI_ORIG) if(shi->obi && shi->obi->duplitexmat) - Mat4MulVecfl(shi->obi->duplitexmat, tempvec); - Mat4MulVecfl(ob->imat, tempvec); + mul_m4_v3(shi->obi->duplitexmat, tempvec); + mul_m4_v3(ob->imat, tempvec); if(shi->osatex) { VECCOPY(dxt, shi->dxco); VECCOPY(dyt, shi->dyco); - Mat4Mul3Vecfl(ob->imat, dxt); - Mat4Mul3Vecfl(ob->imat, dyt); + mul_mat3_m4_v3(ob->imat, dxt); + mul_mat3_m4_v3(ob->imat, dyt); } } else { @@ -1742,7 +1742,7 @@ void do_material_tex(ShadeInput *shi) nn[0] = -shi->vn[0]; nn[1] = -shi->vn[1]; nn[2] = -shi->vn[2]; - VecOrthoBasisf(nn, nu, nv); + ortho_basis_v3v3_v3( nu, nv,nn); nunvdone= 1; } @@ -1819,7 +1819,7 @@ void do_material_tex(ShadeInput *shi) nn[0] = -shi->vn[0]; nn[1] = -shi->vn[1]; nn[2] = -shi->vn[2]; - VecOrthoBasisf(nn, nu, nv); + ortho_basis_v3v3_v3( nu, nv,nn); nunvdone= 1; } @@ -1897,20 +1897,20 @@ void do_material_tex(ShadeInput *shi) idv = (dv < 1e-6f) ? bf : (bf/dv); if ((mtex->texco == TEXCO_ORCO) && shi->obr && shi->obr->ob) { - Mat4Mul3Vecfl(shi->obr->ob->imat, tu); - Mat4Mul3Vecfl(shi->obr->ob->imat, tv); - Normalize(tu); - Normalize(tv); + mul_mat3_m4_v3(shi->obr->ob->imat, tu); + mul_mat3_m4_v3(shi->obr->ob->imat, tv); + normalize_v3(tu); + normalize_v3(tv); } else if (mtex->texco == TEXCO_GLOB) { - Mat4Mul3Vecfl(R.viewinv, tu); - Mat4Mul3Vecfl(R.viewinv, tv); + mul_mat3_m4_v3(R.viewinv, tu); + mul_mat3_m4_v3(R.viewinv, tv); } else if (mtex->texco == TEXCO_OBJECT && mtex->object) { - Mat4Mul3Vecfl(mtex->object->imat, tu); - Mat4Mul3Vecfl(mtex->object->imat, tv); - Normalize(tu); - Normalize(tv); + mul_mat3_m4_v3(mtex->object->imat, tu); + mul_mat3_m4_v3(mtex->object->imat, tv); + normalize_v3(tu); + normalize_v3(tv); } // +u val @@ -1937,7 +1937,7 @@ void do_material_tex(ShadeInput *shi) nv[0] += vd*nn[0]; nv[1] += vd*nn[1]; nv[2] += vd*nn[2]; - Crossf(nvec, nu, nv); + cross_v3_v3v3(nvec, nu, nv); nvec[0] = -nvec[0]; nvec[1] = -nvec[1]; @@ -2020,12 +2020,12 @@ void do_material_tex(ShadeInput *shi) // rotate to global coords if(mtex->texco==TEXCO_ORCO || mtex->texco==TEXCO_UV) { if(shi->vlr && shi->obr && shi->obr->ob) { - float len= Normalize(texres.nor); + float len= normalize_v3(texres.nor); // can be optimized... (ton) - Mat4Mul3Vecfl(shi->obr->ob->obmat, texres.nor); - Mat4Mul3Vecfl(R.viewmat, texres.nor); - Normalize(texres.nor); - VecMulf(texres.nor, len); + mul_mat3_m4_v3(shi->obr->ob->obmat, texres.nor); + mul_mat3_m4_v3(R.viewmat, texres.nor); + normalize_v3(texres.nor); + mul_v3_fl(texres.nor, len); } } } @@ -2100,7 +2100,7 @@ void do_material_tex(ShadeInput *shi) if(mtex->normapspace == MTEX_NSPACE_TANGENT) { /* qdn: tangent space */ float B[3], tv[3]; - Crossf(B, shi->vn, shi->nmaptang); /* bitangent */ + cross_v3_v3v3(B, shi->vn, shi->nmaptang); /* bitangent */ /* transform norvec from tangent space to object surface in camera space */ tv[0] = texres.nor[0]*shi->nmaptang[0] + texres.nor[1]*B[0] + texres.nor[2]*shi->vn[0]; tv[1] = texres.nor[0]*shi->nmaptang[1] + texres.nor[1]*B[1] + texres.nor[2]*shi->vn[1]; @@ -2116,15 +2116,15 @@ void do_material_tex(ShadeInput *shi) if(mtex->normapspace == MTEX_NSPACE_CAMERA); else if(mtex->normapspace == MTEX_NSPACE_WORLD) { - Mat4Mul3Vecfl(R.viewmat, nor); + mul_mat3_m4_v3(R.viewmat, nor); } else if(mtex->normapspace == MTEX_NSPACE_OBJECT) { if(shi->obr && shi->obr->ob) - Mat4Mul3Vecfl(shi->obr->ob->obmat, nor); - Mat4Mul3Vecfl(R.viewmat, nor); + mul_mat3_m4_v3(shi->obr->ob->obmat, nor); + mul_mat3_m4_v3(R.viewmat, nor); } - Normalize(nor); + normalize_v3(nor); /* qdn: worldspace */ shi->vn[0]= facm*shi->vn[0] + fact*nor[0]; @@ -2159,7 +2159,7 @@ void do_material_tex(ShadeInput *shi) shi->vn[2]+= dot*nor[2]; } } - Normalize(shi->vn); + normalize_v3(shi->vn); /* this makes sure the bump is passed on to the next texture */ shi->orn[0]= -shi->vn[0]; @@ -2316,9 +2316,9 @@ void do_volume_tex(ShadeInput *shi, float *xyz, int mapto_flag, float *col, floa VECCOPY(co, xyz); if(mtex->texflag & MTEX_OB_DUPLI_ORIG) { if(shi->obi && shi->obi->duplitexmat) - Mat4MulVecfl(shi->obi->duplitexmat, co); + mul_m4_v3(shi->obi->duplitexmat, co); } - Mat4MulVecfl(ob->imat, co); + mul_m4_v3(ob->imat, co); } } /* not really orco, but 'local' */ @@ -2330,12 +2330,12 @@ void do_volume_tex(ShadeInput *shi, float *xyz, int mapto_flag, float *col, floa else { Object *ob= shi->obi->ob; VECCOPY(co, xyz); - Mat4MulVecfl(ob->imat, co); + mul_m4_v3(ob->imat, co); } } else if(mtex->texco==TEXCO_GLOB) { VECCOPY(co, xyz); - Mat4MulVecfl(R.viewinv, co); + mul_m4_v3(R.viewinv, co); } else continue; // can happen when texco defines disappear and it renders old files @@ -2648,8 +2648,8 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f case TEXCO_H_SPHEREMAP: case TEXCO_H_TUBEMAP: if(skyflag & WO_ZENUP) { - if(mtex->texco==TEXCO_H_TUBEMAP) tubemap(lo[0], lo[2], lo[1], tempvec, tempvec+1); - else spheremap(lo[0], lo[2], lo[1], tempvec, tempvec+1); + if(mtex->texco==TEXCO_H_TUBEMAP) map_to_tube( tempvec, tempvec+1,lo[0], lo[2], lo[1]); + else map_to_sphere( tempvec, tempvec+1,lo[0], lo[2], lo[1]); /* tube/spheremap maps for outside view, not inside */ tempvec[0]= 1.0-tempvec[0]; /* only top half */ @@ -2668,7 +2668,7 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f case TEXCO_OBJECT: if(mtex->object) { VECCOPY(tempvec, lo); - Mat4MulVecfl(mtex->object->imat, tempvec); + mul_m4_v3(mtex->object->imat, tempvec); co= tempvec; } break; @@ -2676,16 +2676,16 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f case TEXCO_GLOB: if(rco) { VECCOPY(tempvec, rco); - Mat4MulVecfl(R.viewinv, tempvec); + mul_m4_v3(R.viewinv, tempvec); co= tempvec; } else co= lo; // VECCOPY(shi->dxgl, shi->dxco); -// Mat3MulVecfl(R.imat, shi->dxco); +// mul_m3_v3(R.imat, shi->dxco); // VECCOPY(shi->dygl, shi->dyco); -// Mat3MulVecfl(R.imat, shi->dyco); +// mul_m3_v3(R.imat, shi->dyco); break; } @@ -2812,12 +2812,12 @@ void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf, int ef dx= dxt; dy= dyt; VECCOPY(tempvec, shi->co); - Mat4MulVecfl(ob->imat, tempvec); + mul_m4_v3(ob->imat, tempvec); if(shi->osatex) { VECCOPY(dxt, shi->dxco); VECCOPY(dyt, shi->dyco); - Mat4Mul3Vecfl(ob->imat, dxt); - Mat4Mul3Vecfl(ob->imat, dyt); + mul_mat3_m4_v3(ob->imat, dxt); + mul_mat3_m4_v3(ob->imat, dyt); } } else { @@ -2828,12 +2828,12 @@ void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf, int ef else if(mtex->texco==TEXCO_GLOB) { co= shi->gl; dx= shi->dxco; dy= shi->dyco; VECCOPY(shi->gl, shi->co); - Mat4MulVecfl(R.viewinv, shi->gl); + mul_m4_v3(R.viewinv, shi->gl); } else if(mtex->texco==TEXCO_VIEW) { VECCOPY(tempvec, lavec); - Mat3MulVecfl(la->imat, tempvec); + mul_m3_v3(la->imat, tempvec); if(la->type==LA_SPOT) { tempvec[0]*= la->spottexfac; @@ -2846,11 +2846,11 @@ void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf, int ef VECCOPY(dxt, shi->dxlv); VECCOPY(dyt, shi->dylv); /* need some matrix conversion here? la->imat is a [3][3] matrix!!! **/ - Mat3MulVecfl(la->imat, dxt); - Mat3MulVecfl(la->imat, dyt); + mul_m3_v3(la->imat, dxt); + mul_m3_v3(la->imat, dyt); - VecMulf(dxt, la->spottexfac); - VecMulf(dyt, la->spottexfac); + mul_v3_fl(dxt, la->spottexfac); + mul_v3_fl(dyt, la->spottexfac); } } diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index cfaf333d656..4ec30721274 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -34,7 +34,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_threads.h" #include "BLI_voxel.h" @@ -444,8 +444,8 @@ static void *vol_precache_part(void *data) continue; } - VecCopyf(shi->view, co); - Normalize(shi->view); + copy_v3_v3(shi->view, co); + normalize_v3(shi->view); vol_get_scattering(shi, scatter_col, co); obi->volume_precache->data_r[ V_I(x, y, z, res) ] = scatter_col[0]; @@ -495,7 +495,7 @@ static void precache_init_parts(Render *re, RayObject *tree, ShadeInput *shi, Ob parts[0] = parts[1] = parts[2] = totthread; res = vp->res; - VecSubf(voxel, bbmax, bbmin); + sub_v3_v3v3(voxel, bbmax, bbmin); voxel[0] /= res[0]; voxel[1] /= res[1]; @@ -564,7 +564,7 @@ static int precache_resolution(VolumePrecache *vp, float *bbmin, float *bbmax, i { float dim[3], div; - VecSubf(dim, bbmax, bbmin); + sub_v3_v3v3(dim, bbmax, bbmin); div = MAX3(dim[0], dim[1], dim[2]); dim[0] /= div; diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index cf4b6b4002f..32ab2980316 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -34,7 +34,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BLI_voxel.h" @@ -85,7 +85,7 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, float *co) /* trace shadow manually, no good lamp api atm */ Isect is; - VecCopyf(is.start, co); + copy_v3_v3(is.start, co); if(lar->type==LA_SUN || lar->type==LA_HEMI) { is.vec[0] = -lar->vec[0]; is.vec[1] = -lar->vec[1]; @@ -93,7 +93,7 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, float *co) is.labda = R.maxdist; } else { VECSUB( is.vec, lar->co, is.start ); - is.labda = VecLength( is.vec ); + is.labda = len_v3( is.vec ); } is.mode = RE_RAY_MIRROR; @@ -122,9 +122,9 @@ static int vol_get_bounds(ShadeInput *shi, float *co, float *vec, float *hitco, /* XXX TODO - get raytrace max distance from object instance's bounding box */ /* need to account for scaling only, but keep coords in camera space... * below code is WIP and doesn't work! - VecSubf(bb_dim, shi->obi->obr->boundbox[1], shi->obi->obr->boundbox[2]); - Mat3MulVecfl(shi->obi->nmat, bb_dim); - maxsize = VecLength(bb_dim); + sub_v3_v3v3(bb_dim, shi->obi->obr->boundbox[1], shi->obi->obr->boundbox[2]); + mul_m3_v3(shi->obi->nmat, bb_dim); + maxsize = len_v3(bb_dim); */ VECCOPY(isect->start, co); @@ -184,7 +184,7 @@ static void shade_intersection(ShadeInput *shi, float *col, Isect *is) shade_ray(is, &shi_new, &shr_new); } - VecCopyf(col, shr_new.combined); + copy_v3_v3(col, shr_new.combined); col[3] = shr_new.alpha; } @@ -225,7 +225,7 @@ static void vol_get_precached_scattering(ShadeInput *shi, float *scatter_col, fl /* convert input coords to 0.0, 1.0 */ VECCOPY(bbmin, shi->obi->obr->boundbox[0]); VECCOPY(bbmax, shi->obi->obr->boundbox[1]); - VecSubf(dim, bbmax, bbmin); + sub_v3_v3v3(dim, bbmax, bbmin); sample_co[0] = ((co[0] - bbmin[0]) / dim[0]); sample_co[1] = ((co[1] - bbmin[1]) / dim[1]); @@ -246,18 +246,18 @@ static float metadensity(Object* ob, float* co) /* transform co to meta-element */ float tco[3] = {co[0], co[1], co[2]}; - Mat4MulMat4(mat, ob->obmat, R.viewmat); - Mat4Invert(imat, mat); - Mat4MulVecfl(imat, tco); + mul_m4_m4m4(mat, ob->obmat, R.viewmat); + invert_m4_m4(imat, mat); + mul_m4_v3(imat, tco); for (ml = mb->elems.first; ml; ml=ml->next) { float bmat[3][3], dist2; /* element rotation transform */ float tp[3] = {ml->x - tco[0], ml->y - tco[1], ml->z - tco[2]}; - QuatToMat3(ml->quat, bmat); - Mat3Transp(bmat); // rot.only, so inverse == transpose - Mat3MulVecfl(bmat, tp); + quat_to_mat3( bmat,ml->quat); + transpose_m3(bmat); // rot.only, so inverse == transpose + mul_m3_v3(bmat, tp); /* MB_BALL default */ switch (ml->type) { @@ -379,7 +379,7 @@ float vol_get_phasefunc(ShadeInput *shi, float g, float *w, float *wp) return normalize * 1.f; } else { /* schlick */ const float k = 1.55f * g - .55f * g * g * g; - const float kcostheta = k * Inpf(w, wp); + const float kcostheta = k * dot_v3v3(w, wp); return normalize * (1.f - k*k) / ((1.f - kcostheta) * (1.f - kcostheta)); } @@ -435,14 +435,14 @@ static void vol_get_transmittance(ShadeInput *shi, float *tr, float *co, float * float tau[3] = {0.f, 0.f, 0.f}; float t0 = 0.f; - float t1 = Normalize(step_vec); + float t1 = normalize_v3(step_vec); float pt0 = t0; t0 += shi->mat->vol.stepsize * ((shi->mat->vol.stepsize_type == MA_VOL_STEP_CONSTANT) ? 0.5f : BLI_thread_frand(shi->thread)); p[0] += t0 * step_vec[0]; p[1] += t0 * step_vec[1]; p[2] += t0 * step_vec[2]; - VecMulf(step_vec, shi->mat->vol.stepsize); + mul_v3_fl(step_vec, shi->mat->vol.stepsize); for (; t0 < t1; pt0 = t0, t0 += shi->mat->vol.stepsize) { const float d = vol_get_density(shi, p); @@ -455,7 +455,7 @@ static void vol_get_transmittance(ShadeInput *shi, float *tr, float *co, float * tau[1] += stepd * sigma_t[1]; tau[2] += stepd * sigma_t[2]; - VecAddf(p, p, step_vec); + add_v3_v3v3(p, p, step_vec); } /* return transmittance */ @@ -477,34 +477,34 @@ void vol_shade_one_lamp(struct ShadeInput *shi, float *co, LampRen *lar, float * if ((visifac= lamp_get_visibility(lar, co, lv, &lampdist)) == 0.f) return; - VecCopyf(lacol, &lar->r); + copy_v3_v3(lacol, &lar->r); if(lar->mode & LA_TEXTURE) { shi->osatex= 0; do_lamp_tex(lar, lv, shi, lacol, LA_TEXTURE); } - VecMulf(lacol, visifac); + mul_v3_fl(lacol, visifac); if (ELEM(lar->type, LA_SUN, LA_HEMI)) VECCOPY(lv, lar->vec); - VecMulf(lv, -1.0f); + mul_v3_fl(lv, -1.0f); if (shi->mat->vol.shade_type == MA_VOL_SHADE_SHADOWED) { - VecMulf(lacol, vol_get_shadow(shi, lar, co)); + mul_v3_fl(lacol, vol_get_shadow(shi, lar, co)); } else if (shi->mat->vol.shade_type == MA_VOL_SHADE_SHADED) { Isect is; if (shi->mat->vol.shadeflag & MA_VOL_RECV_EXT_SHADOW) { - VecMulf(lacol, vol_get_shadow(shi, lar, co)); + mul_v3_fl(lacol, vol_get_shadow(shi, lar, co)); if (luminance(lacol) < 0.001f) return; } /* find minimum of volume bounds, or lamp coord */ if (vol_get_bounds(shi, co, lv, hitco, &is, VOL_BOUNDS_SS)) { - float dist = VecLenf(co, hitco); + float dist = len_v3v3(co, hitco); VlakRen *vlr = (VlakRen *)is.hit.face; /* simple internal shadowing */ @@ -523,7 +523,7 @@ void vol_shade_one_lamp(struct ShadeInput *shi, float *co, LampRen *lar, float * vol_get_transmittance(shi, tr, co, atten_co); - VecMulVecf(lacol, lacol, tr); + mul_v3_v3v3(lacol, lacol, tr); } else { /* Point is on the outside edge of the volume, @@ -561,7 +561,7 @@ void vol_get_scattering(ShadeInput *shi, float *scatter_col, float *co) if (lar) { vol_shade_one_lamp(shi, co, lar, lacol); - VecAddf(scatter_col, scatter_col, lacol); + add_v3_v3v3(scatter_col, scatter_col, lacol); } } } @@ -594,13 +594,13 @@ static void volumeintegrate(struct ShadeInput *shi, float *col, float *co, float float t0 = 0.f; float pt0 = t0; - float t1 = Normalize(step_vec); /* returns vector length */ + float t1 = normalize_v3(step_vec); /* returns vector length */ t0 += stepsize * ((shi->mat->vol.stepsize_type == MA_VOL_STEP_CONSTANT) ? 0.5f : BLI_thread_frand(shi->thread)); p[0] += t0 * step_vec[0]; p[1] += t0 * step_vec[1]; p[2] += t0 * step_vec[2]; - VecMulf(step_vec, stepsize); + mul_v3_fl(step_vec, stepsize); for (; t0 < t1; pt0 = t0, t0 += stepsize) { const float density = vol_get_density(shi, p); @@ -631,12 +631,12 @@ static void volumeintegrate(struct ShadeInput *shi, float *col, float *co, float radiance[1] += stepd * tr[1] * (emit_col[1] + scatter_col[1]); radiance[2] += stepd * tr[2] * (emit_col[2] + scatter_col[2]); } - VecAddf(p, p, step_vec); + add_v3_v3v3(p, p, step_vec); } /* multiply original color (from behind volume) with transmittance over entire distance */ - VecMulVecf(col, tr, col); - VecAddf(col, col, radiance); + mul_v3_v3v3(col, tr, col); + add_v3_v3v3(col, col, radiance); /* alpha <-- transmission luminance */ col[3] = 1.0f - luminance(tr); @@ -729,7 +729,7 @@ static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int in else col[3] = 1.f; - VecCopyf(shr->combined, col); + copy_v3_v3(shr->combined, col); shr->alpha = col[3]; VECCOPY(shr->diff, shr->combined); @@ -768,7 +768,7 @@ void shade_volume_shadow(struct ShadeInput *shi, struct ShadeResult *shr, struct density = vol_get_density(shi, startco); vol_get_transmittance(shi, tr, startco, endco); - VecCopyf(shr->combined, tr); + copy_v3_v3(shr->combined, tr); shr->combined[3] = 1.0f - luminance(tr); } diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index 479f33c9ff2..8e71fec4db9 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -32,7 +32,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_voxel.h" @@ -277,9 +277,9 @@ int voxeldatatex(struct Tex *tex, float *texvec, struct TexResult *texres) /* scale lookup from 0.0-1.0 (original location) to -1.0, 1.0, consistent with image texture tex coords */ /* in implementation this works backwards, bringing sample locations from -1.0, 1.0 * to the range 0.0, 1.0, before looking up in the voxel structure. */ - VecCopyf(co, texvec); - VecMulf(co, 0.5f); - VecAddf(co, co, offset); + copy_v3_v3(co, texvec); + mul_v3_fl(co, 0.5f); + add_v3_v3v3(co, co, offset); /* co is now in the range 0.0, 1.0 */ switch (tex->extend) { diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 6c1055ec9e0..a3a714553d2 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -37,7 +37,7 @@ #include <limits.h> #include <string.h> -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_jitter.h" #include "BLI_threads.h" @@ -1808,16 +1808,16 @@ void zbuf_make_winmat(Render *re, float winmat[][4]) float panomat[4][4]; if(re->r.mode & R_PANORAMA) { - Mat4One(panomat); + unit_m4(panomat); panomat[0][0]= re->panoco; panomat[0][2]= re->panosi; panomat[2][0]= -re->panosi; panomat[2][2]= re->panoco; - Mat4MulMat4(winmat, panomat, re->winmat); + mul_m4_m4m4(winmat, panomat, re->winmat); } else - Mat4CpyMat4(winmat, re->winmat); + copy_m4_m4(winmat, re->winmat); } /* do zbuffering and clip, f1 f2 f3 are hocos, c1 c2 c3 are clipping flags */ @@ -2133,9 +2133,9 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*, continue; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(obwinmat, obi->mat, winmat); + mul_m4_m4m4(obwinmat, obi->mat, winmat); else - Mat4CpyMat4(obwinmat, winmat); + copy_m4_m4(obwinmat, winmat); if(clip_render_object(obi->obr->boundbox, bounds, obwinmat)) continue; @@ -2312,9 +2312,9 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int continue; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(obwinmat, obi->mat, winmat); + mul_m4_m4m4(obwinmat, obi->mat, winmat); else - Mat4CpyMat4(obwinmat, winmat); + copy_m4_m4(obwinmat, winmat); if(clip_render_object(obi->obr->boundbox, NULL, obwinmat)) continue; @@ -2551,9 +2551,9 @@ void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(vo continue; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(obwinmat, obi->mat, winmat); + mul_m4_m4m4(obwinmat, obi->mat, winmat); else - Mat4CpyMat4(obwinmat, winmat); + copy_m4_m4(obwinmat, winmat); if(clip_render_object(obi->obr->boundbox, bounds, obwinmat)) continue; @@ -3297,9 +3297,9 @@ static int zbuffer_abuf(Render *re, RenderPart *pa, APixstr *APixbuf, ListBase * continue; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(obwinmat, obi->mat, winmat); + mul_m4_m4m4(obwinmat, obi->mat, winmat); else - Mat4CpyMat4(obwinmat, winmat); + copy_m4_m4(obwinmat, winmat); if(clip_render_object(obi->obr->boundbox, bounds, obwinmat)) continue; |