diff options
author | Joshua Leung <aligorith@gmail.com> | 2008-12-19 14:45:46 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2008-12-19 14:45:46 +0300 |
commit | c752ec9fc458f6fd1fc0ae7a156d33bf86e73eff (patch) | |
tree | 8f559ef2cd1ce8a1c4ccee72096f34b1caf3c46f /source/blender/blenkernel/intern/action.c | |
parent | 242695011e71a358f466d4f78df3b9c66d739a64 (diff) |
2.5
Merged 'backend' changes from AnimSys2. Many of these changes are necessary for the Dopesheet and other changes I'm currently still stabilising. Those will come in due course.
Diffstat (limited to 'source/blender/blenkernel/intern/action.c')
-rw-r--r-- | source/blender/blenkernel/intern/action.c | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 1c720cea21f..98f8a83f809 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -299,7 +299,7 @@ void copy_pose(bPose **dst, bPose *src, int copycon) outPose= MEM_callocN(sizeof(bPose), "pose"); - BLI_duplicatelist (&outPose->chanbase, &src->chanbase); + BLI_duplicatelist(&outPose->chanbase, &src->chanbase); if (copycon) { for (pchan=outPose->chanbase.first; pchan; pchan=pchan->next) { @@ -401,7 +401,9 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan VECCOPY(pchan->loc, chan->loc); VECCOPY(pchan->size, chan->size); + VECCOPY(pchan->eul, chan->eul); QUATCOPY(pchan->quat, chan->quat); + pchan->rotmode= chan->rotmode; Mat4CpyMat4(pchan->chan_mat, (float(*)[4])chan->chan_mat); Mat4CpyMat4(pchan->pose_mat, (float(*)[4])chan->pose_mat); pchan->flag= chan->flag; @@ -697,7 +699,6 @@ void blend_poses(bPose *dst, bPose *src, float srcweight, short mode) bPoseChannel *dchan; const bPoseChannel *schan; bConstraint *dcon, *scon; - float dquat[4], squat[4]; float dstweight; int i; @@ -719,23 +720,34 @@ void blend_poses(bPose *dst, bPose *src, float srcweight, short mode) /* Do the transformation blend */ if (schan->flag & POSE_ROT) { - QUATCOPY(dquat, dchan->quat); - QUATCOPY(squat, schan->quat); - if(mode==ACTSTRIPMODE_BLEND) - QuatInterpol(dchan->quat, dquat, squat, srcweight); - else { - QuatMulFac(squat, srcweight); - QuatMul(dchan->quat, dquat, squat); + /* quat interpolation done separate */ + if (schan->rotmode == PCHAN_ROT_QUAT) { + float dquat[4], squat[4]; + + QUATCOPY(dquat, dchan->quat); + QUATCOPY(squat, schan->quat); + if (mode==ACTSTRIPMODE_BLEND) + QuatInterpol(dchan->quat, dquat, squat, srcweight); + else { + QuatMulFac(squat, srcweight); + QuatMul(dchan->quat, dquat, squat); + } + + NormalQuat(dchan->quat); } - - NormalQuat (dchan->quat); } - for (i=0; i<3; i++){ + for (i=0; i<3; i++) { + /* blending for loc and scale are pretty self-explanatory... */ if (schan->flag & POSE_LOC) dchan->loc[i] = (dchan->loc[i]*dstweight) + (schan->loc[i]*srcweight); if (schan->flag & POSE_SIZE) dchan->size[i] = 1.0f + ((dchan->size[i]-1.0f)*dstweight) + ((schan->size[i]-1.0f)*srcweight); + + /* euler-rotation interpolation done here instead... */ + // FIXME: are these results decent? + if ((schan->flag & POSE_ROT) && (schan->rotmode)) + dchan->eul[i] = (dchan->eul[i]*dstweight) + (schan->eul[i]*srcweight); } dchan->flag |= schan->flag; } @@ -749,33 +761,33 @@ void blend_poses(bPose *dst, bPose *src, float srcweight, short mode) dst->ctime= src->ctime; } - +/* Calculate the extents of given action */ void calc_action_range(const bAction *act, float *start, float *end, int incl_hidden) { - const bActionChannel *chan; - const bConstraintChannel *conchan; - const IpoCurve *icu; - float min=999999999.0f, max=-999999999.0; + bActionChannel *chan; + bConstraintChannel *conchan; + IpoCurve *icu; + float min=999999999.0f, max=-999999999.0f; int foundvert=0; - if(act) { + if (act) { for (chan=act->chanbase.first; chan; chan=chan->next) { - if(incl_hidden || (chan->flag & ACHAN_HIDDEN)==0) { - if(chan->ipo) { + if ((incl_hidden) || (chan->flag & ACHAN_HIDDEN)==0) { + if (chan->ipo) { for (icu=chan->ipo->curve.first; icu; icu=icu->next) { - if(icu->totvert) { - min= MIN2 (min, icu->bezt[0].vec[1][0]); - max= MAX2 (max, icu->bezt[icu->totvert-1].vec[1][0]); + if (icu->totvert) { + min= MIN2(min, icu->bezt[0].vec[1][0]); + max= MAX2(max, icu->bezt[icu->totvert-1].vec[1][0]); foundvert=1; } } } for (conchan=chan->constraintChannels.first; conchan; conchan=conchan->next) { - if(conchan->ipo) { + if (conchan->ipo) { for (icu=conchan->ipo->curve.first; icu; icu=icu->next) { - if(icu->totvert) { - min= MIN2 (min, icu->bezt[0].vec[1][0]); - max= MAX2 (max, icu->bezt[icu->totvert-1].vec[1][0]); + if (icu->totvert) { + min= MIN2(min, icu->bezt[0].vec[1][0]); + max= MAX2(max, icu->bezt[icu->totvert-1].vec[1][0]); foundvert=1; } } @@ -867,6 +879,7 @@ void rest_pose(bPose *pose) for (i=0; i<3; i++) { pchan->loc[i]= 0.0f; pchan->quat[i+1]= 0.0f; + pchan->eul[i]= 0.0f; pchan->size[i]= 1.0f; } pchan->quat[0]= 1.0f; |