rename axis_angle_to_mat3_no_norm() --> axis_angle_normalized_to_mat3().

this matches closer to convention from existing functions - angle_v3v3() angle_normalized_v3v3().

also added assert to ensure argument given to axis_angle_normalized_to_mat3() is in fact normalized.
This commit is contained in:
Campbell Barton 2013-04-15 15:16:11 +00:00
parent 03d6319862
commit 59ca83c3a9
6 changed files with 17 additions and 32 deletions

View File

@ -97,7 +97,7 @@ void print_qt(const char *str, const float q[4]);
/* conversion */
void axis_angle_to_quat(float r[4], const float axis[3], const float angle);
void axis_angle_to_mat3(float R[3][3], const float axis[3], const float angle);
void axis_angle_to_mat3_no_norm(float R[3][3], const float axis[3], const float angle);
void axis_angle_normalized_to_mat3(float R[3][3], const float axis[3], const float angle);
void axis_angle_to_mat4(float R[4][4], const float axis[3], const float angle);
void quat_to_axis_angle(float axis[3], float *angle, const float q[4]);

View File

@ -750,10 +750,12 @@ void eulO_to_axis_angle(float axis[3], float *angle, const float eul[3], const s
}
/* axis angle to 3x3 matrix - note: requires that axis is normalized */
void axis_angle_to_mat3_no_norm(float mat[3][3], const float nor[3], const float angle)
void axis_angle_normalized_to_mat3(float mat[3][3], const float nor[3], const float angle)
{
float nsi[3], co, si, ico;
BLI_ASSERT_UNIT_V3(nor);
/* now convert this to a 3x3 matrix */
co = cosf(angle);
si = sinf(angle);
@ -778,7 +780,7 @@ void axis_angle_to_mat3_no_norm(float mat[3][3], const float nor[3], const float
/* axis angle to 3x3 matrix - safer version (normalization of axis performed) */
void axis_angle_to_mat3(float mat[3][3], const float axis[3], const float angle)
{
float nor[3], nsi[3], co, si, ico;
float nor[3];
/* normalize the axis first (to remove unwanted scaling) */
if (normalize_v3_v3(nor, axis) == 0.0f) {
@ -786,24 +788,7 @@ void axis_angle_to_mat3(float mat[3][3], const float axis[3], const float angle)
return;
}
/* now convert this to a 3x3 matrix */
co = cosf(angle);
si = sinf(angle);
ico = (1.0f - co);
nsi[0] = nor[0] * si;
nsi[1] = nor[1] * si;
nsi[2] = nor[2] * si;
mat[0][0] = ((nor[0] * nor[0]) * ico) + co;
mat[0][1] = ((nor[0] * nor[1]) * ico) + nsi[2];
mat[0][2] = ((nor[0] * nor[2]) * ico) - nsi[1];
mat[1][0] = ((nor[0] * nor[1]) * ico) - nsi[2];
mat[1][1] = ((nor[1] * nor[1]) * ico) + co;
mat[1][2] = ((nor[1] * nor[2]) * ico) + nsi[0];
mat[2][0] = ((nor[0] * nor[2]) * ico) + nsi[1];
mat[2][1] = ((nor[1] * nor[2]) * ico) - nsi[0];
mat[2][2] = ((nor[2] * nor[2]) * ico) + co;
axis_angle_normalized_to_mat3(mat, nor, angle);
}
/* axis angle to 4x4 matrix - safer version (normalization of axis performed) */

View File

@ -496,7 +496,7 @@ void bmo_spin_exec(BMesh *bm, BMOperator *op)
phi = BMO_slot_float_get(op->slots_in, "angle") / steps;
do_dupli = BMO_slot_bool_get(op->slots_in, "use_duplicate");
axis_angle_to_mat3(rmat, axis, phi);
axis_angle_normalized_to_mat3(rmat, axis, phi);
BMO_slot_copy(op, slots_in, "geom",
op, slots_out, "geom_last.out");

View File

@ -460,10 +460,10 @@ bool paint_space_stroke_enabled(Brush *br, PaintMode mode)
static bool sculpt_is_grab_tool(Brush *br)
{
return ELEM4(br->sculpt_tool,
SCULPT_TOOL_GRAB,
SCULPT_TOOL_THUMB,
SCULPT_TOOL_ROTATE,
SCULPT_TOOL_SNAKE_HOOK);
SCULPT_TOOL_GRAB,
SCULPT_TOOL_THUMB,
SCULPT_TOOL_ROTATE,
SCULPT_TOOL_SNAKE_HOOK);
}
/* return true if the brush size can change during paint (normally used for pressure) */

View File

@ -2120,7 +2120,7 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
NULL, vd.mask ? *vd.mask : 0.0f);
sub_v3_v3v3(vec, orig_data.co, ss->cache->location);
axis_angle_to_mat3_no_norm(rot, ss->cache->sculpt_normal_symm, angle*fade);
axis_angle_normalized_to_mat3(rot, ss->cache->sculpt_normal_symm, angle * fade);
mul_v3_m3v3(proxy[vd.i], rot, vec);
add_v3_v3(proxy[vd.i], ss->cache->location);
sub_v3_v3(proxy[vd.i], orig_data.co);
@ -3955,7 +3955,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
/* only update when we have enough precision, by having the mouse adequately away from center
* may be better to convert to radial representation but square works for small values too*/
if(fabs(dx) > PIXEL_INPUT_THRESHHOLD && fabs(dy) > PIXEL_INPUT_THRESHHOLD) {
if (fabsf(dx) > PIXEL_INPUT_THRESHHOLD && fabsf(dy) > PIXEL_INPUT_THRESHHOLD) {
float mouse_angle;
float dir[2] = {dx, dy};
float cosval, sinval;
@ -3971,8 +3971,8 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
sinval = cross_v2v2(dir, cache->initial_mouse_dir);
/* clamp to avoid nans in acos */
CLAMP(cosval, -1.0, 1.0);
mouse_angle = (sinval > 0)? acos(cosval) : -acos(cosval);
CLAMP(cosval, -1.0f, 1.0f);
mouse_angle = (sinval > 0) ? acosf(cosval) : -acosf(cosval);
/* change of sign, we passed the 180 degree threshold. This means we need to add a turn.
* to distinguish between transition from 0 to -1 and -PI to +PI, use comparison with PI/2 */
@ -3984,7 +3984,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
}
cache->previous_vertex_rotation = mouse_angle;
cache->vertex_rotation = -(mouse_angle + 2*M_PI*cache->num_vertex_turns)* cache->bstrength;
cache->vertex_rotation = -(mouse_angle + 2.0f * (float)M_PI * cache->num_vertex_turns) * cache->bstrength;
#undef PIXEL_INPUT_THRESHHOLD
}

View File

@ -697,7 +697,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
step_angle = (angle / (step_tot - (!close))) * step;
if (ltmd->ob_axis) {
axis_angle_to_mat3(mat3, axis_vec, step_angle);
axis_angle_normalized_to_mat3(mat3, axis_vec, step_angle);
copy_m4_m3(mat, mat3);
}
else {