diff options
author | Ton Roosendaal <ton@blender.org> | 2008-02-05 21:11:16 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2008-02-05 21:11:16 +0300 |
commit | 217b3647b1a1d56390b0795a59c7f82bc6e1d93a (patch) | |
tree | ad9d22abe10816c85f4ab49c8bee275d556e7bbf /source/blender | |
parent | e04d7128cdbcaf05bb3e0b6127eb142e525ac377 (diff) |
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.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/include/BIF_poseobject.h | 2 | ||||
-rw-r--r-- | source/blender/src/poseobject.c | 24 | ||||
-rw-r--r-- | source/blender/src/space.c | 5 | ||||
-rw-r--r-- | source/blender/src/toets.c | 2 |
4 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/include/BIF_poseobject.h b/source/blender/include/BIF_poseobject.h index d0f4428f3f8..9f50257c953 100644 --- a/source/blender/include/BIF_poseobject.h +++ b/source/blender/include/BIF_poseobject.h @@ -77,5 +77,7 @@ void pose_autoside_names(short axis); void pose_activate_flipped_bone(void); void pose_movetolayer(void); void pose_relax(void); +void pose_flipquats(void); + #endif diff --git a/source/blender/src/poseobject.c b/source/blender/src/poseobject.c index fab2dc9d20c..ffba3c8cb05 100644 --- a/source/blender/src/poseobject.c +++ b/source/blender/src/poseobject.c @@ -1496,3 +1496,27 @@ void pose_relax() 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]; + } + } + +} + diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 187cb1c9ef0..b403b2c2f82 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -1924,6 +1924,11 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) 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; diff --git a/source/blender/src/toets.c b/source/blender/src/toets.c index 088d91f7418..230e8b69de9 100644 --- a/source/blender/src/toets.c +++ b/source/blender/src/toets.c @@ -785,6 +785,8 @@ int blenderqread(unsigned short event, short val) 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(); |