2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-01-07 19:13:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
2009-05-22 01:16:26 +00:00
|
|
|
* The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
|
2002-10-12 11:37:38 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
2009-05-22 01:16:26 +00:00
|
|
|
* Contributor(s): Joshua Leung (full recode)
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2011-02-27 20:40:57 +00:00
|
|
|
/** \file blender/blenkernel/intern/nla.c
|
|
|
|
* \ingroup bke
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <stdlib.h>
|
2009-05-22 01:16:26 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdio.h>
|
2009-07-10 23:25:30 +00:00
|
|
|
#include <string.h>
|
2009-05-22 01:16:26 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include <float.h>
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-02-18 15:57:46 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2011-10-20 13:50:24 +00:00
|
|
|
#include "BLI_path_util.h"
|
|
|
|
#include "BLI_listbase.h"
|
|
|
|
#include "BLI_string.h"
|
2009-07-10 23:25:30 +00:00
|
|
|
#include "BLI_ghash.h"
|
2006-02-18 15:57:46 +00:00
|
|
|
|
2013-03-25 08:29:06 +00:00
|
|
|
#include "BLF_translation.h"
|
|
|
|
|
2009-05-22 01:16:26 +00:00
|
|
|
#include "DNA_anim_types.h"
|
2010-04-01 06:26:41 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2011-08-07 12:27:20 +00:00
|
|
|
#include "DNA_sound_types.h"
|
|
|
|
#include "DNA_speaker_types.h"
|
2006-02-18 15:57:46 +00:00
|
|
|
|
|
|
|
#include "BKE_action.h"
|
2009-05-22 01:16:26 +00:00
|
|
|
#include "BKE_fcurve.h"
|
|
|
|
#include "BKE_nla.h"
|
2010-04-01 06:26:41 +00:00
|
|
|
#include "BKE_global.h"
|
2006-02-18 15:57:46 +00:00
|
|
|
#include "BKE_library.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2011-08-07 12:27:20 +00:00
|
|
|
#ifdef WITH_AUDASPACE
|
|
|
|
# include "AUD_C-API.h"
|
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-06-23 13:25:31 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "nla_private.h"
|
|
|
|
|
2006-02-18 15:57:46 +00:00
|
|
|
|
Big commit with work on Groups & Libraries:
-> Any Group Duplicate now can get local timing and local NLA override. This
enables to control the entire animation system of the Group.
Two methods for this have been implemented.
1) The quick way: just give the duplicator a "Startframe" offset.
2) Advanced: in the NLA Editor you can add ActionStrips to the duplicator
to override NLA/action of any Grouped Object.
For "Group NLA" to work, an ActionStrip needs to know which Object in a
group it controls. On adding a strip, the code checks if an Action was
already used by an Object in the Group, and assigns it automatic to that
Object.
You can also set this in the Nkey "Properties" panel for the strip.
Change in NLA: the SHIFT+A "Add strip" command now always adds strips to
the active Object. (It used to check where mouse was). This allows to add
NLA strips to Objects that didn't have actions/nla yet.
Important note: In Blender, duplicates are fully procedural and generated
on the fly for each redraw. This means that redraw speed equals to stepping
through frames, when using animated Duplicated Groups.
-> Recoded entire duplicator system
The old method was antique and clumsy, using globals and full temporal
copies of Object. The new system is nicer in control, faster, and since it
doesn't use temporal object copies anymore, it works better with Derived
Mesh and DisplayList and rendering.
By centralizing the code for duplicating, more options can be easier added.
Features to note:
- Duplicates now draw selected/unselected based on its Duplicator setting.
- Same goes for the drawtype (wire, solid, selection outline, etc)
- Duplicated Groups can be normally selected too
Bonus goodie: SHIFT+A (Toolbox) now has entry "Add group" too, with a
listing of all groups, allowing to add Group instances immediate.
-> Library System
- SHIFT+F4 data browse now shows the entire path for linked data
- Outliner draws Library Icons to denote linked data
- Outliner operation added: "Make Local" for library data.
- Outliner now also draws Groups in regular view, allowing to unlink too.
-> Fixes
- depsgraph missed signal update for bone-parented Objects
- on reading file, the entire database was tagged to "recalc" fully,
causing unnecessary slowdown on reading.
Might have missed stuff... :)
2005-12-11 13:23:30 +00:00
|
|
|
|
2009-05-22 01:16:26 +00:00
|
|
|
/* *************************************************** */
|
|
|
|
/* Data Management */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-05-22 01:16:26 +00:00
|
|
|
/* Freeing ------------------------------------------- */
|
|
|
|
|
|
|
|
/* Remove the given NLA strip from the NLA track it occupies, free the strip's data,
|
|
|
|
* and the strip itself.
|
|
|
|
*/
|
2012-04-29 17:11:40 +00:00
|
|
|
void free_nlastrip(ListBase *strips, NlaStrip *strip)
|
2009-05-22 01:16:26 +00:00
|
|
|
{
|
2009-07-06 03:44:44 +00:00
|
|
|
NlaStrip *cs, *csn;
|
|
|
|
|
2009-05-22 01:16:26 +00:00
|
|
|
/* sanity checks */
|
|
|
|
if (strip == NULL)
|
2002-10-12 11:37:38 +00:00
|
|
|
return;
|
2009-05-22 01:16:26 +00:00
|
|
|
|
2009-07-06 03:44:44 +00:00
|
|
|
/* free child-strips */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (cs = strip->strips.first; cs; cs = csn) {
|
|
|
|
csn = cs->next;
|
2009-07-06 03:44:44 +00:00
|
|
|
free_nlastrip(&strip->strips, cs);
|
|
|
|
}
|
|
|
|
|
2009-05-22 01:16:26 +00:00
|
|
|
/* remove reference to action */
|
|
|
|
if (strip->act)
|
2011-01-19 23:05:02 +00:00
|
|
|
id_us_min(&strip->act->id);
|
2009-05-22 01:16:26 +00:00
|
|
|
|
|
|
|
/* free remapping info */
|
|
|
|
//if (strip->remap)
|
|
|
|
// BKE_animremap_free();
|
|
|
|
|
|
|
|
/* free own F-Curves */
|
|
|
|
free_fcurves(&strip->fcurves);
|
|
|
|
|
2009-07-02 05:25:14 +00:00
|
|
|
/* free own F-Modifiers */
|
|
|
|
free_fmodifiers(&strip->modifiers);
|
2009-05-22 01:16:26 +00:00
|
|
|
|
|
|
|
/* free the strip itself */
|
|
|
|
if (strips)
|
|
|
|
BLI_freelinkN(strips, strip);
|
|
|
|
else
|
|
|
|
MEM_freeN(strip);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-05-22 01:16:26 +00:00
|
|
|
/* Remove the given NLA track from the set of NLA tracks, free the track's data,
|
|
|
|
* and the track itself.
|
|
|
|
*/
|
2012-04-29 17:11:40 +00:00
|
|
|
void free_nlatrack(ListBase *tracks, NlaTrack *nlt)
|
2009-05-22 01:16:26 +00:00
|
|
|
{
|
|
|
|
NlaStrip *strip, *stripn;
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
|
2009-05-22 01:16:26 +00:00
|
|
|
/* sanity checks */
|
|
|
|
if (nlt == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* free strips */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (strip = nlt->strips.first; strip; strip = stripn) {
|
|
|
|
stripn = strip->next;
|
2009-05-22 01:16:26 +00:00
|
|
|
free_nlastrip(&nlt->strips, strip);
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 01:16:26 +00:00
|
|
|
/* free NLA track itself now */
|
|
|
|
if (tracks)
|
|
|
|
BLI_freelinkN(tracks, nlt);
|
|
|
|
else
|
|
|
|
MEM_freeN(nlt);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 01:16:26 +00:00
|
|
|
/* Free the elements of type NLA Tracks provided in the given list, but do not free
|
|
|
|
* the list itself since that is not free-standing
|
|
|
|
*/
|
2012-04-29 17:11:40 +00:00
|
|
|
void free_nladata(ListBase *tracks)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2009-05-22 01:16:26 +00:00
|
|
|
NlaTrack *nlt, *nltn;
|
|
|
|
|
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, tracks, tracks->first))
|
2002-10-12 11:37:38 +00:00
|
|
|
return;
|
2009-05-22 01:16:26 +00:00
|
|
|
|
|
|
|
/* free tracks one by one */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (nlt = tracks->first; nlt; nlt = nltn) {
|
|
|
|
nltn = nlt->next;
|
2009-05-22 01:16:26 +00:00
|
|
|
free_nlatrack(tracks, nlt);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2009-05-22 01:16:26 +00:00
|
|
|
|
|
|
|
/* clear the list's pointers to be safe */
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(tracks);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 01:16:26 +00:00
|
|
|
/* Copying ------------------------------------------- */
|
|
|
|
|
2014-05-29 21:16:04 +10:00
|
|
|
/**
|
|
|
|
* Copy NLA strip
|
|
|
|
*
|
|
|
|
* \param use_same_action When true, the existing action is used (instead of being duplicated)
|
2014-04-29 00:07:15 +12:00
|
|
|
*/
|
|
|
|
NlaStrip *copy_nlastrip(NlaStrip *strip, const bool use_same_action)
|
2009-05-23 09:36:18 +00:00
|
|
|
{
|
|
|
|
NlaStrip *strip_d;
|
2009-07-06 03:44:44 +00:00
|
|
|
NlaStrip *cs, *cs_d;
|
2009-05-23 09:36:18 +00:00
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
if (strip == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* make a copy */
|
2012-05-12 16:11:34 +00:00
|
|
|
strip_d = MEM_dupallocN(strip);
|
|
|
|
strip_d->next = strip_d->prev = NULL;
|
2009-05-23 09:36:18 +00:00
|
|
|
|
2014-04-29 00:07:15 +12:00
|
|
|
/* handle action */
|
|
|
|
if (strip_d->act) {
|
|
|
|
if (use_same_action) {
|
|
|
|
/* increase user-count of action */
|
|
|
|
id_us_plus(&strip_d->act->id);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* use a copy of the action instead (user count shouldn't have changed yet) */
|
|
|
|
strip_d->act = BKE_action_copy(strip_d->act);
|
|
|
|
}
|
|
|
|
}
|
2009-05-23 09:36:18 +00:00
|
|
|
|
|
|
|
/* copy F-Curves and modifiers */
|
|
|
|
copy_fcurves(&strip_d->fcurves, &strip->fcurves);
|
2009-07-02 05:25:14 +00:00
|
|
|
copy_fmodifiers(&strip_d->modifiers, &strip->modifiers);
|
2009-05-23 09:36:18 +00:00
|
|
|
|
2009-07-06 03:44:44 +00:00
|
|
|
/* make a copy of all the child-strips, one at a time */
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(&strip_d->strips);
|
2009-07-06 03:44:44 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (cs = strip->strips.first; cs; cs = cs->next) {
|
2014-04-29 00:07:15 +12:00
|
|
|
cs_d = copy_nlastrip(cs, use_same_action);
|
2009-07-06 03:44:44 +00:00
|
|
|
BLI_addtail(&strip_d->strips, cs_d);
|
|
|
|
}
|
|
|
|
|
2009-05-23 09:36:18 +00:00
|
|
|
/* return the strip */
|
|
|
|
return strip_d;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy NLA Track */
|
2014-04-29 00:07:15 +12:00
|
|
|
NlaTrack *copy_nlatrack(NlaTrack *nlt, const bool use_same_actions)
|
2009-05-23 09:36:18 +00:00
|
|
|
{
|
|
|
|
NlaStrip *strip, *strip_d;
|
|
|
|
NlaTrack *nlt_d;
|
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
if (nlt == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* make a copy */
|
2012-05-12 16:11:34 +00:00
|
|
|
nlt_d = MEM_dupallocN(nlt);
|
|
|
|
nlt_d->next = nlt_d->prev = NULL;
|
2009-05-23 09:36:18 +00:00
|
|
|
|
|
|
|
/* make a copy of all the strips, one at a time */
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(&nlt_d->strips);
|
2009-05-23 09:36:18 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (strip = nlt->strips.first; strip; strip = strip->next) {
|
2014-04-29 00:07:15 +12:00
|
|
|
strip_d = copy_nlastrip(strip, use_same_actions);
|
2009-05-23 09:36:18 +00:00
|
|
|
BLI_addtail(&nlt_d->strips, strip_d);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return the copy */
|
|
|
|
return nlt_d;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy all NLA data */
|
2012-04-29 17:11:40 +00:00
|
|
|
void copy_nladata(ListBase *dst, ListBase *src)
|
2009-05-23 09:36:18 +00:00
|
|
|
{
|
|
|
|
NlaTrack *nlt, *nlt_d;
|
|
|
|
|
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, dst, src))
|
2009-05-23 09:36:18 +00:00
|
|
|
return;
|
|
|
|
|
2009-09-30 04:59:14 +00:00
|
|
|
/* clear out the destination list first for precautions... */
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(dst);
|
2009-09-30 04:59:14 +00:00
|
|
|
|
2009-05-23 09:36:18 +00:00
|
|
|
/* copy each NLA-track, one at a time */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (nlt = src->first; nlt; nlt = nlt->next) {
|
2009-05-23 09:36:18 +00:00
|
|
|
/* make a copy, and add the copy to the destination list */
|
2014-04-29 00:07:15 +12:00
|
|
|
// XXX: we need to fix this sometime
|
|
|
|
nlt_d = copy_nlatrack(nlt, true);
|
2009-05-23 09:36:18 +00:00
|
|
|
BLI_addtail(dst, nlt_d);
|
|
|
|
}
|
|
|
|
}
|
2009-05-22 01:16:26 +00:00
|
|
|
|
|
|
|
/* Adding ------------------------------------------- */
|
|
|
|
|
2009-06-11 03:19:08 +00:00
|
|
|
/* Add a NLA Track to the given AnimData
|
|
|
|
* - prev: NLA-Track to add the new one after
|
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
NlaTrack *add_nlatrack(AnimData *adt, NlaTrack *prev)
|
2009-05-31 04:52:20 +00:00
|
|
|
{
|
|
|
|
NlaTrack *nlt;
|
|
|
|
|
|
|
|
/* sanity checks */
|
|
|
|
if (adt == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* allocate new track */
|
2012-05-12 16:11:34 +00:00
|
|
|
nlt = MEM_callocN(sizeof(NlaTrack), "NlaTrack");
|
2009-05-31 04:52:20 +00:00
|
|
|
|
|
|
|
/* set settings requiring the track to not be part of the stack yet */
|
|
|
|
nlt->flag = NLATRACK_SELECTED;
|
2014-11-16 13:57:58 +01:00
|
|
|
nlt->index = BLI_listbase_count(&adt->nla_tracks);
|
2009-05-31 04:52:20 +00:00
|
|
|
|
|
|
|
/* add track to stack, and make it the active one */
|
2009-06-11 03:19:08 +00:00
|
|
|
if (prev)
|
|
|
|
BLI_insertlinkafter(&adt->nla_tracks, prev, nlt);
|
|
|
|
else
|
|
|
|
BLI_addtail(&adt->nla_tracks, nlt);
|
2009-05-31 04:52:20 +00:00
|
|
|
BKE_nlatrack_set_active(&adt->nla_tracks, nlt);
|
|
|
|
|
|
|
|
/* must have unique name, but we need to seed this */
|
2010-02-18 10:14:49 +00:00
|
|
|
strcpy(nlt->name, "NlaTrack");
|
2013-03-25 08:29:06 +00:00
|
|
|
BLI_uniquename(&adt->nla_tracks, nlt, DATA_("NlaTrack"), '.', offsetof(NlaTrack, name), sizeof(nlt->name));
|
2009-05-31 04:52:20 +00:00
|
|
|
|
|
|
|
/* return the new track */
|
|
|
|
return nlt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add a NLA Strip referencing the given Action */
|
2012-05-12 16:11:34 +00:00
|
|
|
NlaStrip *add_nlastrip(bAction *act)
|
2006-02-08 16:58:12 +00:00
|
|
|
{
|
2009-05-22 01:16:26 +00:00
|
|
|
NlaStrip *strip;
|
|
|
|
|
|
|
|
/* sanity checks */
|
2009-05-31 04:52:20 +00:00
|
|
|
if (act == NULL)
|
2009-05-22 01:16:26 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* allocate new strip */
|
2012-05-12 16:11:34 +00:00
|
|
|
strip = MEM_callocN(sizeof(NlaStrip), "NlaStrip");
|
2009-05-22 01:16:26 +00:00
|
|
|
|
|
|
|
/* generic settings
|
|
|
|
* - selected flag to highlight this to the user
|
2015-02-28 02:43:44 +13:00
|
|
|
* - (XXX) disabled Auto-Blends, as this was often causing some unwanted effects
|
2012-03-01 12:20:18 +00:00
|
|
|
* - (XXX) synchronization of strip-length in accordance with changes to action-length
|
2009-05-22 01:16:26 +00:00
|
|
|
* is not done though, since this should only really happens in editmode for strips now
|
|
|
|
* though this decision is still subject to further review...
|
|
|
|
*/
|
2015-02-28 02:43:44 +13:00
|
|
|
strip->flag = NLASTRIP_FLAG_SELECT;
|
2009-05-22 01:16:26 +00:00
|
|
|
|
|
|
|
/* assign the action reference */
|
2012-05-12 16:11:34 +00:00
|
|
|
strip->act = act;
|
2009-05-22 01:16:26 +00:00
|
|
|
id_us_plus(&act->id);
|
|
|
|
|
|
|
|
/* determine initial range
|
|
|
|
* - strip length cannot be 0... ever...
|
|
|
|
*/
|
2009-08-25 01:46:05 +00:00
|
|
|
calc_action_range(strip->act, &strip->actstart, &strip->actend, 0);
|
2009-05-22 01:16:26 +00:00
|
|
|
|
|
|
|
strip->start = strip->actstart;
|
2012-05-12 16:11:34 +00:00
|
|
|
strip->end = (IS_EQF(strip->actstart, strip->actend)) ? (strip->actstart + 1.0f) : (strip->actend);
|
2009-05-22 01:16:26 +00:00
|
|
|
|
|
|
|
/* strip should be referenced as-is */
|
2012-05-12 16:11:34 +00:00
|
|
|
strip->scale = 1.0f;
|
2009-05-22 01:16:26 +00:00
|
|
|
strip->repeat = 1.0f;
|
|
|
|
|
|
|
|
/* return the new strip */
|
|
|
|
return strip;
|
2006-02-08 16:58:12 +00:00
|
|
|
}
|
|
|
|
|
2009-05-31 04:52:20 +00:00
|
|
|
/* Add new NLA-strip to the top of the NLA stack - i.e. into the last track if space, or a new one otherwise */
|
2012-05-12 16:11:34 +00:00
|
|
|
NlaStrip *add_nlastrip_to_stack(AnimData *adt, bAction *act)
|
2006-02-08 16:58:12 +00:00
|
|
|
{
|
2009-06-19 04:45:56 +00:00
|
|
|
NlaStrip *strip;
|
2009-05-22 01:16:26 +00:00
|
|
|
NlaTrack *nlt;
|
|
|
|
|
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, adt, act))
|
2009-05-22 01:16:26 +00:00
|
|
|
return NULL;
|
|
|
|
|
2009-05-31 04:52:20 +00:00
|
|
|
/* create a new NLA strip */
|
2012-05-12 16:11:34 +00:00
|
|
|
strip = add_nlastrip(act);
|
2009-05-31 04:52:20 +00:00
|
|
|
if (strip == NULL)
|
|
|
|
return NULL;
|
2009-05-22 01:16:26 +00:00
|
|
|
|
2009-06-19 04:45:56 +00:00
|
|
|
/* firstly try adding strip to last track, but if that fails, add to a new track */
|
|
|
|
if (BKE_nlatrack_add_strip(adt->nla_tracks.last, strip) == 0) {
|
|
|
|
/* trying to add to the last track failed (no track or no space),
|
|
|
|
* so add a new track to the stack, and add to that...
|
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
nlt = add_nlatrack(adt, NULL);
|
2009-06-19 04:45:56 +00:00
|
|
|
BKE_nlatrack_add_strip(nlt, strip);
|
2009-05-31 04:52:20 +00:00
|
|
|
}
|
2009-05-22 01:16:26 +00:00
|
|
|
|
2009-07-10 23:25:30 +00:00
|
|
|
/* automatically name it too */
|
|
|
|
BKE_nlastrip_validate_name(adt, strip);
|
|
|
|
|
2009-05-31 04:52:20 +00:00
|
|
|
/* returns the strip added */
|
|
|
|
return strip;
|
2006-02-08 16:58:12 +00:00
|
|
|
}
|
|
|
|
|
2011-08-07 12:27:20 +00:00
|
|
|
/* Add a NLA Strip referencing the given speaker's sound */
|
2012-05-12 16:11:34 +00:00
|
|
|
NlaStrip *add_nla_soundstrip(Scene *scene, Speaker *speaker)
|
2011-08-07 12:27:20 +00:00
|
|
|
{
|
|
|
|
NlaStrip *strip = MEM_callocN(sizeof(NlaStrip), "NlaSoundStrip");
|
|
|
|
|
|
|
|
/* if speaker has a sound, set the strip length to the length of the sound,
|
|
|
|
* otherwise default to length of 10 frames
|
|
|
|
*/
|
|
|
|
#ifdef WITH_AUDASPACE
|
2012-03-06 18:40:15 +00:00
|
|
|
if (speaker->sound) {
|
2011-08-07 12:27:20 +00:00
|
|
|
AUD_SoundInfo info = AUD_getInfo(speaker->sound->playback_handle);
|
|
|
|
|
2011-11-11 12:00:08 +00:00
|
|
|
strip->end = (float)ceil((double)info.length * FPS);
|
2011-08-07 12:27:20 +00:00
|
|
|
}
|
2012-04-28 06:31:57 +00:00
|
|
|
else
|
2011-08-07 12:27:20 +00:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
strip->end = 10.0f;
|
2011-09-02 03:32:57 +00:00
|
|
|
/* quiet compiler warnings */
|
2011-09-02 04:34:58 +00:00
|
|
|
(void)scene;
|
2011-09-02 03:32:57 +00:00
|
|
|
(void)speaker;
|
2011-08-07 12:27:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* general settings */
|
|
|
|
strip->type = NLASTRIP_TYPE_SOUND;
|
|
|
|
|
|
|
|
strip->flag = NLASTRIP_FLAG_SELECT;
|
|
|
|
strip->extendmode = NLASTRIP_EXTEND_NOTHING; /* nothing to extend... */
|
|
|
|
|
|
|
|
/* strip should be referenced as-is */
|
2012-04-28 06:31:57 +00:00
|
|
|
strip->scale = 1.0f;
|
2011-08-07 12:27:20 +00:00
|
|
|
strip->repeat = 1.0f;
|
|
|
|
|
|
|
|
/* return this strip */
|
|
|
|
return strip;
|
|
|
|
}
|
|
|
|
|
2009-06-23 13:25:31 +00:00
|
|
|
/* *************************************************** */
|
|
|
|
/* NLA Evaluation <-> Editing Stuff */
|
|
|
|
|
|
|
|
/* Strip Mapping ------------------------------------- */
|
|
|
|
|
|
|
|
/* non clipped mapping for strip-time <-> global time (for Action-Clips)
|
|
|
|
* invert = convert action-strip time to global time
|
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short mode)
|
2009-06-23 13:25:31 +00:00
|
|
|
{
|
2011-03-28 04:22:50 +00:00
|
|
|
float actlength, scale;
|
|
|
|
// float repeat; // UNUSED
|
2009-06-23 13:25:31 +00:00
|
|
|
|
|
|
|
/* get number of repeats */
|
2011-03-28 04:22:50 +00:00
|
|
|
if (IS_EQF(strip->repeat, 0.0f)) strip->repeat = 1.0f;
|
|
|
|
// repeat = strip->repeat; // UNUSED
|
2009-06-23 13:25:31 +00:00
|
|
|
|
|
|
|
/* scaling */
|
2012-05-12 16:11:34 +00:00
|
|
|
if (IS_EQF(strip->scale, 0.0f)) strip->scale = 1.0f;
|
2011-11-19 01:10:05 +00:00
|
|
|
scale = fabsf(strip->scale); /* scale must be positive - we've got a special flag for reversing */
|
2009-06-23 13:25:31 +00:00
|
|
|
|
|
|
|
/* length of referenced action */
|
|
|
|
actlength = strip->actend - strip->actstart;
|
2011-03-28 04:22:50 +00:00
|
|
|
if (IS_EQF(actlength, 0.0f)) actlength = 1.0f;
|
2009-06-23 13:25:31 +00:00
|
|
|
|
|
|
|
/* reversed = play strip backwards */
|
|
|
|
if (strip->flag & NLASTRIP_FLAG_REVERSE) {
|
2012-07-07 22:51:57 +00:00
|
|
|
/* FIXME: this won't work right with Graph Editor? */
|
2009-06-28 07:32:00 +00:00
|
|
|
if (mode == NLATIME_CONVERT_MAP) {
|
2012-05-12 16:11:34 +00:00
|
|
|
return strip->end - scale * (cframe - strip->actstart);
|
2009-06-28 07:32:00 +00:00
|
|
|
}
|
|
|
|
else if (mode == NLATIME_CONVERT_UNMAP) {
|
2010-11-03 08:46:14 +00:00
|
|
|
return (strip->end + (strip->actstart * scale - cframe)) / scale;
|
2009-06-28 07:32:00 +00:00
|
|
|
}
|
2012-05-12 16:11:34 +00:00
|
|
|
else { /* if (mode == NLATIME_CONVERT_EVAL) */
|
2014-08-04 10:22:45 +10:00
|
|
|
if (IS_EQF((float)cframe, strip->end) && IS_EQF(strip->repeat, floorf(strip->repeat))) {
|
2009-06-27 12:35:11 +00:00
|
|
|
/* this case prevents the motion snapping back to the first frame at the end of the strip
|
|
|
|
* by catching the case where repeats is a whole number, which means that the end of the strip
|
|
|
|
* could also be interpreted as the end of the start of a repeat
|
|
|
|
*/
|
|
|
|
return strip->actstart;
|
|
|
|
}
|
|
|
|
else {
|
2012-10-27 10:42:28 +00:00
|
|
|
/* - the 'fmod(..., actlength * scale)' is needed to get the repeats working
|
2009-06-27 12:35:11 +00:00
|
|
|
* - the '/ scale' is needed to ensure that scaling influences the timing within the repeat
|
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
return strip->actend - fmodf(cframe - strip->start, actlength * scale) / scale;
|
2009-06-27 12:35:11 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-23 13:25:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-06-28 07:32:00 +00:00
|
|
|
if (mode == NLATIME_CONVERT_MAP) {
|
2012-05-12 16:11:34 +00:00
|
|
|
return strip->start + scale * (cframe - strip->actstart);
|
2009-06-28 07:32:00 +00:00
|
|
|
}
|
|
|
|
else if (mode == NLATIME_CONVERT_UNMAP) {
|
2010-01-18 00:35:28 +00:00
|
|
|
return strip->actstart + (cframe - strip->start) / scale;
|
2009-06-28 07:32:00 +00:00
|
|
|
}
|
2012-05-12 16:11:34 +00:00
|
|
|
else { /* if (mode == NLATIME_CONVERT_EVAL) */
|
2014-08-04 10:22:45 +10:00
|
|
|
if (IS_EQF(cframe, strip->end) && IS_EQF(strip->repeat, floorf(strip->repeat))) {
|
2009-06-27 12:35:11 +00:00
|
|
|
/* this case prevents the motion snapping back to the first frame at the end of the strip
|
|
|
|
* by catching the case where repeats is a whole number, which means that the end of the strip
|
|
|
|
* could also be interpreted as the end of the start of a repeat
|
|
|
|
*/
|
|
|
|
return strip->actend;
|
|
|
|
}
|
|
|
|
else {
|
2012-10-27 10:42:28 +00:00
|
|
|
/* - the 'fmod(..., actlength * scale)' is needed to get the repeats working
|
2009-06-27 12:35:11 +00:00
|
|
|
* - the '/ scale' is needed to ensure that scaling influences the timing within the repeat
|
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
return strip->actstart + fmodf(cframe - strip->start, actlength * scale) / scale;
|
2009-06-27 12:35:11 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-23 13:25:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* non clipped mapping for strip-time <-> global time (for Transitions)
|
|
|
|
* invert = convert action-strip time to global time
|
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
static float nlastrip_get_frame_transition(NlaStrip *strip, float cframe, short mode)
|
2009-06-23 13:25:31 +00:00
|
|
|
{
|
|
|
|
float length;
|
|
|
|
|
|
|
|
/* length of strip */
|
2012-05-12 16:11:34 +00:00
|
|
|
length = strip->end - strip->start;
|
2009-06-23 13:25:31 +00:00
|
|
|
|
|
|
|
/* reversed = play strip backwards */
|
|
|
|
if (strip->flag & NLASTRIP_FLAG_REVERSE) {
|
2009-06-28 07:32:00 +00:00
|
|
|
if (mode == NLATIME_CONVERT_MAP)
|
2009-06-23 13:25:31 +00:00
|
|
|
return strip->end - (length * cframe);
|
|
|
|
else
|
|
|
|
return (strip->end - cframe) / length;
|
|
|
|
}
|
|
|
|
else {
|
2009-06-28 07:32:00 +00:00
|
|
|
if (mode == NLATIME_CONVERT_MAP)
|
2009-06-23 13:25:31 +00:00
|
|
|
return (length * cframe) + strip->start;
|
|
|
|
else
|
|
|
|
return (cframe - strip->start) / length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* non clipped mapping for strip-time <-> global time
|
2012-05-12 16:11:34 +00:00
|
|
|
* mode = eNlaTime_ConvertModes[] -> NLATIME_CONVERT_*
|
2009-06-23 13:25:31 +00:00
|
|
|
*
|
|
|
|
* only secure for 'internal' (i.e. within AnimSys evaluation) operations,
|
|
|
|
* but should not be directly relied on for stuff which interacts with editors
|
|
|
|
*/
|
2012-04-29 17:11:40 +00:00
|
|
|
float nlastrip_get_frame(NlaStrip *strip, float cframe, short mode)
|
2009-06-23 13:25:31 +00:00
|
|
|
{
|
|
|
|
switch (strip->type) {
|
2009-07-07 11:37:33 +00:00
|
|
|
case NLASTRIP_TYPE_META: /* meta - for now, does the same as transition (is really just an empty container) */
|
2009-06-23 13:25:31 +00:00
|
|
|
case NLASTRIP_TYPE_TRANSITION: /* transition */
|
2009-06-28 07:32:00 +00:00
|
|
|
return nlastrip_get_frame_transition(strip, cframe, mode);
|
2009-06-23 13:25:31 +00:00
|
|
|
|
|
|
|
case NLASTRIP_TYPE_CLIP: /* action-clip (default) */
|
|
|
|
default:
|
2009-06-28 07:32:00 +00:00
|
|
|
return nlastrip_get_frame_actionclip(strip, cframe, mode);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-06-23 13:25:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Non clipped mapping for strip-time <-> global time
|
2013-06-12 12:32:07 +00:00
|
|
|
* mode = eNlaTime_ConvertModes -> NLATIME_CONVERT_*
|
2009-06-23 13:25:31 +00:00
|
|
|
*
|
|
|
|
* Public API method - perform this mapping using the given AnimData block
|
|
|
|
* and perform any necessary sanity checks on the value
|
|
|
|
*/
|
2012-04-29 17:11:40 +00:00
|
|
|
float BKE_nla_tweakedit_remap(AnimData *adt, float cframe, short mode)
|
2009-06-23 13:25:31 +00:00
|
|
|
{
|
|
|
|
NlaStrip *strip;
|
|
|
|
|
|
|
|
/* sanity checks
|
|
|
|
* - obviously we've got to have some starting data
|
|
|
|
* - when not in tweakmode, the active Action does not have any scaling applied :)
|
2009-07-03 04:48:44 +00:00
|
|
|
* - when in tweakmode, if the no-mapping flag is set, do not map
|
2009-06-23 13:25:31 +00:00
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
if ((adt == NULL) || (adt->flag & ADT_NLA_EDIT_ON) == 0 || (adt->flag & ADT_NLA_EDIT_NOMAP))
|
2009-06-23 13:25:31 +00:00
|
|
|
return cframe;
|
|
|
|
|
|
|
|
/* if the active-strip info has been stored already, access this, otherwise look this up
|
|
|
|
* and store for (very probable) future usage
|
|
|
|
*/
|
|
|
|
if (adt->actstrip == NULL) {
|
2012-05-12 16:11:34 +00:00
|
|
|
NlaTrack *nlt = BKE_nlatrack_find_active(&adt->nla_tracks);
|
|
|
|
adt->actstrip = BKE_nlastrip_find_active(nlt);
|
2009-06-23 13:25:31 +00:00
|
|
|
}
|
2012-05-12 16:11:34 +00:00
|
|
|
strip = adt->actstrip;
|
2009-06-23 13:25:31 +00:00
|
|
|
|
|
|
|
/* sanity checks
|
|
|
|
* - in rare cases, we may not be able to find this strip for some reason (internal error)
|
|
|
|
* - for now, if the user has defined a curve to control the time, this correction cannot be performed
|
|
|
|
* reliably...
|
|
|
|
*/
|
|
|
|
if ((strip == NULL) || (strip->flag & NLASTRIP_FLAG_USR_TIME))
|
|
|
|
return cframe;
|
|
|
|
|
|
|
|
/* perform the correction now... */
|
2009-06-28 07:32:00 +00:00
|
|
|
return nlastrip_get_frame(strip, cframe, mode);
|
2009-06-23 13:25:31 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 01:16:26 +00:00
|
|
|
/* *************************************************** */
|
2009-07-10 23:25:30 +00:00
|
|
|
/* NLA API */
|
2006-02-08 16:58:12 +00:00
|
|
|
|
2009-07-06 03:44:44 +00:00
|
|
|
/* List of Strips ------------------------------------ */
|
|
|
|
/* (these functions are used for NLA-Tracks and also for nested/meta-strips) */
|
|
|
|
|
|
|
|
/* Check if there is any space in the given list to add the given strip */
|
2014-02-03 18:55:59 +11:00
|
|
|
bool BKE_nlastrips_has_space(ListBase *strips, float start, float end)
|
2009-07-06 03:44:44 +00:00
|
|
|
{
|
|
|
|
NlaStrip *strip;
|
|
|
|
|
|
|
|
/* sanity checks */
|
2011-03-28 04:22:50 +00:00
|
|
|
if ((strips == NULL) || IS_EQF(start, end))
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-07-06 03:44:44 +00:00
|
|
|
if (start > end) {
|
|
|
|
puts("BKE_nlastrips_has_space() error... start and end arguments swapped");
|
|
|
|
SWAP(float, start, end);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* loop over NLA strips checking for any overlaps with this area... */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (strip = strips->first; strip; strip = strip->next) {
|
2009-07-06 03:44:44 +00:00
|
|
|
/* if start frame of strip is past the target end-frame, that means that
|
|
|
|
* we've gone past the window we need to check for, so things are fine
|
|
|
|
*/
|
2011-01-18 23:38:36 +00:00
|
|
|
if (strip->start >= end)
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
2009-07-06 03:44:44 +00:00
|
|
|
|
|
|
|
/* if the end of the strip is greater than either of the boundaries, the range
|
|
|
|
* must fall within the extents of the strip
|
|
|
|
*/
|
|
|
|
if ((strip->end > start) || (strip->end > end))
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-07-06 03:44:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* if we are still here, we haven't encountered any overlapping strips */
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
2009-07-06 03:44:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Rearrange the strips in the track so that they are always in order
|
|
|
|
* (usually only needed after a strip has been moved)
|
|
|
|
*/
|
2012-04-29 17:11:40 +00:00
|
|
|
void BKE_nlastrips_sort_strips(ListBase *strips)
|
2009-07-06 03:44:44 +00:00
|
|
|
{
|
|
|
|
ListBase tmp = {NULL, NULL};
|
2009-07-07 10:25:55 +00:00
|
|
|
NlaStrip *strip, *sstrip, *stripn;
|
2009-07-06 03:44:44 +00:00
|
|
|
|
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, strips, strips->first))
|
2009-07-06 03:44:44 +00:00
|
|
|
return;
|
2009-07-07 10:25:55 +00:00
|
|
|
|
2009-07-06 03:44:44 +00:00
|
|
|
/* we simply perform insertion sort on this list, since it is assumed that per track,
|
|
|
|
* there are only likely to be at most 5-10 strips
|
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
for (strip = strips->first; strip; strip = stripn) {
|
2009-07-06 03:44:44 +00:00
|
|
|
short not_added = 1;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
stripn = strip->next;
|
2009-07-07 10:25:55 +00:00
|
|
|
|
2009-07-06 03:44:44 +00:00
|
|
|
/* remove this strip from the list, and add it to the new list, searching from the end of
|
|
|
|
* the list, assuming that the lists are in order
|
|
|
|
*/
|
|
|
|
BLI_remlink(strips, strip);
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (sstrip = tmp.last; sstrip; sstrip = sstrip->prev) {
|
2009-07-06 03:44:44 +00:00
|
|
|
/* check if add after */
|
2009-07-07 10:25:55 +00:00
|
|
|
if (sstrip->end <= strip->start) {
|
2009-07-06 03:44:44 +00:00
|
|
|
BLI_insertlinkafter(&tmp, sstrip, strip);
|
2012-05-12 16:11:34 +00:00
|
|
|
not_added = 0;
|
2009-07-06 03:44:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add before first? */
|
|
|
|
if (not_added)
|
|
|
|
BLI_addhead(&tmp, strip);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reassign the start and end points of the strips */
|
2012-05-12 16:11:34 +00:00
|
|
|
strips->first = tmp.first;
|
|
|
|
strips->last = tmp.last;
|
2009-07-06 03:44:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Add the given NLA-Strip to the given list of strips, assuming that it
|
|
|
|
* isn't currently a member of another list
|
|
|
|
*/
|
2014-04-11 11:25:41 +10:00
|
|
|
bool BKE_nlastrips_add_strip(ListBase *strips, NlaStrip *strip)
|
2009-07-06 03:44:44 +00:00
|
|
|
{
|
|
|
|
NlaStrip *ns;
|
2014-04-11 11:25:41 +10:00
|
|
|
bool not_added = true;
|
2009-07-06 03:44:44 +00:00
|
|
|
|
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, strips, strip))
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-07-06 03:44:44 +00:00
|
|
|
|
|
|
|
/* check if any space to add */
|
2012-05-12 16:11:34 +00:00
|
|
|
if (BKE_nlastrips_has_space(strips, strip->start, strip->end) == 0)
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-07-06 03:44:44 +00:00
|
|
|
|
|
|
|
/* find the right place to add the strip to the nominated track */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (ns = strips->first; ns; ns = ns->next) {
|
2009-07-06 03:44:44 +00:00
|
|
|
/* if current strip occurs after the new strip, add it before */
|
2011-01-18 23:38:36 +00:00
|
|
|
if (ns->start >= strip->end) {
|
2009-07-06 03:44:44 +00:00
|
|
|
BLI_insertlinkbefore(strips, ns, strip);
|
2012-05-12 16:11:34 +00:00
|
|
|
not_added = 0;
|
2009-07-06 03:44:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (not_added) {
|
|
|
|
/* just add to the end of the list of the strips then... */
|
|
|
|
BLI_addtail(strips, strip);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* added... */
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
2009-07-06 03:44:44 +00:00
|
|
|
}
|
|
|
|
|
2009-07-06 11:06:34 +00:00
|
|
|
|
|
|
|
/* Meta-Strips ------------------------------------ */
|
|
|
|
|
|
|
|
/* Convert 'islands' (i.e. continuous string of) selected strips to be
|
|
|
|
* contained within 'Meta-Strips' which act as strips which contain strips.
|
|
|
|
* temp: are the meta-strips to be created 'temporary' ones used for transforms?
|
|
|
|
*/
|
2014-04-11 11:25:41 +10:00
|
|
|
void BKE_nlastrips_make_metas(ListBase *strips, bool is_temp)
|
2009-07-06 11:06:34 +00:00
|
|
|
{
|
|
|
|
NlaStrip *mstrip = NULL;
|
|
|
|
NlaStrip *strip, *stripn;
|
|
|
|
|
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, strips, strips->first))
|
2009-07-06 11:06:34 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* group all continuous chains of selected strips into meta-strips */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (strip = strips->first; strip; strip = stripn) {
|
|
|
|
stripn = strip->next;
|
2009-07-06 11:06:34 +00:00
|
|
|
|
|
|
|
if (strip->flag & NLASTRIP_FLAG_SELECT) {
|
|
|
|
/* if there is an existing meta-strip, add this strip to it, otherwise, create a new one */
|
|
|
|
if (mstrip == NULL) {
|
|
|
|
/* add a new meta-strip, and add it before the current strip that it will replace... */
|
2012-05-12 16:11:34 +00:00
|
|
|
mstrip = MEM_callocN(sizeof(NlaStrip), "Meta-NlaStrip");
|
2009-07-06 11:06:34 +00:00
|
|
|
mstrip->type = NLASTRIP_TYPE_META;
|
|
|
|
BLI_insertlinkbefore(strips, strip, mstrip);
|
|
|
|
|
|
|
|
/* set flags */
|
|
|
|
mstrip->flag = NLASTRIP_FLAG_SELECT;
|
|
|
|
|
|
|
|
/* set temp flag if appropriate (i.e. for transform-type editing) */
|
2014-04-11 11:25:41 +10:00
|
|
|
if (is_temp)
|
2009-07-06 11:06:34 +00:00
|
|
|
mstrip->flag |= NLASTRIP_FLAG_TEMP_META;
|
2009-07-06 12:24:09 +00:00
|
|
|
|
|
|
|
/* set default repeat/scale values to prevent warnings */
|
2012-05-12 16:11:34 +00:00
|
|
|
mstrip->repeat = mstrip->scale = 1.0f;
|
2009-07-06 11:06:34 +00:00
|
|
|
|
|
|
|
/* make its start frame be set to the start frame of the current strip */
|
2012-05-12 16:11:34 +00:00
|
|
|
mstrip->start = strip->start;
|
2009-07-06 11:06:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* remove the selected strips from the track, and add to the meta */
|
|
|
|
BLI_remlink(strips, strip);
|
|
|
|
BLI_addtail(&mstrip->strips, strip);
|
|
|
|
|
|
|
|
/* expand the meta's dimensions to include the newly added strip- i.e. its last frame */
|
2012-05-12 16:11:34 +00:00
|
|
|
mstrip->end = strip->end;
|
2009-07-06 11:06:34 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* current strip wasn't selected, so the end of 'island' of selected strips has been reached,
|
|
|
|
* so stop adding strips to the current meta
|
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
mstrip = NULL;
|
2009-07-06 11:06:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-06 12:24:09 +00:00
|
|
|
/* Split a meta-strip into a set of normal strips */
|
2012-04-29 17:11:40 +00:00
|
|
|
void BKE_nlastrips_clear_metastrip(ListBase *strips, NlaStrip *strip)
|
2009-07-06 12:24:09 +00:00
|
|
|
{
|
|
|
|
NlaStrip *cs, *csn;
|
|
|
|
|
|
|
|
/* sanity check */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, strips, strip))
|
2009-07-06 12:24:09 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* move each one of the meta-strip's children before the meta-strip
|
|
|
|
* in the list of strips after unlinking them from the meta-strip
|
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
for (cs = strip->strips.first; cs; cs = csn) {
|
|
|
|
csn = cs->next;
|
2009-07-06 12:24:09 +00:00
|
|
|
BLI_remlink(&strip->strips, cs);
|
|
|
|
BLI_insertlinkbefore(strips, strip, cs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free the meta-strip now */
|
2011-01-18 23:38:36 +00:00
|
|
|
free_nlastrip(strips, strip);
|
2009-07-06 12:24:09 +00:00
|
|
|
}
|
|
|
|
|
2009-07-06 11:06:34 +00:00
|
|
|
/* Remove meta-strips (i.e. flatten the list of strips) from the top-level of the list of strips
|
|
|
|
* sel: only consider selected meta-strips, otherwise all meta-strips are removed
|
|
|
|
* onlyTemp: only remove the 'temporary' meta-strips used for transforms
|
|
|
|
*/
|
2014-04-11 11:25:41 +10:00
|
|
|
void BKE_nlastrips_clear_metas(ListBase *strips, bool only_sel, bool only_temp)
|
2009-07-06 11:06:34 +00:00
|
|
|
{
|
|
|
|
NlaStrip *strip, *stripn;
|
|
|
|
|
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, strips, strips->first))
|
2009-07-06 11:06:34 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* remove meta-strips fitting the criteria of the arguments */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (strip = strips->first; strip; strip = stripn) {
|
|
|
|
stripn = strip->next;
|
2009-07-06 11:06:34 +00:00
|
|
|
|
|
|
|
/* check if strip is a meta-strip */
|
|
|
|
if (strip->type == NLASTRIP_TYPE_META) {
|
|
|
|
/* if check if selection and 'temporary-only' considerations are met */
|
2014-04-11 11:25:41 +10:00
|
|
|
if ((!only_sel) || (strip->flag & NLASTRIP_FLAG_SELECT)) {
|
|
|
|
if ((!only_temp) || (strip->flag & NLASTRIP_FLAG_TEMP_META)) {
|
2009-07-06 12:24:09 +00:00
|
|
|
BKE_nlastrips_clear_metastrip(strips, strip);
|
2009-07-06 11:06:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add the given NLA-Strip to the given Meta-Strip, assuming that the
|
2012-08-24 23:22:34 +00:00
|
|
|
* strip isn't attached to any list of strips
|
2009-07-06 11:06:34 +00:00
|
|
|
*/
|
2014-04-11 11:25:41 +10:00
|
|
|
bool BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip)
|
2009-07-06 11:06:34 +00:00
|
|
|
{
|
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, mstrip, strip))
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-07-06 11:06:34 +00:00
|
|
|
|
|
|
|
/* firstly, check if the meta-strip has space for this */
|
|
|
|
if (BKE_nlastrips_has_space(&mstrip->strips, strip->start, strip->end) == 0)
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-07-06 11:06:34 +00:00
|
|
|
|
|
|
|
/* check if this would need to be added to the ends of the meta,
|
2012-03-01 12:20:18 +00:00
|
|
|
* and subsequently, if the neighboring strips allow us enough room
|
2009-07-06 11:06:34 +00:00
|
|
|
*/
|
|
|
|
if (strip->start < mstrip->start) {
|
|
|
|
/* check if strip to the left (if it exists) ends before the
|
|
|
|
* start of the strip we're trying to add
|
|
|
|
*/
|
|
|
|
if ((mstrip->prev == NULL) || (mstrip->prev->end <= strip->start)) {
|
|
|
|
/* add strip to start of meta's list, and expand dimensions */
|
|
|
|
BLI_addhead(&mstrip->strips, strip);
|
2012-05-12 16:11:34 +00:00
|
|
|
mstrip->start = strip->start;
|
2009-07-06 11:06:34 +00:00
|
|
|
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
2009-07-06 11:06:34 +00:00
|
|
|
}
|
|
|
|
else /* failed... no room before */
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-07-06 11:06:34 +00:00
|
|
|
}
|
|
|
|
else if (strip->end > mstrip->end) {
|
|
|
|
/* check if strip to the right (if it exists) starts before the
|
|
|
|
* end of the strip we're trying to add
|
|
|
|
*/
|
|
|
|
if ((mstrip->next == NULL) || (mstrip->next->start >= strip->end)) {
|
|
|
|
/* add strip to end of meta's list, and expand dimensions */
|
|
|
|
BLI_addtail(&mstrip->strips, strip);
|
2012-05-12 16:11:34 +00:00
|
|
|
mstrip->end = strip->end;
|
2009-07-06 11:06:34 +00:00
|
|
|
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
2009-07-06 11:06:34 +00:00
|
|
|
}
|
|
|
|
else /* failed... no room after */
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-07-06 11:06:34 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* just try to add to the meta-strip (no dimension changes needed) */
|
|
|
|
return BKE_nlastrips_add_strip(&mstrip->strips, strip);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Adjust the settings of NLA-Strips contained within a Meta-Strip (recursively),
|
|
|
|
* until the Meta-Strips children all fit within the Meta-Strip's new dimensions
|
|
|
|
*/
|
2012-04-29 17:11:40 +00:00
|
|
|
void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
|
2009-07-06 11:06:34 +00:00
|
|
|
{
|
|
|
|
NlaStrip *strip;
|
|
|
|
float oStart, oEnd, offset;
|
2009-07-07 02:12:50 +00:00
|
|
|
float oLen, nLen;
|
2012-05-12 16:11:34 +00:00
|
|
|
short scaleChanged = 0;
|
2009-07-06 11:06:34 +00:00
|
|
|
|
|
|
|
/* sanity checks
|
|
|
|
* - strip must exist
|
|
|
|
* - strip must be a meta-strip with some contents
|
|
|
|
*/
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, mstrip, mstrip->strips.first))
|
2009-07-06 11:06:34 +00:00
|
|
|
return;
|
|
|
|
if (mstrip->type != NLASTRIP_TYPE_META)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* get the original start/end points, and calculate the start-frame offset
|
|
|
|
* - these are simply the start/end frames of the child strips,
|
|
|
|
* since we assume they weren't transformed yet
|
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
oStart = ((NlaStrip *)mstrip->strips.first)->start;
|
|
|
|
oEnd = ((NlaStrip *)mstrip->strips.last)->end;
|
|
|
|
offset = mstrip->start - oStart;
|
2009-07-06 11:06:34 +00:00
|
|
|
|
2012-03-02 16:05:54 +00:00
|
|
|
/* optimization:
|
2009-07-06 11:06:34 +00:00
|
|
|
* don't flush if nothing changed yet
|
|
|
|
* TODO: maybe we need a flag to say always flush?
|
|
|
|
*/
|
2011-03-28 04:22:50 +00:00
|
|
|
if (IS_EQF(oStart, mstrip->start) && IS_EQF(oEnd, mstrip->end))
|
2009-07-06 11:06:34 +00:00
|
|
|
return;
|
|
|
|
|
2009-07-07 02:12:50 +00:00
|
|
|
/* check if scale changed */
|
|
|
|
oLen = oEnd - oStart;
|
|
|
|
nLen = mstrip->end - mstrip->start;
|
2011-03-28 04:22:50 +00:00
|
|
|
if (IS_EQF(nLen, oLen) == 0)
|
2012-05-12 16:11:34 +00:00
|
|
|
scaleChanged = 1;
|
2009-07-07 02:12:50 +00:00
|
|
|
|
2009-07-06 11:06:34 +00:00
|
|
|
/* for each child-strip, calculate new start/end points based on this new info */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (strip = mstrip->strips.first; strip; strip = strip->next) {
|
2009-07-07 02:12:50 +00:00
|
|
|
if (scaleChanged) {
|
2011-08-22 11:51:23 +00:00
|
|
|
float p1, p2;
|
2009-07-07 02:12:50 +00:00
|
|
|
|
|
|
|
/* compute positions of endpoints relative to old extents of strip */
|
2012-05-12 16:11:34 +00:00
|
|
|
p1 = (strip->start - oStart) / oLen;
|
|
|
|
p2 = (strip->end - oStart) / oLen;
|
2009-07-07 02:12:50 +00:00
|
|
|
|
2011-08-22 11:51:23 +00:00
|
|
|
/* apply new strip endpoints using the proportions, then wait for second pass to flush scale properly */
|
2012-05-12 16:11:34 +00:00
|
|
|
strip->start = (p1 * nLen) + mstrip->start;
|
|
|
|
strip->end = (p2 * nLen) + mstrip->start;
|
2009-07-07 02:12:50 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* just apply the changes in offset to both ends of the strip */
|
|
|
|
strip->start += offset;
|
|
|
|
strip->end += offset;
|
|
|
|
}
|
2011-08-22 11:51:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* apply a second pass over child strips, to finish up unfinished business */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (strip = mstrip->strips.first; strip; strip = strip->next) {
|
2011-08-22 11:51:23 +00:00
|
|
|
/* only if scale changed, need to perform RNA updates */
|
|
|
|
if (scaleChanged) {
|
|
|
|
PointerRNA ptr;
|
|
|
|
|
|
|
|
/* use RNA updates to compute scale properly */
|
|
|
|
RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &ptr);
|
|
|
|
|
|
|
|
RNA_float_set(&ptr, "frame_start", strip->start);
|
|
|
|
RNA_float_set(&ptr, "frame_end", strip->end);
|
|
|
|
}
|
2009-07-06 11:06:34 +00:00
|
|
|
|
|
|
|
/* finally, make sure the strip's children (if it is a meta-itself), get updated */
|
|
|
|
BKE_nlameta_flush_transforms(strip);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-23 09:36:18 +00:00
|
|
|
/* NLA-Tracks ---------------------------------------- */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-05-22 01:16:26 +00:00
|
|
|
/* Find the active NLA-track for the given stack */
|
2012-05-12 16:11:34 +00:00
|
|
|
NlaTrack *BKE_nlatrack_find_active(ListBase *tracks)
|
2009-05-22 01:16:26 +00:00
|
|
|
{
|
|
|
|
NlaTrack *nlt;
|
|
|
|
|
|
|
|
/* sanity check */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, tracks, tracks->first))
|
2009-05-22 01:16:26 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* try to find the first active track */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (nlt = tracks->first; nlt; nlt = nlt->next) {
|
2009-05-22 01:16:26 +00:00
|
|
|
if (nlt->flag & NLATRACK_ACTIVE)
|
|
|
|
return nlt;
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 01:16:26 +00:00
|
|
|
/* none found */
|
|
|
|
return NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2009-06-05 11:51:27 +00:00
|
|
|
/* Toggle the 'solo' setting for the given NLA-track, making sure that it is the only one
|
|
|
|
* that has this status in its AnimData block.
|
|
|
|
*/
|
2012-04-29 17:11:40 +00:00
|
|
|
void BKE_nlatrack_solo_toggle(AnimData *adt, NlaTrack *nlt)
|
2009-06-05 11:51:27 +00:00
|
|
|
{
|
|
|
|
NlaTrack *nt;
|
|
|
|
|
|
|
|
/* sanity check */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, adt, adt->nla_tracks.first))
|
2009-06-05 11:51:27 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* firstly, make sure 'solo' flag for all tracks is disabled */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (nt = adt->nla_tracks.first; nt; nt = nt->next) {
|
2009-06-05 11:51:27 +00:00
|
|
|
if (nt != nlt)
|
|
|
|
nt->flag &= ~NLATRACK_SOLO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now, enable 'solo' for the given track if appropriate */
|
|
|
|
if (nlt) {
|
|
|
|
/* toggle solo status */
|
|
|
|
nlt->flag ^= NLATRACK_SOLO;
|
|
|
|
|
|
|
|
/* set or clear solo-status on AnimData */
|
|
|
|
if (nlt->flag & NLATRACK_SOLO)
|
|
|
|
adt->flag |= ADT_NLA_SOLO_TRACK;
|
|
|
|
else
|
|
|
|
adt->flag &= ~ADT_NLA_SOLO_TRACK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
adt->flag &= ~ADT_NLA_SOLO_TRACK;
|
|
|
|
}
|
|
|
|
|
2009-05-22 01:16:26 +00:00
|
|
|
/* Make the given NLA-track the active one for the given stack. If no track is provided,
|
|
|
|
* this function can be used to simply deactivate all the NLA tracks in the given stack too.
|
|
|
|
*/
|
2012-04-29 17:11:40 +00:00
|
|
|
void BKE_nlatrack_set_active(ListBase *tracks, NlaTrack *nlt_a)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2009-05-22 01:16:26 +00:00
|
|
|
NlaTrack *nlt;
|
|
|
|
|
|
|
|
/* sanity check */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, tracks, tracks->first))
|
2002-10-12 11:37:38 +00:00
|
|
|
return;
|
2009-05-22 01:16:26 +00:00
|
|
|
|
|
|
|
/* deactive all the rest */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (nlt = tracks->first; nlt; nlt = nlt->next)
|
2009-05-22 01:16:26 +00:00
|
|
|
nlt->flag &= ~NLATRACK_ACTIVE;
|
|
|
|
|
|
|
|
/* set the given one as the active one */
|
|
|
|
if (nlt_a)
|
|
|
|
nlt_a->flag |= NLATRACK_ACTIVE;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-07-06 03:44:44 +00:00
|
|
|
/* Check if there is any space in the given track to add a strip of the given length */
|
2014-02-03 18:55:59 +11:00
|
|
|
bool BKE_nlatrack_has_space(NlaTrack *nlt, float start, float end)
|
2009-05-23 09:36:18 +00:00
|
|
|
{
|
2010-11-11 10:07:33 +00:00
|
|
|
/* sanity checks
|
2012-05-12 16:11:34 +00:00
|
|
|
* - track must exist
|
|
|
|
* - track must be editable
|
|
|
|
* - bounds cannot be equal (0-length is nasty)
|
2010-11-11 10:07:33 +00:00
|
|
|
*/
|
2011-03-28 04:22:50 +00:00
|
|
|
if ((nlt == NULL) || (nlt->flag & NLATRACK_PROTECTED) || IS_EQF(start, end))
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2010-11-11 10:07:33 +00:00
|
|
|
|
2009-05-23 09:36:18 +00:00
|
|
|
if (start > end) {
|
2009-07-06 03:44:44 +00:00
|
|
|
puts("BKE_nlatrack_has_space() error... start and end arguments swapped");
|
2009-05-23 09:36:18 +00:00
|
|
|
SWAP(float, start, end);
|
|
|
|
}
|
|
|
|
|
2009-07-06 03:44:44 +00:00
|
|
|
/* check if there's any space left in the track for a strip of the given length */
|
|
|
|
return BKE_nlastrips_has_space(&nlt->strips, start, end);
|
2009-05-23 09:36:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Rearrange the strips in the track so that they are always in order
|
|
|
|
* (usually only needed after a strip has been moved)
|
|
|
|
*/
|
2012-04-29 17:11:40 +00:00
|
|
|
void BKE_nlatrack_sort_strips(NlaTrack *nlt)
|
2009-05-23 09:36:18 +00:00
|
|
|
{
|
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, nlt, nlt->strips.first))
|
2009-05-23 09:36:18 +00:00
|
|
|
return;
|
|
|
|
|
2009-07-06 03:44:44 +00:00
|
|
|
/* sort the strips with a more generic function */
|
|
|
|
BKE_nlastrips_sort_strips(&nlt->strips);
|
2009-05-23 09:36:18 +00:00
|
|
|
}
|
2009-05-31 04:52:20 +00:00
|
|
|
|
2009-06-19 04:45:56 +00:00
|
|
|
/* Add the given NLA-Strip to the given NLA-Track, assuming that it
|
|
|
|
* isn't currently attached to another one
|
|
|
|
*/
|
2014-04-11 11:25:41 +10:00
|
|
|
bool BKE_nlatrack_add_strip(NlaTrack *nlt, NlaStrip *strip)
|
2009-06-19 04:45:56 +00:00
|
|
|
{
|
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, nlt, strip))
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-06-19 04:45:56 +00:00
|
|
|
|
2015-03-01 01:48:38 +13:00
|
|
|
/* do not allow adding strips if this track is locked */
|
|
|
|
if (nlt->flag & NLATRACK_PROTECTED)
|
|
|
|
return false;
|
|
|
|
|
2009-07-06 03:44:44 +00:00
|
|
|
/* try to add the strip to the track using a more generic function */
|
|
|
|
return BKE_nlastrips_add_strip(&nlt->strips, strip);
|
2009-06-19 04:45:56 +00:00
|
|
|
}
|
|
|
|
|
2010-04-01 06:26:41 +00:00
|
|
|
/* Get the extents of the given NLA-Track including gaps between strips,
|
|
|
|
* returning whether this succeeded or not
|
|
|
|
*/
|
2014-04-11 11:25:41 +10:00
|
|
|
bool BKE_nlatrack_get_bounds(NlaTrack *nlt, float bounds[2])
|
2010-04-01 06:26:41 +00:00
|
|
|
{
|
|
|
|
NlaStrip *strip;
|
|
|
|
|
2012-03-02 16:05:54 +00:00
|
|
|
/* initialize bounds */
|
2010-04-01 06:26:41 +00:00
|
|
|
if (bounds)
|
|
|
|
bounds[0] = bounds[1] = 0.0f;
|
|
|
|
else
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2010-04-01 06:26:41 +00:00
|
|
|
|
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, nlt, nlt->strips.first))
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2010-04-01 06:26:41 +00:00
|
|
|
|
|
|
|
/* lower bound is first strip's start frame */
|
|
|
|
strip = nlt->strips.first;
|
|
|
|
bounds[0] = strip->start;
|
|
|
|
|
|
|
|
/* upper bound is last strip's end frame */
|
|
|
|
strip = nlt->strips.last;
|
|
|
|
bounds[1] = strip->end;
|
|
|
|
|
|
|
|
/* done */
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
2010-04-01 06:26:41 +00:00
|
|
|
}
|
|
|
|
|
2009-05-31 04:52:20 +00:00
|
|
|
/* NLA Strips -------------------------------------- */
|
|
|
|
|
NLA SoC: More Drawing Tweaks
* Following user feedback, I've increased the separation between normal NLA-tracks and the 'action lines' to try and differentiate them more. This hopefully this will be sufficient, otherwise, I'm going to have to abandon the use of nice, generic channel-identification code for lists of channels...
* Improved drawing of 'active' strips.
- Now, the active strip (when NOT being 'tweaked') will be simply drawn as a yellow strip + a white border.
- The active strip (when BEING 'tweaked') will now be greenish + a white border. The colour here may be tweakable, but we'll see...
* Strip extrapolation modes (hold, etc.) are now visualised as rects with alpha and the same colour as the strip they belong to.
* Selecting strips now makes them 'active' (and deactivates the others). Only one strip can be active at a time. Still need to figure out precisely how this will work with multiple AnimData blocks + NLA-'tweaking'.
* Fixed view-matrix bug introduced in last commit for text drawing. For now, we'll just reset the view matrix after doing that, since it's not too acceptable to move these calls to the end yet, as they should get overlapped by some other editor features (such as the Current Frame indicator)
2009-06-03 11:22:49 +00:00
|
|
|
/* Find the active NLA-strip within the given track */
|
2012-05-12 16:11:34 +00:00
|
|
|
NlaStrip *BKE_nlastrip_find_active(NlaTrack *nlt)
|
NLA SoC: More Drawing Tweaks
* Following user feedback, I've increased the separation between normal NLA-tracks and the 'action lines' to try and differentiate them more. This hopefully this will be sufficient, otherwise, I'm going to have to abandon the use of nice, generic channel-identification code for lists of channels...
* Improved drawing of 'active' strips.
- Now, the active strip (when NOT being 'tweaked') will be simply drawn as a yellow strip + a white border.
- The active strip (when BEING 'tweaked') will now be greenish + a white border. The colour here may be tweakable, but we'll see...
* Strip extrapolation modes (hold, etc.) are now visualised as rects with alpha and the same colour as the strip they belong to.
* Selecting strips now makes them 'active' (and deactivates the others). Only one strip can be active at a time. Still need to figure out precisely how this will work with multiple AnimData blocks + NLA-'tweaking'.
* Fixed view-matrix bug introduced in last commit for text drawing. For now, we'll just reset the view matrix after doing that, since it's not too acceptable to move these calls to the end yet, as they should get overlapped by some other editor features (such as the Current Frame indicator)
2009-06-03 11:22:49 +00:00
|
|
|
{
|
|
|
|
NlaStrip *strip;
|
|
|
|
|
|
|
|
/* sanity check */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, nlt, nlt->strips.first))
|
NLA SoC: More Drawing Tweaks
* Following user feedback, I've increased the separation between normal NLA-tracks and the 'action lines' to try and differentiate them more. This hopefully this will be sufficient, otherwise, I'm going to have to abandon the use of nice, generic channel-identification code for lists of channels...
* Improved drawing of 'active' strips.
- Now, the active strip (when NOT being 'tweaked') will be simply drawn as a yellow strip + a white border.
- The active strip (when BEING 'tweaked') will now be greenish + a white border. The colour here may be tweakable, but we'll see...
* Strip extrapolation modes (hold, etc.) are now visualised as rects with alpha and the same colour as the strip they belong to.
* Selecting strips now makes them 'active' (and deactivates the others). Only one strip can be active at a time. Still need to figure out precisely how this will work with multiple AnimData blocks + NLA-'tweaking'.
* Fixed view-matrix bug introduced in last commit for text drawing. For now, we'll just reset the view matrix after doing that, since it's not too acceptable to move these calls to the end yet, as they should get overlapped by some other editor features (such as the Current Frame indicator)
2009-06-03 11:22:49 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* try to find the first active strip */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (strip = nlt->strips.first; strip; strip = strip->next) {
|
NLA SoC: More Drawing Tweaks
* Following user feedback, I've increased the separation between normal NLA-tracks and the 'action lines' to try and differentiate them more. This hopefully this will be sufficient, otherwise, I'm going to have to abandon the use of nice, generic channel-identification code for lists of channels...
* Improved drawing of 'active' strips.
- Now, the active strip (when NOT being 'tweaked') will be simply drawn as a yellow strip + a white border.
- The active strip (when BEING 'tweaked') will now be greenish + a white border. The colour here may be tweakable, but we'll see...
* Strip extrapolation modes (hold, etc.) are now visualised as rects with alpha and the same colour as the strip they belong to.
* Selecting strips now makes them 'active' (and deactivates the others). Only one strip can be active at a time. Still need to figure out precisely how this will work with multiple AnimData blocks + NLA-'tweaking'.
* Fixed view-matrix bug introduced in last commit for text drawing. For now, we'll just reset the view matrix after doing that, since it's not too acceptable to move these calls to the end yet, as they should get overlapped by some other editor features (such as the Current Frame indicator)
2009-06-03 11:22:49 +00:00
|
|
|
if (strip->flag & NLASTRIP_FLAG_ACTIVE)
|
|
|
|
return strip;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* none found */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-08-02 13:15:20 +00:00
|
|
|
/* Make the given NLA-Strip the active one within the given block */
|
2012-04-29 17:11:40 +00:00
|
|
|
void BKE_nlastrip_set_active(AnimData *adt, NlaStrip *strip)
|
2009-08-02 13:15:20 +00:00
|
|
|
{
|
|
|
|
NlaTrack *nlt;
|
|
|
|
NlaStrip *nls;
|
|
|
|
|
|
|
|
/* sanity checks */
|
|
|
|
if (adt == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* loop over tracks, deactivating*/
|
2012-05-12 16:11:34 +00:00
|
|
|
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
|
|
|
|
for (nls = nlt->strips.first; nls; nls = nls->next) {
|
2009-08-02 13:15:20 +00:00
|
|
|
if (nls != strip)
|
|
|
|
nls->flag &= ~NLASTRIP_FLAG_ACTIVE;
|
|
|
|
else
|
|
|
|
nls->flag |= NLASTRIP_FLAG_ACTIVE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-31 11:14:50 +00:00
|
|
|
/* Does the given NLA-strip fall within the given bounds (times)? */
|
2014-04-11 11:25:41 +10:00
|
|
|
bool BKE_nlastrip_within_bounds(NlaStrip *strip, float min, float max)
|
2009-05-31 11:14:50 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
const float stripLen = (strip) ? strip->end - strip->start : 0.0f;
|
|
|
|
const float boundsLen = fabsf(max - min);
|
2009-05-31 11:14:50 +00:00
|
|
|
|
|
|
|
/* sanity checks */
|
2011-03-28 04:22:50 +00:00
|
|
|
if ((strip == NULL) || IS_EQF(stripLen, 0.0f) || IS_EQF(boundsLen, 0.0f))
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-05-31 11:14:50 +00:00
|
|
|
|
|
|
|
/* only ok if at least part of the strip is within the bounding window
|
|
|
|
* - first 2 cases cover when the strip length is less than the bounding area
|
|
|
|
* - second 2 cases cover when the strip length is greater than the bounding area
|
|
|
|
*/
|
2012-04-29 17:11:40 +00:00
|
|
|
if ((stripLen < boundsLen) &&
|
|
|
|
!(IN_RANGE(strip->start, min, max) ||
|
|
|
|
IN_RANGE(strip->end, min, max)))
|
2009-05-31 11:14:50 +00:00
|
|
|
{
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-05-31 11:14:50 +00:00
|
|
|
}
|
2012-04-29 17:11:40 +00:00
|
|
|
if ((stripLen > boundsLen) &&
|
|
|
|
!(IN_RANGE(min, strip->start, strip->end) ||
|
|
|
|
IN_RANGE(max, strip->start, strip->end)) )
|
2009-05-31 11:14:50 +00:00
|
|
|
{
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-05-31 11:14:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* should be ok! */
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
2009-05-31 11:14:50 +00:00
|
|
|
}
|
|
|
|
|
2013-04-26 13:42:55 +00:00
|
|
|
|
|
|
|
/* Ensure that strip doesn't overlap those around it after resizing by offsetting those which follow */
|
|
|
|
static void nlastrip_fix_resize_overlaps(NlaStrip *strip)
|
|
|
|
{
|
|
|
|
/* next strips - do this first, since we're often just getting longer */
|
|
|
|
if (strip->next) {
|
|
|
|
NlaStrip *nls = strip->next;
|
|
|
|
float offset = 0.0f;
|
|
|
|
|
|
|
|
if (strip->end > nls->start) {
|
|
|
|
/* NOTE: need to ensure we don't have a fractional frame offset, even if that leaves a gap,
|
|
|
|
* otherwise it will be very hard to get rid of later
|
|
|
|
*/
|
|
|
|
offset = ceilf(strip->end - nls->start);
|
|
|
|
|
|
|
|
/* apply to times of all strips in this direction */
|
|
|
|
for (; nls; nls = nls->next) {
|
|
|
|
nls->start += offset;
|
|
|
|
nls->end += offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* previous strips - same routine as before */
|
|
|
|
/* NOTE: when strip bounds are recalculated, this is not considered! */
|
|
|
|
if (strip->prev) {
|
|
|
|
NlaStrip *nls = strip->prev;
|
|
|
|
float offset = 0.0f;
|
|
|
|
|
|
|
|
if (strip->start < nls->end) {
|
|
|
|
/* NOTE: need to ensure we don't have a fractional frame offset, even if that leaves a gap,
|
|
|
|
* otherwise it will be very hard to get rid of later
|
|
|
|
*/
|
|
|
|
offset = ceilf(nls->end - strip->start);
|
|
|
|
|
|
|
|
/* apply to times of all strips in this direction */
|
|
|
|
for (; nls; nls = nls->prev) {
|
|
|
|
nls->start -= offset;
|
|
|
|
nls->end -= offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-24 06:28:53 +00:00
|
|
|
/* Recalculate the start and end frames for the current strip, after changing
|
|
|
|
* the extents of the action or the mapping (repeats or scale factor) info
|
|
|
|
*/
|
2012-04-29 17:11:40 +00:00
|
|
|
void BKE_nlastrip_recalculate_bounds(NlaStrip *strip)
|
2010-01-24 06:28:53 +00:00
|
|
|
{
|
|
|
|
float actlen, mapping;
|
|
|
|
|
|
|
|
/* sanity checks
|
|
|
|
* - must have a strip
|
|
|
|
* - can only be done for action clips
|
|
|
|
*/
|
|
|
|
if ((strip == NULL) || (strip->type != NLASTRIP_TYPE_CLIP))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* calculate new length factors */
|
2012-05-12 16:11:34 +00:00
|
|
|
actlen = strip->actend - strip->actstart;
|
|
|
|
if (IS_EQF(actlen, 0.0f)) actlen = 1.0f;
|
2010-01-24 06:28:53 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
mapping = strip->scale * strip->repeat;
|
2010-01-24 06:28:53 +00:00
|
|
|
|
|
|
|
/* adjust endpoint of strip in response to this */
|
2011-03-28 04:22:50 +00:00
|
|
|
if (IS_EQF(mapping, 0.0f) == 0)
|
2010-01-24 06:28:53 +00:00
|
|
|
strip->end = (actlen * mapping) + strip->start;
|
2013-04-26 13:42:55 +00:00
|
|
|
|
|
|
|
/* make sure we don't overlap our neighbours */
|
|
|
|
nlastrip_fix_resize_overlaps(strip);
|
2010-01-24 06:28:53 +00:00
|
|
|
}
|
|
|
|
|
2009-05-31 04:52:20 +00:00
|
|
|
/* Is the given NLA-strip the first one to occur for the given AnimData block */
|
|
|
|
// TODO: make this an api method if necesary, but need to add prefix first
|
2014-02-05 22:36:15 +11:00
|
|
|
static bool nlastrip_is_first(AnimData *adt, NlaStrip *strip)
|
2009-05-31 04:52:20 +00:00
|
|
|
{
|
|
|
|
NlaTrack *nlt;
|
|
|
|
NlaStrip *ns;
|
|
|
|
|
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, adt, strip))
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-05-31 04:52:20 +00:00
|
|
|
|
|
|
|
/* check if strip has any strips before it */
|
|
|
|
if (strip->prev)
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-05-31 04:52:20 +00:00
|
|
|
|
|
|
|
/* check other tracks to see if they have a strip that's earlier */
|
2012-07-07 22:51:57 +00:00
|
|
|
/* TODO: or should we check that the strip's track is also the first? */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
|
2009-05-31 04:52:20 +00:00
|
|
|
/* only check the first strip, assuming that they're all in order */
|
2012-05-12 16:11:34 +00:00
|
|
|
ns = nlt->strips.first;
|
2009-05-31 04:52:20 +00:00
|
|
|
if (ns) {
|
|
|
|
if (ns->start < strip->start)
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-05-31 04:52:20 +00:00
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-05-31 04:52:20 +00:00
|
|
|
|
|
|
|
/* should be first now */
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
2009-05-31 04:52:20 +00:00
|
|
|
}
|
2009-07-08 05:00:10 +00:00
|
|
|
|
2009-07-09 01:04:42 +00:00
|
|
|
/* Animated Strips ------------------------------------------- */
|
|
|
|
|
|
|
|
/* Check if the given NLA-Track has any strips with own F-Curves */
|
2014-04-11 11:25:41 +10:00
|
|
|
bool BKE_nlatrack_has_animated_strips(NlaTrack *nlt)
|
2009-07-09 01:04:42 +00:00
|
|
|
{
|
|
|
|
NlaStrip *strip;
|
|
|
|
|
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, nlt, nlt->strips.first))
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-07-09 01:04:42 +00:00
|
|
|
|
|
|
|
/* check each strip for F-Curves only (don't care about whether the flags are set) */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (strip = nlt->strips.first; strip; strip = strip->next) {
|
2009-07-09 01:04:42 +00:00
|
|
|
if (strip->fcurves.first)
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
2009-07-09 01:04:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* none found */
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-07-09 01:04:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if given NLA-Tracks have any strips with own F-Curves */
|
2014-04-11 11:25:41 +10:00
|
|
|
bool BKE_nlatracks_have_animated_strips(ListBase *tracks)
|
2009-07-09 01:04:42 +00:00
|
|
|
{
|
|
|
|
NlaTrack *nlt;
|
|
|
|
|
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, tracks, tracks->first))
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-07-09 01:04:42 +00:00
|
|
|
|
|
|
|
/* check each track, stopping on the first hit */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (nlt = tracks->first; nlt; nlt = nlt->next) {
|
2009-07-09 01:04:42 +00:00
|
|
|
if (BKE_nlatrack_has_animated_strips(nlt))
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
2009-07-09 01:04:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* none found */
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-07-09 01:04:42 +00:00
|
|
|
}
|
|
|
|
|
2009-07-08 05:00:10 +00:00
|
|
|
/* Validate the NLA-Strips 'control' F-Curves based on the flags set*/
|
2012-04-29 17:11:40 +00:00
|
|
|
void BKE_nlastrip_validate_fcurves(NlaStrip *strip)
|
2009-07-08 05:00:10 +00:00
|
|
|
{
|
|
|
|
FCurve *fcu;
|
|
|
|
|
|
|
|
/* sanity checks */
|
|
|
|
if (strip == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* if controlling influence... */
|
|
|
|
if (strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) {
|
|
|
|
/* try to get F-Curve */
|
2012-05-12 16:11:34 +00:00
|
|
|
fcu = list_find_fcurve(&strip->fcurves, "influence", 0);
|
2009-07-08 05:00:10 +00:00
|
|
|
|
|
|
|
/* add one if not found */
|
|
|
|
if (fcu == NULL) {
|
|
|
|
/* make new F-Curve */
|
2012-05-12 16:11:34 +00:00
|
|
|
fcu = MEM_callocN(sizeof(FCurve), "NlaStrip FCurve");
|
2009-07-08 05:00:10 +00:00
|
|
|
BLI_addtail(&strip->fcurves, fcu);
|
|
|
|
|
|
|
|
/* set default flags */
|
2012-05-12 16:11:34 +00:00
|
|
|
fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
|
2009-07-08 05:00:10 +00:00
|
|
|
|
|
|
|
/* store path - make copy, and store that */
|
2012-05-12 16:11:34 +00:00
|
|
|
fcu->rna_path = BLI_strdupn("influence", 9);
|
2009-07-08 05:00:10 +00:00
|
|
|
|
2012-07-07 22:51:57 +00:00
|
|
|
/* TODO: insert a few keyframes to ensure default behavior? */
|
2009-07-08 05:00:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if controlling time... */
|
|
|
|
if (strip->flag & NLASTRIP_FLAG_USR_TIME) {
|
|
|
|
/* try to get F-Curve */
|
2012-05-12 16:11:34 +00:00
|
|
|
fcu = list_find_fcurve(&strip->fcurves, "strip_time", 0);
|
2009-07-08 05:00:10 +00:00
|
|
|
|
|
|
|
/* add one if not found */
|
|
|
|
if (fcu == NULL) {
|
|
|
|
/* make new F-Curve */
|
2012-05-12 16:11:34 +00:00
|
|
|
fcu = MEM_callocN(sizeof(FCurve), "NlaStrip FCurve");
|
2009-07-08 05:00:10 +00:00
|
|
|
BLI_addtail(&strip->fcurves, fcu);
|
|
|
|
|
|
|
|
/* set default flags */
|
2012-05-12 16:11:34 +00:00
|
|
|
fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
|
2009-07-08 05:00:10 +00:00
|
|
|
|
|
|
|
/* store path - make copy, and store that */
|
2012-05-12 16:11:34 +00:00
|
|
|
fcu->rna_path = BLI_strdupn("strip_time", 10);
|
2009-07-08 05:00:10 +00:00
|
|
|
|
2012-07-07 22:51:57 +00:00
|
|
|
/* TODO: insert a few keyframes to ensure default behavior? */
|
2009-07-08 05:00:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-10 23:25:30 +00:00
|
|
|
|
2011-01-12 01:36:12 +00:00
|
|
|
/* Sanity Validation ------------------------------------ */
|
|
|
|
|
2013-03-04 19:27:51 +00:00
|
|
|
static bool nla_editbone_name_check(void *arg, const char *name)
|
2010-11-07 08:49:07 +00:00
|
|
|
{
|
2015-01-01 23:26:03 +11:00
|
|
|
return BLI_ghash_haskey((GHash *)arg, (const void *)name);
|
2010-11-07 08:49:07 +00:00
|
|
|
}
|
|
|
|
|
2009-07-10 23:25:30 +00:00
|
|
|
/* Find (and set) a unique name for a strip from the whole AnimData block
|
|
|
|
* Uses a similar method to the BLI method, but is implemented differently
|
|
|
|
* as we need to ensure that the name is unique over several lists of tracks,
|
|
|
|
* not just a single track.
|
|
|
|
*/
|
2012-04-29 17:11:40 +00:00
|
|
|
void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip)
|
2009-07-10 23:25:30 +00:00
|
|
|
{
|
|
|
|
GHash *gh;
|
|
|
|
NlaStrip *tstrip;
|
|
|
|
NlaTrack *nlt;
|
|
|
|
|
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, adt, strip))
|
2009-07-10 23:25:30 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* give strip a default name if none already */
|
2012-05-12 16:11:34 +00:00
|
|
|
if (strip->name[0] == 0) {
|
2009-07-10 23:25:30 +00:00
|
|
|
switch (strip->type) {
|
|
|
|
case NLASTRIP_TYPE_CLIP: /* act-clip */
|
2012-05-12 16:11:34 +00:00
|
|
|
BLI_strncpy(strip->name, (strip->act) ? (strip->act->id.name + 2) : ("<No Action>"), sizeof(strip->name));
|
2009-07-10 23:25:30 +00:00
|
|
|
break;
|
|
|
|
case NLASTRIP_TYPE_TRANSITION: /* transition */
|
2011-10-09 06:03:38 +00:00
|
|
|
BLI_strncpy(strip->name, "Transition", sizeof(strip->name));
|
2009-07-10 23:25:30 +00:00
|
|
|
break;
|
|
|
|
case NLASTRIP_TYPE_META: /* meta */
|
2011-10-09 06:03:38 +00:00
|
|
|
BLI_strncpy(strip->name, "Meta", sizeof(strip->name));
|
2009-07-10 23:25:30 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-10-09 06:03:38 +00:00
|
|
|
BLI_strncpy(strip->name, "NLA Strip", sizeof(strip->name));
|
2009-07-10 23:25:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* build a hash-table of all the strips in the tracks
|
2013-05-26 12:02:29 +00:00
|
|
|
* - this is easier than iterating over all the tracks+strips hierarchy every time
|
2009-07-10 23:25:30 +00:00
|
|
|
* (and probably faster)
|
|
|
|
*/
|
2012-05-16 00:51:36 +00:00
|
|
|
gh = BLI_ghash_str_new("nlastrip_validate_name gh");
|
2009-07-10 23:25:30 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
|
|
|
|
for (tstrip = nlt->strips.first; tstrip; tstrip = tstrip->next) {
|
2009-07-10 23:25:30 +00:00
|
|
|
/* don't add the strip of interest */
|
|
|
|
if (tstrip == strip)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* use the name of the strip as the key, and the strip as the value, since we're mostly interested in the keys */
|
|
|
|
BLI_ghash_insert(gh, tstrip->name, tstrip);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if the hash-table has a match for this name, try other names...
|
|
|
|
* - in an extreme case, it might not be able to find a name, but then everything else in Blender would fail too :)
|
|
|
|
*/
|
2013-03-25 08:29:06 +00:00
|
|
|
BLI_uniquename_cb(nla_editbone_name_check, (void *)gh, DATA_("NlaStrip"), '.', strip->name, sizeof(strip->name));
|
2010-11-01 07:19:41 +00:00
|
|
|
|
2009-07-10 23:25:30 +00:00
|
|
|
/* free the hash... */
|
|
|
|
BLI_ghash_free(gh, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2009-07-11 03:09:44 +00:00
|
|
|
/* ---- */
|
|
|
|
|
2009-07-24 06:08:03 +00:00
|
|
|
/* Get strips which overlap the given one at the start/end of its range
|
|
|
|
* - strip: strip that we're finding overlaps for
|
|
|
|
* - track: nla-track that the overlapping strips should be found from
|
|
|
|
* - start, end: frames for the offending endpoints
|
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
static void nlastrip_get_endpoint_overlaps(NlaStrip *strip, NlaTrack *track, float **start, float **end)
|
2009-07-24 06:08:03 +00:00
|
|
|
{
|
|
|
|
NlaStrip *nls;
|
|
|
|
|
|
|
|
/* find strips that overlap over the start/end of the given strip,
|
|
|
|
* but which don't cover the entire length
|
|
|
|
*/
|
2012-07-07 22:51:57 +00:00
|
|
|
/* TODO: this scheme could get quite slow for doing this on many strips... */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (nls = track->strips.first; nls; nls = nls->next) {
|
2009-07-24 06:08:03 +00:00
|
|
|
/* check if strip overlaps (extends over or exactly on) the entire range of the strip we're validating */
|
|
|
|
if ((nls->start <= strip->start) && (nls->end >= strip->end)) {
|
2012-05-12 16:11:34 +00:00
|
|
|
*start = NULL;
|
|
|
|
*end = NULL;
|
2009-07-24 06:08:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if strip doesn't even occur anywhere near... */
|
|
|
|
if (nls->end < strip->start)
|
2012-05-12 16:11:34 +00:00
|
|
|
continue; /* skip checking this strip... not worthy of mention */
|
2009-07-24 06:08:03 +00:00
|
|
|
if (nls->start > strip->end)
|
2012-05-12 16:11:34 +00:00
|
|
|
return; /* the range we're after has already passed */
|
2009-07-24 06:08:03 +00:00
|
|
|
|
|
|
|
/* if this strip is not part of an island of continuous strips, it can be used
|
|
|
|
* - this check needs to be done for each end of the strip we try and use...
|
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
if ((nls->next == NULL) || IS_EQF(nls->next->start, nls->end) == 0) {
|
2009-07-24 06:08:03 +00:00
|
|
|
if ((nls->end > strip->start) && (nls->end < strip->end))
|
2012-05-12 16:11:34 +00:00
|
|
|
*start = &nls->end;
|
2009-07-24 06:08:03 +00:00
|
|
|
}
|
2012-05-12 16:11:34 +00:00
|
|
|
if ((nls->prev == NULL) || IS_EQF(nls->prev->end, nls->start) == 0) {
|
2009-07-24 06:08:03 +00:00
|
|
|
if ((nls->start < strip->end) && (nls->start > strip->start))
|
2012-05-12 16:11:34 +00:00
|
|
|
*end = &nls->start;
|
2009-07-24 06:08:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-11 03:09:44 +00:00
|
|
|
/* Determine auto-blending for the given strip */
|
2012-05-12 16:11:34 +00:00
|
|
|
static void BKE_nlastrip_validate_autoblends(NlaTrack *nlt, NlaStrip *nls)
|
2009-07-11 03:09:44 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
float *ps = NULL, *pe = NULL;
|
|
|
|
float *ns = NULL, *ne = NULL;
|
2009-07-11 03:09:44 +00:00
|
|
|
|
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, nls, nlt))
|
2009-07-11 03:09:44 +00:00
|
|
|
return;
|
|
|
|
if ((nlt->prev == NULL) && (nlt->next == NULL))
|
|
|
|
return;
|
2012-05-12 16:11:34 +00:00
|
|
|
if ((nls->flag & NLASTRIP_FLAG_AUTO_BLENDS) == 0)
|
2009-07-11 03:09:44 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* get test ranges */
|
2009-07-24 06:08:03 +00:00
|
|
|
if (nlt->prev)
|
|
|
|
nlastrip_get_endpoint_overlaps(nls, nlt->prev, &ps, &pe);
|
|
|
|
if (nlt->next)
|
|
|
|
nlastrip_get_endpoint_overlaps(nls, nlt->next, &ns, &ne);
|
|
|
|
|
|
|
|
/* set overlaps for this strip
|
|
|
|
* - don't use the values obtained though if the end in question
|
2012-07-04 15:04:38 +00:00
|
|
|
* is directly followed/preceded by another strip, forming an
|
2009-07-24 06:08:03 +00:00
|
|
|
* 'island' of continuous strips
|
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
if ((ps || ns) && ((nls->prev == NULL) || IS_EQF(nls->prev->end, nls->start) == 0)) {
|
2009-07-24 06:08:03 +00:00
|
|
|
/* start overlaps - pick the largest overlap */
|
|
|
|
if ( ((ps && ns) && (*ps > *ns)) || (ps) )
|
2012-05-12 16:11:34 +00:00
|
|
|
nls->blendin = *ps - nls->start;
|
2009-07-24 06:08:03 +00:00
|
|
|
else
|
2012-05-12 16:11:34 +00:00
|
|
|
nls->blendin = *ns - nls->start;
|
2009-07-11 03:09:44 +00:00
|
|
|
}
|
2009-07-24 06:08:03 +00:00
|
|
|
else /* no overlap allowed/needed */
|
2012-05-12 16:11:34 +00:00
|
|
|
nls->blendin = 0.0f;
|
2009-07-24 06:08:03 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
if ((pe || ne) && ((nls->next == NULL) || IS_EQF(nls->next->start, nls->end) == 0)) {
|
2009-07-24 06:08:03 +00:00
|
|
|
/* end overlaps - pick the largest overlap */
|
|
|
|
if ( ((pe && ne) && (*pe > *ne)) || (pe) )
|
2012-05-12 16:11:34 +00:00
|
|
|
nls->blendout = nls->end - *pe;
|
2009-07-24 06:08:03 +00:00
|
|
|
else
|
2012-05-12 16:11:34 +00:00
|
|
|
nls->blendout = nls->end - *ne;
|
2009-07-11 03:09:44 +00:00
|
|
|
}
|
2009-07-24 06:08:03 +00:00
|
|
|
else /* no overlap allowed/needed */
|
2012-05-12 16:11:34 +00:00
|
|
|
nls->blendout = 0.0f;
|
2009-07-11 03:09:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Ensure that auto-blending and other settings are set correctly */
|
2012-04-29 17:11:40 +00:00
|
|
|
void BKE_nla_validate_state(AnimData *adt)
|
2009-07-11 03:09:44 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
NlaStrip *strip, *fstrip = NULL;
|
2009-07-11 03:09:44 +00:00
|
|
|
NlaTrack *nlt;
|
|
|
|
|
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, adt, adt->nla_tracks.first))
|
2009-07-11 03:09:44 +00:00
|
|
|
return;
|
|
|
|
|
2009-07-24 06:08:03 +00:00
|
|
|
/* adjust blending values for auto-blending, and also do an initial pass to find the earliest strip */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
|
|
|
|
for (strip = nlt->strips.first; strip; strip = strip->next) {
|
2009-07-24 06:08:03 +00:00
|
|
|
/* auto-blending first */
|
2009-07-11 03:09:44 +00:00
|
|
|
BKE_nlastrip_validate_autoblends(nlt, strip);
|
2009-07-24 06:08:03 +00:00
|
|
|
|
|
|
|
/* extend mode - find first strip */
|
|
|
|
if ((fstrip == NULL) || (strip->start < fstrip->start))
|
2012-05-12 16:11:34 +00:00
|
|
|
fstrip = strip;
|
2009-07-24 06:08:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* second pass over the strips to adjust the extend-mode to fix any problems */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
|
|
|
|
for (strip = nlt->strips.first; strip; strip = strip->next) {
|
2009-07-24 06:08:03 +00:00
|
|
|
/* apart from 'nothing' option which user has to explicitly choose, we don't really know if
|
|
|
|
* we should be overwriting the extend setting (but assume that's what the user wanted)
|
|
|
|
*/
|
2012-07-07 22:51:57 +00:00
|
|
|
/* TODO: 1 solution is to tie this in with auto-blending... */
|
2009-07-24 06:08:03 +00:00
|
|
|
if (strip->extendmode != NLASTRIP_EXTEND_NOTHING) {
|
2012-01-22 04:39:33 +00:00
|
|
|
/* 1) First strip must be set to extend hold, otherwise, stuff before acts dodgy
|
|
|
|
* 2) Only overwrite extend mode if *not* changing it will most probably result in
|
2013-02-06 14:02:19 +00:00
|
|
|
* occlusion problems, which will occur if...
|
|
|
|
* - blendmode = REPLACE
|
|
|
|
* - all channels the same (this is fiddly to test, so is currently assumed)
|
2012-01-22 04:39:33 +00:00
|
|
|
*
|
|
|
|
* Should fix problems such as [#29869]
|
|
|
|
*/
|
2009-07-24 06:08:03 +00:00
|
|
|
if (strip == fstrip)
|
2012-05-12 16:11:34 +00:00
|
|
|
strip->extendmode = NLASTRIP_EXTEND_HOLD;
|
2012-01-22 04:39:33 +00:00
|
|
|
else if (strip->blendmode == NLASTRIP_MODE_REPLACE)
|
2012-05-12 16:11:34 +00:00
|
|
|
strip->extendmode = NLASTRIP_EXTEND_HOLD_FORWARD;
|
2009-07-24 06:08:03 +00:00
|
|
|
}
|
2009-07-11 03:09:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-10 23:25:30 +00:00
|
|
|
|
2015-02-28 12:49:07 +13:00
|
|
|
/* Action Stashing -------------------------------------- */
|
|
|
|
|
2015-02-28 12:57:17 +13:00
|
|
|
/* name of stashed tracks - the translation stuff is included here to save extra work */
|
|
|
|
#define STASH_TRACK_NAME DATA_("[Action Stash]")
|
|
|
|
|
|
|
|
/* Check if an action is "stashed" in the NLA already
|
|
|
|
*
|
|
|
|
* The criteria for this are:
|
|
|
|
* 1) The action in question lives in a "stash" track
|
|
|
|
* 2) We only check first-level strips. That is, we will not check inside meta strips.
|
|
|
|
*/
|
|
|
|
bool BKE_nla_action_is_stashed(AnimData *adt, bAction *act)
|
|
|
|
{
|
|
|
|
NlaTrack *nlt;
|
|
|
|
NlaStrip *strip;
|
|
|
|
|
|
|
|
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
|
|
|
|
if (strstr(nlt->name, STASH_TRACK_NAME)) {
|
|
|
|
for (strip = nlt->strips.first; strip; strip = strip->next) {
|
|
|
|
if (strip->act == act)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-28 12:49:07 +13:00
|
|
|
/* "Stash" an action (i.e. store it as a track/layer in the NLA, but non-contributing)
|
|
|
|
* to retain it in the file for future uses
|
|
|
|
*/
|
|
|
|
bool BKE_nla_action_stash(AnimData *adt)
|
|
|
|
{
|
|
|
|
NlaTrack *prev_track = NULL;
|
|
|
|
NlaTrack *nlt;
|
|
|
|
NlaStrip *strip;
|
|
|
|
|
2015-03-02 05:04:38 +13:00
|
|
|
/* sanity check */
|
|
|
|
if (ELEM(NULL, adt, adt->action)) {
|
|
|
|
printf("%s: Invalid argument - %p %p\n", __func__, adt, adt->action);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-28 12:57:17 +13:00
|
|
|
/* do not add if it is already stashed */
|
|
|
|
if (BKE_nla_action_is_stashed(adt, adt->action))
|
|
|
|
return false;
|
|
|
|
|
2015-02-28 12:49:07 +13:00
|
|
|
/* create a new track, and add this immediately above the previous stashing track */
|
|
|
|
for (prev_track = adt->nla_tracks.last; prev_track; prev_track = prev_track->prev) {
|
|
|
|
if (strstr(prev_track->name, STASH_TRACK_NAME)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nlt = add_nlatrack(adt, prev_track);
|
2015-03-02 05:04:38 +13:00
|
|
|
BLI_assert(nlt != NULL);
|
2015-02-28 12:49:07 +13:00
|
|
|
|
|
|
|
BLI_strncpy(nlt->name, STASH_TRACK_NAME, sizeof(nlt->name));
|
|
|
|
BLI_uniquename(&adt->nla_tracks, nlt, STASH_TRACK_NAME, '.', offsetof(NlaTrack, name), sizeof(nlt->name));
|
|
|
|
|
|
|
|
/* add the action as a strip in this new track
|
|
|
|
* NOTE: a new user is created here
|
|
|
|
*/
|
|
|
|
strip = add_nlastrip(adt->action);
|
2015-03-02 05:04:38 +13:00
|
|
|
BLI_assert(strip != NULL);
|
2015-02-28 12:49:07 +13:00
|
|
|
|
|
|
|
BKE_nlatrack_add_strip(nlt, strip);
|
|
|
|
BKE_nlastrip_validate_name(adt, strip);
|
2015-03-01 01:48:38 +13:00
|
|
|
|
|
|
|
/* mark the stash track and strip so that they doesn't disturb the stack animation,
|
|
|
|
* and are unlikely to draw attention to itself (or be accidentally bumped around)
|
|
|
|
*
|
|
|
|
* NOTE: this must be done *after* adding the strip to the track, or else
|
|
|
|
* the strip locking will prevent the strip from getting added
|
|
|
|
*/
|
|
|
|
nlt->flag = (NLATRACK_MUTED | NLATRACK_PROTECTED);
|
|
|
|
strip->flag &= ~(NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_ACTIVE);
|
2015-02-28 12:49:07 +13:00
|
|
|
|
|
|
|
/* succeeded */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-07-10 23:25:30 +00:00
|
|
|
/* Core Tools ------------------------------------------- */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-05-22 01:16:26 +00:00
|
|
|
/* For the given AnimData block, add the active action to the NLA
|
|
|
|
* stack (i.e. 'push-down' action). The UI should only allow this
|
|
|
|
* for normal editing only (i.e. not in editmode for some strip's action),
|
|
|
|
* so no checks for this are performed.
|
|
|
|
*/
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: maybe we should have checks for this too... */
|
2012-04-29 17:11:40 +00:00
|
|
|
void BKE_nla_action_pushdown(AnimData *adt)
|
2009-05-22 01:16:26 +00:00
|
|
|
{
|
|
|
|
NlaStrip *strip;
|
2012-07-06 23:56:59 +00:00
|
|
|
|
2009-05-22 01:16:26 +00:00
|
|
|
/* sanity checks */
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: need to report the error for this */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, adt, adt->action))
|
2009-05-22 01:16:26 +00:00
|
|
|
return;
|
2012-07-06 23:56:59 +00:00
|
|
|
|
|
|
|
/* if the action is empty, we also shouldn't try to add to stack,
|
2009-05-22 01:16:26 +00:00
|
|
|
* as that will cause us grief down the track
|
|
|
|
*/
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: what about modifiers? */
|
2009-05-30 11:05:29 +00:00
|
|
|
if (action_has_motion(adt->action) == 0) {
|
2012-03-31 00:59:17 +00:00
|
|
|
printf("BKE_nla_action_pushdown(): action has no data\n");
|
2009-05-23 09:36:18 +00:00
|
|
|
return;
|
2009-05-30 11:05:29 +00:00
|
|
|
}
|
2009-05-22 01:16:26 +00:00
|
|
|
|
|
|
|
/* add a new NLA strip to the track, which references the active action */
|
2012-05-12 16:11:34 +00:00
|
|
|
strip = add_nlastrip_to_stack(adt, adt->action);
|
2009-05-22 01:16:26 +00:00
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
/* do other necessary work on strip */
|
2009-05-22 01:16:26 +00:00
|
|
|
if (strip) {
|
2009-05-31 04:52:20 +00:00
|
|
|
/* clear reference to action now that we've pushed it onto the stack */
|
2011-01-19 23:05:02 +00:00
|
|
|
id_us_min(&adt->action->id);
|
2012-05-12 16:11:34 +00:00
|
|
|
adt->action = NULL;
|
2009-05-31 04:52:20 +00:00
|
|
|
|
|
|
|
/* if the strip is the first one in the track it lives in, check if there
|
|
|
|
* are strips in any other tracks that may be before this, and set the extend
|
|
|
|
* mode accordingly
|
|
|
|
*/
|
|
|
|
if (nlastrip_is_first(adt, strip) == 0) {
|
|
|
|
/* not first, so extend mode can only be NLASTRIP_EXTEND_HOLD_FORWARD not NLASTRIP_EXTEND_HOLD,
|
|
|
|
* so that it doesn't override strips in previous tracks
|
|
|
|
*/
|
2012-07-07 22:51:57 +00:00
|
|
|
/* FIXME: this needs to be more automated, since user can rearrange strips */
|
2012-05-12 16:11:34 +00:00
|
|
|
strip->extendmode = NLASTRIP_EXTEND_HOLD_FORWARD;
|
2009-05-31 04:52:20 +00:00
|
|
|
}
|
2009-08-02 13:15:20 +00:00
|
|
|
|
|
|
|
/* make strip the active one... */
|
|
|
|
BKE_nlastrip_set_active(adt, strip);
|
2009-05-22 01:16:26 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2009-05-22 01:16:26 +00:00
|
|
|
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
/* Find the active strip + track combo, and set them up as the tweaking track,
|
|
|
|
* and return if successful or not.
|
|
|
|
*/
|
2014-04-11 11:25:41 +10:00
|
|
|
bool BKE_nla_tweakmode_enter(AnimData *adt)
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
NlaTrack *nlt, *activeTrack = NULL;
|
|
|
|
NlaStrip *strip, *activeStrip = NULL;
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
|
|
|
|
/* verify that data is valid */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, adt, adt->nla_tracks.first))
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
|
|
|
|
/* if block is already in tweakmode, just leave, but we should report
|
|
|
|
* that this block is in tweakmode (as our returncode)
|
|
|
|
*/
|
|
|
|
if (adt->flag & ADT_NLA_EDIT_ON)
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
|
|
|
|
/* go over the tracks, finding the active one, and its active strip
|
2012-05-12 16:11:34 +00:00
|
|
|
* - if we cannot find both, then there's nothing to do
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
/* check if active */
|
|
|
|
if (nlt->flag & NLATRACK_ACTIVE) {
|
|
|
|
/* store reference to this active track */
|
2012-05-12 16:11:34 +00:00
|
|
|
activeTrack = nlt;
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
|
|
|
|
/* now try to find active strip */
|
2012-05-12 16:11:34 +00:00
|
|
|
activeStrip = BKE_nlastrip_find_active(nlt);
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
break;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
}
|
2012-01-22 04:30:52 +00:00
|
|
|
|
|
|
|
/* There are situations where we may have multiple strips selected and we want to enter tweakmode on all
|
|
|
|
* of those at once. Usually in those cases, it will usually just be a single strip per AnimData.
|
|
|
|
* In such cases, compromise and take the last selected track and/or last selected strip [#28468]
|
|
|
|
*/
|
|
|
|
if (activeTrack == NULL) {
|
|
|
|
/* try last selected track for active strip */
|
|
|
|
for (nlt = adt->nla_tracks.last; nlt; nlt = nlt->prev) {
|
|
|
|
if (nlt->flag & NLATRACK_SELECTED) {
|
|
|
|
/* assume this is the active track */
|
2012-05-12 16:11:34 +00:00
|
|
|
activeTrack = nlt;
|
2012-01-22 04:30:52 +00:00
|
|
|
|
|
|
|
/* try to find active strip */
|
2012-05-12 16:11:34 +00:00
|
|
|
activeStrip = BKE_nlastrip_find_active(nlt);
|
2012-01-22 04:30:52 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2012-01-22 04:30:52 +00:00
|
|
|
}
|
|
|
|
if ((activeTrack) && (activeStrip == NULL)) {
|
|
|
|
/* no active strip in active or last selected track; compromise for first selected (assuming only single)... */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (strip = activeTrack->strips.first; strip; strip = strip->next) {
|
|
|
|
if (strip->flag & (NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_ACTIVE)) {
|
2012-01-22 04:30:52 +00:00
|
|
|
activeStrip = strip;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(NULL, activeTrack, activeStrip, activeStrip->act)) {
|
2012-03-31 00:59:17 +00:00
|
|
|
if (G.debug & G_DEBUG) {
|
|
|
|
printf("NLA tweakmode enter - neither active requirement found\n");
|
|
|
|
printf("\tactiveTrack = %p, activeStrip = %p\n", (void *)activeTrack, (void *)activeStrip);
|
2010-04-01 06:26:41 +00:00
|
|
|
}
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* go over all the tracks up to the active one, tagging each strip that uses the same
|
|
|
|
* action as the active strip, but leaving everything else alone
|
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
for (nlt = activeTrack->prev; nlt; nlt = nlt->prev) {
|
|
|
|
for (strip = nlt->strips.first; strip; strip = strip->next) {
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
if (strip->act == activeStrip->act)
|
|
|
|
strip->flag |= NLASTRIP_FLAG_TWEAKUSER;
|
|
|
|
else
|
2009-07-03 01:10:46 +00:00
|
|
|
strip->flag &= ~NLASTRIP_FLAG_TWEAKUSER;
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* go over all the tracks after AND INCLUDING the active one, tagging them as being disabled
|
|
|
|
* - the active track needs to also be tagged, otherwise, it'll overlap with the tweaks going on
|
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
for (nlt = activeTrack; nlt; nlt = nlt->next)
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
nlt->flag |= NLATRACK_DISABLED;
|
|
|
|
|
|
|
|
/* handle AnimData level changes:
|
|
|
|
* - 'real' active action to temp storage (no need to change user-counts)
|
2009-06-06 05:06:46 +00:00
|
|
|
* - action of active strip set to be the 'active action', and have its usercount incremented
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
* - editing-flag for this AnimData block should also get turned on (for more efficient restoring)
|
2009-06-23 13:25:31 +00:00
|
|
|
* - take note of the active strip for mapping-correction of keyframes in the action being edited
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
adt->tmpact = adt->action;
|
|
|
|
adt->action = activeStrip->act;
|
|
|
|
adt->actstrip = activeStrip;
|
2009-06-06 05:06:46 +00:00
|
|
|
id_us_plus(&activeStrip->act->id);
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
adt->flag |= ADT_NLA_EDIT_ON;
|
|
|
|
|
|
|
|
/* done! */
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Exit tweakmode for this AnimData block */
|
2012-04-29 17:11:40 +00:00
|
|
|
void BKE_nla_tweakmode_exit(AnimData *adt)
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
{
|
2009-06-20 04:02:49 +00:00
|
|
|
NlaStrip *strip;
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
NlaTrack *nlt;
|
|
|
|
|
|
|
|
/* verify that data is valid */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, adt, adt->nla_tracks.first))
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* hopefully the flag is correct - skip if not on */
|
|
|
|
if ((adt->flag & ADT_NLA_EDIT_ON) == 0)
|
|
|
|
return;
|
|
|
|
|
2013-04-26 13:42:55 +00:00
|
|
|
/* sync the length of the user-strip with the new state of the action
|
|
|
|
* but only if the user has explicitly asked for this to happen
|
|
|
|
* (see [#34645] for things to be careful about)
|
|
|
|
*/
|
|
|
|
if ((adt->actstrip) && (adt->actstrip->flag & NLASTRIP_FLAG_SYNC_LENGTH)) {
|
|
|
|
strip = adt->actstrip;
|
|
|
|
|
|
|
|
/* must be action-clip only (transitions don't have scale) */
|
|
|
|
if ((strip->type == NLASTRIP_TYPE_CLIP) && (strip->act)) {
|
|
|
|
/* recalculate the length of the action */
|
|
|
|
calc_action_range(strip->act, &strip->actstart, &strip->actend, 0);
|
|
|
|
|
|
|
|
/* adjust the strip extents in response to this */
|
|
|
|
BKE_nlastrip_recalculate_bounds(strip);
|
|
|
|
}
|
|
|
|
}
|
2012-07-07 22:51:57 +00:00
|
|
|
|
2009-07-03 01:10:46 +00:00
|
|
|
/* for all Tracks, clear the 'disabled' flag
|
|
|
|
* for all Strips, clear the 'tweak-user' flag
|
2009-06-20 04:02:49 +00:00
|
|
|
*/
|
2012-05-12 16:11:34 +00:00
|
|
|
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
nlt->flag &= ~NLATRACK_DISABLED;
|
2009-06-20 04:02:49 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (strip = nlt->strips.first; strip; strip = strip->next)
|
2009-06-20 04:02:49 +00:00
|
|
|
strip->flag &= ~NLASTRIP_FLAG_TWEAKUSER;
|
|
|
|
}
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
|
|
|
|
/* handle AnimData level changes:
|
2009-06-06 05:06:46 +00:00
|
|
|
* - 'temporary' active action needs its usercount decreased, since we're removing this reference
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
* - 'real' active action is restored from storage
|
|
|
|
* - storage pointer gets cleared (to avoid having bad notes hanging around)
|
|
|
|
* - editing-flag for this AnimData block should also get turned off
|
2009-06-23 13:25:31 +00:00
|
|
|
* - clear pointer to active strip
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
*/
|
2009-06-06 05:06:46 +00:00
|
|
|
if (adt->action) adt->action->id.us--;
|
2012-05-12 16:11:34 +00:00
|
|
|
adt->action = adt->tmpact;
|
|
|
|
adt->tmpact = NULL;
|
|
|
|
adt->actstrip = NULL;
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
adt->flag &= ~ADT_NLA_EDIT_ON;
|
|
|
|
}
|
|
|
|
|
2010-04-01 06:26:41 +00:00
|
|
|
/* Baking Tools ------------------------------------------- */
|
|
|
|
|
2013-03-08 04:00:06 +00:00
|
|
|
static void UNUSED_FUNCTION(BKE_nla_bake) (Scene *scene, ID *UNUSED(id), AnimData *adt, int UNUSED(flag))
|
2010-04-01 06:26:41 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/* verify that data is valid
|
|
|
|
* 1) Scene and AnimData must be provided
|
|
|
|
* 2) there must be tracks to merge...
|
|
|
|
*/
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(NULL, scene, adt, adt->nla_tracks.first))
|
2010-04-01 06:26:41 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* if animdata currently has an action, 'push down' this onto the stack first */
|
|
|
|
if (adt->action)
|
|
|
|
BKE_nla_action_pushdown(adt);
|
|
|
|
|
|
|
|
/* get range of motion to bake, and the channels involved... */
|
|
|
|
|
|
|
|
/* temporarily mute the action, and start keying to it */
|
|
|
|
|
|
|
|
/* start keying... */
|
|
|
|
|
|
|
|
/* unmute the action */
|
|
|
|
}
|
|
|
|
|
2009-05-22 01:16:26 +00:00
|
|
|
/* *************************************************** */
|