Cleanup: use normalize_v#_length
This commit is contained in:
@@ -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 */
|
||||
|
||||
@@ -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!
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.*/
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user