Revision: 43814
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43814
Author:   campbellbarton
Date:     2012-02-01 05:59:50 +0000 (Wed, 01 Feb 2012)
Log Message:
-----------
Previous fix for [#29484] wasn't working right (did work in report file though).

this now shares code with RNA's 'pchan.matrix = matrix'

tested with parent scale/rot/translation

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_armature.h
    trunk/blender/source/blender/blenkernel/intern/armature.c
    trunk/blender/source/blender/blenkernel/intern/constraint.c
    trunk/blender/source/blender/makesrna/intern/rna_pose.c

Modified: trunk/blender/source/blender/blenkernel/BKE_armature.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_armature.h      2012-02-01 
05:04:51 UTC (rev 43813)
+++ trunk/blender/source/blender/blenkernel/BKE_armature.h      2012-02-01 
05:59:50 UTC (rev 43814)
@@ -109,6 +109,8 @@
 void armature_loc_pose_to_bone(struct bPoseChannel *pchan, float *inloc, float 
*outloc);
 void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], 
float arm_mat[][4]);
 
+void armature_mat_pose_to_bone_ex(struct Object *ob, struct bPoseChannel 
*pchan, float inmat[][4], float outmat[][4]);
+
 void pchan_mat3_to_rot(struct bPoseChannel *pchan, float mat[][3], short 
use_compat);
 void pchan_apply_mat4(struct bPoseChannel *pchan, float mat[][4], short 
use_comat);
 void pchan_to_mat4(struct bPoseChannel *pchan, float chan_mat[4][4]);

Modified: trunk/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/armature.c   2012-02-01 
05:04:51 UTC (rev 43813)
+++ trunk/blender/source/blender/blenkernel/intern/armature.c   2012-02-01 
05:59:50 UTC (rev 43814)
@@ -1319,6 +1319,23 @@
        copy_v3_v3(outloc, nLocMat[3]);
 }
 
+void armature_mat_pose_to_bone_ex(Object *ob, bPoseChannel *pchan, float 
inmat[][4], float outmat[][4])
+{
+       bPoseChannel work_pchan = *pchan;
+
+       /* recalculate pose matrix with only parent transformations,
+        * bone loc/sca/rot is ignored, scene and frame are not used. */
+       where_is_pose_bone(NULL, ob, &work_pchan, 0.0f, FALSE);
+
+       /* find the matrix, need to remove the bone transforms first so this is
+        * calculated as a matrix to set rather then a difference ontop of whats
+        * already there. */
+       unit_m4(outmat);
+       pchan_apply_mat4(&work_pchan, outmat, FALSE);
+
+       armature_mat_pose_to_bone(&work_pchan, inmat, outmat);
+}
+
 /* same as object_mat3_to_rot() */
 void pchan_mat3_to_rot(bPoseChannel *pchan, float mat[][3], short use_compat)
 {

Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c 2012-02-01 
05:04:51 UTC (rev 43813)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c 2012-02-01 
05:59:50 UTC (rev 43814)
@@ -302,7 +302,8 @@
 
                                                /* override with local location 
*/
                                                if ((pchan->parent) && 
(pchan->bone->flag & BONE_NO_LOCAL_LOCATION)) {
-                                                       sub_v3_v3v3(mat[3], 
tempmat[3], pchan->bone->arm_mat[3]);
+                                                       
armature_mat_pose_to_bone_ex(ob, pchan, pchan->pose_mat, tempmat);
+                                                       copy_v3_v3(mat[3], 
tempmat[3]);
                                                }
                                        }
                                }

Modified: trunk/blender/source/blender/makesrna/intern/rna_pose.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_pose.c     2012-02-01 
05:04:51 UTC (rev 43813)
+++ trunk/blender/source/blender/makesrna/intern/rna_pose.c     2012-02-01 
05:59:50 UTC (rev 43814)
@@ -613,18 +613,10 @@
 {
        bPoseChannel *pchan= (bPoseChannel*)ptr->data;
        Object *ob= (Object*)ptr->id.data;
-       float umat[4][4]= MAT4_UNITY;
        float tmat[4][4];
 
-       /* recalculate pose matrix with only parent transformations,
-        * bone loc/sca/rot is ignored, scene and frame are not used. */
-       where_is_pose_bone(NULL, ob, pchan, 0.0f, FALSE);
+       armature_mat_pose_to_bone_ex(ob, pchan, (float (*)[4])values, tmat);
 
-       /* find the matrix, need to remove the bone transforms first so this is
-        * calculated as a matrix to set rather then a difference ontop of whats
-        * already there. */
-       pchan_apply_mat4(pchan, umat, FALSE);
-       armature_mat_pose_to_bone(pchan, (float (*)[4])values, tmat);
        pchan_apply_mat4(pchan, tmat, FALSE); /* no compat for predictable 
result */
 }
 

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

Reply via email to