From a8aaec6f210626d2beb2d23f297c1a412b047e8e Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 22 Nov 2007 20:25:59 +0000 Subject: [PATCH] Bugfix #7573 NLA Window, Strip blending mode "Add" didn't work at all. It was using very bad quaternion addition. Replaced with proper code. For devs; new is the function QuatMulFac(quat, factor) which allows to multiply a rotation with a value (make it rotate more or less) --- source/blender/blenkernel/intern/action.c | 6 ++++-- source/blender/blenlib/BLI_arithb.h | 3 ++- source/blender/blenlib/intern/arithb.c | 15 +++++++++++++++ source/blender/src/drawipo.c | 8 +++++--- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index bd5e5d612c6..e30d7dd4ac9 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -607,8 +607,10 @@ void blend_poses(bPose *dst, bPose *src, float srcweight, short mode) QUATCOPY(squat, schan->quat); if(mode==ACTSTRIPMODE_BLEND) QuatInterpol(dchan->quat, dquat, squat, srcweight); - else - QuatAdd(dchan->quat, dquat, squat, srcweight); + else { + QuatMulFac(squat, srcweight); + QuatMul(dchan->quat, dquat, squat); + } NormalQuat (dchan->quat); } diff --git a/source/blender/blenlib/BLI_arithb.h b/source/blender/blenlib/BLI_arithb.h index 9e4412d3cd3..32308f89a15 100644 --- a/source/blender/blenlib/BLI_arithb.h +++ b/source/blender/blenlib/BLI_arithb.h @@ -119,6 +119,8 @@ void QuatToEul(float *quat, float *eul); void QuatOne(float *); void QuatMul(float *, float *, float *); void QuatMulVecf(float *q, float *v); +void QuatMulf(float *q, float f); +void QuatMulFac(float *q, float fac); void NormalQuat(float *); void VecRotToQuat(float *vec, float phi, float *quat); @@ -126,7 +128,6 @@ void VecRotToQuat(float *vec, float phi, float *quat); void QuatSub(float *q, float *q1, float *q2); void QuatConj(float *q); void QuatInv(float *q); -void QuatMulf(float *q, float f); float QuatDot(float *q1, float *q2); void QuatCopy(float *q1, float *q2); diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c index 5a37205af01..2888a684af1 100644 --- a/source/blender/blenlib/intern/arithb.c +++ b/source/blender/blenlib/intern/arithb.c @@ -1109,6 +1109,7 @@ void QuatInv(float *q) QuatMulf(q, 1.0f/f); } +/* simple mult */ void QuatMulf(float *q, float f) { q[0] *= f; @@ -1124,6 +1125,20 @@ void QuatSub(float *q, float *q1, float *q2) q2[0]= -q2[0]; } +/* angular mult factor */ +void QuatMulFac(float *q, float fac) +{ + float angle= fac*saacos(q[0]); /* quat[0]= cos(0.5*angle), but now the 0.5 and 2.0 rule out */ + + float co= (float)cos(angle); + float si= (float)sin(angle); + q[0]= co; + Normalize(q+1); + q[1]*= si; + q[2]*= si; + q[3]*= si; + +} void QuatToMat3( float *q, float m[][3]) { diff --git a/source/blender/src/drawipo.c b/source/blender/src/drawipo.c index d9ef3349ec1..9b64d350b9f 100644 --- a/source/blender/src/drawipo.c +++ b/source/blender/src/drawipo.c @@ -2014,7 +2014,7 @@ static char *ipodriver_modeselect_pup(Object *ob) return (string); } -static char *ipodriver_channelselect_pup(void) +static char *ipodriver_channelselect_pup(int is_armature) { static char string[1024]; char *tmp; @@ -2031,7 +2031,8 @@ static char *ipodriver_channelselect_pup(void) tmp+= sprintf(tmp, "|Scale X %%x%d", OB_SIZE_X); tmp+= sprintf(tmp, "|Scale Y %%x%d", OB_SIZE_Y); tmp+= sprintf(tmp, "|Scale Z %%x%d", OB_SIZE_Z); - tmp+= sprintf(tmp, "|Rotation Differance %%x%d", OB_ROT_DIFF); + if(is_armature) + tmp+= sprintf(tmp, "|Rotation Differance %%x%d", OB_ROT_DIFF); return (string); } @@ -2094,7 +2095,8 @@ static void ipo_panel_properties(short cntrl) // IPO_HANDLER_PROPERTIES ipodriver_modeselect_pup(driver->ob), 165,240,145,20, &(driver->blocktype), 0, 0, 0, 0, "Driver type"); uiDefButS(block, MENU, B_IPO_REDR, - ipodriver_channelselect_pup(), 165,220,145,20, &(driver->adrcode), 0, 0, 0, 0, "Driver channel"); + ipodriver_channelselect_pup(driver->ob->type==OB_ARMATURE && driver->blocktype==ID_AR), + 165,220,145,20, &(driver->adrcode), 0, 0, 0, 0, "Driver channel"); } uiBlockEndAlign(block); }