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:
authorJoshua Leung <aligorith@gmail.com>2009-06-23 17:25:31 +0400
committerJoshua Leung <aligorith@gmail.com>2009-06-23 17:25:31 +0400
commitb4acd77526f32faab0c3d86436eef56096985c3d (patch)
tree9b0212ceb39f1299b5e49508ed40bffb1bbf5318 /source/blender/editors/animation/anim_draw.c
parentaa267976b86f90423204e11a30eec4e0def0f296 (diff)
NLA SoC: Big Commit - Restored NLA-Mapping Corrections
In TweakMode, the keyframes of the Active Action are now shown (and can be edited) in NLA-mapped time, with appropriate corrections applied when editing. This works in the DopeSheet and Graph Editors :) To do this, got rid of the old wrappers/API-methods, replacing them with new-style ones. A few methods previously (in this branch) used only for evaluation are now used for this purpose too. As the same code is used for editing + evaluation, this should now be much better to work with. I've only done a few brief tests now, but I think I might've muddled the invert-flags on one or two cases which I'll need to check out tomorrow. So, beware that there may be some weird and critical bugs for the next few days here... Also, added proper license headers to new NLA files. TODO: - testing + bugfixing due to this commit - show range of keyframes in NLA Editor active-action line
Diffstat (limited to 'source/blender/editors/animation/anim_draw.c')
-rw-r--r--source/blender/editors/animation/anim_draw.c72
1 files changed, 28 insertions, 44 deletions
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 */