[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38193] trunk/blender/source/blender/ makesrna/intern/rna_pose.c: Allow pose matrix to be set for Benjy Cook' s GSOC project.

Campbell Barton ideasman42 at gmail.com
Thu Jul 7 18:09:57 CEST 2011


Revision: 38193
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38193
Author:   campbellbarton
Date:     2011-07-07 16:09:57 +0000 (Thu, 07 Jul 2011)
Log Message:
-----------
Allow pose matrix to be set for Benjy Cook's GSOC project.
this uses the same function as pose mode snapping.

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_pose.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_pose.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_pose.c	2011-07-07 15:42:50 UTC (rev 38192)
+++ trunk/blender/source/blender/makesrna/intern/rna_pose.c	2011-07-07 16:09:57 UTC (rev 38193)
@@ -585,6 +585,25 @@
 	pchan_apply_mat4(pchan, (float (*)[4])values, FALSE); /* no compat for predictable result */
 }
 
+static void rna_PoseChannel_matrix_set(PointerRNA *ptr, const float *values)
+{
+	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);
+
+	/* 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 */
+}
+
 #else
 
 static void rna_def_bone_group(BlenderRNA *brna)
@@ -830,8 +849,9 @@
 	prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
 	RNA_def_property_float_sdna(prop, NULL, "pose_mat");
 	RNA_def_property_multi_array(prop, 2, matrix_dimsize);
-	RNA_def_property_clear_flag(prop, PROP_EDITABLE); 
+	RNA_def_property_float_funcs(prop, NULL, "rna_PoseChannel_matrix_set", NULL);
 	RNA_def_property_ui_text(prop, "Pose Matrix", "Final 4x4 matrix after constraints and drivers are applied (object space)");
+	RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update");
 
 	/* Head/Tail Coordinates (in Pose Space) - Automatically calculated... */
 	prop= RNA_def_property(srna, "head", PROP_FLOAT, PROP_TRANSLATION);




More information about the Bf-blender-cvs mailing list