Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-07-07 20:09:57 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-07-07 20:09:57 +0400
commit99736f373c12e7ab91f962c738243bddf2d713c6 (patch)
treee8054311cc964efbcb9980e66919990a254e217e
parent5e6abb8004ad8750bc99f092b79b2bc6922c27eb (diff)
Allow pose matrix to be set for Benjy Cook's GSOC project.
this uses the same function as pose mode snapping.
-rw-r--r--source/blender/makesrna/intern/rna_pose.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 949415fbf29..47c8435cc46 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -585,6 +585,25 @@ static void rna_PoseChannel_matrix_basis_set(PointerRNA *ptr, const float *value
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 @@ static void rna_def_pose_channel(BlenderRNA *brna)
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);