[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13579] trunk/blender/source/blender: When iserting rotations in poses, the quaternion sometimes rotates exactly
Ton Roosendaal
ton at blender.org
Tue Feb 5 19:11:16 CET 2008
Revision: 13579
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13579
Author: ton
Date: 2008-02-05 19:11:16 +0100 (Tue, 05 Feb 2008)
Log Message:
-----------
When iserting rotations in poses, the quaternion sometimes rotates exactly
the opposite way as you want. Or even worse, you can never really define
which way it rotates (officially it should do shortest path).
This hotkey flips the quaternion (which means it rotates to same position
exactly via the other way). Hotkey ALT+F (flip) in 3d window posemode.
Modified Paths:
--------------
trunk/blender/source/blender/include/BIF_poseobject.h
trunk/blender/source/blender/src/poseobject.c
trunk/blender/source/blender/src/space.c
trunk/blender/source/blender/src/toets.c
Modified: trunk/blender/source/blender/include/BIF_poseobject.h
===================================================================
--- trunk/blender/source/blender/include/BIF_poseobject.h 2008-02-05 17:37:52 UTC (rev 13578)
+++ trunk/blender/source/blender/include/BIF_poseobject.h 2008-02-05 18:11:16 UTC (rev 13579)
@@ -77,5 +77,7 @@
void pose_activate_flipped_bone(void);
void pose_movetolayer(void);
void pose_relax(void);
+void pose_flipquats(void);
+
#endif
Modified: trunk/blender/source/blender/src/poseobject.c
===================================================================
--- trunk/blender/source/blender/src/poseobject.c 2008-02-05 17:37:52 UTC (rev 13578)
+++ trunk/blender/source/blender/src/poseobject.c 2008-02-05 18:11:16 UTC (rev 13579)
@@ -1496,3 +1496,27 @@
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
BIF_undo_push("Relax Pose");
}
+
+/* for use in insertkey, ensure rotation goes other way around */
+void pose_flipquats(void)
+{
+ Object *ob = OBACT;
+ bArmature *arm= ob->data;
+ bPoseChannel *pchan;
+
+ if(ob->pose==NULL)
+ return;
+
+ /* find sel bones */
+ for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ if(pchan->bone && (pchan->bone->flag & BONE_SELECTED) && (pchan->bone->layer & arm->layer)) {
+ /* quaternions have 720 degree range */
+ pchan->quat[0]= -pchan->quat[0];
+ pchan->quat[1]= -pchan->quat[1];
+ pchan->quat[2]= -pchan->quat[2];
+ pchan->quat[3]= -pchan->quat[3];
+ }
+ }
+
+}
+
Modified: trunk/blender/source/blender/src/space.c
===================================================================
--- trunk/blender/source/blender/src/space.c 2008-02-05 17:37:52 UTC (rev 13578)
+++ trunk/blender/source/blender/src/space.c 2008-02-05 18:11:16 UTC (rev 13579)
@@ -1924,6 +1924,11 @@
else
fly();
}
+ else if((G.qual==LR_ALTKEY)) {
+ if(ob && (ob->flag & OB_POSEMODE))
+ if(okee("Flip quaternion rotations"))
+ pose_flipquats();
+ }
else {
if (G.f & (G_VERTEXPAINT|G_WEIGHTPAINT|G_TEXTUREPAINT)){
G.f ^= G_FACESELECT;
Modified: trunk/blender/source/blender/src/toets.c
===================================================================
--- trunk/blender/source/blender/src/toets.c 2008-02-05 17:37:52 UTC (rev 13578)
+++ trunk/blender/source/blender/src/toets.c 2008-02-05 18:11:16 UTC (rev 13579)
@@ -785,6 +785,8 @@
break;
case IKEY:
if(textediting==0 && textspace==0 && !ELEM3(curarea->spacetype, SPACE_FILE, SPACE_IMASEL, SPACE_NODE)) {
+ ob= OBACT;
+
if(G.f & G_SCULPTMODE) return 1;
else if(G.qual==0) {
common_insertkey();
More information about the Bf-blender-cvs
mailing list