diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-01-22 21:20:37 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-01-22 21:20:37 +0400 |
commit | cd4123e1db8a40836fa04813ef7dc440ef7feeb0 (patch) | |
tree | 9a10e2dd83251954c8dfcfddd430cb46931b9d99 /source/blender | |
parent | 39aaf4f2f0af3e0663a19381d65081a9090fc10e (diff) |
use inline BLI_math functions for dot product and length calculation.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_armature.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 18 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_kdtree.c | 9 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 3 | ||||
-rw-r--r-- | source/blender/blenlib/intern/noise.c | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/convertblender.c | 30 | ||||
-rw-r--r-- | source/blender/render/intern/source/occlusion.c | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/pixelshading.c | 6 | ||||
-rw-r--r-- | source/blender/render/intern/source/rayshade.c | 14 | ||||
-rw-r--r-- | source/blender/render/intern/source/shadbuf.c | 4 | ||||
-rw-r--r-- | source/blender/render/intern/source/shadeinput.c | 4 | ||||
-rw-r--r-- | source/blender/render/intern/source/volumetric.c | 2 |
14 files changed, 50 insertions, 54 deletions
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index a89bfbd50b1..11ab981822e 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -86,7 +86,7 @@ int bone_autoside_name (char name[64], int strip_number, short axis, float head, struct Bone *get_named_bone (struct bArmature *arm, const char *name); -float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, float rad2, float rdist); +float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3], float rad1, float rad2, float rdist); void where_is_armature (struct bArmature *arm); void where_is_armature_bone(struct Bone *bone, struct Bone *prevbone); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 4f83bcf7e7f..64ea862477f 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -665,7 +665,7 @@ static void b_bone_deform(bPoseChanDeform *pdef_info, Bone *bone, float *co, Dua } /* using vec with dist to bone b1 - b2 */ -float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, float rad2, float rdist) +float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3], float rad1, float rad2, float rdist) { float dist=0.0f; float bdelta[3]; @@ -677,18 +677,18 @@ float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, fl sub_v3_v3v3(pdelta, vec, b1); - a = bdelta[0]*pdelta[0] + bdelta[1]*pdelta[1] + bdelta[2]*pdelta[2]; - hsqr = ((pdelta[0]*pdelta[0]) + (pdelta[1]*pdelta[1]) + (pdelta[2]*pdelta[2])); + a = dot_v3v3(bdelta, pdelta); + hsqr = dot_v3v3(pdelta, pdelta); - if (a < 0.0F){ + if (a < 0.0f) { /* If we're past the end of the bone, do a spherical field attenuation thing */ - dist= ((b1[0]-vec[0])*(b1[0]-vec[0]) +(b1[1]-vec[1])*(b1[1]-vec[1]) +(b1[2]-vec[2])*(b1[2]-vec[2])) ; + dist = len_squared_v3v3(b1, vec); rad= rad1; } - else if (a > l){ + else if (a > l) { /* If we're past the end of the bone, do a spherical field attenuation thing */ - dist= ((b2[0]-vec[0])*(b2[0]-vec[0]) +(b2[1]-vec[1])*(b2[1]-vec[1]) +(b2[2]-vec[2])*(b2[2]-vec[2])) ; - rad= rad2; + dist = len_squared_v3v3(b2, vec); + rad = rad2; } else { dist= (hsqr - (a*a)); @@ -709,7 +709,7 @@ float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, fl if(rdist==0.0f || dist >= l) return 0.0f; else { - a= (float)sqrt(dist)-rad; + a = sqrtf(dist)-rad; return 1.0f-( a*a )/( rdist*rdist ); } } diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c index 3543b847f19..d5f66c0e75f 100644 --- a/source/blender/blenlib/intern/BLI_kdtree.c +++ b/source/blender/blenlib/intern/BLI_kdtree.c @@ -132,19 +132,18 @@ void BLI_kdtree_balance(KDTree *tree) tree->root= kdtree_balance(tree->nodes, tree->totnode, 0); } -static float squared_distance(float *v2, float *v1, float *n1, float *n2) +static float squared_distance(float *v2, float *v1, float *UNUSED(n1), float *n2) { float d[3], dist; - (void)n1; /* unused */ d[0]= v2[0]-v1[0]; d[1]= v2[1]-v1[1]; d[2]= v2[2]-v1[2]; - dist= d[0]*d[0] + d[1]*d[1] + d[2]*d[2]; + dist = dot_v3v3(d, d); - //if(n1 && n2 && n1[0]*n2[0] + n1[1]*n2[1] + n1[2]*n2[2] < 0.0f) - if(n2 && d[0]*n2[0] + d[1]*n2[1] + d[2]*n2[2] < 0.0f) + //if(n1 && n2 && (dot_v3v3(n1, n2) < 0.0f)) + if(n2 && (dot_v3v3(d, n2) < 0.0f)) dist *= 10.0f; return dist; diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index d7880e40626..500e27064d7 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -2485,8 +2485,9 @@ void tangent_from_uv(float uv1[2], float uv2[2], float uv3[3], float co1[3], flo cross_v3_v3v3(ct, tang, tangv); /* check flip */ - if ((ct[0]*n[0] + ct[1]*n[1] + ct[2]*n[2]) < 0.0f) + if (dot_v3v3(ct, n) < 0.0f) { negate_v3(tang); + } } else { tang[0]= tang[1]= tang[2]= 0.0; diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index e1a08de0dd8..b3cb2856383 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -919,10 +919,6 @@ static float g[512+2][3]= { {-0.944031, -0.326599, -0.045624}, }; - - -#define DOT(a,b) (a[0] * b[0] + a[1] * b[1] + a[2] * b[2]) - #define setup(i,b0,b1,r0,r1) \ t = vec[i] + 10000.0f; \ b0 = ((int)t) & 255; \ diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index f91740f4b47..7fe98a604ec 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -870,7 +870,7 @@ static void getVerticalAndHorizontalChange(const float norm[3], float d, const f closest_to_plane_v3(projB, coord, norm, end); // (vertical and horizontal refer to the plane's y and xz respectively) // vertical distance - dists[index] = norm[0]*end[0] + norm[1]*end[1] + norm[2]*end[2] + d; + dists[index] = dot_v3v3(norm, end) + d; // vertical change changes[index][0] = dists[index] - distToStart; //printf("vc %f %f\n", distance(end, projB, 3)-distance(start, projA, 3), changes[index][0]); @@ -1111,7 +1111,7 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength, mag= normalize_v3(norm); if(mag) { /* zeros fix */ d = -dot_v3v3(norm, coord); - /* dist = (norm[0]*m.co[0] + norm[1]*m.co[1] + norm[2]*m.co[2] + d); */ /* UNUSED */ + /* dist = (dot_v3v3(norm, m.co) + d); */ /* UNUSED */ moveCloserToDistanceFromPlane(scene, ob, me, i, norm, coord, d, distToBe, strength, cp); } } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 2620fe4ac71..f617f673397 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -634,7 +634,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) sub_v3_v3v3(dvec, newvec, vod->trackvec); - si= sqrt(dvec[0]*dvec[0]+ dvec[1]*dvec[1]+ dvec[2]*dvec[2]); + si = len_v3(dvec); si /= (float)(2.0 * TRACKBALLSIZE); cross_v3_v3v3(q1+1, vod->trackvec, newvec); diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 1ec400138a7..fa8540b352d 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -671,7 +671,7 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen float *tav= RE_vertren_get_tangent(obr, ver, 0); if (tav) { /* orthonorm. */ - float tdn = tav[0]*ver->n[0] + tav[1]*ver->n[1] + tav[2]*ver->n[2]; + const float tdn = dot_v3v3(tav, ver->n); tav[0] -= ver->n[0]*tdn; tav[1] -= ver->n[1]*tdn; tav[2] -= ver->n[2]*tdn; @@ -767,7 +767,7 @@ static int as_testvertex(VlakRen *vlr, VertRen *UNUSED(ver), ASvert *asv, float while(asf) { for(a=0; a<4; a++) { if(asf->vlr[a] && asf->vlr[a]!=vlr) { - inp= fabs( vlr->n[0]*asf->vlr[a]->n[0] + vlr->n[1]*asf->vlr[a]->n[1] + vlr->n[2]*asf->vlr[a]->n[2] ); + inp = fabsf(dot_v3v3(vlr->n, asf->vlr[a]->n)); if(inp < thresh) return 1; } } @@ -790,7 +790,7 @@ static VertRen *as_findvertex(VlakRen *vlr, VertRen *UNUSED(ver), ASvert *asv, f if(asf->vlr[a] && asf->vlr[a]!=vlr) { /* this face already made a copy for this vertex! */ if(asf->nver[a]) { - inp= fabs( vlr->n[0]*asf->vlr[a]->n[0] + vlr->n[1]*asf->vlr[a]->n[1] + vlr->n[2]*asf->vlr[a]->n[2] ); + inp = fabsf(dot_v3v3(vlr->n, asf->vlr[a]->n)); if(inp >= thresh) { return asf->nver[a]; } @@ -2158,7 +2158,7 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *UNUSED(me), int copy_v3_v3(view, vec); normalize_v3(view); - zn= nor[0]*view[0]+nor[1]*view[1]+nor[2]*view[2]; + zn = dot_v3v3(nor, view); if(zn>=0.0f) hasize= 0.0f; else hasize*= zn*zn*zn*zn; } @@ -2240,9 +2240,9 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve 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]; - shi->vn[1]= imat[1][0]*vr->n[0]+imat[1][1]*vr->n[1]+imat[1][2]*vr->n[2]; - shi->vn[2]= imat[2][0]*vr->n[0]+imat[2][1]*vr->n[1]+imat[2][2]*vr->n[2]; + shi->vn[0] = dot_v3v3(imat[0], vr->n); + shi->vn[1] = dot_v3v3(imat[1], vr->n); + shi->vn[2] = dot_v3v3(imat[2], vr->n); } if (texco & TEXCO_UV) { @@ -4241,7 +4241,7 @@ static void check_non_flat_quads(ObjectRen *obr) flen= normal_tri_v3( nor,vlr->v4->co, vlr->v3->co, vlr->v1->co); if(flen==0.0f) 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]; + xn = dot_v3v3(nor, vlr->n); if(ABS(xn) < 0.999995f ) { // checked on noisy fractal grid @@ -4252,11 +4252,11 @@ static void check_non_flat_quads(ObjectRen *obr) /* split direction based on vnorms */ 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]; + d1 = dot_v3v3(nor, vlr->v1->n); 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]; - + d2 = dot_v3v3(nor, vlr->v2->n); + if( fabs(d1) < fabs(d2) ) vlr->flag |= R_DIVIDE_24; else vlr->flag &= ~R_DIVIDE_24; @@ -5267,7 +5267,7 @@ static void speedvector_project(Render *re, float zco[2], const float co[3], con if(vec[0]<0.0f) ang= -ang; zco[0]= ang/pixelphix + zmulx; - ang= 0.5f*(float)M_PI - saacos(vec[1]/sqrtf(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2])); + ang= 0.5f*(float)M_PI - saacos(vec[1] / len_v3(vec)); zco[1]= ang/pixelphiy + zmuly; } @@ -5487,9 +5487,9 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * } // transform (=rotate) to cam space - camco[0]= imat[0][0]*fsvec[0] + imat[0][1]*fsvec[1] + imat[0][2]*fsvec[2]; - camco[1]= imat[1][0]*fsvec[0] + imat[1][1]*fsvec[1] + imat[1][2]*fsvec[2]; - camco[2]= imat[2][0]*fsvec[0] + imat[2][1]*fsvec[1] + imat[2][2]*fsvec[2]; + camco[0] = dot_v3v3(imat[0], fsvec); + camco[1] = dot_v3v3(imat[1], fsvec); + camco[2] = dot_v3v3(imat[2], fsvec); // get homogenous coordinates projectvert(camco, winmat, hoco); diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index e20fd85d0f0..782e0b59388 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -1413,7 +1413,7 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f if(env) { /* sky shading using bent normal */ if(ELEM(envcolor, WO_AOSKYCOL, WO_AOSKYTEX)) { - fac= 0.5f*(1.0f+bn[0]*re->grvec[0]+ bn[1]*re->grvec[1]+ bn[2]*re->grvec[2]); + fac= 0.5f * (1.0f + dot_v3v3(bn, re->grvec)); env[0]= (1.0f-fac)*re->wrld.horr + fac*re->wrld.zenr; env[1]= (1.0f-fac)*re->wrld.horg + fac*re->wrld.zeng; env[2]= (1.0f-fac)*re->wrld.horb + fac*re->wrld.zenb; diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index f261ec41746..24683ec57f7 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -104,7 +104,7 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) lv[0]= rco[0]-lar->co[0]; lv[1]= rco[1]-lar->co[1]; lv[2]= rco[2]-lar->co[2]; - ld= sqrt(lv[0]*lv[0]+lv[1]*lv[1]+lv[2]*lv[2]); + ld = len_v3(lv); lv[0]/= ld; lv[1]/= ld; lv[2]/= ld; @@ -210,7 +210,7 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) /* dot product and reflectivity*/ - inp= 1.0-fabs(vn[0]*lv[0] + vn[1]*lv[1] + vn[2]*lv[2]); + inp = 1.0 - fabs(dot_v3v3(vn, lv)); /* inp= cos(0.5*M_PI-acos(inp)); */ @@ -511,7 +511,7 @@ void shadeSkyView(float col_r[3], const float rco[3], const float view[3], const /* Some view vector stuff. */ if(R.wrld.skytype & WO_SKYREAL) { - blend= view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]; + blend = dot_v3v3(view, R.grvec); if(blend<0.0f) skyflag= 0; diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index f9ffc2532eb..6c0386cc8b1 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -471,7 +471,7 @@ void makeraytree(Render *re) sub[i] = max[i]-min[i]; } - re->maxdist= sub[0]*sub[0] + sub[1]*sub[1] + sub[2]*sub[2]; + re->maxdist = dot_v3v3(sub, sub); if(re->maxdist > 0.0f) re->maxdist= sqrt(re->maxdist); re->i.infostr= "Raytree finished"; @@ -598,7 +598,7 @@ static int refraction(float refract[3], const float n[3], const float view[3], f copy_v3_v3(refract, view); - dot= view[0]*n[0] + view[1]*n[1] + view[2]*n[2]; + dot = dot_v3v3(view, n); if(dot>0.0f) { index = 1.0f/index; @@ -1708,7 +1708,7 @@ static int UNUSED_FUNCTION(ray_trace_shadow_rad)(ShadeInput *ship, ShadeResult * counter+=3; counter %= 768; copy_v3_v3(vec, hashvectf+counter); - if(ship->vn[0]*vec[0]+ship->vn[1]*vec[1]+ship->vn[2]*vec[2]>0.0f) { + if (dot_v3v3(ship->vn, vec) > 0.0f) { vec[0]-= vec[0]; vec[1]-= vec[1]; vec[2]-= vec[2]; @@ -1771,7 +1771,7 @@ static void DS_energy(float *sphere, int tot, float vec[3]) for(a=0, fp=sphere; a<tot; a++, fp+=3) { sub_v3_v3v3(force, vec, fp); - fac= force[0]*force[0] + force[1]*force[1] + force[2]*force[2]; + fac = dot_v3v3(force, force); if(fac!=0.0f) { fac= 1.0f/fac; res[0]+= fac*force[0]; @@ -1997,7 +1997,7 @@ static void ray_ao_qmc(ShadeInput *shi, float ao[3], float env[3]) normalize_v3(view); if(envcolor==WO_AOSKYCOL) { - const float skyfac= 0.5f*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]); + const float skyfac= 0.5f * (1.0f + dot_v3v3(view, R.grvec)); env[0]+= (1.0f-skyfac)*R.wrld.horr + skyfac*R.wrld.zenr; env[1]+= (1.0f-skyfac)*R.wrld.horg + skyfac*R.wrld.zeng; env[2]+= (1.0f-skyfac)*R.wrld.horb + skyfac*R.wrld.zenb; @@ -2101,7 +2101,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3]) while(tot--) { - if ((vec[0]*nrm[0] + vec[1]*nrm[1] + vec[2]*nrm[2]) > bias) { + if (dot_v3v3(vec, nrm) > bias) { /* only ao samples for mask */ if(R.r.mode & R_OSA) { j++; @@ -2135,7 +2135,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3]) normalize_v3(view); if(envcolor==WO_AOSKYCOL) { - const float fac= 0.5f*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]); + const float fac = 0.5f * (1.0f + dot_v3v3(view, R.grvec)); env[0]+= (1.0f-fac)*R.wrld.horr + fac*R.wrld.zenr; env[1]+= (1.0f-fac)*R.wrld.horg + fac*R.wrld.zeng; env[2]+= (1.0f-fac)*R.wrld.horb + fac*R.wrld.zenb; diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index c14a768d1ce..88d86d5bd43 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -2068,7 +2068,7 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v mul_m4_v3(obi->mat, v1); /* from shadepixel() */ - dface= v1[0]*nor[0] + v1[1]*nor[1] + v1[2]*nor[2]; + dface = dot_v3v3(v1, nor); hoco[3]= 1.0f; /* ortho viewplane cannot intersect using view vector originating in (0,0,0) */ @@ -2091,7 +2091,7 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v calc_view_vector(view, x, y); - div= nor[0]*view[0] + nor[1]*view[1] + nor[2]*view[2]; + div = dot_v3v3(nor, view); if (div==0.0f) return 0; diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index 580a09d5050..e0b5da817cb 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -608,7 +608,7 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v if(shi->obi->flag & R_TRANSFORMED) mul_m4_v3(shi->obi->mat, v1); - dface= v1[0]*shi->facenor[0]+v1[1]*shi->facenor[1]+v1[2]*shi->facenor[2]; + dface = dot_v3v3(v1, shi->facenor); /* ortho viewplane cannot intersect using view vector originating in (0,0,0) */ if(R.r.mode & R_ORTHO) { @@ -650,7 +650,7 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v else { float div; - div= shi->facenor[0]*view[0] + shi->facenor[1]*view[1] + shi->facenor[2]*view[2]; + div = dot_v3v3(shi->facenor, view); if (div!=0.0f) fac= dface/div; else fac= 0.0f; diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index 3637c2de1fb..66cbb18bc57 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -274,7 +274,7 @@ static float metadensity(Object* ob, const float co[3]) } /* ml->rad2 is not set */ - dist2 = 1.f - ((tp[0]*tp[0] + tp[1]*tp[1] + tp[2]*tp[2]) / (ml->rad*ml->rad)); + dist2 = 1.0f - (dot_v3v3(tp, tp) / (ml->rad * ml->rad)); if (dist2 > 0.f) dens += (ml->flag & MB_NEGATIVE) ? -ml->s*dist2*dist2*dist2 : ml->s*dist2*dist2*dist2; } |