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)
This commit is contained in:
2007-11-22 20:25:59 +00:00
parent a038363124
commit a8aaec6f21
4 changed files with 26 additions and 6 deletions

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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])
{

View File

@@ -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);
}