2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-22 08:13:25 +00:00
|
|
|
* ***** 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-22 08:13:25 +00:00
|
|
|
*
|
2009-07-18 07:11:37 +00:00
|
|
|
* The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
|
2008-12-22 08:13:25 +00:00
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
2009-07-18 07:11:37 +00:00
|
|
|
* Contributor(s): Joshua Leung (full recode)
|
2008-12-22 08:13:25 +00:00
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/animation/keyframes_draw.c
|
|
|
|
|
* \ingroup edanimation
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2008-12-22 08:13:25 +00:00
|
|
|
/* System includes ----------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <float.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2009-07-18 07:11:37 +00:00
|
|
|
#include "BLI_dlrbTree.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2009-01-20 11:07:42 +00:00
|
|
|
#include "DNA_anim_types.h"
|
2008-12-22 08:13:25 +00:00
|
|
|
#include "DNA_armature_types.h"
|
|
|
|
|
#include "DNA_camera_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_key_types.h"
|
|
|
|
|
#include "DNA_lamp_types.h"
|
2011-01-05 00:37:21 +00:00
|
|
|
#include "DNA_lattice_types.h"
|
2009-12-28 00:52:31 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
2008-12-22 08:13:25 +00:00
|
|
|
#include "DNA_material_types.h"
|
2009-10-06 03:05:20 +00:00
|
|
|
#include "DNA_meta_types.h"
|
2009-11-11 05:03:49 +00:00
|
|
|
#include "DNA_node_types.h"
|
2009-10-06 03:05:20 +00:00
|
|
|
#include "DNA_particle_types.h"
|
2011-08-01 11:44:20 +00:00
|
|
|
#include "DNA_speaker_types.h"
|
2009-02-13 06:33:07 +00:00
|
|
|
#include "DNA_world_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_gpencil_types.h"
|
2012-06-04 16:42:58 +00:00
|
|
|
#include "DNA_mask_types.h"
|
2008-12-22 08:13:25 +00:00
|
|
|
|
Optimisations for building "Long Keyframes"
For a long time, one of the bottlenecks when drawing summary channels in the dopesheet
(especially with many objects) was how the long keyframes feature (i.e showing holds
between keyframes) got built. Specifically, it was the step where we check on the previous
keyframe to see whether there's a hold between those two.
The old code performed some elaborate checks, which made sense back when we used to handle
certain summary channels (e.g. object-action/ipo, and groups IIRC) differently. However,
nowadays, everything just does it by going over the FCurves one by one, so the offending
code wasn't really providing much benefit. Unless I've forgotten some other reason why
that old method is necessary, this commit should provide a decent speedup here, making
things somewhat interactive now (if still a bit jerky).
Other Tweaks:
1) Introduced float-precision threshold when checking to see whether an existing long
keyframe could be reused. This should hopefully reduce the number of fp-jitter issues
when creating summaries for many channels, reducing the number of duplicates created.
2) Precompute colours used for shading the long keyframes, instead of recomputing for
each block.
2014-04-16 03:21:06 +12:00
|
|
|
#include "BKE_fcurve.h"
|
2008-12-22 08:13:25 +00:00
|
|
|
#include "BKE_key.h"
|
|
|
|
|
#include "BKE_material.h"
|
2012-05-08 15:30:00 +00:00
|
|
|
#include "BKE_global.h" // XXX remove me!
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2008-12-22 08:13:25 +00:00
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
|
|
|
|
|
#include "ED_anim_api.h"
|
|
|
|
|
#include "ED_keyframes_draw.h"
|
|
|
|
|
|
2009-07-17 00:17:37 +00:00
|
|
|
/* *************************** Keyframe Processing *************************** */
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2009-11-17 08:27:46 +00:00
|
|
|
/* ActKeyColumns (Keyframe Columns) ------------------------------------------ */
|
|
|
|
|
|
2009-11-15 11:20:44 +00:00
|
|
|
/* Comparator callback used for ActKeyColumns and cframe float-value pointer */
|
2011-03-24 03:02:34 +00:00
|
|
|
/* NOTE: this is exported to other modules that use the ActKeyColumns for finding keyframes */
|
2012-04-29 17:11:40 +00:00
|
|
|
short compare_ak_cfraPtr(void *node, void *data)
|
2009-11-15 11:20:44 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
ActKeyColumn *ak = (ActKeyColumn *)node;
|
|
|
|
|
float *cframe = data;
|
2014-04-16 03:22:02 +12:00
|
|
|
float val = *cframe;
|
2009-11-15 11:20:44 +00:00
|
|
|
|
2014-04-16 03:22:02 +12:00
|
|
|
if (IS_EQT(val, ak->cfra, BEZT_BINARYSEARCH_THRESH))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if (val < ak->cfra)
|
2009-11-15 11:20:44 +00:00
|
|
|
return -1;
|
2014-04-16 03:22:02 +12:00
|
|
|
else if (val > ak->cfra)
|
2009-11-15 11:20:44 +00:00
|
|
|
return 1;
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-17 08:27:46 +00:00
|
|
|
/* --------------- */
|
2009-11-15 11:20:44 +00:00
|
|
|
|
|
|
|
|
/* Comparator callback used for ActKeyColumns and BezTriple */
|
2012-05-08 15:30:00 +00:00
|
|
|
static short compare_ak_bezt(void *node, void *data)
|
2009-11-15 11:20:44 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
ActKeyColumn *ak = (ActKeyColumn *)node;
|
|
|
|
|
BezTriple *bezt = (BezTriple *)data;
|
2009-11-15 11:20:44 +00:00
|
|
|
|
|
|
|
|
if (bezt->vec[1][0] < ak->cfra)
|
|
|
|
|
return -1;
|
|
|
|
|
else if (bezt->vec[1][0] > ak->cfra)
|
|
|
|
|
return 1;
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* New node callback used for building ActKeyColumns from BezTriples */
|
2012-05-08 15:30:00 +00:00
|
|
|
static DLRBT_Node *nalloc_ak_bezt(void *data)
|
2008-12-22 08:13:25 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
ActKeyColumn *ak = MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumn");
|
|
|
|
|
BezTriple *bezt = (BezTriple *)data;
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
/* store settings based on state of BezTriple */
|
2012-05-08 15:30:00 +00:00
|
|
|
ak->cfra = bezt->vec[1][0];
|
|
|
|
|
ak->sel = BEZSELECTED(bezt) ? SELECT : 0;
|
|
|
|
|
ak->key_type = BEZKEYTYPE(bezt);
|
2009-07-18 07:11:37 +00:00
|
|
|
|
|
|
|
|
/* set 'modified', since this is used to identify long keyframes */
|
|
|
|
|
ak->modified = 1;
|
|
|
|
|
|
2009-11-15 11:20:44 +00:00
|
|
|
return (DLRBT_Node *)ak;
|
2009-07-18 07:11:37 +00:00
|
|
|
}
|
|
|
|
|
|
2009-11-15 11:20:44 +00:00
|
|
|
/* Node updater callback used for building ActKeyColumns from BezTriples */
|
2012-05-08 15:30:00 +00:00
|
|
|
static void nupdate_ak_bezt(void *node, void *data)
|
2009-07-18 07:11:37 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
ActKeyColumn *ak = (ActKeyColumn *)node;
|
|
|
|
|
BezTriple *bezt = (BezTriple *)data;
|
2009-07-18 07:11:37 +00:00
|
|
|
|
2009-11-15 11:20:44 +00:00
|
|
|
/* set selection status and 'touched' status */
|
|
|
|
|
if (BEZSELECTED(bezt)) ak->sel = SELECT;
|
|
|
|
|
ak->modified += 1;
|
2009-07-18 07:11:37 +00:00
|
|
|
|
2009-11-15 11:20:44 +00:00
|
|
|
/* for keyframe type, 'proper' keyframes have priority over breakdowns (and other types for now) */
|
|
|
|
|
if (BEZKEYTYPE(bezt) == BEZT_KEYTYPE_KEYFRAME)
|
2012-05-08 15:30:00 +00:00
|
|
|
ak->key_type = BEZT_KEYTYPE_KEYFRAME;
|
2009-11-15 11:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-10 22:10:28 +00:00
|
|
|
/* ......... */
|
|
|
|
|
|
|
|
|
|
/* Comparator callback used for ActKeyColumns and GPencil frame */
|
2012-05-08 15:30:00 +00:00
|
|
|
static short compare_ak_gpframe(void *node, void *data)
|
2011-01-10 22:10:28 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
ActKeyColumn *ak = (ActKeyColumn *)node;
|
|
|
|
|
bGPDframe *gpf = (bGPDframe *)data;
|
2011-01-10 22:10:28 +00:00
|
|
|
|
|
|
|
|
if (gpf->framenum < ak->cfra)
|
|
|
|
|
return -1;
|
|
|
|
|
else if (gpf->framenum > ak->cfra)
|
|
|
|
|
return 1;
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* New node callback used for building ActKeyColumns from GPencil frames */
|
2012-05-08 15:30:00 +00:00
|
|
|
static DLRBT_Node *nalloc_ak_gpframe(void *data)
|
2011-01-10 22:10:28 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
ActKeyColumn *ak = MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumnGPF");
|
|
|
|
|
bGPDframe *gpf = (bGPDframe *)data;
|
2011-01-10 22:10:28 +00:00
|
|
|
|
|
|
|
|
/* store settings based on state of BezTriple */
|
2012-05-08 15:30:00 +00:00
|
|
|
ak->cfra = gpf->framenum;
|
|
|
|
|
ak->sel = (gpf->flag & GP_FRAME_SELECT) ? SELECT : 0;
|
2011-01-10 22:10:28 +00:00
|
|
|
|
|
|
|
|
/* set 'modified', since this is used to identify long keyframes */
|
|
|
|
|
ak->modified = 1;
|
|
|
|
|
|
|
|
|
|
return (DLRBT_Node *)ak;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Node updater callback used for building ActKeyColumns from GPencil frames */
|
2012-05-08 15:30:00 +00:00
|
|
|
static void nupdate_ak_gpframe(void *node, void *data)
|
2011-01-10 22:10:28 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
ActKeyColumn *ak = (ActKeyColumn *)node;
|
|
|
|
|
bGPDframe *gpf = (bGPDframe *)data;
|
2011-01-10 22:10:28 +00:00
|
|
|
|
|
|
|
|
/* set selection status and 'touched' status */
|
|
|
|
|
if (gpf->flag & GP_FRAME_SELECT) ak->sel = SELECT;
|
|
|
|
|
ak->modified += 1;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-04 16:42:58 +00:00
|
|
|
/* ......... */
|
|
|
|
|
|
|
|
|
|
/* Comparator callback used for ActKeyColumns and GPencil frame */
|
|
|
|
|
static short compare_ak_masklayshape(void *node, void *data)
|
|
|
|
|
{
|
|
|
|
|
ActKeyColumn *ak = (ActKeyColumn *)node;
|
|
|
|
|
MaskLayerShape *masklay_shape = (MaskLayerShape *)data;
|
|
|
|
|
|
|
|
|
|
if (masklay_shape->frame < ak->cfra)
|
|
|
|
|
return -1;
|
|
|
|
|
else if (masklay_shape->frame > ak->cfra)
|
|
|
|
|
return 1;
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* New node callback used for building ActKeyColumns from GPencil frames */
|
|
|
|
|
static DLRBT_Node *nalloc_ak_masklayshape(void *data)
|
|
|
|
|
{
|
|
|
|
|
ActKeyColumn *ak = MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumnGPF");
|
|
|
|
|
MaskLayerShape *masklay_shape = (MaskLayerShape *)data;
|
|
|
|
|
|
|
|
|
|
/* store settings based on state of BezTriple */
|
|
|
|
|
ak->cfra = masklay_shape->frame;
|
2012-06-08 14:31:38 +00:00
|
|
|
ak->sel = (masklay_shape->flag & MASK_SHAPE_SELECT) ? SELECT : 0;
|
2012-06-04 16:42:58 +00:00
|
|
|
|
|
|
|
|
/* set 'modified', since this is used to identify long keyframes */
|
|
|
|
|
ak->modified = 1;
|
|
|
|
|
|
|
|
|
|
return (DLRBT_Node *)ak;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Node updater callback used for building ActKeyColumns from GPencil frames */
|
|
|
|
|
static void nupdate_ak_masklayshape(void *node, void *data)
|
|
|
|
|
{
|
|
|
|
|
ActKeyColumn *ak = (ActKeyColumn *)node;
|
|
|
|
|
MaskLayerShape *masklay_shape = (MaskLayerShape *)data;
|
|
|
|
|
|
|
|
|
|
/* set selection status and 'touched' status */
|
2012-06-08 14:31:38 +00:00
|
|
|
if (masklay_shape->flag & MASK_SHAPE_SELECT) ak->sel = SELECT;
|
2012-06-04 16:42:58 +00:00
|
|
|
ak->modified += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-11-15 11:20:44 +00:00
|
|
|
/* --------------- */
|
|
|
|
|
|
|
|
|
|
/* Add the given BezTriple to the given 'list' of Keyframes */
|
|
|
|
|
static void add_bezt_to_keycolumns_list(DLRBT_Tree *keys, BezTriple *bezt)
|
|
|
|
|
{
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, keys, bezt))
|
2009-11-15 11:20:44 +00:00
|
|
|
return;
|
|
|
|
|
else
|
|
|
|
|
BLI_dlrbTree_add(keys, compare_ak_bezt, nalloc_ak_bezt, nupdate_ak_bezt, bezt);
|
2009-07-18 07:11:37 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-10 22:10:28 +00:00
|
|
|
/* Add the given GPencil Frame to the given 'list' of Keyframes */
|
|
|
|
|
static void add_gpframe_to_keycolumns_list(DLRBT_Tree *keys, bGPDframe *gpf)
|
|
|
|
|
{
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, keys, gpf))
|
2011-01-10 22:10:28 +00:00
|
|
|
return;
|
|
|
|
|
else
|
|
|
|
|
BLI_dlrbTree_add(keys, compare_ak_gpframe, nalloc_ak_gpframe, nupdate_ak_gpframe, gpf);
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-04 16:42:58 +00:00
|
|
|
/* Add the given MaskLayerShape Frame to the given 'list' of Keyframes */
|
|
|
|
|
static void add_masklay_to_keycolumns_list(DLRBT_Tree *keys, MaskLayerShape *masklay_shape)
|
|
|
|
|
{
|
|
|
|
|
if (ELEM(NULL, keys, masklay_shape))
|
|
|
|
|
return;
|
|
|
|
|
else
|
|
|
|
|
BLI_dlrbTree_add(keys, compare_ak_masklayshape, nalloc_ak_masklayshape, nupdate_ak_masklayshape, masklay_shape);
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-17 08:27:46 +00:00
|
|
|
/* ActKeyBlocks (Long Keyframes) ------------------------------------------ */
|
2009-07-18 07:11:37 +00:00
|
|
|
|
2011-03-24 03:02:34 +00:00
|
|
|
/* Comparator callback used for ActKeyBlock and cframe float-value pointer */
|
|
|
|
|
/* NOTE: this is exported to other modules that use the ActKeyBlocks for finding long-keyframes */
|
2012-04-29 17:11:40 +00:00
|
|
|
short compare_ab_cfraPtr(void *node, void *data)
|
2011-03-24 03:02:34 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
ActKeyBlock *ab = (ActKeyBlock *)node;
|
|
|
|
|
float *cframe = data;
|
Optimisations for building "Long Keyframes"
For a long time, one of the bottlenecks when drawing summary channels in the dopesheet
(especially with many objects) was how the long keyframes feature (i.e showing holds
between keyframes) got built. Specifically, it was the step where we check on the previous
keyframe to see whether there's a hold between those two.
The old code performed some elaborate checks, which made sense back when we used to handle
certain summary channels (e.g. object-action/ipo, and groups IIRC) differently. However,
nowadays, everything just does it by going over the FCurves one by one, so the offending
code wasn't really providing much benefit. Unless I've forgotten some other reason why
that old method is necessary, this commit should provide a decent speedup here, making
things somewhat interactive now (if still a bit jerky).
Other Tweaks:
1) Introduced float-precision threshold when checking to see whether an existing long
keyframe could be reused. This should hopefully reduce the number of fp-jitter issues
when creating summaries for many channels, reducing the number of duplicates created.
2) Precompute colours used for shading the long keyframes, instead of recomputing for
each block.
2014-04-16 03:21:06 +12:00
|
|
|
float val = *cframe;
|
2011-03-24 03:02:34 +00:00
|
|
|
|
Optimisations for building "Long Keyframes"
For a long time, one of the bottlenecks when drawing summary channels in the dopesheet
(especially with many objects) was how the long keyframes feature (i.e showing holds
between keyframes) got built. Specifically, it was the step where we check on the previous
keyframe to see whether there's a hold between those two.
The old code performed some elaborate checks, which made sense back when we used to handle
certain summary channels (e.g. object-action/ipo, and groups IIRC) differently. However,
nowadays, everything just does it by going over the FCurves one by one, so the offending
code wasn't really providing much benefit. Unless I've forgotten some other reason why
that old method is necessary, this commit should provide a decent speedup here, making
things somewhat interactive now (if still a bit jerky).
Other Tweaks:
1) Introduced float-precision threshold when checking to see whether an existing long
keyframe could be reused. This should hopefully reduce the number of fp-jitter issues
when creating summaries for many channels, reducing the number of duplicates created.
2) Precompute colours used for shading the long keyframes, instead of recomputing for
each block.
2014-04-16 03:21:06 +12:00
|
|
|
if (val < ab->start)
|
2011-03-24 03:02:34 +00:00
|
|
|
return -1;
|
Optimisations for building "Long Keyframes"
For a long time, one of the bottlenecks when drawing summary channels in the dopesheet
(especially with many objects) was how the long keyframes feature (i.e showing holds
between keyframes) got built. Specifically, it was the step where we check on the previous
keyframe to see whether there's a hold between those two.
The old code performed some elaborate checks, which made sense back when we used to handle
certain summary channels (e.g. object-action/ipo, and groups IIRC) differently. However,
nowadays, everything just does it by going over the FCurves one by one, so the offending
code wasn't really providing much benefit. Unless I've forgotten some other reason why
that old method is necessary, this commit should provide a decent speedup here, making
things somewhat interactive now (if still a bit jerky).
Other Tweaks:
1) Introduced float-precision threshold when checking to see whether an existing long
keyframe could be reused. This should hopefully reduce the number of fp-jitter issues
when creating summaries for many channels, reducing the number of duplicates created.
2) Precompute colours used for shading the long keyframes, instead of recomputing for
each block.
2014-04-16 03:21:06 +12:00
|
|
|
else if (val > ab->start)
|
2011-03-24 03:02:34 +00:00
|
|
|
return 1;
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* --------------- */
|
|
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
/* Create a ActKeyColumn for a pair of BezTriples */
|
|
|
|
|
static ActKeyBlock *bezts_to_new_actkeyblock(BezTriple *prev, BezTriple *beztn)
|
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
ActKeyBlock *ab = MEM_callocN(sizeof(ActKeyBlock), "ActKeyBlock");
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
ab->start = prev->vec[1][0];
|
|
|
|
|
ab->end = beztn->vec[1][0];
|
|
|
|
|
ab->val = beztn->vec[1][1];
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
ab->sel = (BEZSELECTED(prev) || BEZSELECTED(beztn)) ? SELECT : 0;
|
2009-07-18 07:11:37 +00:00
|
|
|
ab->modified = 1;
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
return ab;
|
2008-12-22 08:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
Optimisations for building "Long Keyframes"
For a long time, one of the bottlenecks when drawing summary channels in the dopesheet
(especially with many objects) was how the long keyframes feature (i.e showing holds
between keyframes) got built. Specifically, it was the step where we check on the previous
keyframe to see whether there's a hold between those two.
The old code performed some elaborate checks, which made sense back when we used to handle
certain summary channels (e.g. object-action/ipo, and groups IIRC) differently. However,
nowadays, everything just does it by going over the FCurves one by one, so the offending
code wasn't really providing much benefit. Unless I've forgotten some other reason why
that old method is necessary, this commit should provide a decent speedup here, making
things somewhat interactive now (if still a bit jerky).
Other Tweaks:
1) Introduced float-precision threshold when checking to see whether an existing long
keyframe could be reused. This should hopefully reduce the number of fp-jitter issues
when creating summaries for many channels, reducing the number of duplicates created.
2) Precompute colours used for shading the long keyframes, instead of recomputing for
each block.
2014-04-16 03:21:06 +12:00
|
|
|
static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, BezTriple *first_bezt, BezTriple *beztn)
|
2008-12-22 08:13:25 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
ActKeyBlock *new_ab = NULL;
|
Optimisations for building "Long Keyframes"
For a long time, one of the bottlenecks when drawing summary channels in the dopesheet
(especially with many objects) was how the long keyframes feature (i.e showing holds
between keyframes) got built. Specifically, it was the step where we check on the previous
keyframe to see whether there's a hold between those two.
The old code performed some elaborate checks, which made sense back when we used to handle
certain summary channels (e.g. object-action/ipo, and groups IIRC) differently. However,
nowadays, everything just does it by going over the FCurves one by one, so the offending
code wasn't really providing much benefit. Unless I've forgotten some other reason why
that old method is necessary, this commit should provide a decent speedup here, making
things somewhat interactive now (if still a bit jerky).
Other Tweaks:
1) Introduced float-precision threshold when checking to see whether an existing long
keyframe could be reused. This should hopefully reduce the number of fp-jitter issues
when creating summaries for many channels, reducing the number of duplicates created.
2) Precompute colours used for shading the long keyframes, instead of recomputing for
each block.
2014-04-16 03:21:06 +12:00
|
|
|
BezTriple *prev = NULL;
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2009-11-17 08:27:46 +00:00
|
|
|
/* get the BezTriple immediately before the given one which has the same value */
|
Optimisations for building "Long Keyframes"
For a long time, one of the bottlenecks when drawing summary channels in the dopesheet
(especially with many objects) was how the long keyframes feature (i.e showing holds
between keyframes) got built. Specifically, it was the step where we check on the previous
keyframe to see whether there's a hold between those two.
The old code performed some elaborate checks, which made sense back when we used to handle
certain summary channels (e.g. object-action/ipo, and groups IIRC) differently. However,
nowadays, everything just does it by going over the FCurves one by one, so the offending
code wasn't really providing much benefit. Unless I've forgotten some other reason why
that old method is necessary, this commit should provide a decent speedup here, making
things somewhat interactive now (if still a bit jerky).
Other Tweaks:
1) Introduced float-precision threshold when checking to see whether an existing long
keyframe could be reused. This should hopefully reduce the number of fp-jitter issues
when creating summaries for many channels, reducing the number of duplicates created.
2) Precompute colours used for shading the long keyframes, instead of recomputing for
each block.
2014-04-16 03:21:06 +12:00
|
|
|
if (beztn != first_bezt) {
|
|
|
|
|
/* XXX: Unless I'm overlooking some details from the past, this should be sufficient?
|
|
|
|
|
* The old code did some elaborate stuff trying to find keyframe columns for
|
|
|
|
|
* the given BezTriple, then step backwards to the column before that, and find
|
|
|
|
|
* an appropriate BezTriple with matching values there. Maybe that was warranted
|
|
|
|
|
* in the past, but now, that list is only ever filled with keyframes from the
|
|
|
|
|
* current FCurve.
|
|
|
|
|
*
|
|
|
|
|
* -- Aligorith (20140415)
|
|
|
|
|
*/
|
|
|
|
|
prev = beztn - 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-05 02:00:24 +00:00
|
|
|
|
2008-12-22 08:13:25 +00:00
|
|
|
/* check if block needed - same value(s)?
|
|
|
|
|
* -> firstly, handles must have same central value as each other
|
|
|
|
|
* -> secondly, handles which control that section of the curve must be constant
|
|
|
|
|
*/
|
2012-09-14 06:17:14 +00:00
|
|
|
if (prev == NULL) return;
|
2012-05-08 15:30:00 +00:00
|
|
|
if (IS_EQF(beztn->vec[1][1], prev->vec[1][1]) == 0) return;
|
Optimisations for building "Long Keyframes"
For a long time, one of the bottlenecks when drawing summary channels in the dopesheet
(especially with many objects) was how the long keyframes feature (i.e showing holds
between keyframes) got built. Specifically, it was the step where we check on the previous
keyframe to see whether there's a hold between those two.
The old code performed some elaborate checks, which made sense back when we used to handle
certain summary channels (e.g. object-action/ipo, and groups IIRC) differently. However,
nowadays, everything just does it by going over the FCurves one by one, so the offending
code wasn't really providing much benefit. Unless I've forgotten some other reason why
that old method is necessary, this commit should provide a decent speedup here, making
things somewhat interactive now (if still a bit jerky).
Other Tweaks:
1) Introduced float-precision threshold when checking to see whether an existing long
keyframe could be reused. This should hopefully reduce the number of fp-jitter issues
when creating summaries for many channels, reducing the number of duplicates created.
2) Precompute colours used for shading the long keyframes, instead of recomputing for
each block.
2014-04-16 03:21:06 +12:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
if (IS_EQF(beztn->vec[1][1], beztn->vec[0][1]) == 0) return;
|
|
|
|
|
if (IS_EQF(prev->vec[1][1], prev->vec[2][1]) == 0) return;
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
|
|
|
|
|
/* if there are no blocks already, just add as root */
|
|
|
|
|
if (blocks->root == NULL) {
|
|
|
|
|
/* just add this as the root, then call the tree-balancing functions to validate */
|
2012-05-08 15:30:00 +00:00
|
|
|
new_ab = bezts_to_new_actkeyblock(prev, beztn);
|
|
|
|
|
blocks->root = (DLRBT_Node *)new_ab;
|
2009-07-18 07:11:37 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-05-08 15:30:00 +00:00
|
|
|
ActKeyBlock *ab, *abn = NULL;
|
2009-07-18 07:11:37 +00:00
|
|
|
|
|
|
|
|
/* try to find a keyblock that starts on the previous beztriple, and add a new one if none start there
|
Optimisations for building "Long Keyframes"
For a long time, one of the bottlenecks when drawing summary channels in the dopesheet
(especially with many objects) was how the long keyframes feature (i.e showing holds
between keyframes) got built. Specifically, it was the step where we check on the previous
keyframe to see whether there's a hold between those two.
The old code performed some elaborate checks, which made sense back when we used to handle
certain summary channels (e.g. object-action/ipo, and groups IIRC) differently. However,
nowadays, everything just does it by going over the FCurves one by one, so the offending
code wasn't really providing much benefit. Unless I've forgotten some other reason why
that old method is necessary, this commit should provide a decent speedup here, making
things somewhat interactive now (if still a bit jerky).
Other Tweaks:
1) Introduced float-precision threshold when checking to see whether an existing long
keyframe could be reused. This should hopefully reduce the number of fp-jitter issues
when creating summaries for many channels, reducing the number of duplicates created.
2) Precompute colours used for shading the long keyframes, instead of recomputing for
each block.
2014-04-16 03:21:06 +12:00
|
|
|
* Note: we perform a tree traversal here NOT a standard linked-list traversal...
|
2012-03-02 16:05:54 +00:00
|
|
|
* Note: we can't search from end to try to optimize this as it causes errors there's
|
2012-05-08 15:30:00 +00:00
|
|
|
* an A ___ B |---| B situation
|
2009-07-18 07:11:37 +00:00
|
|
|
*/
|
|
|
|
|
// FIXME: here there is a bug where we are trying to get the summary for the following channels
|
|
|
|
|
// A|--------------|A ______________ B|--------------|B
|
|
|
|
|
// A|------------------------------------------------|A
|
|
|
|
|
// A|----|A|---|A|-----------------------------------|A
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ab = blocks->root; ab; ab = abn) {
|
Optimisations for building "Long Keyframes"
For a long time, one of the bottlenecks when drawing summary channels in the dopesheet
(especially with many objects) was how the long keyframes feature (i.e showing holds
between keyframes) got built. Specifically, it was the step where we check on the previous
keyframe to see whether there's a hold between those two.
The old code performed some elaborate checks, which made sense back when we used to handle
certain summary channels (e.g. object-action/ipo, and groups IIRC) differently. However,
nowadays, everything just does it by going over the FCurves one by one, so the offending
code wasn't really providing much benefit. Unless I've forgotten some other reason why
that old method is necessary, this commit should provide a decent speedup here, making
things somewhat interactive now (if still a bit jerky).
Other Tweaks:
1) Introduced float-precision threshold when checking to see whether an existing long
keyframe could be reused. This should hopefully reduce the number of fp-jitter issues
when creating summaries for many channels, reducing the number of duplicates created.
2) Precompute colours used for shading the long keyframes, instead of recomputing for
each block.
2014-04-16 03:21:06 +12:00
|
|
|
/* check if this is a match, or whether we go left or right
|
|
|
|
|
* NOTE: we now use a float threshold to prevent precision errors causing problems with summaries
|
|
|
|
|
*/
|
|
|
|
|
if (IS_EQT(ab->start, prev->vec[1][0], BEZT_BINARYSEARCH_THRESH)) {
|
2009-07-18 07:11:37 +00:00
|
|
|
/* set selection status and 'touched' status */
|
|
|
|
|
if (BEZSELECTED(beztn)) ab->sel = SELECT;
|
Optimisations for building "Long Keyframes"
For a long time, one of the bottlenecks when drawing summary channels in the dopesheet
(especially with many objects) was how the long keyframes feature (i.e showing holds
between keyframes) got built. Specifically, it was the step where we check on the previous
keyframe to see whether there's a hold between those two.
The old code performed some elaborate checks, which made sense back when we used to handle
certain summary channels (e.g. object-action/ipo, and groups IIRC) differently. However,
nowadays, everything just does it by going over the FCurves one by one, so the offending
code wasn't really providing much benefit. Unless I've forgotten some other reason why
that old method is necessary, this commit should provide a decent speedup here, making
things somewhat interactive now (if still a bit jerky).
Other Tweaks:
1) Introduced float-precision threshold when checking to see whether an existing long
keyframe could be reused. This should hopefully reduce the number of fp-jitter issues
when creating summaries for many channels, reducing the number of duplicates created.
2) Precompute colours used for shading the long keyframes, instead of recomputing for
each block.
2014-04-16 03:21:06 +12:00
|
|
|
ab->modified++;
|
2009-07-18 07:11:37 +00:00
|
|
|
|
|
|
|
|
/* done... no need to insert */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else {
|
Optimisations for building "Long Keyframes"
For a long time, one of the bottlenecks when drawing summary channels in the dopesheet
(especially with many objects) was how the long keyframes feature (i.e showing holds
between keyframes) got built. Specifically, it was the step where we check on the previous
keyframe to see whether there's a hold between those two.
The old code performed some elaborate checks, which made sense back when we used to handle
certain summary channels (e.g. object-action/ipo, and groups IIRC) differently. However,
nowadays, everything just does it by going over the FCurves one by one, so the offending
code wasn't really providing much benefit. Unless I've forgotten some other reason why
that old method is necessary, this commit should provide a decent speedup here, making
things somewhat interactive now (if still a bit jerky).
Other Tweaks:
1) Introduced float-precision threshold when checking to see whether an existing long
keyframe could be reused. This should hopefully reduce the number of fp-jitter issues
when creating summaries for many channels, reducing the number of duplicates created.
2) Precompute colours used for shading the long keyframes, instead of recomputing for
each block.
2014-04-16 03:21:06 +12:00
|
|
|
ActKeyBlock **abnp = NULL; /* branch to go down - used to hook new blocks to parents */
|
2009-07-18 07:11:37 +00:00
|
|
|
|
|
|
|
|
/* check if go left or right, but if not available, add new node */
|
|
|
|
|
if (ab->start < prev->vec[1][0])
|
2012-05-08 15:30:00 +00:00
|
|
|
abnp = &ab->right;
|
2009-07-18 07:11:37 +00:00
|
|
|
else
|
2012-05-08 15:30:00 +00:00
|
|
|
abnp = &ab->left;
|
2009-07-18 07:11:37 +00:00
|
|
|
|
|
|
|
|
/* if this does not exist, add a new node, otherwise continue... */
|
|
|
|
|
if (*abnp == NULL) {
|
|
|
|
|
/* add a new node representing this, and attach it to the relevant place */
|
2012-05-08 15:30:00 +00:00
|
|
|
new_ab = bezts_to_new_actkeyblock(prev, beztn);
|
|
|
|
|
new_ab->parent = ab;
|
|
|
|
|
*abnp = new_ab;
|
2009-07-18 07:11:37 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
2012-05-08 15:30:00 +00:00
|
|
|
abn = *abnp;
|
2009-07-18 07:11:37 +00:00
|
|
|
}
|
2008-12-22 08:13:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
/* now, balance the tree taking into account this newly added node */
|
|
|
|
|
BLI_dlrbTree_insert(blocks, (DLRBT_Node *)new_ab);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* --------- */
|
|
|
|
|
|
|
|
|
|
/* Handle the 'touched' status of ActKeyColumn tree nodes */
|
2012-05-08 15:30:00 +00:00
|
|
|
static void set_touched_actkeycolumn(ActKeyColumn *ak)
|
2009-07-18 07:11:37 +00:00
|
|
|
{
|
|
|
|
|
/* sanity check */
|
|
|
|
|
if (ak == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* deal with self first */
|
|
|
|
|
if (ak->modified) {
|
2012-05-08 15:30:00 +00:00
|
|
|
ak->modified = 0;
|
2009-07-18 07:11:37 +00:00
|
|
|
ak->totcurve++;
|
|
|
|
|
}
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
/* children */
|
|
|
|
|
set_touched_actkeycolumn(ak->left);
|
|
|
|
|
set_touched_actkeycolumn(ak->right);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Handle the 'touched' status of ActKeyBlock tree nodes */
|
2012-05-08 15:30:00 +00:00
|
|
|
static void set_touched_actkeyblock(ActKeyBlock *ab)
|
2009-07-18 07:11:37 +00:00
|
|
|
{
|
|
|
|
|
/* sanity check */
|
|
|
|
|
if (ab == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* deal with self first */
|
|
|
|
|
if (ab->modified) {
|
2012-05-08 15:30:00 +00:00
|
|
|
ab->modified = 0;
|
2009-07-18 07:11:37 +00:00
|
|
|
ab->totcurve++;
|
|
|
|
|
}
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
/* children */
|
|
|
|
|
set_touched_actkeyblock(ab->left);
|
|
|
|
|
set_touched_actkeyblock(ab->right);
|
2008-12-22 08:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
2011-03-24 03:19:30 +00:00
|
|
|
/* --------- */
|
|
|
|
|
|
|
|
|
|
/* Checks if ActKeyBlock should exist... */
|
2014-02-03 18:55:59 +11:00
|
|
|
bool actkeyblock_is_valid(ActKeyBlock *ab, DLRBT_Tree *keys)
|
2011-03-24 03:19:30 +00:00
|
|
|
{
|
|
|
|
|
ActKeyColumn *ak;
|
|
|
|
|
short startCurves, endCurves, totCurves;
|
|
|
|
|
|
|
|
|
|
/* check that block is valid */
|
|
|
|
|
if (ab == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* find out how many curves occur at each keyframe */
|
2012-05-08 15:30:00 +00:00
|
|
|
ak = (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->start);
|
|
|
|
|
startCurves = (ak) ? ak->totcurve : 0;
|
2011-03-24 03:19:30 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
ak = (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->end);
|
|
|
|
|
endCurves = (ak) ? ak->totcurve : 0;
|
2011-03-24 03:19:30 +00:00
|
|
|
|
|
|
|
|
/* only draw keyblock if it appears in at all of the keyframes at lowest end */
|
|
|
|
|
if (!startCurves && !endCurves)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
totCurves = (startCurves > endCurves) ? endCurves : startCurves;
|
2011-03-24 03:19:30 +00:00
|
|
|
return (ab->totcurve >= totCurves);
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-17 00:17:37 +00:00
|
|
|
/* *************************** Keyframe Drawing *************************** */
|
|
|
|
|
|
2009-07-09 13:14:51 +00:00
|
|
|
/* coordinates for diamond shape */
|
|
|
|
|
static const float _unit_diamond_shape[4][2] = {
|
2012-05-08 15:30:00 +00:00
|
|
|
{0.0f, 1.0f}, /* top vert */
|
|
|
|
|
{1.0f, 0.0f}, /* mid-right */
|
|
|
|
|
{0.0f, -1.0f}, /* bottom vert */
|
|
|
|
|
{-1.0f, 0.0f} /* mid-left */
|
2009-07-09 13:14:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* draw a simple diamond shape with OpenGL */
|
2012-04-29 17:11:40 +00:00
|
|
|
void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, short key_type, short mode, float alpha)
|
2008-12-22 08:13:25 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
static GLuint displist1 = 0;
|
|
|
|
|
static GLuint displist2 = 0;
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2012-03-02 16:05:54 +00:00
|
|
|
/* initialize 2 display lists for diamond shape - one empty, one filled */
|
2009-07-09 13:14:51 +00:00
|
|
|
if (displist1 == 0) {
|
2012-05-08 15:30:00 +00:00
|
|
|
displist1 = glGenLists(1);
|
|
|
|
|
glNewList(displist1, GL_COMPILE);
|
2009-07-09 13:14:51 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
glBegin(GL_LINE_LOOP);
|
|
|
|
|
glVertex2fv(_unit_diamond_shape[0]);
|
|
|
|
|
glVertex2fv(_unit_diamond_shape[1]);
|
|
|
|
|
glVertex2fv(_unit_diamond_shape[2]);
|
|
|
|
|
glVertex2fv(_unit_diamond_shape[3]);
|
|
|
|
|
glEnd();
|
|
|
|
|
|
2009-07-09 13:14:51 +00:00
|
|
|
glEndList();
|
|
|
|
|
}
|
|
|
|
|
if (displist2 == 0) {
|
2012-05-08 15:30:00 +00:00
|
|
|
displist2 = glGenLists(1);
|
|
|
|
|
glNewList(displist2, GL_COMPILE);
|
2009-07-09 13:14:51 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
glBegin(GL_QUADS);
|
|
|
|
|
glVertex2fv(_unit_diamond_shape[0]);
|
|
|
|
|
glVertex2fv(_unit_diamond_shape[1]);
|
|
|
|
|
glVertex2fv(_unit_diamond_shape[2]);
|
|
|
|
|
glVertex2fv(_unit_diamond_shape[3]);
|
|
|
|
|
glEnd();
|
|
|
|
|
|
2009-07-09 13:14:51 +00:00
|
|
|
glEndList();
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-04 02:44:56 +00:00
|
|
|
/* tweak size of keyframe shape according to type of keyframe
|
2012-10-23 03:38:26 +00:00
|
|
|
* - 'proper' keyframes have key_type = 0, so get drawn at full size
|
2009-09-04 02:44:56 +00:00
|
|
|
*/
|
2012-05-08 15:30:00 +00:00
|
|
|
hsize -= 0.5f * key_type;
|
2009-09-04 02:44:56 +00:00
|
|
|
|
2009-07-09 13:14:51 +00:00
|
|
|
/* adjust view transform before starting */
|
|
|
|
|
glTranslatef(x, y, 0.0f);
|
2012-05-08 15:30:00 +00:00
|
|
|
glScalef(1.0f / xscale * hsize, hsize, 1.0f);
|
2009-07-09 13:14:51 +00:00
|
|
|
|
|
|
|
|
/* anti-aliased lines for more consistent appearance */
|
|
|
|
|
glEnable(GL_LINE_SMOOTH);
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2009-07-10 00:32:13 +00:00
|
|
|
/* draw! */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(mode, KEYFRAME_SHAPE_INSIDE, KEYFRAME_SHAPE_BOTH)) {
|
2014-01-16 23:56:40 +13:00
|
|
|
float inner_col[4];
|
|
|
|
|
|
|
|
|
|
/* get interior colors from theme (for selected and unselected only) */
|
2009-09-04 02:44:56 +00:00
|
|
|
switch (key_type) {
|
2014-01-16 23:56:40 +13:00
|
|
|
case BEZT_KEYTYPE_BREAKDOWN: /* bluish frames (default theme) */
|
2009-09-04 02:44:56 +00:00
|
|
|
{
|
2014-01-16 23:56:40 +13:00
|
|
|
if (sel) UI_GetThemeColor4fv(TH_KEYTYPE_BREAKDOWN_SELECT, inner_col);
|
|
|
|
|
else UI_GetThemeColor4fv(TH_KEYTYPE_BREAKDOWN, inner_col);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2009-09-04 02:44:56 +00:00
|
|
|
}
|
2014-01-16 23:56:40 +13:00
|
|
|
case BEZT_KEYTYPE_EXTREME: /* reddish frames (default theme) */
|
2009-09-21 12:29:53 +00:00
|
|
|
{
|
2014-01-16 23:56:40 +13:00
|
|
|
if (sel) UI_GetThemeColor4fv(TH_KEYTYPE_EXTREME_SELECT, inner_col);
|
|
|
|
|
else UI_GetThemeColor4fv(TH_KEYTYPE_EXTREME, inner_col);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2009-09-21 12:29:53 +00:00
|
|
|
}
|
2014-01-16 23:56:40 +13:00
|
|
|
case BEZT_KEYTYPE_JITTER: /* greenish frames (default theme) */
|
2011-02-01 11:35:27 +00:00
|
|
|
{
|
2014-01-16 23:56:40 +13:00
|
|
|
if (sel) UI_GetThemeColor4fv(TH_KEYTYPE_JITTER_SELECT, inner_col);
|
|
|
|
|
else UI_GetThemeColor4fv(TH_KEYTYPE_JITTER, inner_col);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2011-02-01 11:35:27 +00:00
|
|
|
}
|
2014-01-16 23:56:40 +13:00
|
|
|
case BEZT_KEYTYPE_KEYFRAME: /* traditional yellowish frames (default theme) */
|
2009-09-04 02:44:56 +00:00
|
|
|
default:
|
|
|
|
|
{
|
2014-01-16 23:56:40 +13:00
|
|
|
if (sel) UI_GetThemeColor4fv(TH_KEYTYPE_KEYFRAME_SELECT, inner_col);
|
|
|
|
|
else UI_GetThemeColor4fv(TH_KEYTYPE_KEYFRAME, inner_col);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2009-09-04 02:44:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-07-10 00:32:13 +00:00
|
|
|
|
2014-01-16 23:56:40 +13:00
|
|
|
/* NOTE: we don't use the straight alpha from the theme, or else effects such as
|
|
|
|
|
* greying out protected/muted channels doesn't work correctly!
|
|
|
|
|
*/
|
|
|
|
|
inner_col[3] *= alpha;
|
|
|
|
|
glColor4fv(inner_col);
|
|
|
|
|
|
|
|
|
|
/* draw the "filled in" interior poly now */
|
2009-07-10 00:32:13 +00:00
|
|
|
glCallList(displist2);
|
|
|
|
|
}
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(mode, KEYFRAME_SHAPE_FRAME, KEYFRAME_SHAPE_BOTH)) {
|
2014-01-16 23:56:40 +13:00
|
|
|
float border_col[4];
|
|
|
|
|
|
2009-07-10 00:32:13 +00:00
|
|
|
/* exterior - black frame */
|
2014-01-16 23:56:40 +13:00
|
|
|
if (sel) UI_GetThemeColor4fv(TH_KEYBORDER_SELECT, border_col);
|
|
|
|
|
else UI_GetThemeColor4fv(TH_KEYBORDER, border_col);
|
|
|
|
|
|
|
|
|
|
border_col[3] *= alpha;
|
|
|
|
|
glColor4fv(border_col);
|
2009-07-10 00:32:13 +00:00
|
|
|
|
|
|
|
|
glCallList(displist1);
|
|
|
|
|
}
|
2009-07-09 13:14:51 +00:00
|
|
|
|
|
|
|
|
glDisable(GL_LINE_SMOOTH);
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2009-07-09 13:14:51 +00:00
|
|
|
/* restore view transform */
|
2012-05-08 15:30:00 +00:00
|
|
|
glScalef(xscale / hsize, 1.0f / hsize, 1.0f);
|
2009-07-09 13:14:51 +00:00
|
|
|
glTranslatef(-x, -y, 0.0f);
|
2008-12-22 08:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
2010-12-29 12:52:06 +00:00
|
|
|
static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, float ypos, short channelLocked)
|
2008-12-22 08:13:25 +00:00
|
|
|
{
|
|
|
|
|
ActKeyColumn *ak;
|
|
|
|
|
ActKeyBlock *ab;
|
2014-01-17 00:00:40 +13:00
|
|
|
float alpha;
|
2009-07-09 13:14:51 +00:00
|
|
|
float xscale;
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
float iconsize = U.widget_unit / 4.0f;
|
2008-12-22 08:13:25 +00:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
|
2009-07-09 13:14:51 +00:00
|
|
|
/* get View2D scaling factor */
|
|
|
|
|
UI_view2d_getscale(v2d, &xscale, NULL);
|
|
|
|
|
|
2014-01-17 00:00:40 +13:00
|
|
|
/* locked channels are less strongly shown, as feedback for locked channels in DopeSheet */
|
|
|
|
|
/* TODO: allow this opacity factor to be themed? */
|
|
|
|
|
alpha = (channelLocked) ? 0.25f : 1.0f;
|
|
|
|
|
|
2008-12-22 08:13:25 +00:00
|
|
|
/* draw keyblocks */
|
|
|
|
|
if (blocks) {
|
Optimisations for building "Long Keyframes"
For a long time, one of the bottlenecks when drawing summary channels in the dopesheet
(especially with many objects) was how the long keyframes feature (i.e showing holds
between keyframes) got built. Specifically, it was the step where we check on the previous
keyframe to see whether there's a hold between those two.
The old code performed some elaborate checks, which made sense back when we used to handle
certain summary channels (e.g. object-action/ipo, and groups IIRC) differently. However,
nowadays, everything just does it by going over the FCurves one by one, so the offending
code wasn't really providing much benefit. Unless I've forgotten some other reason why
that old method is necessary, this commit should provide a decent speedup here, making
things somewhat interactive now (if still a bit jerky).
Other Tweaks:
1) Introduced float-precision threshold when checking to see whether an existing long
keyframe could be reused. This should hopefully reduce the number of fp-jitter issues
when creating summaries for many channels, reducing the number of duplicates created.
2) Precompute colours used for shading the long keyframes, instead of recomputing for
each block.
2014-04-16 03:21:06 +12:00
|
|
|
float sel_color[4], unsel_color[4];
|
|
|
|
|
|
|
|
|
|
/* cache colours first */
|
|
|
|
|
UI_GetThemeColor4fv(TH_STRIP_SELECT, sel_color);
|
|
|
|
|
UI_GetThemeColor4fv(TH_STRIP, unsel_color);
|
|
|
|
|
|
|
|
|
|
sel_color[3] *= alpha;
|
|
|
|
|
unsel_color[3] *= alpha;
|
|
|
|
|
|
|
|
|
|
/* NOTE: the tradeoff for changing colors between each draw is dwarfed by the cost of checking validity */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ab = blocks->first; ab; ab = ab->next) {
|
2011-03-24 03:19:30 +00:00
|
|
|
if (actkeyblock_is_valid(ab, keys)) {
|
2008-12-22 08:13:25 +00:00
|
|
|
/* draw block */
|
|
|
|
|
if (ab->sel)
|
Optimisations for building "Long Keyframes"
For a long time, one of the bottlenecks when drawing summary channels in the dopesheet
(especially with many objects) was how the long keyframes feature (i.e showing holds
between keyframes) got built. Specifically, it was the step where we check on the previous
keyframe to see whether there's a hold between those two.
The old code performed some elaborate checks, which made sense back when we used to handle
certain summary channels (e.g. object-action/ipo, and groups IIRC) differently. However,
nowadays, everything just does it by going over the FCurves one by one, so the offending
code wasn't really providing much benefit. Unless I've forgotten some other reason why
that old method is necessary, this commit should provide a decent speedup here, making
things somewhat interactive now (if still a bit jerky).
Other Tweaks:
1) Introduced float-precision threshold when checking to see whether an existing long
keyframe could be reused. This should hopefully reduce the number of fp-jitter issues
when creating summaries for many channels, reducing the number of duplicates created.
2) Precompute colours used for shading the long keyframes, instead of recomputing for
each block.
2014-04-16 03:21:06 +12:00
|
|
|
glColor4fv(sel_color);
|
2008-12-22 08:13:25 +00:00
|
|
|
else
|
Optimisations for building "Long Keyframes"
For a long time, one of the bottlenecks when drawing summary channels in the dopesheet
(especially with many objects) was how the long keyframes feature (i.e showing holds
between keyframes) got built. Specifically, it was the step where we check on the previous
keyframe to see whether there's a hold between those two.
The old code performed some elaborate checks, which made sense back when we used to handle
certain summary channels (e.g. object-action/ipo, and groups IIRC) differently. However,
nowadays, everything just does it by going over the FCurves one by one, so the offending
code wasn't really providing much benefit. Unless I've forgotten some other reason why
that old method is necessary, this commit should provide a decent speedup here, making
things somewhat interactive now (if still a bit jerky).
Other Tweaks:
1) Introduced float-precision threshold when checking to see whether an existing long
keyframe could be reused. This should hopefully reduce the number of fp-jitter issues
when creating summaries for many channels, reducing the number of duplicates created.
2) Precompute colours used for shading the long keyframes, instead of recomputing for
each block.
2014-04-16 03:21:06 +12:00
|
|
|
glColor4fv(unsel_color);
|
2009-07-09 13:14:51 +00:00
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
glRectf(ab->start, ypos - iconsize, ab->end, ypos + iconsize);
|
2008-12-22 08:13:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* draw keys */
|
|
|
|
|
if (keys) {
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ak = keys->first; ak; ak = ak->next) {
|
2012-07-06 23:56:59 +00:00
|
|
|
/* optimization: if keyframe doesn't appear within 5 units (screenspace) in visible area, don't draw
|
2009-07-20 12:42:31 +00:00
|
|
|
* - this might give some improvements, since we current have to flip between view/region matrices
|
|
|
|
|
*/
|
|
|
|
|
if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax) == 0)
|
|
|
|
|
continue;
|
2012-07-20 12:18:45 +00:00
|
|
|
|
2009-07-09 13:14:51 +00:00
|
|
|
/* draw using OpenGL - uglier but faster */
|
2012-07-06 23:56:59 +00:00
|
|
|
/* NOTE1: a previous version of this didn't work nice for some intel cards
|
|
|
|
|
* NOTE2: if we wanted to go back to icons, these are icon = (ak->sel & SELECT) ? ICON_SPACE2 : ICON_SPACE3; */
|
2014-01-17 00:00:40 +13:00
|
|
|
draw_keyframe_shape(ak->cfra, ypos, xscale, iconsize, (ak->sel & SELECT), ak->key_type, KEYFRAME_SHAPE_BOTH, alpha);
|
2012-07-06 23:56:59 +00:00
|
|
|
}
|
2008-12-22 08:13:25 +00:00
|
|
|
}
|
2012-07-06 23:56:59 +00:00
|
|
|
|
2008-12-22 08:13:25 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-22 10:15:02 +00:00
|
|
|
/* *************************** Channel Drawing Funcs *************************** */
|
|
|
|
|
|
2009-10-13 11:21:02 +00:00
|
|
|
void draw_summary_channel(View2D *v2d, bAnimContext *ac, float ypos)
|
|
|
|
|
{
|
|
|
|
|
DLRBT_Tree keys, blocks;
|
|
|
|
|
|
|
|
|
|
BLI_dlrbTree_init(&keys);
|
|
|
|
|
BLI_dlrbTree_init(&blocks);
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
summary_to_keylist(ac, &keys, &blocks);
|
2009-10-13 11:21:02 +00:00
|
|
|
|
|
|
|
|
BLI_dlrbTree_linkedlist_sync(&keys);
|
|
|
|
|
BLI_dlrbTree_linkedlist_sync(&blocks);
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
draw_keylist(v2d, &keys, &blocks, ypos, 0);
|
2009-10-13 11:21:02 +00:00
|
|
|
|
|
|
|
|
BLI_dlrbTree_free(&keys);
|
|
|
|
|
BLI_dlrbTree_free(&blocks);
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-09 13:14:51 +00:00
|
|
|
void draw_scene_channel(View2D *v2d, bDopeSheet *ads, Scene *sce, float ypos)
|
2009-02-13 06:33:07 +00:00
|
|
|
{
|
2009-07-18 07:11:37 +00:00
|
|
|
DLRBT_Tree keys, blocks;
|
|
|
|
|
|
|
|
|
|
BLI_dlrbTree_init(&keys);
|
|
|
|
|
BLI_dlrbTree_init(&blocks);
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
scene_to_keylist(ads, sce, &keys, &blocks);
|
2009-02-13 06:33:07 +00:00
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
BLI_dlrbTree_linkedlist_sync(&keys);
|
|
|
|
|
BLI_dlrbTree_linkedlist_sync(&blocks);
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
draw_keylist(v2d, &keys, &blocks, ypos, 0);
|
2009-07-18 07:11:37 +00:00
|
|
|
|
|
|
|
|
BLI_dlrbTree_free(&keys);
|
|
|
|
|
BLI_dlrbTree_free(&blocks);
|
2009-02-13 06:33:07 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-09 13:14:51 +00:00
|
|
|
void draw_object_channel(View2D *v2d, bDopeSheet *ads, Object *ob, float ypos)
|
2008-12-22 08:13:25 +00:00
|
|
|
{
|
2009-07-18 07:11:37 +00:00
|
|
|
DLRBT_Tree keys, blocks;
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
BLI_dlrbTree_init(&keys);
|
|
|
|
|
BLI_dlrbTree_init(&blocks);
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
ob_to_keylist(ads, ob, &keys, &blocks);
|
2009-07-18 07:11:37 +00:00
|
|
|
|
|
|
|
|
BLI_dlrbTree_linkedlist_sync(&keys);
|
|
|
|
|
BLI_dlrbTree_linkedlist_sync(&blocks);
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
draw_keylist(v2d, &keys, &blocks, ypos, 0);
|
2009-07-18 07:11:37 +00:00
|
|
|
|
|
|
|
|
BLI_dlrbTree_free(&keys);
|
|
|
|
|
BLI_dlrbTree_free(&blocks);
|
2008-12-22 08:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-09 13:14:51 +00:00
|
|
|
void draw_fcurve_channel(View2D *v2d, AnimData *adt, FCurve *fcu, float ypos)
|
2008-12-22 08:13:25 +00:00
|
|
|
{
|
2009-07-18 07:11:37 +00:00
|
|
|
DLRBT_Tree keys, blocks;
|
|
|
|
|
|
2012-07-20 12:18:45 +00:00
|
|
|
short locked = (fcu->flag & FCURVE_PROTECTED) ||
|
|
|
|
|
((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) ||
|
|
|
|
|
((adt && adt->action) && (adt->action->id.lib));
|
|
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
BLI_dlrbTree_init(&keys);
|
|
|
|
|
BLI_dlrbTree_init(&blocks);
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
fcurve_to_keylist(adt, fcu, &keys, &blocks);
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
BLI_dlrbTree_linkedlist_sync(&keys);
|
|
|
|
|
BLI_dlrbTree_linkedlist_sync(&blocks);
|
|
|
|
|
|
2012-07-20 12:18:45 +00:00
|
|
|
draw_keylist(v2d, &keys, &blocks, ypos, locked);
|
2009-07-18 07:11:37 +00:00
|
|
|
|
|
|
|
|
BLI_dlrbTree_free(&keys);
|
|
|
|
|
BLI_dlrbTree_free(&blocks);
|
2008-12-22 08:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-09 13:14:51 +00:00
|
|
|
void draw_agroup_channel(View2D *v2d, AnimData *adt, bActionGroup *agrp, float ypos)
|
2008-12-22 08:13:25 +00:00
|
|
|
{
|
2009-07-18 07:11:37 +00:00
|
|
|
DLRBT_Tree keys, blocks;
|
|
|
|
|
|
2012-07-20 12:18:45 +00:00
|
|
|
short locked = (agrp->flag & AGRP_PROTECTED) ||
|
|
|
|
|
((adt && adt->action) && (adt->action->id.lib));
|
|
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
BLI_dlrbTree_init(&keys);
|
|
|
|
|
BLI_dlrbTree_init(&blocks);
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
agroup_to_keylist(adt, agrp, &keys, &blocks);
|
2009-07-18 07:11:37 +00:00
|
|
|
|
|
|
|
|
BLI_dlrbTree_linkedlist_sync(&keys);
|
|
|
|
|
BLI_dlrbTree_linkedlist_sync(&blocks);
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2012-07-20 12:18:45 +00:00
|
|
|
draw_keylist(v2d, &keys, &blocks, ypos, locked);
|
2009-07-18 07:11:37 +00:00
|
|
|
|
|
|
|
|
BLI_dlrbTree_free(&keys);
|
|
|
|
|
BLI_dlrbTree_free(&blocks);
|
2008-12-22 08:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-09 13:14:51 +00:00
|
|
|
void draw_action_channel(View2D *v2d, AnimData *adt, bAction *act, float ypos)
|
2008-12-22 08:13:25 +00:00
|
|
|
{
|
2009-07-18 07:11:37 +00:00
|
|
|
DLRBT_Tree keys, blocks;
|
|
|
|
|
|
2013-08-07 03:36:05 +00:00
|
|
|
short locked = (act && act->id.lib != NULL);
|
2012-07-20 12:18:45 +00:00
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
BLI_dlrbTree_init(&keys);
|
|
|
|
|
BLI_dlrbTree_init(&blocks);
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
action_to_keylist(adt, act, &keys, &blocks);
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
BLI_dlrbTree_linkedlist_sync(&keys);
|
|
|
|
|
BLI_dlrbTree_linkedlist_sync(&blocks);
|
|
|
|
|
|
2012-07-20 12:18:45 +00:00
|
|
|
draw_keylist(v2d, &keys, &blocks, ypos, locked);
|
2009-07-18 07:11:37 +00:00
|
|
|
|
|
|
|
|
BLI_dlrbTree_free(&keys);
|
|
|
|
|
BLI_dlrbTree_free(&blocks);
|
2008-12-22 08:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-09 13:14:51 +00:00
|
|
|
void draw_gpl_channel(View2D *v2d, bDopeSheet *ads, bGPDlayer *gpl, float ypos)
|
2008-12-22 08:13:25 +00:00
|
|
|
{
|
2009-07-18 07:11:37 +00:00
|
|
|
DLRBT_Tree keys;
|
|
|
|
|
|
|
|
|
|
BLI_dlrbTree_init(&keys);
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
gpl_to_keylist(ads, gpl, &keys);
|
2009-07-18 07:11:37 +00:00
|
|
|
|
|
|
|
|
BLI_dlrbTree_linkedlist_sync(&keys);
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
draw_keylist(v2d, &keys, NULL, ypos, (gpl->flag & GP_LAYER_LOCKED));
|
2009-07-18 07:11:37 +00:00
|
|
|
|
2012-06-08 14:31:38 +00:00
|
|
|
BLI_dlrbTree_free(&keys);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void draw_masklay_channel(View2D *v2d, bDopeSheet *ads, MaskLayer *masklay, float ypos)
|
|
|
|
|
{
|
|
|
|
|
DLRBT_Tree keys;
|
|
|
|
|
|
|
|
|
|
BLI_dlrbTree_init(&keys);
|
|
|
|
|
|
|
|
|
|
mask_to_keylist(ads, masklay, &keys);
|
|
|
|
|
|
|
|
|
|
BLI_dlrbTree_linkedlist_sync(&keys);
|
|
|
|
|
|
|
|
|
|
draw_keylist(v2d, &keys, NULL, ypos, (masklay->flag & MASK_LAYERFLAG_LOCKED));
|
|
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
BLI_dlrbTree_free(&keys);
|
2008-12-22 08:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-22 10:15:02 +00:00
|
|
|
/* *************************** Keyframe List Conversions *************************** */
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2009-10-13 11:21:02 +00:00
|
|
|
void summary_to_keylist(bAnimContext *ac, DLRBT_Tree *keys, DLRBT_Tree *blocks)
|
|
|
|
|
{
|
|
|
|
|
if (ac) {
|
|
|
|
|
ListBase anim_data = {NULL, NULL};
|
|
|
|
|
bAnimListElem *ale;
|
|
|
|
|
int filter;
|
|
|
|
|
|
|
|
|
|
/* get F-Curves to take keyframes from */
|
2012-08-27 08:23:51 +00:00
|
|
|
filter = ANIMFILTER_DATA_VISIBLE;
|
2009-10-13 11:21:02 +00:00
|
|
|
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
|
|
|
|
|
|
|
|
|
/* loop through each F-Curve, grabbing the keyframes */
|
2012-06-26 10:14:50 +00:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
2012-08-27 08:23:51 +00:00
|
|
|
/* Why not use all #eAnim_KeyType here?
|
|
|
|
|
* All of the other key types are actually "summaries" themselves, and will just end up duplicating stuff
|
|
|
|
|
* that comes up through standard filtering of just F-Curves.
|
|
|
|
|
* Given the way that these work, there isn't really any benefit at all from including them. - Aligorith */
|
|
|
|
|
|
2012-08-27 06:55:33 +00:00
|
|
|
switch (ale->datatype) {
|
|
|
|
|
case ALE_FCURVE:
|
|
|
|
|
fcurve_to_keylist(ale->adt, ale->data, keys, blocks);
|
|
|
|
|
break;
|
|
|
|
|
case ALE_MASKLAY:
|
|
|
|
|
mask_to_keylist(ac->ads, ale->data, keys);
|
|
|
|
|
break;
|
|
|
|
|
case ALE_GPFRAME:
|
|
|
|
|
gpl_to_keylist(ac->ads, ale->data, keys);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2012-08-27 08:23:51 +00:00
|
|
|
// printf("%s: datatype %d unhandled\n", __func__, ale->datatype);
|
2012-08-27 06:55:33 +00:00
|
|
|
break;
|
2012-06-26 10:14:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
Optimisations for building "Long Keyframes"
For a long time, one of the bottlenecks when drawing summary channels in the dopesheet
(especially with many objects) was how the long keyframes feature (i.e showing holds
between keyframes) got built. Specifically, it was the step where we check on the previous
keyframe to see whether there's a hold between those two.
The old code performed some elaborate checks, which made sense back when we used to handle
certain summary channels (e.g. object-action/ipo, and groups IIRC) differently. However,
nowadays, everything just does it by going over the FCurves one by one, so the offending
code wasn't really providing much benefit. Unless I've forgotten some other reason why
that old method is necessary, this commit should provide a decent speedup here, making
things somewhat interactive now (if still a bit jerky).
Other Tweaks:
1) Introduced float-precision threshold when checking to see whether an existing long
keyframe could be reused. This should hopefully reduce the number of fp-jitter issues
when creating summaries for many channels, reducing the number of duplicates created.
2) Precompute colours used for shading the long keyframes, instead of recomputing for
each block.
2014-04-16 03:21:06 +12:00
|
|
|
|
2009-10-13 11:21:02 +00:00
|
|
|
BLI_freelistN(&anim_data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, DLRBT_Tree *blocks)
|
2009-02-13 06:33:07 +00:00
|
|
|
{
|
2011-06-30 13:56:47 +00:00
|
|
|
bAnimContext ac = {NULL};
|
|
|
|
|
ListBase anim_data = {NULL, NULL};
|
|
|
|
|
bAnimListElem *ale;
|
|
|
|
|
int filter;
|
|
|
|
|
|
2013-08-07 03:36:05 +00:00
|
|
|
bAnimListElem dummychan = {NULL};
|
2011-06-30 13:56:47 +00:00
|
|
|
|
|
|
|
|
if (sce == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* create a dummy wrapper data to work with */
|
|
|
|
|
dummychan.type = ANIMTYPE_SCENE;
|
|
|
|
|
dummychan.data = sce;
|
|
|
|
|
dummychan.id = &sce->id;
|
|
|
|
|
dummychan.adt = sce->adt;
|
|
|
|
|
|
|
|
|
|
ac.ads = ads;
|
|
|
|
|
ac.data = &dummychan;
|
|
|
|
|
ac.datatype = ANIMCONT_CHANNEL;
|
|
|
|
|
|
|
|
|
|
/* get F-Curves to take keyframes from */
|
2012-05-08 15:30:00 +00:00
|
|
|
filter = ANIMFILTER_DATA_VISIBLE; // curves only
|
2011-06-30 13:56:47 +00:00
|
|
|
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
|
|
|
|
|
|
|
|
|
/* loop through each F-Curve, grabbing the keyframes */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next)
|
2011-06-30 13:56:47 +00:00
|
|
|
fcurve_to_keylist(ale->adt, ale->data, keys, blocks);
|
|
|
|
|
|
|
|
|
|
BLI_freelistN(&anim_data);
|
2009-02-13 06:33:07 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, DLRBT_Tree *blocks)
|
2011-06-30 13:56:47 +00:00
|
|
|
{
|
|
|
|
|
bAnimContext ac = {NULL};
|
|
|
|
|
ListBase anim_data = {NULL, NULL};
|
|
|
|
|
bAnimListElem *ale;
|
|
|
|
|
int filter;
|
|
|
|
|
|
2013-08-07 03:36:05 +00:00
|
|
|
bAnimListElem dummychan = {NULL};
|
|
|
|
|
Base dummybase = {NULL};
|
2009-10-06 03:05:20 +00:00
|
|
|
|
|
|
|
|
if (ob == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2011-06-30 13:56:47 +00:00
|
|
|
/* create a dummy wrapper data to work with */
|
|
|
|
|
dummybase.object = ob;
|
2009-10-06 03:05:20 +00:00
|
|
|
|
2011-06-30 13:56:47 +00:00
|
|
|
dummychan.type = ANIMTYPE_OBJECT;
|
|
|
|
|
dummychan.data = &dummybase;
|
|
|
|
|
dummychan.id = &ob->id;
|
|
|
|
|
dummychan.adt = ob->adt;
|
2009-10-06 03:05:20 +00:00
|
|
|
|
2011-06-30 13:56:47 +00:00
|
|
|
ac.ads = ads;
|
|
|
|
|
ac.data = &dummychan;
|
|
|
|
|
ac.datatype = ANIMCONT_CHANNEL;
|
2009-10-06 03:05:20 +00:00
|
|
|
|
2011-06-30 13:56:47 +00:00
|
|
|
/* get F-Curves to take keyframes from */
|
2012-05-08 15:30:00 +00:00
|
|
|
filter = ANIMFILTER_DATA_VISIBLE; // curves only
|
2011-06-30 13:56:47 +00:00
|
|
|
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
|
|
|
|
|
|
|
|
|
/* loop through each F-Curve, grabbing the keyframes */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next)
|
2011-06-30 13:56:47 +00:00
|
|
|
fcurve_to_keylist(ale->adt, ale->data, keys, blocks);
|
|
|
|
|
|
|
|
|
|
BLI_freelistN(&anim_data);
|
2008-12-22 08:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree *blocks)
|
2008-12-22 08:13:25 +00:00
|
|
|
{
|
|
|
|
|
BezTriple *bezt;
|
2011-02-27 08:31:10 +00:00
|
|
|
unsigned int v;
|
|
|
|
|
|
2009-03-02 00:55:10 +00:00
|
|
|
if (fcu && fcu->totvert && fcu->bezt) {
|
2009-07-09 13:14:51 +00:00
|
|
|
/* apply NLA-mapping (if applicable) */
|
2012-10-21 05:46:41 +00:00
|
|
|
if (adt)
|
2010-01-18 00:35:28 +00:00
|
|
|
ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 0);
|
2009-07-09 13:14:51 +00:00
|
|
|
|
2009-11-17 08:27:46 +00:00
|
|
|
/* loop through beztriples, making ActKeysColumns and ActKeyBlocks */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (v = 0, bezt = fcu->bezt; v < fcu->totvert; v++, bezt++) {
|
2009-07-18 07:11:37 +00:00
|
|
|
add_bezt_to_keycolumns_list(keys, bezt);
|
Optimisations for building "Long Keyframes"
For a long time, one of the bottlenecks when drawing summary channels in the dopesheet
(especially with many objects) was how the long keyframes feature (i.e showing holds
between keyframes) got built. Specifically, it was the step where we check on the previous
keyframe to see whether there's a hold between those two.
The old code performed some elaborate checks, which made sense back when we used to handle
certain summary channels (e.g. object-action/ipo, and groups IIRC) differently. However,
nowadays, everything just does it by going over the FCurves one by one, so the offending
code wasn't really providing much benefit. Unless I've forgotten some other reason why
that old method is necessary, this commit should provide a decent speedup here, making
things somewhat interactive now (if still a bit jerky).
Other Tweaks:
1) Introduced float-precision threshold when checking to see whether an existing long
keyframe could be reused. This should hopefully reduce the number of fp-jitter issues
when creating summaries for many channels, reducing the number of duplicates created.
2) Precompute colours used for shading the long keyframes, instead of recomputing for
each block.
2014-04-16 03:21:06 +12:00
|
|
|
if (blocks) add_bezt_to_keyblocks_list(blocks, fcu->bezt, bezt);
|
2008-12-22 08:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* update the number of curves that elements have appeared in */
|
2009-07-18 07:11:37 +00:00
|
|
|
if (keys)
|
|
|
|
|
set_touched_actkeycolumn(keys->root);
|
|
|
|
|
if (blocks)
|
|
|
|
|
set_touched_actkeyblock(blocks->root);
|
2009-07-09 13:14:51 +00:00
|
|
|
|
|
|
|
|
/* unapply NLA-mapping if applicable */
|
2010-01-12 21:20:09 +00:00
|
|
|
if (adt)
|
2010-01-18 00:35:28 +00:00
|
|
|
ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 0);
|
2008-12-22 08:13:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
void agroup_to_keylist(AnimData *adt, bActionGroup *agrp, DLRBT_Tree *keys, DLRBT_Tree *blocks)
|
2008-12-22 08:13:25 +00:00
|
|
|
{
|
2009-01-20 11:07:42 +00:00
|
|
|
FCurve *fcu;
|
2008-12-22 08:13:25 +00:00
|
|
|
|
|
|
|
|
if (agrp) {
|
2009-01-20 11:07:42 +00:00
|
|
|
/* loop through F-Curves */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) {
|
2009-07-09 13:14:51 +00:00
|
|
|
fcurve_to_keylist(adt, fcu, keys, blocks);
|
2008-12-22 08:13:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-18 07:11:37 +00:00
|
|
|
void action_to_keylist(AnimData *adt, bAction *act, DLRBT_Tree *keys, DLRBT_Tree *blocks)
|
2008-12-22 08:13:25 +00:00
|
|
|
{
|
2009-01-20 11:07:42 +00:00
|
|
|
FCurve *fcu;
|
2008-12-22 08:13:25 +00:00
|
|
|
|
|
|
|
|
if (act) {
|
2009-01-20 11:07:42 +00:00
|
|
|
/* loop through F-Curves */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
|
2009-07-09 13:14:51 +00:00
|
|
|
fcurve_to_keylist(adt, fcu, keys, blocks);
|
2008-12-22 08:13:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-10-16 14:32:17 +00:00
|
|
|
void gpl_to_keylist(bDopeSheet *UNUSED(ads), bGPDlayer *gpl, DLRBT_Tree *keys)
|
2008-12-22 08:13:25 +00:00
|
|
|
{
|
|
|
|
|
bGPDframe *gpf;
|
|
|
|
|
|
|
|
|
|
if (gpl && keys) {
|
2011-01-10 22:10:28 +00:00
|
|
|
/* although the frames should already be in an ordered list, they are not suitable for displaying yet */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (gpf = gpl->frames.first; gpf; gpf = gpf->next)
|
2011-01-10 22:10:28 +00:00
|
|
|
add_gpframe_to_keycolumns_list(keys, gpf);
|
2008-12-22 08:13:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-04 16:42:58 +00:00
|
|
|
void mask_to_keylist(bDopeSheet *UNUSED(ads), MaskLayer *masklay, DLRBT_Tree *keys)
|
|
|
|
|
{
|
|
|
|
|
MaskLayerShape *masklay_shape;
|
|
|
|
|
|
|
|
|
|
if (masklay && keys) {
|
|
|
|
|
for (masklay_shape = masklay->splines_shapes.first;
|
|
|
|
|
masklay_shape;
|
|
|
|
|
masklay_shape = masklay_shape->next)
|
|
|
|
|
{
|
|
|
|
|
add_masklay_to_keycolumns_list(keys, masklay_shape);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|