code cleanup: typos and set exceptional cases of zero length normals as UNLIKELY().

This commit is contained in:
Campbell Barton 2012-09-17 22:22:06 +00:00
parent 7f32f412ad
commit aff591c6e1
4 changed files with 10 additions and 8 deletions

View File

@ -1944,8 +1944,9 @@ void BKE_mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpo
MVert *mv = &mverts[i];
float *no = tnorms[i];
if (normalize_v3(no) == 0.0f)
if (UNLIKELY(normalize_v3(no) == 0.0f)) {
normalize_v3_v3(no, mv->co);
}
normal_float_to_short_v3(mv->no, no);
}
@ -1981,8 +1982,9 @@ void BKE_mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces,
MVert *mv = &mverts[i];
float *no = tnorms[i];
if (normalize_v3(no) == 0.0f)
if (UNLIKELY(normalize_v3(no) == 0.0f)) {
normalize_v3_v3(no, mv->co);
}
normal_float_to_short_v3(mv->no, no);
}

View File

@ -282,7 +282,7 @@ void BM_mesh_normals_update(BMesh *bm, const short skip_hidden)
if (skip_hidden && BM_elem_flag_test(v, BM_ELEM_HIDDEN))
continue;
if (normalize_v3(v->no) == 0.0f) {
if (UNLIKELY(normalize_v3(v->no) == 0.0f)) {
normalize_v3_v3(v->no, v->co);
}
}

View File

@ -1253,7 +1253,7 @@ int BMO_error_occurred(BMesh *bm)
return bm->errorstack.first != NULL;
}
/* returns error code or 0 if no erro */
/* returns error code or 0 if no error */
int BMO_error_get(BMesh *bm, const char **msg, BMOperator **op)
{
BMOpError *err = bm->errorstack.first;

View File

@ -393,7 +393,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
mul_m4_v3(mtx_tx, vc->co);
/* length in 2d, don't sqrt because this is only for comparison */
vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] +
vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] +
vc->co[other_axis_2] * vc->co[other_axis_2];
/* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/
@ -410,7 +410,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
vc->v[0] = vc->v[1] = -1;
/* length in 2d, don't sqrt because this is only for comparison */
vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] +
vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] +
vc->co[other_axis_2] * vc->co[other_axis_2];
/* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/
@ -430,7 +430,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
vc->e[1] = med_new;
}
else {
vc->v[0] = vc->v[1] = -2; /* erro value - don't use, 3 edges on vert */
vc->v[0] = vc->v[1] = -2; /* error value - don't use, 3 edges on vert */
}
vc = &vert_connect[med_new->v2];
@ -445,7 +445,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
vc->e[1] = med_new;
}
else {
vc->v[0] = vc->v[1] = -2; /* erro value - don't use, 3 edges on vert */
vc->v[0] = vc->v[1] = -2; /* error value - don't use, 3 edges on vert */
}
}