Revision: 32645
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32645
Author:   campbellbarton
Date:     2010-10-22 05:56:50 +0200 (Fri, 22 Oct 2010)

Log Message:
-----------
Fix for snapping pose bones with axis-angle rotation.
- armature_mat_pose_to_bone() was missing axis-angle check.
- added loc_axisangle_size_to_mat4() for completeness.
- use 'const' prefix where possible in math rotation functions.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/armature.c
    trunk/blender/source/blender/blenlib/BLI_math_matrix.h
    trunk/blender/source/blender/blenlib/BLI_math_rotation.h
    trunk/blender/source/blender/blenlib/intern/math_matrix.c
    trunk/blender/source/blender/blenlib/intern/math_rotation.c
    trunk/blender/source/blender/editors/space_view3d/view3d_snap.c

Modified: trunk/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/armature.c   2010-10-22 
03:27:01 UTC (rev 32644)
+++ trunk/blender/source/blender/blenkernel/intern/armature.c   2010-10-22 
03:56:50 UTC (rev 32645)
@@ -1108,12 +1108,19 @@
        
        /* paranoia: prevent crashes with no pose-channel supplied */
        if (pchan==NULL) return;
-       
+
        /* get the inverse matrix of the pchan's transforms */
-       if (pchan->rotmode)
+       switch(pchan->rotmode) {
+       case ROT_MODE_QUAT:
+               loc_quat_size_to_mat4(pc_trans, pchan->loc, pchan->quat, 
pchan->size);
+               break;
+       case ROT_MODE_AXISANGLE:
+               loc_axisangle_size_to_mat4(pc_trans, pchan->loc, 
pchan->rotAxis, pchan->rotAngle, pchan->size);
+               break;
+       default: /* euler */
                loc_eul_size_to_mat4(pc_trans, pchan->loc, pchan->eul, 
pchan->size);
-       else
-               loc_quat_size_to_mat4(pc_trans, pchan->loc, pchan->quat, 
pchan->size);
+       }
+
        invert_m4_m4(inv_trans, pc_trans);
        
        /* Remove the pchan's transforms from it's pose_mat.

Modified: trunk/blender/source/blender/blenlib/BLI_math_matrix.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_matrix.h      2010-10-22 
03:27:01 UTC (rev 32644)
+++ trunk/blender/source/blender/blenlib/BLI_math_matrix.h      2010-10-22 
03:56:50 UTC (rev 32645)
@@ -135,8 +135,8 @@
 float mat3_to_scale(float M[3][3]);
 float mat4_to_scale(float M[4][4]);
 
-void size_to_mat3(float R[3][3], float size[3]);
-void size_to_mat4(float R[4][4], float size[3]);
+void size_to_mat3(float R[3][3], const float size[3]);
+void size_to_mat4(float R[4][4], const float size[3]);
 
 void mat3_to_size(float r[3], float M[3][3]);
 void mat4_to_size(float r[3], float M[4][4]);
@@ -145,11 +145,13 @@
 void rotate_m4(float mat[4][4], char axis, float angle);
 
 void loc_eul_size_to_mat4(float R[4][4],
-       float loc[3], float eul[3], float size[3]);
+       const float loc[3], const float eul[3], const float size[3]);
 void loc_eulO_size_to_mat4(float R[4][4],
-       float loc[3], float eul[3], float size[3], short order);
+       const float loc[3], const float eul[3], const float size[3], const 
short order);
 void loc_quat_size_to_mat4(float R[4][4],
-       float loc[3], float quat[4], float size[3]);
+       const float loc[3], const float quat[4], const float size[3]);
+void loc_axisangle_size_to_mat4(float R[4][4],
+       const float loc[3], const float axis[4], const float angle, const float 
size[3]);
 
 void blend_m3_m3m3(float R[3][3], float A[3][3], float B[3][3], float t);
 void blend_m4_m4m4(float R[4][4], float A[4][4], float B[4][4], float t);

Modified: trunk/blender/source/blender/blenlib/BLI_math_rotation.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_rotation.h    2010-10-22 
03:27:01 UTC (rev 32644)
+++ trunk/blender/source/blender/blenlib/BLI_math_rotation.h    2010-10-22 
03:56:50 UTC (rev 32645)
@@ -48,29 +48,29 @@
 void mul_qt_fl(float q[4], const float f);
 void mul_fac_qt_fl(float q[4], const float f);
 
-void sub_qt_qtqt(float q[4], float a[4], float b[4]);
+void sub_qt_qtqt(float q[4], const float a[4], const float b[4]);
 
 void invert_qt(float q[4]);
 void invert_qt_qt(float *q1, const float *q2);
 void conjugate_qt(float q[4]);
-float dot_qtqt(float a[4], float b[4]);
+float dot_qtqt(const float a[4], const float b[4]);
 void normalize_qt(float q[4]);
 
 /* comparison */
 int is_zero_qt(float q[4]);
 
 /* interpolation */
-void interp_qt_qtqt(float q[4], float a[4], float b[4], float t);
-void add_qt_qtqt(float q[4], float a[4], float b[4], float t);
+void interp_qt_qtqt(float q[4], const float a[4], const float b[4], const 
float t);
+void add_qt_qtqt(float q[4], const float a[4], const float b[4], const float 
t);
 
 /* conversion */
-void quat_to_mat3(float mat[3][3], float q[4]);
-void quat_to_mat4(float mat[4][4], float q[4]);
+void quat_to_mat3(float mat[3][3], const float q[4]);
+void quat_to_mat4(float mat[4][4], const float q[4]);
 
 void mat3_to_quat(float q[4], float mat[3][3]);
 void mat4_to_quat(float q[4], float mat[4][4]);
-void tri_to_quat(float q[4], float a[3], float b[3], float c[3]);
-void vec_to_quat(float q[4], float vec[3], short axis, short upflag);
+void tri_to_quat(float q[4], const float a[3], const float b[3], const float 
c[3]);
+void vec_to_quat(float q[4], const float vec[3], short axis, const short 
upflag);
 /* note: v1 and v2 must be normalized */
 void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float 
v2[3]);
 void rotation_between_quats_to_quat(float q[4], const float q1[4], const float 
q2[4]);
@@ -84,11 +84,11 @@
 /******************************** Axis Angle *********************************/
 
 /* conversion */
-void axis_angle_to_quat(float r[4], float axis[3], float angle);
-void axis_angle_to_mat3(float R[3][3], float axis[3], float angle);
-void axis_angle_to_mat4(float R[4][4], float axis[3], float angle);
+void axis_angle_to_quat(float r[4], const float axis[3], float angle);
+void axis_angle_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, float q[4]);
+void quat_to_axis_angle(float axis[3], float *angle, const float q[4]);
 void mat3_to_axis_angle(float axis[3], float *angle, float M[3][3]);
 void mat4_to_axis_angle(float axis[3], float *angle, float M[4][4]);
 
@@ -100,24 +100,24 @@
 void mat3_to_vec_rot(float vec[3], float *phi, float mat[3][3]);
 void mat4_to_vec_rot(float vec[3], float *phi, float mat[4][4]);
 
-void vec_rot_to_quat(float quat[4], float vec[3], float phi);
-void vec_rot_to_mat3(float mat[3][3], float vec[3], float phi);
-void vec_rot_to_mat4(float mat[4][4], float vec[3], float phi);
+void vec_rot_to_quat(float quat[4], const float vec[3], const float phi);
+void vec_rot_to_mat3(float mat[3][3], const float vec[3], const float phi);
+void vec_rot_to_mat4(float mat[4][4], const float vec[3], const float phi);
 
 /******************************** XYZ Eulers *********************************/
 
-void eul_to_quat(float quat[4], float eul[3]);
-void eul_to_mat3(float mat[3][3], float eul[3]);
-void eul_to_mat4(float mat[4][4], float eul[3]);
+void eul_to_quat(float quat[4], const float eul[3]);
+void eul_to_mat3(float mat[3][3], const float eul[3]);
+void eul_to_mat4(float mat[4][4], const float eul[3]);
 
-void quat_to_eul(float eul[3], float quat[4]);
+void quat_to_eul(float eul[3], const float quat[4]);
 void mat3_to_eul(float eul[3], float mat[3][3]);
 void mat4_to_eul(float eul[3], float mat[4][4]);
 
-void compatible_eul(float eul[3], float old[3]);
-void mat3_to_compatible_eul(float eul[3], float old[3], float mat[3][3]);
+void compatible_eul(float eul[3], const float old[3]);
+void mat3_to_compatible_eul(float eul[3], const float old[3], float mat[3][3]);
 
-void rotate_eul(float eul[3], char axis, float angle);
+void rotate_eul(float eul[3], const char axis, const float angle);
 
 /************************** Arbitrary Order Eulers ***************************/
 
@@ -135,16 +135,16 @@
        /* there are 6 more entries with dulpicate entries included */
 } eEulerRotationOrders;
 
-void eulO_to_quat(float quat[4], float eul[3], short order);
-void eulO_to_mat3(float mat[3][3], float eul[3], short order);
-void eulO_to_mat4(float mat[4][4], float eul[3], short order);
-void eulO_to_axis_angle(float axis[3], float *angle, float eul[3], short 
order);
-void eulO_to_gimbal_axis(float gmat[3][3], float eul[3], short order);
+void eulO_to_quat(float quat[4], const float eul[3], const short order);
+void eulO_to_mat3(float mat[3][3], const float eul[3], const short order);
+void eulO_to_mat4(float mat[4][4], const float eul[3], const short order);
+void eulO_to_axis_angle(float axis[3], float *angle, const float eul[3], const 
short order);
+void eulO_to_gimbal_axis(float gmat[3][3], const float eul[3], const short 
order);
  
-void quat_to_eulO(float eul[3], short order, float quat[4]);
-void mat3_to_eulO(float eul[3], short order, float mat[3][3]);
-void mat4_to_eulO(float eul[3], short order, float mat[4][4]);
-void axis_angle_to_eulO(float eul[3], short order, float axis[3], float angle);
+void quat_to_eulO(float eul[3], const short order, const float quat[4]);
+void mat3_to_eulO(float eul[3], const short order, float mat[3][3]);
+void mat4_to_eulO(float eul[3], const short order, float mat[4][4]);
+void axis_angle_to_eulO(float eul[3], const short order, const float axis[3], 
const float angle);
 
 void mat3_to_compatible_eulO(float eul[3], float old[3], short order, float 
mat[3][3]);
 void mat4_to_compatible_eulO(float eul[3], float old[3], short order, float 
mat[4][4]);

Modified: trunk/blender/source/blender/blenlib/intern/math_matrix.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_matrix.c   2010-10-22 
03:27:01 UTC (rev 32644)
+++ trunk/blender/source/blender/blenlib/intern/math_matrix.c   2010-10-22 
03:56:50 UTC (rev 32645)
@@ -898,7 +898,7 @@
 
 /****************************** Transformations ******************************/
 
-void size_to_mat3(float mat[][3], float *size)
+void size_to_mat3(float mat[][3], const float size[3])
 {
        mat[0][0]= size[0];
        mat[0][1]= 0.0f;
@@ -911,7 +911,7 @@
        mat[2][0]= 0.0f;
 }
 
-void size_to_mat4(float mat[][4], float *size)
+void size_to_mat4(float mat[][4], const float size[3])
 {
        float tmat[3][3];
        
@@ -1078,7 +1078,7 @@
 /* make a 4x4 matrix out of 3 transform components */
 /* matrices are made in the order: scale * rot * loc */
 // TODO: need to have a version that allows for rotation order...
-void loc_eul_size_to_mat4(float mat[4][4], float loc[3], float eul[3], float 
size[3])
+void loc_eul_size_to_mat4(float mat[4][4], const float loc[3], const float 
eul[3], const float size[3])
 {
        float rmat[3][3], smat[3][3], tmat[3][3];
        
@@ -1101,7 +1101,7 @@
 
 /* make a 4x4 matrix out of 3 transform components */
 /* matrices are made in the order: scale * rot * loc */
-void loc_eulO_size_to_mat4(float mat[4][4], float loc[3], float eul[3], float 
size[3], short rotOrder)
+void loc_eulO_size_to_mat4(float mat[4][4], const float loc[3], const float 
eul[3], const float size[3], const short rotOrder)
 {
        float rmat[3][3], smat[3][3], tmat[3][3];
        
@@ -1125,7 +1125,7 @@
 

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to