diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-09-04 02:32:03 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-09-04 02:32:03 +0400 |
commit | 9467d9940583d6c3a2e1b83f854453da9e64fdd7 (patch) | |
tree | b69c66e465ee618bfc4888648be557b74f26e822 | |
parent | 4ee18eaf12e0430c267054ff04952586fa461153 (diff) |
replace sqrt(dot()) with length functions.
-rw-r--r-- | source/blender/blenkernel/intern/collision.c | 2 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 11 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_array.c | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/shadeoutput.c | 4 |
4 files changed, 10 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 9a457882ad5..e3081b9e670 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -281,7 +281,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM /* Decrease in magnitude of relative tangential velocity due to coulomb friction * in original formula "magrelVel" should be the "change of relative velocity in normal direction" */ - magtangent = min_ff(clmd->coll_parms->friction * 0.01f * magrelVel, sqrtf(dot_v3v3(vrel_t_pre, vrel_t_pre))); + magtangent = min_ff(clmd->coll_parms->friction * 0.01f * magrelVel, len_v3(vrel_t_pre)); /* Apply friction impulse. */ if ( magtangent > ALMOST_ZERO ) { diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index d4f8e608f0b..538e8394b1f 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -919,15 +919,13 @@ static float calc_vp_strength_col_dl(VPaint *vp, ViewContext *vc, const float co co, co_ss, V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) { - float delta[2]; - float dist_squared; - float factor = 1.0; + const float dist_squared = len_squared_v2v2(mval, co_ss); - sub_v2_v2v2(delta, mval, co_ss); - dist_squared = dot_v2v2(delta, delta); /* len squared */ if (dist_squared <= brush_size_pressure * brush_size_pressure) { Brush *brush = BKE_paint_brush(&vp->paint); const float dist = sqrtf(dist_squared); + float factor; + if (brush->mtex.tex && rgba) { if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_3D) { BKE_brush_sample_tex_3D(vc->scene, brush, co, rgba, 0, NULL); @@ -938,6 +936,9 @@ static float calc_vp_strength_col_dl(VPaint *vp, ViewContext *vc, const float co } factor = rgba[3]; } + else { + factor = 1.0f; + } return factor * BKE_brush_curve_strength_clamp(brush, dist, brush_size_pressure); } } diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 70362227c65..7c47fd5862e 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -402,7 +402,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, /* calculate the maximum number of copies which will fit within the * prescribed length */ if (amd->fit_type == MOD_ARR_FITLENGTH || amd->fit_type == MOD_ARR_FITCURVE) { - float dist = sqrt(dot_v3v3(offset[3], offset[3])); + float dist = len_v3(offset[3]); if (dist > 1e-6f) /* this gives length = first copy start to last copy end diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 178d304eca2..114961394c4 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -1191,8 +1191,8 @@ float lamp_get_visibility(LampRen *lar, const float co[3], float lv[3], float *d float visifac= 1.0f, t; sub_v3_v3v3(lv, co, lar->co); - *dist= sqrtf(dot_v3v3(lv, lv)); - t= 1.0f/dist[0]; + *dist = len_v3(lv); + t = 1.0f / (*dist); mul_v3_fl(lv, t); /* area type has no quad or sphere option */ |