Cleanup: use normalize_v#_length
authorCampbell Barton <ideasman42@gmail.com>
Fri, 8 Jul 2016 00:14:49 +0000 (10:14 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 8 Jul 2016 00:14:49 +0000 (10:14 +1000)
14 files changed:
source/blender/blenlib/intern/math_rotation.c
source/blender/bmesh/operators/bmo_extrude.c
source/blender/bmesh/operators/bmo_subdivide.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/mesh/editmesh_extrude.c
source/blender/editors/mesh/editmesh_rip.c
source/blender/editors/mesh/editmesh_utils.c
source/blender/editors/space_view3d/view3d_walk.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_constraints.c
source/blender/editors/transform/transform_manipulator.c
source/blender/modifiers/intern/MOD_solidify.c
source/blender/render/intern/source/multires_bake.c
source/blender/render/intern/source/render_texture.c

index d962e4f0fa7dbb502991bf637e6d77e0243d7303..b285a74b8acc0b12ca4113f4dd165b3b54192112 100644 (file)
@@ -200,8 +200,7 @@ void mul_fac_qt_fl(float q[4], const float fac)
        const float co = cosf(angle);
        const float si = sinf(angle);
        q[0] = co;
-       normalize_v3(q + 1);
-       mul_v3_fl(q + 1, si);
+       normalize_v3_length(q + 1, si);
 }
 
 /* skip error check, currently only needed by mat3_to_quat_is_ok */
index f2a8e05d76347d2849dc73e13544e9c5fd620738..87369472df79540538db7f044d0658632bafa615 100644 (file)
@@ -667,8 +667,7 @@ static void calc_solidify_normals(BMesh *bm)
                                /* two faces using this edge, calculate the edge normal
                                 * using the angle between the faces as a weighting */
                                add_v3_v3v3(edge_normal, f1->no, f2->no);
-                               normalize_v3(edge_normal);
-                               mul_v3_fl(edge_normal, angle);
+                               normalize_v3_length(edge_normal, angle);
                        }
                        else {
                                /* can't do anything useful here!
index 8d672b32caa9d904e262a15e60f89a64ec435244..894129b4a332ad28dcce50b34948e506ceb2ac97 100644 (file)
@@ -254,8 +254,7 @@ static void alter_co(
        copy_v3_v3(co, v->co);
 
        if (UNLIKELY(params->use_sphere)) { /* subdivide sphere */
-               normalize_v3(co);
-               mul_v3_fl(co, params->smooth);
+               normalize_v3_length(co, params->smooth);
        }
        else if (params->use_smooth) {
                /* calculating twice and blending gives smoother results,
index e0b8003d8a9dbd3a8589a6c1ae3d917da868b007..0a0ecf93d17a3655236c701d7b55fce53c98122a 100644 (file)
@@ -5607,8 +5607,7 @@ static bool ui_numedit_but_HSVCIRCLE(
        ui_color_picker_to_rgb_v(hsv, rgb);
 
        if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (rgb[0] || rgb[1] || rgb[2])) {
-               normalize_v3(rgb);
-               mul_v3_fl(rgb, but->a2);
+               normalize_v3_length(rgb, but->a2);
        }
 
        if (use_display_colorspace)
@@ -5684,8 +5683,7 @@ static void ui_ndofedit_but_HSVCIRCLE(
        ui_color_picker_to_rgb_v(hsv, data->vec);
        
        if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (data->vec[0] || data->vec[1] || data->vec[2])) {
-               normalize_v3(data->vec);
-               mul_v3_fl(data->vec, but->a2);
+               normalize_v3_length(data->vec, but->a2);
        }
 
        if (use_display_colorspace)
@@ -8722,8 +8720,7 @@ static bool ui_mouse_motion_towards_check(
                float delta[2];
 
                sub_v2_v2v2(delta, oldp, cent);
-               normalize_v2(delta);
-               mul_v2_fl(delta, MENU_TOWARDS_WIGGLE_ROOM);
+               normalize_v2_length(delta, MENU_TOWARDS_WIGGLE_ROOM);
                add_v2_v2(oldp, delta);
        }
 
index 1dfb1cddd2c94caad6aa47d0d50b56b45fc8c58c..d4c49833c2c548a469e23a2eb227caaad7dc5386 100644 (file)
@@ -287,8 +287,7 @@ static int edbm_extrude_repeat_exec(bContext *C, wmOperator *op)
        short a;
 
        /* dvec */
-       normalize_v3_v3(dvec, rv3d->persinv[2]);
-       mul_v3_fl(dvec, offs);
+       normalize_v3_v3_length(dvec, rv3d->persinv[2], offs);
 
        /* base correction */
        copy_m3_m4(bmat, obedit->obmat);
index 8868827a11fb23ac631fc7cf3521ef17638bf1df..e3e5863dc0e6394cf4232b90bc0d1cb2b1eda5a0 100644 (file)
@@ -153,8 +153,7 @@ static float edbm_rip_edge_side_measure(
        ED_view3d_project_float_v2_m4(ar, e->v2->co, e_v2_co, projectMat);
 
        sub_v2_v2v2(vec, cent, mid);
-       normalize_v2(vec);
-       mul_v2_fl(vec, 0.01f);
+       normalize_v2_length(vec, 0.01f);
 
        /* rather then adding to both verts, subtract from the mouse */
        sub_v2_v2v2(fmval_tweak, fmval, vec);
index 5101608246a593e3e754f02bfa94c1e5aa11fe9d..4fc61e0912e7da6d2b905806f882b5285d66f63a 100644 (file)
@@ -1440,13 +1440,9 @@ bool BMBVH_EdgeVisible(struct BMBVHTree *tree, BMEdge *e, ARegion *ar, View3D *v
        sub_v3_v3v3(dir2, origin, co2);
        sub_v3_v3v3(dir3, origin, co3);
 
-       normalize_v3(dir1);
-       normalize_v3(dir2);
-       normalize_v3(dir3);
-
-       mul_v3_fl(dir1, epsilon);
-       mul_v3_fl(dir2, epsilon);
-       mul_v3_fl(dir3, epsilon);
+       normalize_v3_length(dir1, epsilon);
+       normalize_v3_length(dir2, epsilon);
+       normalize_v3_length(dir3, epsilon);
 
        /* offset coordinates slightly along view vectors, to avoid
         * hitting the faces that own the edge.*/
index 3269e0cfbfc907522d8f5e797608613dbe4ecc60..c9e4bb301b82f6f846588458b4f2ebee57db8e12 100644 (file)
@@ -924,8 +924,7 @@ static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent
                                        copy_v3_v3(teleport->origin, walk->rv3d->viewinv[3]);
 
                                        /* stop the camera from a distance (camera height) */
-                                       normalize_v3(nor);
-                                       mul_v3_fl(nor, walk->view_height);
+                                       normalize_v3_length(nor, walk->view_height);
                                        add_v3_v3(loc, nor);
 
                                        sub_v3_v3v3(teleport->direction, loc, teleport->origin);
index 95864474fc0335ca68d3fc31c96d92e40c35ea24..f18493e4b3496c20fe509e3138aee9239c5e0a58 100644 (file)
@@ -100,7 +100,6 @@ static void doVertSlide(TransInfo *t, float perc);
 
 static void drawEdgeSlide(TransInfo *t);
 static void drawVertSlide(TransInfo *t);
-static void len_v3_ensure(float v[3], const float length);
 static void postInputRotation(TransInfo *t, float values[3]);
 
 static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short around);
@@ -4957,9 +4956,7 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2]))
                                project_v3_v3v3(vec, vec, axis);
                        }
                }
-               normalize_v3(vec);
-               mul_v3_fl(vec, distance);
-               mul_v3_fl(vec, td->factor);
+               normalize_v3_length(vec, distance * td->factor);
 
                add_v3_v3v3(td->loc, td->iloc, vec);
        }
@@ -5753,13 +5750,6 @@ static void interp_line_v3_v3v3v3(float p[3], const float v1[3], const float v2[
        }
 }
 
-
-static void len_v3_ensure(float v[3], const float length)
-{
-       normalize_v3(v);
-       mul_v3_fl(v, length);
-}
-
 /**
  * Find the closest point on the ngon on the opposite side.
  * used to set the edge slide distance for ngons.
@@ -5823,7 +5813,7 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l,
                
                if (l->e == e_next) {
                        if (i) {
-                               len_v3_ensure(vec_accum, vec_accum_len / (float)i);
+                               normalize_v3_length(vec_accum, vec_accum_len / (float)i);
                        }
                        else {
                                /* When there is no edge to slide along,
@@ -5843,7 +5833,7 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l,
                                        cross_v3_v3v3(vec_accum, l_tmp->f->no, tdir);
 #if 0
                                        /* rough guess, we can  do better! */
-                                       len_v3_ensure(vec_accum, (BM_edge_calc_length(e_prev) + BM_edge_calc_length(e_next)) / 2.0f);
+                                       normalize_v3_length(vec_accum, (BM_edge_calc_length(e_prev) + BM_edge_calc_length(e_next)) / 2.0f);
 #else
                                        /* be clever, check the opposite ngon edge to slide into.
                                         * this gives best results */
@@ -5858,7 +5848,7 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l,
                                                        dist = (BM_edge_calc_length(e_prev) + BM_edge_calc_length(e_next)) / 2.0f;
                                                }
 
-                                               len_v3_ensure(vec_accum, dist);
+                                               normalize_v3_length(vec_accum, dist);
                                        }
 #endif
                                }
@@ -5879,7 +5869,7 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l,
 
                if (BM_loop_other_edge_loop(l, v)->e == e_next) {
                        if (i) {
-                               len_v3_ensure(vec_accum, vec_accum_len / (float)i);
+                               normalize_v3_length(vec_accum, vec_accum_len / (float)i);
                        }
 
                        copy_v3_v3(r_slide_vec, vec_accum);
@@ -5890,7 +5880,7 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l,
                 ((l = l->radial_next) != l_first));
 
        if (i) {
-               len_v3_ensure(vec_accum, vec_accum_len / (float)i);
+               normalize_v3_length(vec_accum, vec_accum_len / (float)i);
        }
        
        copy_v3_v3(r_slide_vec, vec_accum);
index 13cc0c227788bbc5420b839ae911af03fe7c8b9a..d7b670b64764dcb2b88921218b565bd60b16529c 100644 (file)
@@ -187,9 +187,7 @@ static void viewAxisCorrectCenter(TransInfo *t, float t_con_center[3])
 
                if (l < min_dist) {
                        float diff[3];
-                       normalize_v3_v3(diff, t->viewinv[2]);
-                       mul_v3_fl(diff, min_dist - l);
-
+                       normalize_v3_v3_length(diff, t->viewinv[2], min_dist - l);
                        sub_v3_v3(t_con_center, diff);
                }
        }
@@ -225,9 +223,8 @@ static void axisProjection(TransInfo *t, const float axis[3], const float in[3],
                if (factor < 0.0f) factor *= -factor;
                else factor *= factor;
 
-               copy_v3_v3(out, axis);
-               normalize_v3(out);
-               mul_v3_fl(out, -factor);  /* -factor makes move down going backwards */
+               /* -factor makes move down going backwards */
+               normalize_v3_v3_length(out, axis, -factor);
        }
        else {
                float v[3], i1[3], i2[3];
index 992fde0cce3fbdebb45d0362bd13efdf6e6562e8..309ad22e31c6a451750f0e5b64d660603a512cc8 100644 (file)
@@ -995,8 +995,7 @@ static void draw_manipulator_rotate(
                        vec[0] = 0; // XXX (float)(t->mouse.imval[0] - t->center2d[0]);
                        vec[1] = 0; // XXX (float)(t->mouse.imval[1] - t->center2d[1]);
                        vec[2] = 0.0f;
-                       normalize_v3(vec);
-                       mul_v3_fl(vec, 1.2f * size);
+                       normalize_v3_length(vec, 1.2f * size);
                        glBegin(GL_LINES);
                        glVertex3f(0.0f, 0.0f, 0.0f);
                        glVertex3fv(vec);
@@ -1516,8 +1515,7 @@ static void draw_manipulator_rotate_cyl(
                        vec[0] = 0; // XXX (float)(t->mouse.imval[0] - t->center2d[0]);
                        vec[1] = 0; // XXX (float)(t->mouse.imval[1] - t->center2d[1]);
                        vec[2] = 0.0f;
-                       normalize_v3(vec);
-                       mul_v3_fl(vec, 1.2f * size);
+                       normalize_v3_length(vec, 1.2f * size);
                        glBegin(GL_LINES);
                        glVertex3f(0.0, 0.0, 0.0);
                        glVertex3fv(vec);
index 527576843e36afe21372b117414bc80b48b6aa78..911b6997058e62edf4534a76487bd545eac633a6 100644 (file)
@@ -141,9 +141,9 @@ static void dm_calc_normal(DerivedMesh *dm, float (*face_nors)[3], float (*r_ver
                                         * using the angle between the 2 faces as a weighting */
 #if 0
                                        add_v3_v3v3(edge_normal, face_nors[edge_ref->f1], face_nors[edge_ref->f2]);
-                                       normalize_v3(edge_normal);
-
-                                       mul_v3_fl(edge_normal, angle_normalized_v3v3(face_nors[edge_ref->f1], face_nors[edge_ref->f2]));
+                                       normalize_v3_length(
+                                               edge_normal,
+                                               angle_normalized_v3v3(face_nors[edge_ref->f1], face_nors[edge_ref->f2]));
 #else
                                        mid_v3_v3v3_angle_weighted(edge_normal, face_nors[edge_ref->f1], face_nors[edge_ref->f2]);
 #endif
index 8c6d9c5f951f5630ed4503c329290652604c369a..fba5836ac32a6b0ed7fe3373e8a790752d7e829d 100644 (file)
@@ -864,8 +864,7 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
                       lvl, lt, uv[0], uv[1], NULL, n);
 
        mul_v3_m3v3(vec, tangmat, n);
-       normalize_v3(vec);
-       mul_v3_fl(vec, 0.5);
+       normalize_v3_length(vec, 0.5);
        add_v3_v3(vec, tmp);
 
        if (ibuf->rect_float) {
index dc22859bdc1a8bc6c320bb6a5a38e82be2d5243e..513cfa6df7de585c219403f1786c0caf14bb8745 100644 (file)
@@ -2495,8 +2495,7 @@ void do_material_tex(ShadeInput *shi, Render *re)
                                                        /* can be optimized... (ton) */
                                                        mul_mat3_m4_v3(shi->obr->ob->obmat, texres.nor);
                                                        mul_mat3_m4_v3(re->viewmat, texres.nor);
-                                                       normalize_v3(texres.nor);
-                                                       mul_v3_fl(texres.nor, len);
+                                                       normalize_v3_length(texres.nor, len);
                                                }
                                        }
                                }