diff options
author | Ton Roosendaal <ton@blender.org> | 2005-12-17 13:08:57 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-12-17 13:08:57 +0300 |
commit | e506a34bf860cf0cdc0b423e1f5635390359c125 (patch) | |
tree | f443353c2dde4f3f55322759a56ca6a3d622ea9d /source/blender | |
parent | 466ef7667b580ee58ceeff965a16da24fd4aa1a7 (diff) |
Orange:
For some ancient reason, the stride option only worked on a single strip,
and extended always. This made it nearly impossible to integrate it well
with other actions in NLA.
This commit changes it as follows;
- As any strip, the striding-strip also stops at the end of a strip
- This allows to put multiple different actions on a single path, and if
all of these have the striding option set, the actions will each do their
own individual stride.
- To match the different actions, a new "Action Offset" button was added
in the NLA Panel, which allows to internally cycle the action.
- Of course, blend-in and blend-out works nicely too.
Here's a quick AVI test with 2 actions. There's some slipping of the feet
between actions still, because of the stridebone blending. I might look
at that later, for now you can correct it with a simple Ipo on Armature too
http://www.blender.org/bf/0007_0151.avi
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/action.c | 135 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_nla_types.h | 1 | ||||
-rw-r--r-- | source/blender/src/drawnla.c | 16 |
3 files changed, 80 insertions, 72 deletions
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index d6bca577013..316f7c26926 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -769,11 +769,14 @@ static float stridechannel_frame(Object *ob, bActionStrip *strip, Path *path, fl if(foundvert && miny!=maxy) { float stridelen= fabs(maxy-miny), striptime; - float actiondist, pdist, pdistNewNormalized; + float actiondist, pdist, pdistNewNormalized, offs; float vec1[4], vec2[4], dir[3]; + /* internal cycling, actoffs is in frames */ + offs= stridelen*strip->actoffs/(maxx-minx); + /* amount path moves object */ - pdist = (float)fmod (pathdist, stridelen); + pdist = (float)fmod (pathdist+offs, stridelen); striptime= pdist/stridelen; /* amount stride bone moves */ @@ -837,74 +840,78 @@ static void do_nla(Object *ob, int blocktype) if(blocktype==ID_AR) rest_pose(tpose); - /* Handle path */ - if ((strip->flag & ACTSTRIP_USESTRIDE) && (blocktype==ID_AR) && (ob->ipoflag & OB_DISABLE_PATH)==0){ - if (ob->parent && ob->parent->type==OB_CURVE){ - Curve *cu = ob->parent->data; - float ctime, pdist; - - if (cu->flag & CU_PATH){ - /* Ensure we have a valid path */ - if(cu->path==NULL || cu->path->data==NULL) makeDispListCurveTypes(ob->parent, 0); - if(cu->path) { - - /* Find the position on the path */ - ctime= bsystem_time(ob, ob->parent, (float)G.scene->r.cfra, 0.0); - - if(calc_ipo_spec(cu->ipo, CU_SPEED, &ctime)==0) { - ctime /= cu->pathlen; - CLAMP(ctime, 0.0, 1.0); - } - pdist = ctime*cu->path->totdist; - - if(tpose && strip->stridechannel[0]) { - striptime= stridechannel_frame(ob->parent, strip, cu->path, pdist, tpose->stride_offset); - } - else { - if (strip->stridelen) { - striptime = pdist / strip->stridelen; - striptime = (float)fmod (striptime, 1.0); + /* To handle repeat, we add 0.1 frame extra to make sure the last frame is included */ + if (striptime < 1.0f + 0.1f/length) { + + /* Handle path */ + if ((strip->flag & ACTSTRIP_USESTRIDE) && (blocktype==ID_AR) && (ob->ipoflag & OB_DISABLE_PATH)==0){ + if (ob->parent && ob->parent->type==OB_CURVE){ + Curve *cu = ob->parent->data; + float ctime, pdist; + + if (cu->flag & CU_PATH){ + /* Ensure we have a valid path */ + if(cu->path==NULL || cu->path->data==NULL) makeDispListCurveTypes(ob->parent, 0); + if(cu->path) { + + /* Find the position on the path */ + ctime= bsystem_time(ob, ob->parent, (float)G.scene->r.cfra, 0.0); + + if(calc_ipo_spec(cu->ipo, CU_SPEED, &ctime)==0) { + ctime /= cu->pathlen; + CLAMP(ctime, 0.0, 1.0); } - else - striptime = 0; - } - - frametime = (striptime * actlength) + strip->actstart; - frametime= bsystem_time(ob, 0, frametime, 0.0); - - if(blocktype==ID_AR) { - extract_pose_from_action (tpose, strip->act, frametime); - } - else if(blocktype==ID_OB) { - extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime); - if(key) - extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime); + pdist = ctime*cu->path->totdist; + + if(tpose && strip->stridechannel[0]) { + striptime= stridechannel_frame(ob->parent, strip, cu->path, pdist, tpose->stride_offset); + } + else { + if (strip->stridelen) { + striptime = pdist / strip->stridelen; + striptime = (float)fmod (striptime+strip->actoffs, 1.0); + } + else + striptime = 0; + } + + frametime = (striptime * actlength) + strip->actstart; + frametime= bsystem_time(ob, 0, frametime, 0.0); + + if(blocktype==ID_AR) { + extract_pose_from_action (tpose, strip->act, frametime); + } + else if(blocktype==ID_OB) { + extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime); + if(key) + extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime); + } + doit=dostride= 1; } - doit=dostride= 1; } } } - } - /* Handle repeat, we add 0.1 frame extra to make sure the last frame is included */ - else if (striptime < 1.0f + 0.1f/length) { - - /* Mod to repeat */ - if(strip->repeat!=1.0f) { - striptime*= strip->repeat; - striptime = (float)fmod (striptime, 1.0f + 0.1f/length); - } - - frametime = (striptime * actlength) + strip->actstart; - frametime= nla_time(frametime, (float)strip->repeat); + /* To handle repeat, we add 0.1 frame extra to make sure the last frame is included */ + else { - if(blocktype==ID_AR) - extract_pose_from_action (tpose, strip->act, frametime); - else if(blocktype==ID_OB) { - extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime); - if(key) - extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime); - } - doit=1; + /* Mod to repeat */ + if(strip->repeat!=1.0f) { + striptime*= strip->repeat; + striptime = (float)fmod (striptime, 1.0f + 0.1f/length); + } + + frametime = (striptime * actlength) + strip->actstart; + frametime= nla_time(frametime, (float)strip->repeat); + + if(blocktype==ID_AR) + extract_pose_from_action (tpose, strip->act, frametime); + else if(blocktype==ID_OB) { + extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime); + if(key) + extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime); + } + doit=1; + } } /* Handle extend */ else{ diff --git a/source/blender/makesdna/DNA_nla_types.h b/source/blender/makesdna/DNA_nla_types.h index fa1a4fbe456..fe01fa91eb2 100644 --- a/source/blender/makesdna/DNA_nla_types.h +++ b/source/blender/makesdna/DNA_nla_types.h @@ -47,6 +47,7 @@ typedef struct bActionStrip { struct Object *object; /* For groups, the actual object being nla'ed */ float start, end; /* The range of frames covered by this strip */ float actstart, actend; /* The range of frames taken from the action */ + float actoffs, padf; /* Offset within action, for cycles and striding */ float stridelen; /* The stridelength (considered when flag & ACT_USESTRIDE) */ float repeat; /* The number of times to repeat the action range */ diff --git a/source/blender/src/drawnla.c b/source/blender/src/drawnla.c index bb6e77bc507..1c83c69a548 100644 --- a/source/blender/src/drawnla.c +++ b/source/blender/src/drawnla.c @@ -463,7 +463,6 @@ static void nla_panel_properties(short cntrl) // NLA_HANDLER_PROPERTIES uiDefBut(block, LABEL, 0, "Timeline Range:", 10,180,300,19, 0, 0, 0, 0, 0, ""); uiDefBut(block, LABEL, 0, "Blending:", 10,120,150,19, 0, 0, 0, 0, 0, ""); uiDefBut(block, LABEL, 0, "Options:", 160,120,150,19, 0, 0, 0, 0, 0, ""); - uiDefBut(block, LABEL, 0, "Stride Support:", 10,40,300,19, 0, 0, 0, 0, 0, ""); uiBlockBeginAlign(block); uiDefButF(block, NUM, B_NLA_PANEL, "Strip Start:", 10,160,150,19, &strip->start, -1000.0, strip->end-1, 100, 0, "First frame in the timeline"); @@ -483,7 +482,7 @@ static void nla_panel_properties(short cntrl) // NLA_HANDLER_PROPERTIES } uiBlockBeginAlign(block); - uiDefButF(block, NUM, B_NLA_PANEL, "Blendin:", 10,100,156,19, &strip->blendin, 0.0, strip->actend-strip->actstart, 100, 0, "Number of frames of ease-in"); + uiDefButF(block, NUM, B_NLA_PANEL, "Blendin:", 10,100,145,19, &strip->blendin, 0.0, strip->actend-strip->actstart, 100, 0, "Number of frames of ease-in"); uiDefButF(block, NUM, B_NLA_PANEL, "Blendout:", 10,80,145,19, &strip->blendout, 0.0, strip->actend-strip->actstart, 100, 0, "Number of frames of ease-out"); uiBlockBeginAlign(block); @@ -492,14 +491,15 @@ static void nla_panel_properties(short cntrl) // NLA_HANDLER_PROPERTIES uiDefButS(block, TOG, B_NLA_PANEL, "Add", 235,80,75,19, &strip->mode, 0, 0, 0, 0, "Toggles additive blending mode"); uiBlockEndAlign(block); - if(ob->dup_group) { - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_NLA_PANEL, "Target:", 160, 50, 150, 19, &strip->object, "Target Object in this group"); - } + uiDefButBitS(block, TOG, ACTSTRIP_USESTRIDE, B_NLA_PANEL, "Stride Path", 10, 50,140,19, &strip->flag, 0, 0, 0, 0, "Plays action based on path position & stride"); + if(ob->dup_group) + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_NLA_PANEL, "Target:", 160,50, 150, 19, &strip->object, "Target Object in this group"); uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, ACTSTRIP_USESTRIDE, B_NLA_PANEL, "Stride Path", 10,20,100,19, &strip->flag, 0, 0, 0, 0, "Plays action based on path position & stride"); - uiDefButBitS(block, TOG, OB_DISABLE_PATH, B_NLA_PANEL, "Disable Path", 110,20,100,19, &ob->ipoflag, 0, 0, 0, 0, "Plays action based on path position & stride"); - uiDefButF(block, NUM, B_NLA_PANEL, "Stride:", 210,20,100,19, &strip->stridelen, 0.0001, 1000.0, 100, 0, "Distance covered by one complete cycle of the action specified in the Action Range"); + uiDefButBitS(block, TOG, OB_DISABLE_PATH, B_NLA_PANEL, "Disable", 10,20,60,19, &ob->ipoflag, 0, 0, 0, 0, "Disable path temporally, for editing cycles"); + + uiDefButF(block, NUM, B_NLA_PANEL, "Offs:", 70,20,120,19, &strip->actoffs, -500, 500.0, 100, 0, "Action offset in frames to tweak cycle of the action within the stride"); + uiDefButF(block, NUM, B_NLA_PANEL, "Stri:", 190,20,120,19, &strip->stridelen, 0.0001, 1000.0, 100, 0, "Distance covered by one complete cycle of the action specified in the Action Range"); uiDefButS(block, ROW, B_NLA_PANEL, "X", 10, 0, 33, 19, &strip->stride_axis, 1, 0, 0, 0, "Dominant axis for Stride Bone"); uiDefButS(block, ROW, B_NLA_PANEL, "Y", 43, 0, 33, 19, &strip->stride_axis, 1, 1, 0, 0, "Dominant axis for Stride Bone"); |