[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32647] trunk/blender/source/blender/ blenkernel/intern/armature.c: [#21331] Pose snap not working in some cases
Campbell Barton
ideasman42 at gmail.com
Fri Oct 22 08:25:35 CEST 2010
Revision: 32647
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32647
Author: campbellbarton
Date: 2010-10-22 08:25:14 +0200 (Fri, 22 Oct 2010)
Log Message:
-----------
[#21331] Pose snap not working in some cases
The bone option 'Local Location' (flag BONE_NO_LOCAL_LOCATION) makes the location apply differently so snap to cursor failed for pose bones.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/armature.c
Modified: trunk/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/armature.c 2010-10-22 06:00:12 UTC (rev 32646)
+++ trunk/blender/source/blender/blenkernel/intern/armature.c 2010-10-22 06:25:14 UTC (rev 32647)
@@ -1105,29 +1105,50 @@
{
float pc_trans[4][4], inv_trans[4][4];
float pc_posemat[4][4], inv_posemat[4][4];
-
+ float pose_mat[4][4];
+
/* paranoia: prevent crashes with no pose-channel supplied */
if (pchan==NULL) return;
- /* get the inverse matrix of the pchan's transforms */
- 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);
+ /* default flag */
+ if((pchan->bone->flag & BONE_NO_LOCAL_LOCATION)==0) {
+ /* get the inverse matrix of the pchan's transforms */
+ 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);
+ }
+
+ copy_m4_m4(pose_mat, pchan->pose_mat);
}
+ else {
+ /* local location, this is not default, different calculation
+ * note: only tested for location with pose bone snapping.
+ * If this is not useful in other cases the BONE_NO_LOCAL_LOCATION
+ * case may have to be split into its own function. */
+ unit_m4(pc_trans);
+ copy_v3_v3(pc_trans[3], pchan->loc);
+ /* use parents rotation/scale space + own absolute position */
+ if(pchan->parent) copy_m4_m4(pose_mat, pchan->parent->pose_mat);
+ else unit_m4(pose_mat);
+
+ copy_v3_v3(pose_mat[3], pchan->pose_mat[3]);
+ }
+
+
invert_m4_m4(inv_trans, pc_trans);
/* Remove the pchan's transforms from it's pose_mat.
* This should leave behind the effects of restpose +
* parenting + constraints
*/
- mul_m4_m4m4(pc_posemat, inv_trans, pchan->pose_mat);
+ mul_m4_m4m4(pc_posemat, inv_trans, pose_mat);
/* get the inverse of the leftovers so that we can remove
* that component from the supplied matrix
More information about the Bf-blender-cvs
mailing list