Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_action.h6
-rw-r--r--source/blender/blenkernel/BKE_nla.h2
-rw-r--r--source/blender/blenkernel/intern/action.c42
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c158
-rw-r--r--source/blender/blenkernel/intern/fcurve.c29
-rw-r--r--source/blender/blenkernel/intern/nla.c136
-rw-r--r--source/blender/blenkernel/nla_private.h78
-rw-r--r--source/blender/blenloader/intern/readfile.c4
-rw-r--r--source/blender/editors/animation/anim_draw.c72
-rw-r--r--source/blender/editors/animation/keyframes_draw.c18
-rw-r--r--source/blender/editors/include/ED_anim_api.h14
-rw-r--r--source/blender/editors/include/ED_keyframes_draw.h5
-rw-r--r--source/blender/editors/space_action/action_draw.c24
-rw-r--r--source/blender/editors/space_action/action_edit.c48
-rw-r--r--source/blender/editors/space_action/action_select.c45
-rw-r--r--source/blender/editors/space_graph/graph_draw.c10
-rw-r--r--source/blender/editors/space_graph/graph_edit.c51
-rw-r--r--source/blender/editors/space_graph/graph_select.c46
-rw-r--r--source/blender/editors/transform/transform.c58
-rw-r--r--source/blender/editors/transform/transform_conversions.c103
-rw-r--r--source/blender/editors/transform/transform_generics.c31
-rw-r--r--source/blender/makesdna/DNA_anim_types.h29
22 files changed, 569 insertions, 440 deletions
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index 1fb200b94a8..0c9bba5e413 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -148,12 +148,6 @@ void copy_pose_result(struct bPose *to, struct bPose *from);
/* clear all transforms */
void rest_pose(struct bPose *pose);
-/* map global time (frame nr) to strip converted time, doesn't clip */
-float get_action_frame(struct Object *ob, float cframe);
-/* map strip time to global time (frame nr) */
-float get_action_frame_inv(struct Object *ob, float cframe);
-
-
/* functions used by the game engine */
void game_copy_pose(struct bPose **dst, struct bPose *src);
void game_free_pose(struct bPose *pose);
diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h
index 5200ca6d4d7..cc73ac02690 100644
--- a/source/blender/blenkernel/BKE_nla.h
+++ b/source/blender/blenkernel/BKE_nla.h
@@ -73,5 +73,7 @@ void BKE_nla_action_pushdown(struct AnimData *adt);
short BKE_nla_tweakmode_enter(struct AnimData *adt);
void BKE_nla_tweakmode_exit(struct AnimData *adt);
+float BKE_nla_tweakedit_remap(struct AnimData *adt, float cframe, short invert);
+
#endif
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index f88e249d38c..96896509f60 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -769,48 +769,6 @@ void framechange_poses_clear_unkeyed(void)
/* ************** time ****************** */
-static bActionStrip *get_active_strip(Object *ob)
-{
-#if 0 // XXX old animation system
- bActionStrip *strip;
-
- if(ob->action==NULL)
- return NULL;
-
- for (strip=ob->nlastrips.first; strip; strip=strip->next)
- if(strip->flag & ACTSTRIP_ACTIVE)
- break;
-
- if(strip && strip->act==ob->action)
- return strip;
-#endif // XXX old animation system
-
- return NULL;
-}
-
-/* if the conditions match, it converts current time to strip time */
-// TODO: change this adt
-float get_action_frame(Object *ob, float cframe)
-{
- bActionStrip *strip= get_active_strip(ob);
-
- //if(strip)
- // return get_actionstrip_frame(strip, cframe, 0);
- return cframe;
-}
-
-/* inverted, strip time to current time */
-// TODO: change this to adt
-float get_action_frame_inv(Object *ob, float cframe)
-{
- bActionStrip *strip= get_active_strip(ob);
-
- //if(strip)
- // return get_actionstrip_frame(strip, cframe, 1);
- return cframe;
-}
-
-
/* Check if the given action has any keyframes */
short action_has_motion(const bAction *act)
{
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 7a6706b7c5a..877353a85e9 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1,5 +1,30 @@
-/* Testing code for new animation system in 2.5
- * Copyright 2009, Joshua Leung
+/**
+ * $Id: anim_sys.c 21023 2009-06-20 04:02:49Z aligorith $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Joshua Leung (full recode)
+ *
+ * ***** END GPL LICENSE BLOCK *****
*/
#include <stdio.h>
@@ -14,6 +39,8 @@
#include "BLI_arithb.h"
#include "BLI_dynstr.h"
+#include "DNA_anim_types.h"
+
#include "BKE_animsys.h"
#include "BKE_action.h"
#include "BKE_fcurve.h"
@@ -25,7 +52,7 @@
#include "RNA_access.h"
#include "RNA_types.h"
-#include "DNA_anim_types.h"
+#include "nla_private.h"
/* ***************************************** */
/* AnimData API */
@@ -549,129 +576,6 @@ void animsys_evaluate_action (PointerRNA *ptr, bAction *act, AnimMapper *remap,
/* ***************************************** */
/* NLA System - Evaluation */
-/* used for list of strips to accumulate at current time */
-typedef struct NlaEvalStrip {
- struct NlaEvalStrip *next, *prev;
-
- NlaTrack *track; /* track that this strip belongs to */
- NlaStrip *strip; /* strip that's being used */
-
- short track_index; /* the index of the track within the list */
- short strip_mode; /* which end of the strip are we looking at */
-
- float strip_time; /* time at which which strip is being evaluated */
-} NlaEvalStrip;
-
-/* NlaEvalStrip->strip_mode */
-enum {
- /* standard evaluation */
- NES_TIME_BEFORE = -1,
- NES_TIME_WITHIN,
- NES_TIME_AFTER,
-
- /* transition-strip evaluations */
- NES_TIME_TRANSITION_START,
- NES_TIME_TRANSITION_END,
-} eNlaEvalStrip_StripMode;
-
-
-/* temp channel for accumulating data from NLA (avoids needing to clear all values first) */
-// TODO: maybe this will be used as the 'cache' stuff needed for editable values too?
-typedef struct NlaEvalChannel {
- struct NlaEvalChannel *next, *prev;
-
- PointerRNA ptr; /* pointer to struct containing property to use */
- PropertyRNA *prop; /* RNA-property type to use (should be in the struct given) */
- int index; /* array index (where applicable) */
-
- float value; /* value of this channel */
-} NlaEvalChannel;
-
-
-/* ---------------------- */
-
-/* non clipped mapping for strip-time <-> global time (for Action-Clips)
- * invert = convert action-strip time to global time
- */
-static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short invert)
-{
- float length, actlength, repeat, scale;
-
- /* get number of repeats */
- if (IS_EQ(strip->repeat, 0.0f)) strip->repeat = 1.0f;
- repeat = strip->repeat;
-
- /* scaling */
- if (IS_EQ(strip->scale, 0.0f)) strip->scale= 1.0f;
- scale = (float)fabs(strip->scale); /* scale must be positive - we've got a special flag for reversing */
-
- /* length of referenced action */
- actlength = strip->actend - strip->actstart;
- if (IS_EQ(actlength, 0.0f)) actlength = 1.0f;
-
- /* length of strip */
- length= actlength * scale * repeat;
- if (IS_EQ(length, 0.0f)) length= strip->end - strip->start;
-
- /* reversed = play strip backwards */
- if (strip->flag & NLASTRIP_FLAG_REVERSE) {
- /* invert = convert action-strip time to global time */
- if (invert)
- return length*(strip->actend - cframe)/(repeat*actlength) + strip->start;
- else
- return strip->actend - repeat*actlength*(cframe - strip->start)/length;
- }
- else {
- /* invert = convert action-strip time to global time */
- if (invert)
- return length*(cframe - strip->actstart)/(repeat*actlength) + strip->start;
- else
- return repeat*actlength*(cframe - strip->start)/length + strip->actstart;
- }
-}
-
-/* non clipped mapping for strip-time <-> global time (for Transitions)
- * invert = convert action-strip time to global time
- */
-static float nlastrip_get_frame_transition (NlaStrip *strip, float cframe, short invert)
-{
- float length;
-
- /* length of strip */
- length= strip->end - strip->start;
-
- /* reversed = play strip backwards */
- if (strip->flag & NLASTRIP_FLAG_REVERSE) {
- /* invert = convert within-strip-time to global time */
- if (invert)
- return strip->end - (length * cframe);
- else
- return (strip->end - cframe) / length;
- }
- else {
- /* invert = convert within-strip-time to global time */
- if (invert)
- return (length * cframe) + strip->start;
- else
- return (cframe - strip->start) / length;
- }
-}
-
-/* non clipped mapping for strip-time <-> global time
- * invert = convert action-strip time to global time
- */
-static float nlastrip_get_frame (NlaStrip *strip, float cframe, short invert)
-{
- switch (strip->type) {
- case NLASTRIP_TYPE_TRANSITION: /* transition */
- return nlastrip_get_frame_transition(strip, cframe, invert);
-
- case NLASTRIP_TYPE_CLIP: /* action-clip (default) */
- default:
- return nlastrip_get_frame_actionclip(strip, cframe, invert);
- }
-}
-
/* calculate influence of strip based for given frame based on blendin/out values */
static float nlastrip_get_influence (NlaStrip *strip, float cframe)
{
@@ -695,7 +599,7 @@ static float nlastrip_get_influence (NlaStrip *strip, float cframe)
}
/* evaluate the evaluation time and influence for the strip, storing the results in the strip */
-void nlastrip_evaluate_controls (NlaStrip *strip, float ctime)
+static void nlastrip_evaluate_controls (NlaStrip *strip, float ctime)
{
/* firstly, analytically generate values for influence and time (if applicable) */
if ((strip->flag & NLASTRIP_FLAG_USR_TIME) == 0)
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 856930e5a44..27ca6332cdc 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1,5 +1,30 @@
-/* Testing code for new animation system in 2.5
- * Copyright 2009, Joshua Leung
+/**
+ * $Id: fcurve.c 21023 2009-06-20 04:02:49Z aligorith $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Joshua Leung (full recode)
+ *
+ * ***** END GPL LICENSE BLOCK *****
*/
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 1ce6d9f98c7..a5b3b59d310 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -49,6 +49,9 @@
#include "BKE_object.h"
#include "BKE_utildefines.h"
+#include "RNA_access.h"
+#include "nla_private.h"
+
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -319,6 +322,135 @@ NlaStrip *add_nlastrip_to_stack (AnimData *adt, bAction *act)
}
/* *************************************************** */
+/* 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
+ */
+static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short invert)
+{
+ float length, actlength, repeat, scale;
+
+ /* get number of repeats */
+ if (IS_EQ(strip->repeat, 0.0f)) strip->repeat = 1.0f;
+ repeat = strip->repeat;
+
+ /* scaling */
+ if (IS_EQ(strip->scale, 0.0f)) strip->scale= 1.0f;
+ scale = (float)fabs(strip->scale); /* scale must be positive - we've got a special flag for reversing */
+
+ /* length of referenced action */
+ actlength = strip->actend - strip->actstart;
+ if (IS_EQ(actlength, 0.0f)) actlength = 1.0f;
+
+ /* length of strip */
+ length= actlength * scale * repeat;
+ if (IS_EQ(length, 0.0f)) length= strip->end - strip->start;
+
+ /* reversed = play strip backwards */
+ if (strip->flag & NLASTRIP_FLAG_REVERSE) {
+ /* invert = convert action-strip time to global time */
+ if (invert)
+ return length*(strip->actend - cframe)/(repeat*actlength) + strip->start;
+ else
+ return strip->actend - repeat*actlength*(cframe - strip->start)/length;
+ }
+ else {
+ /* invert = convert action-strip time to global time */
+ if (invert)
+ return length*(cframe - strip->actstart)/(repeat*actlength) + strip->start;
+ else
+ return repeat*actlength*(cframe - strip->start)/length + strip->actstart;
+ }
+}
+
+/* non clipped mapping for strip-time <-> global time (for Transitions)
+ * invert = convert action-strip time to global time
+ */
+static float nlastrip_get_frame_transition (NlaStrip *strip, float cframe, short invert)
+{
+ float length;
+
+ /* length of strip */
+ length= strip->end - strip->start;
+
+ /* reversed = play strip backwards */
+ if (strip->flag & NLASTRIP_FLAG_REVERSE) {
+ /* invert = convert within-strip-time to global time */
+ if (invert)
+ return strip->end - (length * cframe);
+ else
+ return (strip->end - cframe) / length;
+ }
+ else {
+ /* invert = convert within-strip-time to global time */
+ if (invert)
+ return (length * cframe) + strip->start;
+ else
+ return (cframe - strip->start) / length;
+ }
+}
+
+/* non clipped mapping for strip-time <-> global time
+ * invert = convert action-strip time to global time
+ *
+ * only secure for 'internal' (i.e. within AnimSys evaluation) operations,
+ * but should not be directly relied on for stuff which interacts with editors
+ */
+float nlastrip_get_frame (NlaStrip *strip, float cframe, short invert)
+{
+ switch (strip->type) {
+ case NLASTRIP_TYPE_TRANSITION: /* transition */
+ return nlastrip_get_frame_transition(strip, cframe, invert);
+
+ case NLASTRIP_TYPE_CLIP: /* action-clip (default) */
+ default:
+ return nlastrip_get_frame_actionclip(strip, cframe, invert);
+ }
+}
+
+
+/* Non clipped mapping for strip-time <-> global time
+ * invert = convert strip-time to global time
+ *
+ * Public API method - perform this mapping using the given AnimData block
+ * and perform any necessary sanity checks on the value
+ */
+float BKE_nla_tweakedit_remap (AnimData *adt, float cframe, short invert)
+{
+ 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 :)
+ */
+ if ((adt == NULL) || (adt->flag & ADT_NLA_EDIT_ON)==0)
+ 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) {
+ NlaTrack *nlt= BKE_nlatrack_find_active(adt);
+ adt->actstrip= BKE_nlastrip_find_active(nlt);
+ }
+ strip= adt->actstrip;
+
+ /* 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... */
+ return nlastrip_get_frame(strip, cframe, invert);
+}
+
+/* *************************************************** */
/* Basic Utilities */
/* NLA-Tracks ---------------------------------------- */
@@ -693,9 +825,11 @@ short BKE_nla_tweakmode_enter (AnimData *adt)
* - 'real' active action to temp storage (no need to change user-counts)
* - action of active strip set to be the 'active action', and have its usercount incremented
* - editing-flag for this AnimData block should also get turned on (for more efficient restoring)
+ * - take note of the active strip for mapping-correction of keyframes in the action being edited
*/
adt->tmpact= adt->action;
adt->action= activeStrip->act;
+ adt->actstrip= activeStrip;
id_us_plus(&activeStrip->act->id);
adt->flag |= ADT_NLA_EDIT_ON;
@@ -734,10 +868,12 @@ void BKE_nla_tweakmode_exit (AnimData *adt)
* - '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
+ * - clear pointer to active strip
*/
if (adt->action) adt->action->id.us--;
adt->action= adt->tmpact;
adt->tmpact= NULL;
+ adt->actstrip= NULL;
adt->flag &= ~ADT_NLA_EDIT_ON;
}
diff --git a/source/blender/blenkernel/nla_private.h b/source/blender/blenkernel/nla_private.h
new file mode 100644
index 00000000000..af886fb7de8
--- /dev/null
+++ b/source/blender/blenkernel/nla_private.h
@@ -0,0 +1,78 @@
+/**
+ * $Id: BKE_nla.h 20999 2009-06-19 04:45:56Z aligorith $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Joshua Leung (full recode)
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef NLA_PRIVATE
+#define NLA_PRIVATE
+
+/* --------------- NLA Evaluation DataTypes ----------------------- */
+
+/* used for list of strips to accumulate at current time */
+typedef struct NlaEvalStrip {
+ struct NlaEvalStrip *next, *prev;
+
+ NlaTrack *track; /* track that this strip belongs to */
+ NlaStrip *strip; /* strip that's being used */
+
+ short track_index; /* the index of the track within the list */
+ short strip_mode; /* which end of the strip are we looking at */
+
+ float strip_time; /* time at which which strip is being evaluated */
+} NlaEvalStrip;
+
+/* NlaEvalStrip->strip_mode */
+enum {
+ /* standard evaluation */
+ NES_TIME_BEFORE = -1,
+ NES_TIME_WITHIN,
+ NES_TIME_AFTER,
+
+ /* transition-strip evaluations */
+ NES_TIME_TRANSITION_START,
+ NES_TIME_TRANSITION_END,
+} eNlaEvalStrip_StripMode;
+
+
+/* temp channel for accumulating data from NLA (avoids needing to clear all values first) */
+// TODO: maybe this will be used as the 'cache' stuff needed for editable values too?
+typedef struct NlaEvalChannel {
+ struct NlaEvalChannel *next, *prev;
+
+ PointerRNA ptr; /* pointer to struct containing property to use */
+ PropertyRNA *prop; /* RNA-property type to use (should be in the struct given) */
+ int index; /* array index (where applicable) */
+
+ float value; /* value of this channel */
+} NlaEvalChannel;
+
+/* --------------- NLA Functions (not to be used as a proper API) ----------------------- */
+
+/* convert from strip time <-> global time */
+float nlastrip_get_frame(NlaStrip *strip, float cframe, short invert);
+
+#endif // NLA_PRIVATE
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index af4f61fccc4..d7f60e1928b 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -1933,6 +1933,10 @@ static void direct_link_animdata(FileData *fd, AnimData *adt)
/* link NLA-data */
link_list(fd, &adt->nla_tracks);
direct_link_nladata(fd, &adt->nla_tracks);
+
+ /* clear temp pointers that may have been set... */
+ // TODO: it's probably only a small cost to reload this anyway...
+ adt->actstrip= NULL;
}
/* ************ READ NODE TREE *************** */
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index c176f20c26b..6d079fe148a 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -43,10 +43,12 @@
#include "BLI_blenlib.h"
+#include "BKE_animsys.h"
#include "BKE_action.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_fcurve.h"
+#include "BKE_nla.h"
#include "BKE_object.h"
#include "BKE_screen.h"
#include "BKE_utildefines.h"
@@ -232,37 +234,16 @@ void ANIM_draw_previewrange (const bContext *C, View2D *v2d)
/* *************************************************** */
/* NLA-MAPPING UTILITIES (required for drawing and also editing keyframes) */
-/* Obtain the Object providing NLA-scaling for the given channel (if applicable) */
-Object *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
+/* Obtain the AnimData block providing NLA-mapping for the given channel (if applicable) */
+AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
{
/* sanity checks */
if (ac == NULL)
return NULL;
/* handling depends on the type of animation-context we've got */
- if (ac->datatype == ANIMCONT_ACTION) {
- /* Action Editor (action mode) or Graph Editor (ipo mode):
- * Only use if editor is not pinned, and active object has action
- */
- if (ac->obact && ac->obact->action) {
- SpaceAction *saction= (SpaceAction *)ac->sa->spacedata.first;
-
- if (saction->pin == 0)
- return ac->obact;
- }
- }
- else if ((ac->datatype == ANIMCONT_DOPESHEET) && (ale)) {
- /* Dopesheet:
- * Only if channel is available, and is owned by an Object with an Action
- */
- if ((ale->id) && (GS(ale->id->name) == ID_OB)) {
- Object *ob= (Object *)ale->id;
-
- if (ob->action)
- return ob;
- }
- }
- // XXX todo: add F-Curves mode (Graph Editor) ...
+ if (ale && ale->id)
+ return BKE_animdata_from_id(ale->id);
/* no appropriate object found */
return NULL;
@@ -273,7 +254,8 @@ Object *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
* (where this is called) is single-threaded anyway
*/
// XXX was called: map_active_strip()
-void ANIM_nla_mapping_draw(gla2DDrawInfo *di, Object *ob, short restore)
+// TODO: should this be depreceated?
+void ANIM_nla_mapping_draw(gla2DDrawInfo *di, AnimData *adt, short restore)
{
static rctf stored;
@@ -288,8 +270,8 @@ void ANIM_nla_mapping_draw(gla2DDrawInfo *di, Object *ob, short restore)
gla2DGetMap(di, &stored);
map= stored;
- map.xmin= get_action_frame(ob, map.xmin);
- map.xmax= get_action_frame(ob, map.xmax);
+ map.xmin= BKE_nla_tweakedit_remap(adt, map.xmin, 0);
+ map.xmax= BKE_nla_tweakedit_remap(adt, map.xmax, 0);
if (map.xmin == map.xmax) map.xmax += 1.0f;
gla2DSetMap(di, &map);
@@ -298,36 +280,38 @@ void ANIM_nla_mapping_draw(gla2DDrawInfo *di, Object *ob, short restore)
/* ------------------- */
-/* helper function for ANIM_nla_mapping_apply_ipocurve() -> "restore", i.e. mapping points back to IPO-time */
+/* helper function for ANIM_nla_mapping_apply_fcurve() -> "restore", i.e. mapping points back to action-time */
static short bezt_nlamapping_restore(BeztEditData *bed, BezTriple *bezt)
{
- /* object providing scaling is stored in 'data', only_keys option is stored in i1 */
- Object *ob= (Object *)bed->data;
+ /* AnimData block providing scaling is stored in 'data', only_keys option is stored in i1 */
+ AnimData *adt= (AnimData *)bed->data;
short only_keys= (short)bed->i1;
/* adjust BezTriple handles only if allowed to */
if (only_keys == 0) {
- bezt->vec[0][0]= get_action_frame(ob, bezt->vec[0][0]);
- bezt->vec[2][0]= get_action_frame(ob, bezt->vec[2][0]);
- }
- bezt->vec[1][0]= get_action_frame(ob, bezt->vec[1][0]);
+ bezt->vec[0][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[0][0], 0);
+ bezt->vec[2][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[2][0], 0);
+ }
+
+ bezt->vec[1][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[1][0], 0);
return 0;
}
-/* helper function for ANIM_nla_mapping_apply_ipocurve() -> "apply", i.e. mapping points to NLA-mapped global time */
+/* helper function for ANIM_nla_mapping_apply_fcurve() -> "apply", i.e. mapping points to NLA-mapped global time */
static short bezt_nlamapping_apply(BeztEditData *bed, BezTriple *bezt)
{
- /* object providing scaling is stored in 'data', only_keys option is stored in i1 */
- Object *ob= (Object *)bed->data;
+ /* AnimData block providing scaling is stored in 'data', only_keys option is stored in i1 */
+ AnimData *adt= (AnimData *)bed->data;
short only_keys= (short)bed->i1;
/* adjust BezTriple handles only if allowed to */
if (only_keys == 0) {
- bezt->vec[0][0]= get_action_frame_inv(ob, bezt->vec[0][0]);
- bezt->vec[2][0]= get_action_frame_inv(ob, bezt->vec[2][0]);
+ bezt->vec[0][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[0][0], 1);
+ bezt->vec[2][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[2][0], 1);
}
- bezt->vec[1][0]= get_action_frame_inv(ob, bezt->vec[1][0]);
+
+ bezt->vec[1][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[1][0], 1);
return 0;
}
@@ -338,17 +322,17 @@ static short bezt_nlamapping_apply(BeztEditData *bed, BezTriple *bezt)
* - restore = whether to map points back to non-mapped time
* - only_keys = whether to only adjust the location of the center point of beztriples
*/
-void ANIM_nla_mapping_apply_fcurve(Object *ob, FCurve *fcu, short restore, short only_keys)
+void ANIM_nla_mapping_apply_fcurve (AnimData *adt, FCurve *fcu, short restore, short only_keys)
{
BeztEditData bed;
BeztEditFunc map_cb;
/* init edit data
- * - ob is stored in 'data'
+ * - AnimData is stored in 'data'
* - only_keys is stored in 'i1'
*/
memset(&bed, 0, sizeof(BeztEditData));
- bed.data= (void *)ob;
+ bed.data= (void *)adt;
bed.i1= (int)only_keys;
/* get editing callback */
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 144cd68f6df..07db47c8fed 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -451,7 +451,7 @@ void ob_to_keylist(Object *ob, ListBase *keys, ListBase *blocks, ActKeysInc *aki
/* Add action keyframes */
if (ob->adt && ob->adt->action)
- action_nlascaled_to_keylist(ob, ob->adt->action, keys, blocks, aki);
+ action_nlascaled_to_keylist(ob->adt, ob->adt->action, keys, blocks, aki);
/* Add shapekey keyframes (only if dopesheet allows, if it is available) */
// TODO: when we adapt NLA system, this needs to be the NLA-scaled version
@@ -602,34 +602,34 @@ void action_to_keylist(bAction *act, ListBase *keys, ListBase *blocks, ActKeysIn
}
}
-void action_nlascaled_to_keylist(Object *ob, bAction *act, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
+void action_nlascaled_to_keylist(AnimData *adt, bAction *act, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
{
FCurve *fcu;
- Object *oldob= NULL;
+ AnimData *oldadt= NULL;
- /* although apply and clearing NLA-scaling pre-post creating keylist does impact on performance,
+ /* although apply and clearing NLA-mapping pre-post creating keylist does impact on performance,
* the effects should be fairly minimal, as we're already going through the keyframes multiple times
* already for blocks too...
*/
if (act) {
/* if 'aki' is provided, store it's current ob to restore later as it might not be the same */
if (aki) {
- oldob= aki->ob;
- aki->ob= ob;
+ oldadt= aki->adt;
+ aki->adt= adt;
}
/* loop through F-Curves
* - scaling correction only does times for center-points, so should be faster
*/
for (fcu= act->curves.first; fcu; fcu= fcu->next) {
- ANIM_nla_mapping_apply_fcurve(ob, fcu, 0, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1);
fcurve_to_keylist(fcu, keys, blocks, aki);
- ANIM_nla_mapping_apply_fcurve(ob, fcu, 1, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1);
}
/* if 'aki' is provided, restore ob */
if (aki)
- aki->ob= oldob;
+ aki->adt= oldadt;
}
}
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index 8c54c4e8f67..4bfcbde8f1e 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -310,16 +310,14 @@ void ipo_rainbow(int cur, int tot, float *out);
/* ------------- NLA-Mapping ----------------------- */
/* anim_draw.c */
-// XXX these need attention for the new editing method...
+/* Obtain the AnimData block providing NLA-scaling for the given channel if applicable */
+struct AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale);
-/* Obtain the Object providing NLA-scaling for the given channel if applicable */
-struct Object *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale);
+/* Set/clear temporary mapping of coordinates from 'local-action' time to 'global-nla-mapped' time */
+void ANIM_nla_mapping_draw(struct gla2DDrawInfo *di, struct AnimData *adt, short restore);
-/* Set/clear temporary mapping of coordinates from 'local-action' time to 'global-nla-scaled' time */
-void ANIM_nla_mapping_draw(struct gla2DDrawInfo *di, struct Object *ob, short restore);
-
-/* Apply/Unapply NLA mapping to all keyframes in the nominated IPO block */
-void ANIM_nla_mapping_apply_fcurve(struct Object *ob, struct FCurve *fcu, short restore, short only_keys);
+/* Apply/Unapply NLA mapping to all keyframes in the nominated F-Curve */
+void ANIM_nla_mapping_apply_fcurve(struct AnimData *adt, struct FCurve *fcu, short restore, short only_keys);
/* ------------- Utility macros ----------------------- */
diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h
index 81420ac95e5..153b10cf832 100644
--- a/source/blender/editors/include/ED_keyframes_draw.h
+++ b/source/blender/editors/include/ED_keyframes_draw.h
@@ -30,6 +30,7 @@
#ifndef ED_KEYFRAMES_DRAW_H
#define ED_KEYFRAMES_DRAW_H
+struct AnimData;
struct BezTriple;
struct FCurve;
struct gla2DDrawInfo;
@@ -69,7 +70,7 @@ typedef struct ActKeyBlock {
/* Inclusion-Range Limiting Struct (optional) */
typedef struct ActKeysInc {
struct bDopeSheet *ads; /* dopesheet data (for dopesheet mode) */
- struct Object *ob; /* owner object for NLA-scaling info (if Object channels, is just Object) */
+ struct AnimData *adt; /* owner for NLA-mapping info */
short actmode; /* mode of the Action Editor (-1 is for NLA) */
float start, end; /* frames (global-time) to only consider keys between */ // XXX not used anymore!
@@ -89,7 +90,7 @@ void draw_gpl_channel(struct gla2DDrawInfo *di, ActKeysInc *aki, struct bGPDlaye
void fcurve_to_keylist(struct FCurve *fcu, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
void agroup_to_keylist(struct bActionGroup *agrp, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
void action_to_keylist(struct bAction *act, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
-void action_nlascaled_to_keylist(struct Object *ob, struct bAction *act, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
+void action_nlascaled_to_keylist(struct AnimData *adt, struct bAction *act, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
void ob_to_keylist(struct Object *ob, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
void scene_to_keylist(struct Scene *sce, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
void gpl_to_keylist(struct bGPDlayer *gpl, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 6eae581aa40..61048598644 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -964,7 +964,7 @@ ActKeysInc *init_aki_data(bAnimContext *ac, bAnimListElem *ale)
return NULL;
/* if strip is mapped, store settings */
- aki.ob= ANIM_nla_mapping_get(ac, ale);
+ aki.adt= ANIM_nla_mapping_get(ac, ale);
if (ac->datatype == ANIMCONT_DOPESHEET)
aki.ads= (bDopeSheet *)ac->data;
@@ -985,7 +985,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
int filter;
View2D *v2d= &ar->v2d;
- Object *nob= NULL;
+ AnimData *adt= NULL;
gla2DDrawInfo *di;
rcti scr_rct;
@@ -1016,18 +1016,18 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
/* if in NLA there's a strip active, map the view */
if (ac->datatype == ANIMCONT_ACTION) {
- nob= ANIM_nla_mapping_get(ac, NULL);
+ adt= ANIM_nla_mapping_get(ac, NULL);
- if (nob)
- ANIM_nla_mapping_draw(di, nob, 0);
+ if (adt)
+ ANIM_nla_mapping_draw(di, adt, 0);
/* start and end of action itself */
calc_action_range(ac->data, &sta, &end, 0);
gla2DDrawTranslatePt(di, sta, 0.0f, &act_start, &dummy);
gla2DDrawTranslatePt(di, end, 0.0f, &act_end, &dummy);
- if (nob)
- ANIM_nla_mapping_draw(di, nob, 1);
+ if (adt)
+ ANIM_nla_mapping_draw(di, adt, 1);
}
/* build list of channels to draw */
@@ -1191,10 +1191,10 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
/* check if anything to show for this channel */
if (ale->datatype != ALE_NONE) {
ActKeysInc *aki= init_aki_data(ac, ale);
- nob= ANIM_nla_mapping_get(ac, ale);
+ adt= ANIM_nla_mapping_get(ac, ale);
- if (nob)
- ANIM_nla_mapping_draw(di, nob, 0);
+ if (adt)
+ ANIM_nla_mapping_draw(di, adt, 0);
/* draw 'keyframes' for each specific datatype */
switch (ale->datatype) {
@@ -1218,8 +1218,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
break;
}
- if (nob)
- ANIM_nla_mapping_draw(di, nob, 1);
+ if (adt)
+ ANIM_nla_mapping_draw(di, adt, 1);
}
}
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index deaa6597bd2..272ef3222ce 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -67,6 +67,7 @@
#include "BKE_fcurve.h"
#include "BKE_key.h"
#include "BKE_material.h"
+#include "BKE_nla.h"
#include "BKE_object.h"
#include "BKE_context.h"
#include "BKE_report.h"
@@ -112,16 +113,16 @@ static void get_keyframe_extents (bAnimContext *ac, float *min, float *max)
if (anim_data.first) {
/* go through channels, finding max extents */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
float tmin, tmax;
/* get range and apply necessary scaling before */
calc_fcurve_range(fcu, &tmin, &tmax);
- if (nob) {
- tmin= get_action_frame_inv(nob, tmin);
- tmax= get_action_frame_inv(nob, tmax);
+ if (adt) {
+ tmin= BKE_nla_tweakedit_remap(adt, tmin, 1);
+ tmax= BKE_nla_tweakedit_remap(adt, tmax, 1);
}
/* try to set cur using these values, if they're more extreme than previously set values */
@@ -400,14 +401,14 @@ static void insert_action_keys(bAnimContext *ac, short mode)
/* insert keyframes */
for (ale= anim_data.first; ale; ale= ale->next) {
- //Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
/* adjust current frame for NLA-scaling */
- //if (nob)
- // cfra= get_action_frame(nob, CFRA);
- //else
- // cfra= (float)CFRA;
+ if (adt)
+ cfra= BKE_nla_tweakedit_remap(adt, (float)CFRA, 1);
+ else
+ cfra= (float)CFRA;
/* if there's an id */
if (ale->id)
@@ -1054,8 +1055,17 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *op)
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- for (ale= anim_data.first; ale; ale= ale->next)
- ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL);
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
+
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
+ ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
+ }
+ else
+ ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL);
+ }
BLI_freelistN(&anim_data);
@@ -1125,12 +1135,12 @@ static void snap_action_keys(bAnimContext *ac, short mode)
/* snap keyframes */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
- if (nob) {
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 1);
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve);
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 1, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
//else if (ale->type == ACTTYPE_GPLAYER)
// snap_gplayer_frames(ale->data, mode);
@@ -1241,12 +1251,12 @@ static void mirror_action_keys(bAnimContext *ac, short mode)
/* mirror keyframes */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
- if (nob) {
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 1);
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve);
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 1, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
//else if (ale->type == ACTTYPE_GPLAYER)
// snap_gplayer_frames(ale->data, mode);
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 4cb39712f84..3583d16fd8c 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -64,6 +64,7 @@
#include "BKE_fcurve.h"
#include "BKE_key.h"
#include "BKE_material.h"
+#include "BKE_nla.h"
#include "BKE_object.h"
#include "BKE_context.h"
#include "BKE_utildefines.h"
@@ -245,7 +246,7 @@ static void borderselect_action (bAnimContext *ac, rcti rect, short mode, short
/* loop over data, doing border select */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
/* get new vertical minimum extent of channel */
ymin= ymax - ACHANNEL_STEP;
@@ -253,9 +254,9 @@ static void borderselect_action (bAnimContext *ac, rcti rect, short mode, short
/* set horizontal range (if applicable) */
if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) {
/* if channel is mapped in NLA, apply correction */
- if (nob) {
- bed.f1= get_action_frame(nob, rectf.xmin);
- bed.f2= get_action_frame(nob, rectf.xmax);
+ if (adt) {
+ bed.f1= BKE_nla_tweakedit_remap(adt, rectf.xmin, 0);
+ bed.f2= BKE_nla_tweakedit_remap(adt, rectf.xmax, 0);
}
else {
bed.f1= rectf.xmin;
@@ -413,12 +414,12 @@ static void markers_selectkeys_between (bAnimContext *ac)
/* select keys in-between */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
- if (nob) {
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 1);
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL);
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 1, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
else {
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL);
@@ -495,15 +496,15 @@ static void columnselect_action_keys (bAnimContext *ac, short mode)
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
/* loop over cfraelems (stored in the BeztEditData->list)
* - we need to do this here, as we can apply fewer NLA-mapping conversions
*/
for (ce= bed.list.first; ce; ce= ce->next) {
/* set frame for validation callback to refer to */
- if (nob)
- bed.f1= get_action_frame(nob, ce->cfra);
+ if (adt)
+ bed.f1= BKE_nla_tweakedit_remap(adt, ce->cfra, 0);
else
bed.f1= ce->cfra;
@@ -658,12 +659,12 @@ static void actkeys_mselect_leftright (bAnimContext *ac, short leftright, short
/* select keys on the side where most data occurs */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
- if (nob) {
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 1);
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL);
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 1, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
//else if (ale->type == ANIMTYPE_GPLAYER)
// borderselect_gplayer_frames(ale->data, min, max, SELECT_ADD);
@@ -702,11 +703,11 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
/* set frame for validation callback to refer to */
- if (nob)
- bed.f1= get_action_frame(nob, selx);
+ if (adt)
+ bed.f1= BKE_nla_tweakedit_remap(adt, selx, 0);
else
bed.f1= selx;
@@ -771,15 +772,15 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short select_mode,
}
else {
/* found match - must return here... */
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
ActKeysInc *aki= init_aki_data(ac, ale);
ActKeyColumn *ak;
float xmin, xmax;
/* apply NLA-scaling correction? */
- if (nob) {
- xmin= get_action_frame(nob, rectf.xmin);
- xmax= get_action_frame(nob, rectf.xmax);
+ if (adt) {
+ xmin= BKE_nla_tweakedit_remap(adt, rectf.xmin, 0);
+ xmax= BKE_nla_tweakedit_remap(adt, rectf.xmax, 0);
}
else {
xmin= rectf.xmin;
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index acf712d0147..d9e12afc947 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -836,11 +836,11 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri
for (ale=anim_data.first; ale; ale=ale->next) {
FCurve *fcu= (FCurve *)ale->key_data;
FModifier *fcm= fcurve_find_active_modifier(fcu);
- //Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
/* map keyframes for drawing if scaled F-Curve */
- //if (nob)
- // ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 0);
+ if (adt)
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
/* draw curve:
* - curve line may be result of one or more destructive modifiers or just the raw data,
@@ -918,8 +918,8 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri
}
/* undo mapping of keyframes for drawing if scaled F-Curve */
- //if (nob)
- // ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 1, 0);
+ if (adt)
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
}
/* free list of curves */
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 8903d95b288..a1888e252d2 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -67,6 +67,7 @@
#include "BKE_fcurve.h"
#include "BKE_key.h"
#include "BKE_material.h"
+#include "BKE_nla.h"
#include "BKE_object.h"
#include "BKE_context.h"
#include "BKE_report.h"
@@ -114,16 +115,16 @@ static void get_graph_keyframe_extents (bAnimContext *ac, float *xmin, float *xm
if (anim_data.first) {
/* go through channels, finding max extents */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= NULL; //ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
float txmin, txmax, tymin, tymax;
/* get range and apply necessary scaling before */
calc_fcurve_bounds(fcu, &txmin, &txmax, &tymin, &tymax);
- if (nob) {
- txmin= get_action_frame_inv(nob, txmin);
- txmax= get_action_frame_inv(nob, txmax);
+ if (adt) {
+ txmin= BKE_nla_tweakedit_remap(adt, txmin, 1);
+ txmax= BKE_nla_tweakedit_remap(adt, txmax, 1);
}
/* try to set cur using these values, if they're more extreme than previously set values */
@@ -271,6 +272,7 @@ static void create_ghost_curves (bAnimContext *ac, int start, int end)
for (ale= anim_data.first; ale; ale= ale->next) {
FCurve *fcu= (FCurve *)ale->key_data;
FCurve *gcu= MEM_callocN(sizeof(FCurve), "Ghost FCurve");
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
ChannelDriver *driver= fcu->driver;
FPoint *fpt;
int cfra;
@@ -286,8 +288,10 @@ static void create_ghost_curves (bAnimContext *ac, int start, int end)
/* use the sampling callback at 1-frame intervals from start to end frames */
for (cfra= start; cfra <= end; cfra++, fpt++) {
- fpt->vec[0]= (float)cfra;
- fpt->vec[1]= fcurve_samplingcb_evalcurve(fcu, NULL, (float)cfra);
+ float cfrae= BKE_nla_tweakedit_remap(adt, cfra, 1);
+
+ fpt->vec[0]= cfrae;
+ fpt->vec[1]= fcurve_samplingcb_evalcurve(fcu, NULL, cfrae);
}
/* set color of ghost curve
@@ -403,6 +407,7 @@ static int graphkeys_click_insert_exec (bContext *C, wmOperator *op)
{
bAnimContext ac;
bAnimListElem *ale;
+ AnimData *adt;
float frame, val;
/* get animation context */
@@ -420,6 +425,10 @@ static int graphkeys_click_insert_exec (bContext *C, wmOperator *op)
frame= RNA_float_get(op->ptr, "frame");
val= RNA_float_get(op->ptr, "value");
+ /* apply inverse NLA-mapping to frame to get correct time in un-scaled action */
+ adt= ANIM_nla_mapping_get(&ac, ale);
+ frame= BKE_nla_tweakedit_remap(adt, frame, 1);
+
/* insert keyframe on the specified frame + value */
insert_vert_fcurve((FCurve *)ale->data, frame, val, 0);
@@ -1336,8 +1345,18 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *op)
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE| ANIMFILTER_CURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- for (ale= anim_data.first; ale; ale= ale->next)
- ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL);
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
+
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
+ ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
+ }
+ else
+ ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL);
+
+ }
BLI_freelistN(&anim_data);
@@ -1405,12 +1424,12 @@ static void snap_graph_keys(bAnimContext *ac, short mode)
/* snap keyframes */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
- if (nob) {
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 1);
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve);
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 1, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
else
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve);
@@ -1516,12 +1535,12 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
/* mirror keyframes */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
- if (nob) {
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 1);
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve);
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 1, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
else
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve);
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 632ce30863d..4451cfae227 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -63,6 +63,7 @@
#include "BKE_fcurve.h"
#include "BKE_key.h"
#include "BKE_material.h"
+#include "BKE_nla.h"
#include "BKE_object.h"
#include "BKE_context.h"
#include "BKE_utildefines.h"
@@ -231,14 +232,14 @@ static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, sho
/* loop over data, doing border select */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
/* set horizontal range (if applicable) */
if (mode != BEZT_OK_VALUERANGE) {
/* if channel is mapped in NLA, apply correction */
- if (nob) {
- bed.f1= get_action_frame(nob, rectf.xmin);
- bed.f2= get_action_frame(nob, rectf.xmax);
+ if (adt) {
+ bed.f1= BKE_nla_tweakedit_remap(adt, rectf.xmin, 0);
+ bed.f2= BKE_nla_tweakedit_remap(adt, rectf.xmax, 0);
}
else {
bed.f1= rectf.xmin;
@@ -379,12 +380,12 @@ static void markers_selectkeys_between (bAnimContext *ac)
/* select keys in-between */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
- if (nob) {
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 1);
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL);
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 1, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
else {
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL);
@@ -450,15 +451,15 @@ static void columnselect_graph_keys (bAnimContext *ac, short mode)
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
/* loop over cfraelems (stored in the BeztEditData->list)
* - we need to do this here, as we can apply fewer NLA-mapping conversions
*/
for (ce= bed.list.first; ce; ce= ce->next) {
/* set frame for validation callback to refer to */
- if (nob)
- bed.f1= get_action_frame(nob, ce->cfra);
+ if (ale)
+ bed.f1= BKE_nla_tweakedit_remap(adt, ce->cfra, 0);
else
bed.f1= ce->cfra;
@@ -566,11 +567,16 @@ static short findnearest_fcurve_vert (bAnimContext *ac, int mval[2], FCurve **fc
for (ale= anim_data.first; ale; ale= ale->next) {
FCurve *fcu= (FCurve *)ale->key_data;
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
/* try to progressively get closer to the right point... */
if (fcu->bezt) {
BezTriple *bezt1=fcu->bezt, *prevbezt=NULL;
+ /* apply NLA mapping to all the keyframes */
+ if (adt)
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
+
for (i=0; i < fcu->totvert; i++, prevbezt=bezt1, bezt1++) {
/* convert beztriple points to screen-space */
UI_view2d_to_region_no_clip(v2d, bezt1->vec[0][0], bezt1->vec[0][1], &sco[0][0], &sco[0][1]);
@@ -624,6 +630,10 @@ static short findnearest_fcurve_vert (bAnimContext *ac, int mval[2], FCurve **fc
}
}
}
+
+ /* un-apply NLA mapping from all the keyframes */
+ if (adt)
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
}
@@ -767,12 +777,12 @@ static void graphkeys_mselect_leftright (bAnimContext *ac, short leftright, shor
/* select keys on the side where most data occurs */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
- if (nob) {
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 1);
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL);
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 1, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
else
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL);
@@ -827,11 +837,11 @@ static void graphkeys_mselect_column (bAnimContext *ac, int mval[2], short selec
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
/* set frame for validation callback to refer to */
- if (nob)
- bed.f1= get_action_frame(nob, selx);
+ if (adt)
+ bed.f1= BKE_nla_tweakedit_remap(adt, selx, 0);
else
bed.f1= selx;
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index fa93d2a143d..f115bb9a068 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -45,6 +45,7 @@
#include "MEM_guardedalloc.h"
+#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_action_types.h" /* for some special action-editor settings */
#include "DNA_constraint_types.h"
@@ -76,9 +77,9 @@
//#include "BIF_editmesh.h"
//#include "BIF_editsima.h"
//#include "BIF_editparticle.h"
-//#include "BIF_editaction.h"
-#include "BKE_action.h" /* get_action_frame */
+#include "BKE_action.h"
+#include "BKE_nla.h"
//#include "BKE_bad_level_calls.h"/* popmenu and error */
#include "BKE_bmesh.h"
#include "BKE_context.h"
@@ -89,7 +90,6 @@
#include "BKE_utildefines.h"
#include "BKE_context.h"
-//#include "BSE_editaction_types.h"
//#include "BSE_view.h"
#include "ED_image.h"
@@ -4354,7 +4354,7 @@ static short getAnimEdit_DrawTime(TransInfo *t)
/* This function is used by Animation Editor specific transform functions to do
* the Snap Keyframe to Nearest Frame/Marker
*/
-static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, Object *ob, short autosnap)
+static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, AnimData *adt, short autosnap)
{
/* snap key to nearest frame? */
if (autosnap == SACTSNAP_FRAME) {
@@ -4364,8 +4364,8 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, Object *ob, short
double val;
/* convert frame to nla-action time (if needed) */
- if (ob)
- val= get_action_frame_inv(ob, *(td->val));
+ if (adt)
+ val= BKE_nla_tweakedit_remap(adt, *(td->val), 1);
else
val= *(td->val);
@@ -4376,8 +4376,8 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, Object *ob, short
val= (float)( floor(val+0.5f) );
/* convert frame out of nla-action time */
- if (ob)
- *(td->val)= get_action_frame(ob, val);
+ if (adt)
+ *(td->val)= BKE_nla_tweakedit_remap(adt, val, 0);
else
*(td->val)= val;
}
@@ -4386,8 +4386,8 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, Object *ob, short
float val;
/* convert frame to nla-action time (if needed) */
- if (ob)
- val= get_action_frame_inv(ob, *(td->val));
+ if (adt)
+ val= BKE_nla_tweakedit_remap(adt, *(td->val), 1);
else
val= *(td->val);
@@ -4396,8 +4396,8 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, Object *ob, short
val= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, val);
/* convert frame out of nla-action time */
- if (ob)
- *(td->val)= get_action_frame(ob, val);
+ if (adt)
+ *(td->val)= BKE_nla_tweakedit_remap(adt, val, 0);
else
*(td->val)= val;
}
@@ -4473,10 +4473,10 @@ static void applyTimeTranslate(TransInfo *t, float sval)
/* it is assumed that td->ob is a pointer to the object,
* whose active action is where this keyframe comes from
*/
- Object *ob= td->ob;
+ AnimData *adt= td->extra;
- /* check if any need to apply nla-scaling */
- if (ob) {
+ /* check if any need to apply nla-mapping */
+ if (adt) {
deltax = t->values[0];
if (autosnap == SACTSNAP_STEP) {
@@ -4486,9 +4486,9 @@ static void applyTimeTranslate(TransInfo *t, float sval)
deltax= (float)( floor(deltax + 0.5f) );
}
- val = get_action_frame_inv(ob, td->ival);
+ val = BKE_nla_tweakedit_remap(adt, td->ival, 1);
val += deltax;
- *(td->val) = get_action_frame(ob, val);
+ *(td->val) = BKE_nla_tweakedit_remap(adt, val, 0);
}
else {
deltax = val = t->values[0];
@@ -4504,7 +4504,7 @@ static void applyTimeTranslate(TransInfo *t, float sval)
}
/* apply nearest snapping */
- doAnimEdit_SnapFrame(t, td, ob, autosnap);
+ doAnimEdit_SnapFrame(t, td, adt, autosnap);
}
}
@@ -4604,15 +4604,15 @@ static void applyTimeSlide(TransInfo *t, float sval)
/* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */
for (i = 0 ; i < t->total; i++, td++) {
- /* it is assumed that td->ob is a pointer to the object,
+ /* it is assumed that td->extra is a pointer to the AnimData,
* whose active action is where this keyframe comes from
*/
- Object *ob= td->ob;
+ AnimData *adt= td->extra;
float cval = t->values[0];
- /* apply scaling to necessary values */
- if (ob)
- cval= get_action_frame(ob, cval);
+ /* apply NLA-mapping to necessary values */
+ if (adt)
+ cval= BKE_nla_tweakedit_remap(adt, cval, 0);
/* only apply to data if in range */
if ((sval > minx) && (sval < maxx)) {
@@ -4707,10 +4707,10 @@ static void applyTimeScale(TransInfo *t) {
for (i = 0 ; i < t->total; i++, td++) {
- /* it is assumed that td->ob is a pointer to the object,
+ /* it is assumed that td->extra is a pointer to the AnimData,
* whose active action is where this keyframe comes from
*/
- Object *ob= td->ob;
+ AnimData *adt= td->extra;
float startx= CFRA;
float fac= t->values[0];
@@ -4721,9 +4721,9 @@ static void applyTimeScale(TransInfo *t) {
fac= (float)( floor(fac + 0.5f) );
}
- /* check if any need to apply nla-scaling */
- if (ob)
- startx= get_action_frame(ob, startx);
+ /* check if any need to apply nla-mapping */
+ if (adt)
+ startx= BKE_nla_tweakedit_remap(adt, startx, 0);
/* now, calculate the new value */
*(td->val) = td->ival - startx;
@@ -4731,7 +4731,7 @@ static void applyTimeScale(TransInfo *t) {
*(td->val) += startx;
/* apply nearest snapping */
- doAnimEdit_SnapFrame(t, td, ob, autosnap);
+ doAnimEdit_SnapFrame(t, td, adt, autosnap);
}
}
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index cb210a37bf4..fc5a6b85de4 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -90,6 +90,7 @@
#include "BKE_mball.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
+#include "BKE_nla.h"
#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_sequence.h"
@@ -2857,12 +2858,12 @@ static void posttrans_action_clean (bAnimContext *ac, bAction *act)
* - all keyframes are converted in/out of global time
*/
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
- if (nob) {
- //ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 0, 1);
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
posttrans_fcurve_clean(ale->key_data);
- //ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 1, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
else
posttrans_fcurve_clean(ale->key_data);
@@ -2920,17 +2921,16 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra)
}
/* This function assigns the information to transdata */
-static void TimeToTransData(TransData *td, float *time, Object *ob)
+static void TimeToTransData(TransData *td, float *time, AnimData *adt)
{
/* memory is calloc'ed, so that should zero everything nicely for us */
td->val = time;
td->ival = *(time);
- /* store the Object where this keyframe exists as a keyframe of the
- * active action as td->ob. Usually, this member is only used for constraints
- * drawing
+ /* store the AnimData where this keyframe exists as a keyframe of the
+ * active action as td->extra.
*/
- td->ob= ob;
+ td->extra= adt;
}
/* This function advances the address to which td points to, so it must return
@@ -2940,7 +2940,7 @@ static void TimeToTransData(TransData *td, float *time, Object *ob)
* The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data
* on the named side are used.
*/
-static TransData *FCurveToTransData(TransData *td, FCurve *fcu, Object *ob, char side, float cfra)
+static TransData *FCurveToTransData(TransData *td, FCurve *fcu, AnimData *adt, char side, float cfra)
{
BezTriple *bezt;
int i;
@@ -2954,13 +2954,13 @@ static TransData *FCurveToTransData(TransData *td, FCurve *fcu, Object *ob, char
/* only add if on the right 'side' of the current frame */
if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) {
/* each control point needs to be added separetely */
- TimeToTransData(td, bezt->vec[0], ob);
+ TimeToTransData(td, bezt->vec[0], adt);
td++;
- TimeToTransData(td, bezt->vec[1], ob);
+ TimeToTransData(td, bezt->vec[1], adt);
td++;
- TimeToTransData(td, bezt->vec[2], ob);
+ TimeToTransData(td, bezt->vec[2], adt);
td++;
}
}
@@ -3068,13 +3068,13 @@ static void createTransActionData(bContext *C, TransInfo *t)
/* loop 1: fully select ipo-keys and count how many BezTriples are selected */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(&ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
/* convert current-frame to action-time (slightly less accurate, espcially under
* higher scaling ratios, but is faster than converting all points)
*/
- if (nob)
- cfra = get_action_frame(nob, (float)CFRA);
+ if (adt)
+ cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, 0);
else
cfra = (float)CFRA;
@@ -3121,18 +3121,18 @@ static void createTransActionData(bContext *C, TransInfo *t)
// tfd += i;
//}
//else {
- Object *nob= ANIM_nla_mapping_get(&ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
/* convert current-frame to action-time (slightly less accurate, espcially under
* higher scaling ratios, but is faster than converting all points)
*/
- if (nob)
- cfra = get_action_frame(nob, (float)CFRA);
+ if (adt)
+ cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, 0);
else
cfra = (float)CFRA;
- td= FCurveToTransData(td, fcu, nob, side, cfra);
+ td= FCurveToTransData(td, fcu, adt, side, cfra);
//}
}
@@ -3164,23 +3164,23 @@ static void createTransActionData(bContext *C, TransInfo *t)
/* Helper function for createTransGraphEditData, which is reponsible for associating
* source data with transform data
*/
-static void bezt_to_transdata (TransData *td, TransData2D *td2d, Object *nob, float *loc, float *cent, short selected, short ishandle, short intvals)
+static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt, float *loc, float *cent, short selected, short ishandle, short intvals)
{
/* New location from td gets dumped onto the old-location of td2d, which then
* gets copied to the actual data at td2d->loc2d (bezt->vec[n])
*
- * Due to NLA scaling, we apply NLA scaling to some of the verts here,
- * and then that scaling will be undone after transform is done.
+ * Due to NLA mapping, we apply NLA mapping to some of the verts here,
+ * and then that mapping will be undone after transform is done.
*/
- if (nob) {
- td2d->loc[0] = get_action_frame_inv(nob, loc[0]);
+ if (adt) {
+ td2d->loc[0] = BKE_nla_tweakedit_remap(adt, loc[0], 0);
td2d->loc[1] = loc[1];
td2d->loc[2] = 0.0f;
td2d->loc2d = loc;
td->loc = td2d->loc;
- td->center[0] = get_action_frame_inv(nob, cent[0]);
+ td->center[0] = BKE_nla_tweakedit_remap(adt, cent[0], 0);
td->center[1] = cent[1];
td->center[2] = 0.0f;
@@ -3201,6 +3201,9 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, Object *nob, fl
td->axismtx[2][2] = 1.0f;
td->ext= NULL; td->tdi= NULL; td->val= NULL;
+
+ /* store AnimData info in td->extra, for applying mapping when flushing */
+ td->extra= adt;
if (selected) {
td->flag |= TD_SELECTED;
@@ -3261,14 +3264,14 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
/* loop 1: count how many BezTriples (specifically their verts) are selected (or should be edited) */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= NULL; //ANIM_nla_mapping_get(&ac, ale); // XXX we don't handle NLA mapping for now here...
+ AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
/* convert current-frame to action-time (slightly less accurate, espcially under
* higher scaling ratios, but is faster than converting all points)
*/
- if (nob)
- cfra = get_action_frame(nob, (float)CFRA);
+ if (adt)
+ cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, 1);
else
cfra = (float)CFRA;
@@ -3318,13 +3321,19 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
td2d= t->data2d;
/* loop 2: build transdata arrays */
- cfra = (float)CFRA;
-
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= NULL; //ANIM_nla_mapping_get(&ac, ale); // XXX we don't handle NLA mapping here yet
+ AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
short intvals= (fcu->flag & FCURVE_INT_VALUES);
+ /* convert current-frame to action-time (slightly less accurate, espcially under
+ * higher scaling ratios, but is faster than converting all points)
+ */
+ if (adt)
+ cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, 1);
+ else
+ cfra = (float)CFRA;
+
/* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse (if applicable) */
bezt= fcu->bezt;
prevbezt= NULL;
@@ -3338,7 +3347,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) {
if (bezt->f1 & SELECT) {
hdata = initTransDataCurveHandes(td, bezt);
- bezt_to_transdata(td++, td2d++, nob, bezt->vec[0], bezt->vec[1], 1, 1, intvals);
+ bezt_to_transdata(td++, td2d++, adt, bezt->vec[0], bezt->vec[1], 1, 1, intvals);
}
else
h1= 0;
@@ -3347,7 +3356,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if (bezt->f3 & SELECT) {
if (hdata==NULL)
hdata = initTransDataCurveHandes(td, bezt);
- bezt_to_transdata(td++, td2d++, nob, bezt->vec[2], bezt->vec[1], 1, 1, intvals);
+ bezt_to_transdata(td++, td2d++, adt, bezt->vec[2], bezt->vec[1], 1, 1, intvals);
}
else
h2= 0;
@@ -3363,7 +3372,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
hdata = initTransDataCurveHandes(td, bezt);
}
- bezt_to_transdata(td++, td2d++, nob, bezt->vec[1], bezt->vec[1], 1, 0, intvals);
+ bezt_to_transdata(td++, td2d++, adt, bezt->vec[1], bezt->vec[1], 1, 0, intvals);
}
/* special hack (must be done after initTransDataCurveHandes(), as that stores handle settings to restore...):
@@ -3587,6 +3596,8 @@ void flushTransGraphData(TransInfo *t)
/* flush to 2d vector from internally used 3d vector */
for (a=0, td= t->data, td2d=t->data2d; a<t->total; a++, td++, td2d++) {
+ AnimData *adt= (AnimData *)td->extra; /* pointers to relevant AnimData blocks are stored in the td->extra pointers */
+
/* handle snapping for time values
* - we should still be in NLA-mapping timespace
* - only apply to keyframes (but never to handles)
@@ -3604,9 +3615,9 @@ void flushTransGraphData(TransInfo *t)
}
/* we need to unapply the nla-scaling from the time in some situations */
- //if (NLA_IPO_SCALED)
- // td2d->loc2d[0]= get_action_frame(OBACT, td2d->loc[0]);
- //else
+ if (adt)
+ td2d->loc2d[0]= BKE_nla_tweakedit_remap(adt, td2d->loc[0], 0);
+ else
td2d->loc2d[0]= td2d->loc[0];
/* if int-values only, truncate to integers */
@@ -4584,16 +4595,16 @@ void special_aftertrans_update(TransInfo *t)
/* these should all be ipo-blocks */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(&ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
((cancelled == 0) || (duplicate)) )
{
- if (nob) {
- ANIM_nla_mapping_apply_fcurve(nob, fcu, 0, 1);
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1);
posttrans_fcurve_clean(fcu);
- ANIM_nla_mapping_apply_fcurve(nob, fcu, 1, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1);
}
else
posttrans_fcurve_clean(fcu);
@@ -4695,16 +4706,16 @@ void special_aftertrans_update(TransInfo *t)
/* these should all be ipo-blocks */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(&ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
if ( (sipo->flag & SIPO_NOTRANSKEYCULL)==0 &&
((cancelled == 0) || (duplicate)) )
{
- if (nob) {
- ANIM_nla_mapping_apply_fcurve(nob, fcu, 0, 1);
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1);
posttrans_fcurve_clean(fcu);
- ANIM_nla_mapping_apply_fcurve(nob, fcu, 1, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1);
}
else
posttrans_fcurve_clean(fcu);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 4c9592fb27a..a60135107bc 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -272,37 +272,6 @@ void recalcData(TransInfo *t)
Scene *scene = t->scene;
Base *base;
-#if 0 // TRANSFORM_FIX_ME
- if (t->spacetype == SPACE_ACTION) {
- Object *ob= OBACT;
- void *data;
- short context;
-
- /* determine what type of data we are operating on */
- data = get_action_context(&context);
- if (data == NULL) return;
-
- /* always flush data if gpencil context */
- if (context == ACTCONT_GPENCIL) {
- flushTransGPactionData(t);
- }
-
- if (G.saction->lock) {
- if (context == ACTCONT_ACTION) {
- if(ob) {
- ob->ctime= -1234567.0f;
- if(ob->pose || ob_get_key(ob))
- DAG_object_flush_update(G.scene, ob, OB_RECALC);
- else
- DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
- }
- }
- else if (context == ACTCONT_SHAPEKEY) {
- DAG_object_flush_update(G.scene, OBACT, OB_RECALC_OB|OB_RECALC_DATA);
- }
- }
- }
-#endif
if (t->obedit) {
}
else if(G.f & G_PARTICLEEDIT) {
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index a784adaf35f..2b089530236 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -1,5 +1,28 @@
-/* Testing code for new animation system in 2.5
- * Copyright 2009, Joshua Leung
+/**
+ * $Id: DNA_anim_types.h 21023 2009-06-20 04:02:49Z aligorith $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
+ * All rights reserved.
+ *
+ * Contributor(s): Joshua Leung (full recode)
+ *
+ * ***** END GPL LICENSE BLOCK *****
*/
#ifndef DNA_ANIM_TYPES_H
@@ -668,6 +691,8 @@ typedef struct AnimData {
/* nla-tracks */
ListBase nla_tracks;
+ /* active NLA-strip (only set/used during tweaking, so no need to worry about dangling pointers) */
+ NlaStrip *actstrip;
/* 'drivers' for this ID-block's settings - FCurves, but are completely
* separate from those for animation data