Revision: 56064
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56064
Author:   campbellbarton
Date:     2013-04-15 15:16:11 +0000 (Mon, 15 Apr 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_math_rotation.h
    trunk/blender/source/blender/blenlib/intern/math_rotation.c
    trunk/blender/source/blender/bmesh/operators/bmo_dupe.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
    trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
    trunk/blender/source/blender/modifiers/intern/MOD_screw.c

Modified: trunk/blender/source/blender/blenlib/BLI_math_rotation.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_rotation.h    2013-04-15 
15:01:12 UTC (rev 56063)
+++ trunk/blender/source/blender/blenlib/BLI_math_rotation.h    2013-04-15 
15:16:11 UTC (rev 56064)
@@ -97,7 +97,7 @@
 /* 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]);

Modified: trunk/blender/source/blender/blenlib/intern/math_rotation.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_rotation.c 2013-04-15 
15:01:12 UTC (rev 56063)
+++ trunk/blender/source/blender/blenlib/intern/math_rotation.c 2013-04-15 
15:16:11 UTC (rev 56064)
@@ -750,10 +750,12 @@
 }
 
 /* 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 @@
 /* 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 @@
                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) 
*/

Modified: trunk/blender/source/blender/bmesh/operators/bmo_dupe.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_dupe.c     2013-04-15 
15:01:12 UTC (rev 56063)
+++ trunk/blender/source/blender/bmesh/operators/bmo_dupe.c     2013-04-15 
15:16:11 UTC (rev 56064)
@@ -496,7 +496,7 @@
        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");

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c    
2013-04-15 15:01:12 UTC (rev 56063)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c    
2013-04-15 15:16:11 UTC (rev 56064)
@@ -460,10 +460,10 @@
 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) */

Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c  2013-04-15 
15:01:12 UTC (rev 56063)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c  2013-04-15 
15:16:11 UTC (rev 56064)
@@ -2120,7 +2120,7 @@
                                                                            
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 @@
 
                /* 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 @@
                        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 @@
                        }
                        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
                }

Modified: trunk/blender/source/blender/modifiers/intern/MOD_screw.c
===================================================================
--- trunk/blender/source/blender/modifiers/intern/MOD_screw.c   2013-04-15 
15:01:12 UTC (rev 56063)
+++ trunk/blender/source/blender/modifiers/intern/MOD_screw.c   2013-04-15 
15:16:11 UTC (rev 56064)
@@ -697,7 +697,7 @@
                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 {

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to