2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-01-09 06:25:14 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* 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.
|
2009-01-09 06:25:14 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) Blender Foundation
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup spgraph
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include <float.h>
|
2009-01-09 06:25:14 +00:00
|
|
|
#include <math.h>
|
2020-03-19 09:33:03 +01:00
|
|
|
#include <stdio.h>
|
2009-01-09 06:25:14 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2014-11-16 23:32:23 +13:00
|
|
|
#include "BLI_math.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2009-01-09 06:25:14 +00:00
|
|
|
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
#include "DNA_anim_types.h"
|
2009-01-09 06:25:14 +00:00
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
#include "DNA_space_types.h"
|
2012-03-22 12:19:31 +00:00
|
|
|
#include "DNA_userdef_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_windowmanager_types.h"
|
2009-01-09 06:25:14 +00:00
|
|
|
|
2021-03-09 15:09:09 -05:00
|
|
|
#include "BKE_action.h"
|
2021-01-14 15:13:26 -05:00
|
|
|
#include "BKE_anim_data.h"
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
#include "BKE_context.h"
|
2014-11-16 23:32:23 +13:00
|
|
|
#include "BKE_curve.h"
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
#include "BKE_fcurve.h"
|
2021-01-14 15:13:26 -05:00
|
|
|
#include "BKE_nla.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2016-10-08 03:27:02 -04:00
|
|
|
#include "GPU_immediate.h"
|
2017-03-08 02:30:51 -03:00
|
|
|
#include "GPU_matrix.h"
|
2018-06-27 19:07:23 -06:00
|
|
|
#include "GPU_state.h"
|
2016-10-08 03:27:02 -04:00
|
|
|
|
2009-01-09 06:25:14 +00:00
|
|
|
#include "ED_anim_api.h"
|
|
|
|
|
|
2009-02-03 12:04:05 +00:00
|
|
|
#include "graph_intern.h"
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
2009-01-09 06:25:14 +00:00
|
|
|
#include "UI_resources.h"
|
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
|
2020-09-17 11:30:41 -05:00
|
|
|
static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu);
|
|
|
|
|
|
2020-09-17 13:14:47 -05:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Utility Drawing Defines
|
|
|
|
|
* \{ */
|
2009-09-25 10:52:29 +00:00
|
|
|
|
2018-06-04 09:31:30 +02:00
|
|
|
/* determine the alpha value that should be used when
|
2009-09-25 10:52:29 +00:00
|
|
|
* drawing components for some F-Curve (fcu)
|
2018-11-14 12:53:15 +11:00
|
|
|
* - selected F-Curves should be more visible than partially visible ones
|
2009-09-25 10:52:29 +00:00
|
|
|
*/
|
2012-03-31 04:04:58 +00:00
|
|
|
static float fcurve_display_alpha(FCurve *fcu)
|
|
|
|
|
{
|
|
|
|
|
return (fcu->flag & FCURVE_SELECTED) ? 1.0f : U.fcu_inactive_alpha;
|
|
|
|
|
}
|
2009-09-25 10:52:29 +00:00
|
|
|
|
2020-09-17 13:14:47 -05:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name FCurve Modifier Drawing
|
|
|
|
|
* \{ */
|
2009-03-21 03:49:22 +00:00
|
|
|
|
|
|
|
|
/* Envelope -------------- */
|
|
|
|
|
|
2012-10-20 20:20:02 +00:00
|
|
|
/* TODO: draw a shaded poly showing the region of influence too!!! */
|
2021-01-14 15:13:26 -05:00
|
|
|
/**
|
|
|
|
|
* \param adt_nla_remap: Send NULL if no NLA remapping necessary.
|
|
|
|
|
*/
|
|
|
|
|
static void draw_fcurve_modifier_controls_envelope(FModifier *fcm,
|
|
|
|
|
View2D *v2d,
|
|
|
|
|
AnimData *adt_nla_remap)
|
2009-03-21 03:49:22 +00:00
|
|
|
{
|
2012-05-08 20:18:33 +00:00
|
|
|
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
|
2009-03-21 03:49:22 +00:00
|
|
|
FCM_EnvelopeData *fed;
|
2012-09-15 11:48:20 +00:00
|
|
|
const float fac = 0.05f * BLI_rctf_size_x(&v2d->cur);
|
2009-03-21 03:49:22 +00:00
|
|
|
int i;
|
2017-03-08 02:30:51 -03:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
const uint shdr_pos = GPU_vertformat_attr_add(
|
|
|
|
|
immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2017-03-08 02:30:51 -03:00
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_width(1.0f);
|
2017-05-01 17:43:20 +02:00
|
|
|
|
2017-07-13 16:44:02 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
2017-05-01 17:43:20 +02:00
|
|
|
|
|
|
|
|
float viewport_size[4];
|
2018-07-02 18:27:05 +02:00
|
|
|
GPU_viewport_size_get_f(viewport_size);
|
2017-05-01 17:43:20 +02:00
|
|
|
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
|
|
|
|
|
2018-07-01 08:42:16 +02:00
|
|
|
immUniform1i("colors_len", 0); /* Simple dashes. */
|
2017-03-08 02:30:51 -03:00
|
|
|
immUniformColor3f(0.0f, 0.0f, 0.0f);
|
2017-05-01 17:43:20 +02:00
|
|
|
immUniform1f("dash_width", 10.0f);
|
|
|
|
|
immUniform1f("dash_factor", 0.5f);
|
|
|
|
|
|
|
|
|
|
/* draw two black lines showing the standard reference levels */
|
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 4);
|
2017-05-01 17:43:20 +02:00
|
|
|
immVertex2f(shdr_pos, v2d->cur.xmin, env->midval + env->min);
|
|
|
|
|
immVertex2f(shdr_pos, v2d->cur.xmax, env->midval + env->min);
|
|
|
|
|
|
|
|
|
|
immVertex2f(shdr_pos, v2d->cur.xmin, env->midval + env->max);
|
|
|
|
|
immVertex2f(shdr_pos, v2d->cur.xmax, env->midval + env->max);
|
2017-03-08 02:30:51 -03:00
|
|
|
immEnd();
|
|
|
|
|
|
2017-05-01 17:43:20 +02:00
|
|
|
immUnbindProgram();
|
2017-03-08 02:30:51 -03:00
|
|
|
|
2017-05-01 17:43:20 +02:00
|
|
|
if (env->totvert > 0) {
|
|
|
|
|
/* set size of vertices (non-adjustable for now) */
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_point_size(2.0f);
|
2017-03-08 02:30:51 -03:00
|
|
|
|
2017-05-01 17:43:20 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
|
|
|
|
|
/* for now, point color is fixed, and is white */
|
|
|
|
|
immUniformColor3f(1.0f, 1.0f, 1.0f);
|
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBeginAtMost(GPU_PRIM_POINTS, env->totvert * 2);
|
2017-05-01 17:43:20 +02:00
|
|
|
|
|
|
|
|
for (i = 0, fed = env->data; i < env->totvert; i++, fed++) {
|
2021-01-14 15:13:26 -05:00
|
|
|
const float env_scene_time = BKE_nla_tweakedit_remap(
|
|
|
|
|
adt_nla_remap, fed->time, NLATIME_CONVERT_MAP);
|
|
|
|
|
|
2017-05-01 17:43:20 +02:00
|
|
|
/* only draw if visible
|
2018-11-14 17:12:52 +11:00
|
|
|
* - min/max here are fixed, not relative
|
2017-05-01 17:43:20 +02:00
|
|
|
*/
|
2021-01-14 15:13:26 -05:00
|
|
|
if (IN_RANGE(env_scene_time, (v2d->cur.xmin - fac), (v2d->cur.xmax + fac))) {
|
|
|
|
|
immVertex2f(shdr_pos, env_scene_time, fed->min);
|
|
|
|
|
immVertex2f(shdr_pos, env_scene_time, fed->max);
|
2017-05-01 17:43:20 +02:00
|
|
|
}
|
2009-03-21 03:49:22 +00:00
|
|
|
}
|
2017-03-08 02:30:51 -03:00
|
|
|
|
2017-05-01 17:43:20 +02:00
|
|
|
immEnd();
|
2017-03-08 02:30:51 -03:00
|
|
|
|
2017-05-01 17:43:20 +02:00
|
|
|
immUnbindProgram();
|
|
|
|
|
}
|
2009-03-21 03:49:22 +00:00
|
|
|
}
|
|
|
|
|
|
2020-09-17 13:14:47 -05:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name FCurve Modifier Drawing
|
|
|
|
|
* \{ */
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
|
|
|
|
|
/* Points ---------------- */
|
2009-01-09 06:25:14 +00:00
|
|
|
|
2016-10-08 03:27:02 -04:00
|
|
|
/* helper func - set color to draw F-Curve data with */
|
|
|
|
|
static void set_fcurve_vertex_color(FCurve *fcu, bool sel)
|
|
|
|
|
{
|
2016-10-13 04:23:58 +00:00
|
|
|
float color[4];
|
2018-07-06 15:38:25 +12:00
|
|
|
float diff;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-08 03:27:02 -04:00
|
|
|
/* Set color of curve vertex based on state of curve (i.e. 'Edit' Mode) */
|
|
|
|
|
if ((fcu->flag & FCURVE_PROTECTED) == 0) {
|
|
|
|
|
/* Curve's points ARE BEING edited */
|
2018-07-06 15:38:25 +12:00
|
|
|
UI_GetThemeColor3fv(sel ? TH_VERTEX_SELECT : TH_VERTEX, color);
|
2016-10-08 03:27:02 -04:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Curve's points CANNOT BE edited */
|
2018-07-06 15:38:25 +12:00
|
|
|
UI_GetThemeColor3fv(sel ? TH_TEXT_HI : TH_TEXT, color);
|
2016-10-08 03:27:02 -04:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-06 15:38:25 +12:00
|
|
|
/* Fade the 'intensity' of the vertices based on the selection of the curves too
|
|
|
|
|
* - Only fade by 50% the amount the curves were faded by, so that the points
|
|
|
|
|
* still stand out for easier selection
|
|
|
|
|
*/
|
|
|
|
|
diff = 1.0f - fcurve_display_alpha(fcu);
|
|
|
|
|
color[3] = 1.0f - (diff * 0.5f);
|
|
|
|
|
CLAMP(color[3], 0.2f, 1.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-08 03:27:02 -04:00
|
|
|
immUniformColor4fv(color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void draw_fcurve_selected_keyframe_vertices(
|
2020-02-08 01:02:18 +11:00
|
|
|
FCurve *fcu, View2D *v2d, bool edit, bool sel, uint pos)
|
2009-01-09 06:25:14 +00:00
|
|
|
{
|
2012-09-15 11:48:20 +00:00
|
|
|
const float fac = 0.05f * BLI_rctf_size_x(&v2d->cur);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-08 03:27:02 -04:00
|
|
|
set_fcurve_vertex_color(fcu, sel);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBeginAtMost(GPU_PRIM_POINTS, fcu->totvert);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-08 03:27:02 -04:00
|
|
|
BezTriple *bezt = fcu->bezt;
|
|
|
|
|
for (int i = 0; i < fcu->totvert; i++, bezt++) {
|
2019-04-22 00:18:34 +10:00
|
|
|
/* As an optimization step, only draw those in view
|
|
|
|
|
* - We apply a correction factor to ensure that points
|
|
|
|
|
* don't pop in/out due to slight twitches of view size.
|
2009-01-29 03:43:04 +00:00
|
|
|
*/
|
2012-04-02 02:41:28 +00:00
|
|
|
if (IN_RANGE(bezt->vec[1][0], (v2d->cur.xmin - fac), (v2d->cur.xmax + fac))) {
|
2009-01-29 03:43:04 +00:00
|
|
|
if (edit) {
|
|
|
|
|
/* 'Keyframe' vertex only, as handle lines and handles have already been drawn
|
2018-11-14 12:53:15 +11:00
|
|
|
* - only draw those with correct selection state for the current drawing color
|
|
|
|
|
* -
|
2009-01-29 03:43:04 +00:00
|
|
|
*/
|
2019-04-22 09:19:45 +10:00
|
|
|
if ((bezt->f2 & SELECT) == sel) {
|
2016-10-08 03:27:02 -04:00
|
|
|
immVertex2fv(pos, bezt->vec[1]);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2009-01-29 03:43:04 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* no check for selection here, as curve is not editable... */
|
2012-10-20 20:20:02 +00:00
|
|
|
/* XXX perhaps we don't want to even draw points? maybe add an option for that later */
|
2016-10-08 03:27:02 -04:00
|
|
|
immVertex2fv(pos, bezt->vec[1]);
|
2009-01-29 03:43:04 +00:00
|
|
|
}
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-08 03:27:02 -04:00
|
|
|
immEnd();
|
|
|
|
|
}
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
|
2020-10-07 08:27:58 -05:00
|
|
|
/**
|
|
|
|
|
* Draw the extra indicator for the active point.
|
|
|
|
|
*/
|
|
|
|
|
static void draw_fcurve_active_vertex(const FCurve *fcu, const View2D *v2d, const uint pos)
|
|
|
|
|
{
|
|
|
|
|
const int active_keyframe_index = BKE_fcurve_active_keyframe_index(fcu);
|
|
|
|
|
if (!(fcu->flag & FCURVE_ACTIVE) || active_keyframe_index == FCURVE_ACTIVE_KEYFRAME_NONE) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const float fac = 0.05f * BLI_rctf_size_x(&v2d->cur);
|
|
|
|
|
const BezTriple *bezt = &fcu->bezt[active_keyframe_index];
|
|
|
|
|
|
|
|
|
|
if (!IN_RANGE(bezt->vec[1][0], (v2d->cur.xmin - fac), (v2d->cur.xmax + fac))) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!(bezt->f2 & SELECT)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
immBegin(GPU_PRIM_POINTS, 1);
|
|
|
|
|
immUniformThemeColor(TH_VERTEX_ACTIVE);
|
|
|
|
|
immVertex2fv(pos, bezt->vec[1]);
|
|
|
|
|
immEnd();
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-08 03:27:02 -04:00
|
|
|
/* helper func - draw keyframe vertices only for an F-Curve */
|
2020-02-08 01:02:18 +11:00
|
|
|
static void draw_fcurve_keyframe_vertices(FCurve *fcu, View2D *v2d, bool edit, uint pos)
|
2009-01-09 06:25:14 +00:00
|
|
|
{
|
2017-02-28 02:18:52 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
|
2016-10-08 03:27:02 -04:00
|
|
|
|
2019-08-27 08:04:06 -07:00
|
|
|
immUniform1f("size", UI_GetThemeValuef(TH_VERTEX_SIZE) * U.dpi_fac);
|
2016-10-08 03:27:02 -04:00
|
|
|
|
|
|
|
|
draw_fcurve_selected_keyframe_vertices(fcu, v2d, edit, false, pos);
|
|
|
|
|
draw_fcurve_selected_keyframe_vertices(fcu, v2d, edit, true, pos);
|
2020-10-07 08:27:58 -05:00
|
|
|
draw_fcurve_active_vertex(fcu, v2d, pos);
|
2016-10-08 03:27:02 -04:00
|
|
|
|
|
|
|
|
immUnbindProgram();
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
|
|
|
|
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
/* helper func - draw handle vertices only for an F-Curve (if it is not protected) */
|
2016-10-08 03:27:02 -04:00
|
|
|
static void draw_fcurve_selected_handle_vertices(
|
2020-02-08 01:02:18 +11:00
|
|
|
FCurve *fcu, View2D *v2d, bool sel, bool sel_handle_only, uint pos)
|
2009-01-09 06:25:14 +00:00
|
|
|
{
|
2016-10-08 03:27:02 -04:00
|
|
|
(void)v2d; /* TODO: use this to draw only points in view */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-09 06:25:14 +00:00
|
|
|
/* set handle color */
|
2016-10-08 03:27:02 -04:00
|
|
|
float hcolor[3];
|
|
|
|
|
UI_GetThemeColor3fv(sel ? TH_HANDLE_VERTEX_SELECT : TH_HANDLE_VERTEX, hcolor);
|
|
|
|
|
immUniform4f("outlineColor", hcolor[0], hcolor[1], hcolor[2], 1.0f);
|
2017-08-03 13:45:26 +12:00
|
|
|
immUniformColor3fvAlpha(hcolor, 0.01f); /* almost invisible - only keep for smoothness */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBeginAtMost(GPU_PRIM_POINTS, fcu->totvert * 2);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-08 03:27:02 -04:00
|
|
|
BezTriple *bezt = fcu->bezt;
|
|
|
|
|
BezTriple *prevbezt = NULL;
|
|
|
|
|
for (int i = 0; i < fcu->totvert; i++, prevbezt = bezt, bezt++) {
|
|
|
|
|
/* Draw the editmode handles for a bezier curve (others don't have handles)
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
* if their selection status matches the selection status we're drawing for
|
2018-11-14 12:53:15 +11:00
|
|
|
* - first handle only if previous beztriple was bezier-mode
|
|
|
|
|
* - second handle only if current beztriple is bezier-mode
|
2009-11-30 11:37:27 +00:00
|
|
|
*
|
|
|
|
|
* Also, need to take into account whether the keyframe was selected
|
|
|
|
|
* if a Graph Editor option to only show handles of selected keys is on.
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
*/
|
2015-07-09 14:31:27 +10:00
|
|
|
if (!sel_handle_only || BEZT_ISSEL_ANY(bezt)) {
|
2012-09-09 00:00:21 +00:00
|
|
|
if ((!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) ||
|
|
|
|
|
(prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) {
|
2019-01-15 23:24:20 +11:00
|
|
|
if ((bezt->f1 & SELECT) == sel
|
2019-01-18 08:59:41 +11:00
|
|
|
/* && v2d->cur.xmin < bezt->vec[0][0] < v2d->cur.xmax) */) {
|
2016-10-08 03:27:02 -04:00
|
|
|
immVertex2fv(pos, bezt->vec[0]);
|
2009-11-30 11:37:27 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
if (bezt->ipo == BEZT_IPO_BEZ) {
|
2019-01-15 23:24:20 +11:00
|
|
|
if ((bezt->f3 & SELECT) == sel
|
2019-01-18 08:59:41 +11:00
|
|
|
/* && v2d->cur.xmin < bezt->vec[2][0] < v2d->cur.xmax) */) {
|
2016-10-08 03:27:02 -04:00
|
|
|
immVertex2fv(pos, bezt->vec[2]);
|
2019-01-15 23:24:20 +11:00
|
|
|
}
|
2009-11-30 11:37:27 +00:00
|
|
|
}
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-08 03:27:02 -04:00
|
|
|
immEnd();
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
|
|
|
|
|
2020-10-07 08:27:58 -05:00
|
|
|
/**
|
|
|
|
|
* Draw the extra handles for the active point.
|
|
|
|
|
*/
|
|
|
|
|
static void draw_fcurve_active_handle_vertices(const FCurve *fcu,
|
|
|
|
|
const bool sel_handle_only,
|
|
|
|
|
const uint pos)
|
|
|
|
|
{
|
|
|
|
|
const int active_keyframe_index = BKE_fcurve_active_keyframe_index(fcu);
|
|
|
|
|
if (!(fcu->flag & FCURVE_ACTIVE) || active_keyframe_index == FCURVE_ACTIVE_KEYFRAME_NONE) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const BezTriple *bezt = &fcu->bezt[active_keyframe_index];
|
|
|
|
|
|
|
|
|
|
if (sel_handle_only && !BEZT_ISSEL_ANY(bezt)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float active_col[4];
|
|
|
|
|
UI_GetThemeColor4fv(TH_VERTEX_ACTIVE, active_col);
|
|
|
|
|
immUniform4fv("outlineColor", active_col);
|
|
|
|
|
immUniformColor3fvAlpha(active_col, 0.01f); /* Almost invisible - only keep for smoothness. */
|
|
|
|
|
immBeginAtMost(GPU_PRIM_POINTS, 2);
|
|
|
|
|
|
2020-10-23 16:32:51 +02:00
|
|
|
const BezTriple *left_bezt = active_keyframe_index > 0 ? &fcu->bezt[active_keyframe_index - 1] :
|
|
|
|
|
bezt;
|
|
|
|
|
if (left_bezt->ipo == BEZT_IPO_BEZ && (bezt->f1 & SELECT)) {
|
2020-10-07 08:27:58 -05:00
|
|
|
immVertex2fv(pos, bezt->vec[0]);
|
|
|
|
|
}
|
2020-10-23 16:32:51 +02:00
|
|
|
if (bezt->ipo == BEZT_IPO_BEZ && (bezt->f3 & SELECT)) {
|
2020-10-07 08:27:58 -05:00
|
|
|
immVertex2fv(pos, bezt->vec[2]);
|
|
|
|
|
}
|
|
|
|
|
immEnd();
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-08 03:27:02 -04:00
|
|
|
/* helper func - draw handle vertices only for an F-Curve (if it is not protected) */
|
2020-02-08 01:02:18 +11:00
|
|
|
static void draw_fcurve_handle_vertices(FCurve *fcu, View2D *v2d, bool sel_handle_only, uint pos)
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
{
|
2016-10-08 03:27:02 -04:00
|
|
|
/* smooth outlines for more consistent appearance */
|
2017-02-28 02:18:52 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA);
|
2016-10-08 03:27:02 -04:00
|
|
|
|
|
|
|
|
/* set handle size */
|
2019-08-27 08:04:06 -07:00
|
|
|
immUniform1f("size", (1.4f * UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE)) * U.dpi_fac);
|
|
|
|
|
immUniform1f("outlineWidth", 1.5f * U.dpi_fac);
|
2016-10-08 03:27:02 -04:00
|
|
|
|
|
|
|
|
draw_fcurve_selected_handle_vertices(fcu, v2d, false, sel_handle_only, pos);
|
|
|
|
|
draw_fcurve_selected_handle_vertices(fcu, v2d, true, sel_handle_only, pos);
|
2020-10-07 08:27:58 -05:00
|
|
|
draw_fcurve_active_handle_vertices(fcu, sel_handle_only, pos);
|
2016-10-08 03:27:02 -04:00
|
|
|
|
|
|
|
|
immUnbindProgram();
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
static void draw_fcurve_vertices(ARegion *region,
|
|
|
|
|
FCurve *fcu,
|
|
|
|
|
bool do_handles,
|
|
|
|
|
bool sel_handle_only)
|
2009-01-09 06:25:14 +00:00
|
|
|
{
|
2020-03-06 16:56:42 +01:00
|
|
|
View2D *v2d = ®ion->v2d;
|
2016-10-08 03:27:02 -04:00
|
|
|
|
2018-06-04 09:31:30 +02:00
|
|
|
/* only draw points if curve is visible
|
2019-04-22 00:18:34 +10:00
|
|
|
* - Draw unselected points before selected points as separate passes
|
2018-11-14 17:12:52 +11:00
|
|
|
* to make sure in the case of overlapping points that the selected is always visible
|
2019-04-22 00:18:34 +10:00
|
|
|
* - Draw handles before keyframes, so that keyframes will overlap handles
|
|
|
|
|
* (keyframes are more important for users).
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
*/
|
2016-10-08 03:27:02 -04:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2016-10-08 03:27:02 -04:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-05-28 17:14:22 +02:00
|
|
|
GPU_program_point_size(true);
|
2016-10-08 03:27:02 -04:00
|
|
|
|
2019-01-15 23:24:20 +11:00
|
|
|
/* draw the two handles first (if they're shown, the curve doesn't
|
|
|
|
|
* have just a single keyframe, and the curve is being edited) */
|
2012-03-06 18:40:15 +00:00
|
|
|
if (do_handles) {
|
2016-10-08 03:27:02 -04:00
|
|
|
draw_fcurve_handle_vertices(fcu, v2d, sel_handle_only, pos);
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
2016-10-08 03:27:02 -04:00
|
|
|
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
/* draw keyframes over the handles */
|
2016-10-08 03:27:02 -04:00
|
|
|
draw_fcurve_keyframe_vertices(fcu, v2d, !(fcu->flag & FCURVE_PROTECTED), pos);
|
|
|
|
|
|
2019-05-28 17:14:22 +02:00
|
|
|
GPU_program_point_size(false);
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
|
|
|
|
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
/* Handles ---------------- */
|
|
|
|
|
|
2019-02-16 10:16:16 +11:00
|
|
|
static bool draw_fcurve_handles_check(SpaceGraph *sipo, FCurve *fcu)
|
2010-01-30 17:17:23 +00:00
|
|
|
{
|
2010-01-30 21:11:46 +00:00
|
|
|
/* don't draw handle lines if handles are not to be shown */
|
2019-01-15 23:24:20 +11:00
|
|
|
if (
|
|
|
|
|
/* handles shouldn't be shown anywhere */
|
|
|
|
|
(sipo->flag & SIPO_NOHANDLES) ||
|
|
|
|
|
/* keyframes aren't editable */
|
|
|
|
|
(fcu->flag & FCURVE_PROTECTED) ||
|
2012-05-08 20:18:33 +00:00
|
|
|
#if 0 /* handles can still be selected and handle types set, better draw - campbell */
|
2019-04-17 08:24:14 +02:00
|
|
|
/* editing the handles here will cause weird/incorrect interpolation issues */
|
|
|
|
|
(fcu->flag & FCURVE_INT_VALUES) ||
|
2011-05-20 01:02:00 +00:00
|
|
|
#endif
|
2019-01-15 23:24:20 +11:00
|
|
|
/* group that curve belongs to is not editable */
|
|
|
|
|
((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) ||
|
2019-04-18 07:21:26 +02:00
|
|
|
/* Do not show handles if there is only 1 keyframe,
|
|
|
|
|
* otherwise they all clump together in an ugly ball. */
|
2019-01-15 23:24:20 +11:00
|
|
|
(fcu->totvert <= 1)) {
|
2016-10-08 03:27:02 -04:00
|
|
|
return false;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2020-07-03 17:30:31 +02:00
|
|
|
return true;
|
2010-01-30 17:17:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* draw lines for F-Curve handles only (this is only done in EditMode)
|
|
|
|
|
* note: draw_fcurve_handles_check must be checked before running this. */
|
2019-02-16 10:16:16 +11:00
|
|
|
static void draw_fcurve_handles(SpaceGraph *sipo, FCurve *fcu)
|
2009-01-09 06:25:14 +00:00
|
|
|
{
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
int sel, b;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
|
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
|
|
|
|
uint color = GPU_vertformat_attr_add(
|
|
|
|
|
format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
2018-04-06 15:39:09 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
2020-05-15 15:12:58 -04:00
|
|
|
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
|
|
|
|
|
GPU_line_smooth(true);
|
|
|
|
|
}
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBeginAtMost(GPU_PRIM_LINES, 4 * 2 * fcu->totvert);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-04 09:31:30 +02:00
|
|
|
/* slightly hacky, but we want to draw unselected points before selected ones
|
2009-11-30 11:37:27 +00:00
|
|
|
* so that selected points are clearly visible
|
|
|
|
|
*/
|
2012-05-08 20:18:33 +00:00
|
|
|
for (sel = 0; sel < 2; sel++) {
|
|
|
|
|
BezTriple *bezt = fcu->bezt, *prevbezt = NULL;
|
|
|
|
|
int basecol = (sel) ? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE;
|
2014-04-27 00:22:49 +10:00
|
|
|
const float *fp;
|
2020-02-08 01:02:18 +11:00
|
|
|
uchar col[4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
for (b = 0; b < fcu->totvert; b++, prevbezt = bezt, bezt++) {
|
2018-06-04 09:31:30 +02:00
|
|
|
/* if only selected keyframes can get their handles shown,
|
2009-11-30 11:37:27 +00:00
|
|
|
* check that keyframe is selected
|
|
|
|
|
*/
|
|
|
|
|
if (sipo->flag & SIPO_SELVHANDLESONLY) {
|
2019-04-22 09:19:45 +10:00
|
|
|
if (BEZT_ISSEL_ANY(bezt) == 0) {
|
2009-11-30 11:37:27 +00:00
|
|
|
continue;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2009-11-30 11:37:27 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-30 11:37:27 +00:00
|
|
|
/* draw handle with appropriate set of colors if selection is ok */
|
2012-05-08 20:18:33 +00:00
|
|
|
if ((bezt->f2 & SELECT) == sel) {
|
|
|
|
|
fp = bezt->vec[0];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
/* only draw first handle if previous segment had handles */
|
2012-05-08 20:18:33 +00:00
|
|
|
if ((!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) ||
|
|
|
|
|
(prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) {
|
2010-03-12 16:43:04 +00:00
|
|
|
UI_GetThemeColor3ubv(basecol + bezt->h1, col);
|
2012-05-08 20:18:33 +00:00
|
|
|
col[3] = fcurve_display_alpha(fcu) * 255;
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ubv(color, col);
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2fv(pos, fp);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ubv(color, col);
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2fv(pos, fp + 3);
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
/* only draw second handle if this segment is bezier */
|
2012-03-06 18:40:15 +00:00
|
|
|
if (bezt->ipo == BEZT_IPO_BEZ) {
|
2010-03-12 16:43:04 +00:00
|
|
|
UI_GetThemeColor3ubv(basecol + bezt->h2, col);
|
2012-05-08 20:18:33 +00:00
|
|
|
col[3] = fcurve_display_alpha(fcu) * 255;
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ubv(color, col);
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2fv(pos, fp + 3);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ubv(color, col);
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2fv(pos, fp + 6);
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
else {
|
|
|
|
|
/* only draw first handle if previous segment was had handles, and selection is ok */
|
2012-09-09 00:00:21 +00:00
|
|
|
if (((bezt->f1 & SELECT) == sel) && ((!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) ||
|
|
|
|
|
(prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ)))) {
|
2012-05-08 20:18:33 +00:00
|
|
|
fp = bezt->vec[0];
|
2010-03-12 16:43:04 +00:00
|
|
|
UI_GetThemeColor3ubv(basecol + bezt->h1, col);
|
2012-05-08 20:18:33 +00:00
|
|
|
col[3] = fcurve_display_alpha(fcu) * 255;
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ubv(color, col);
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2fv(pos, fp);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ubv(color, col);
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2fv(pos, fp + 3);
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
/* only draw second handle if this segment is bezier, and selection is ok */
|
2012-09-09 00:00:21 +00:00
|
|
|
if (((bezt->f3 & SELECT) == sel) && (bezt->ipo == BEZT_IPO_BEZ)) {
|
2012-05-08 20:18:33 +00:00
|
|
|
fp = bezt->vec[1];
|
2010-03-12 16:43:04 +00:00
|
|
|
UI_GetThemeColor3ubv(basecol + bezt->h2, col);
|
2012-05-08 20:18:33 +00:00
|
|
|
col[3] = fcurve_display_alpha(fcu) * 255;
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ubv(color, col);
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2fv(pos, fp);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ubv(color, col);
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2fv(pos, fp + 3);
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
}
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-06 15:39:09 +02:00
|
|
|
immEnd();
|
2017-03-08 02:30:51 -03:00
|
|
|
immUnbindProgram();
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2020-05-15 15:12:58 -04:00
|
|
|
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
|
|
|
|
|
GPU_line_smooth(false);
|
|
|
|
|
}
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
|
|
|
|
|
2009-02-09 23:46:13 +00:00
|
|
|
/* Samples ---------------- */
|
|
|
|
|
|
2018-06-04 09:31:30 +02:00
|
|
|
/* helper func - draw sample-range marker for an F-Curve as a cross
|
2018-06-01 18:19:39 +02:00
|
|
|
* NOTE: the caller MUST HAVE GL_LINE_SMOOTH & GL_BLEND ENABLED, otherwise, the controls don't
|
2009-10-20 23:51:31 +00:00
|
|
|
* have a consistent appearance (due to off-pixel alignments)...
|
|
|
|
|
*/
|
2017-03-08 02:30:51 -03:00
|
|
|
static void draw_fcurve_sample_control(
|
2020-02-08 01:02:18 +11:00
|
|
|
float x, float y, float xscale, float yscale, float hsize, uint pos)
|
2009-02-09 23:46:13 +00:00
|
|
|
{
|
|
|
|
|
/* adjust view transform before starting */
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_push();
|
|
|
|
|
GPU_matrix_translate_2f(x, y);
|
|
|
|
|
GPU_matrix_scale_2f(1.0f / xscale * hsize, 1.0f / yscale * hsize);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-28 13:15:11 -05:00
|
|
|
/* draw X shape */
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 4);
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2f(pos, -0.7f, -0.7f);
|
|
|
|
|
immVertex2f(pos, +0.7f, +0.7f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2f(pos, -0.7f, +0.7f);
|
|
|
|
|
immVertex2f(pos, +0.7f, -0.7f);
|
|
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-02-09 23:46:13 +00:00
|
|
|
/* restore view transform */
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_pop();
|
2009-02-09 23:46:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* helper func - draw keyframe vertices only for an F-Curve */
|
2020-03-06 16:56:42 +01:00
|
|
|
static void draw_fcurve_samples(SpaceGraph *sipo, ARegion *region, FCurve *fcu)
|
2009-02-09 23:46:13 +00:00
|
|
|
{
|
|
|
|
|
FPoint *first, *last;
|
|
|
|
|
float hsize, xscale, yscale;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-02-09 23:46:13 +00:00
|
|
|
/* get view settings */
|
2012-05-08 20:18:33 +00:00
|
|
|
hsize = UI_GetThemeValuef(TH_VERTEX_SIZE);
|
2020-03-06 16:56:42 +01:00
|
|
|
UI_view2d_scale_get(®ion->v2d, &xscale, &yscale);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-02-09 23:46:13 +00:00
|
|
|
/* get verts */
|
2012-05-08 20:18:33 +00:00
|
|
|
first = fcu->fpt;
|
|
|
|
|
last = (first) ? (first + (fcu->totvert - 1)) : (NULL);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-02-09 23:46:13 +00:00
|
|
|
/* draw */
|
|
|
|
|
if (first && last) {
|
2009-10-20 23:51:31 +00:00
|
|
|
/* anti-aliased lines for more consistent appearance */
|
2019-04-22 09:19:45 +10:00
|
|
|
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_smooth(true);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2017-03-08 02:30:51 -03:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2017-03-08 02:30:51 -03:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
|
|
|
|
|
immUniformThemeColor((fcu->flag & FCURVE_SELECTED) ? TH_TEXT_HI : TH_TEXT);
|
|
|
|
|
|
|
|
|
|
draw_fcurve_sample_control(first->vec[0], first->vec[1], xscale, yscale, hsize, pos);
|
|
|
|
|
draw_fcurve_sample_control(last->vec[0], last->vec[1], xscale, yscale, hsize, pos);
|
|
|
|
|
|
|
|
|
|
immUnbindProgram();
|
|
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2019-04-22 09:19:45 +10:00
|
|
|
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_smooth(false);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2009-02-09 23:46:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
/* Curve ---------------- */
|
|
|
|
|
|
2019-04-22 00:18:34 +10:00
|
|
|
/* Helper func - just draw the F-Curve by sampling the visible region
|
|
|
|
|
* (for drawing curves with modifiers). */
|
2021-03-09 15:09:09 -05:00
|
|
|
static void draw_fcurve_curve(bAnimContext *ac,
|
|
|
|
|
ID *id,
|
|
|
|
|
FCurve *fcu_,
|
|
|
|
|
View2D *v2d,
|
|
|
|
|
uint pos,
|
|
|
|
|
const bool use_nla_remap,
|
|
|
|
|
const bool draw_extrapolation)
|
2009-03-15 10:39:02 +00:00
|
|
|
{
|
2019-02-16 10:16:16 +11:00
|
|
|
SpaceGraph *sipo = (SpaceGraph *)ac->sl;
|
2017-04-04 19:36:07 -04:00
|
|
|
short mapping_flag = ANIM_get_normalization_flags(ac);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 00:18:34 +10:00
|
|
|
/* when opening a blend file on a different sized screen or while dragging the toolbar this can
|
|
|
|
|
* happen best just bail out in this case. */
|
Refactor grid and scale indicator text drawing
This affects the timeline, dopesheet, graph editor, sequencer,
clip editor and nla editor.
Removed structs and enums: `V2D_ARG_DUMMY`, `eView2D_Units`,
`eView2D_Clamp`, `eView2D_Gridlines`, `View2DGrid`.
A main goal of this refactor is to get rid of the very generic
`View2DGrid` struct. The drawing code became very complex
because there were many different combinations of settings.
This refactor implements a different approach.
Instead of one very generic API, there are many slighly
different functions that do exactly, what we need in the
different editors. Only very little code is duplicated,
because the API functions compose some shared low level code.
This structure makes the code much easier to debug and change,
because every function has much fewer responsibilities.
Additionally, this refactor fixes some long standing bugs.
E.g. when `Show Seconds` is enabled, you zoom in and pan the view.
Or that the step size between displayed frame numbers was
always `>= 2`, no matter how close you zoom in.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D4776
2019-05-02 12:00:12 +02:00
|
|
|
if (UI_view2d_scale_get_x(v2d) <= 0.0f) {
|
2010-05-11 21:46:20 +00:00
|
|
|
return;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-20 16:06:44 +01:00
|
|
|
/* disable any drivers */
|
|
|
|
|
FCurve fcurve_for_draw = *fcu_;
|
|
|
|
|
fcurve_for_draw.driver = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-01-26 03:16:14 +00:00
|
|
|
/* compute unit correction factor */
|
2020-09-09 18:41:07 +02:00
|
|
|
float offset;
|
|
|
|
|
float unitFac = ANIM_unit_mapping_get_factor(
|
|
|
|
|
ac->scene, id, &fcurve_for_draw, mapping_flag, &offset);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-03-15 10:39:02 +00:00
|
|
|
/* Note about sampling frequency:
|
2018-11-14 12:53:15 +11:00
|
|
|
* Ideally, this is chosen such that we have 1-2 pixels = 1 segment
|
|
|
|
|
* which means that our curves can be as smooth as possible. However,
|
|
|
|
|
* this does mean that curves may not be fully accurate (i.e. if they have
|
|
|
|
|
* sudden spikes which happen at the sampling point, we may have problems).
|
|
|
|
|
* Also, this may introduce lower performance on less densely detailed curves,
|
|
|
|
|
* though it is impossible to predict this from the modifiers!
|
2009-03-15 10:39:02 +00:00
|
|
|
*
|
2018-11-14 12:53:15 +11:00
|
|
|
* If the automatically determined sampling frequency is likely to cause an infinite
|
|
|
|
|
* loop (i.e. too close to 0), then clamp it to a determined "safe" value. The value
|
2012-05-08 20:18:33 +00:00
|
|
|
* chosen here is just the coarsest value which still looks reasonable...
|
2009-03-15 10:39:02 +00:00
|
|
|
*/
|
Refactor grid and scale indicator text drawing
This affects the timeline, dopesheet, graph editor, sequencer,
clip editor and nla editor.
Removed structs and enums: `V2D_ARG_DUMMY`, `eView2D_Units`,
`eView2D_Clamp`, `eView2D_Gridlines`, `View2DGrid`.
A main goal of this refactor is to get rid of the very generic
`View2DGrid` struct. The drawing code became very complex
because there were many different combinations of settings.
This refactor implements a different approach.
Instead of one very generic API, there are many slighly
different functions that do exactly, what we need in the
different editors. Only very little code is duplicated,
because the API functions compose some shared low level code.
This structure makes the code much easier to debug and change,
because every function has much fewer responsibilities.
Additionally, this refactor fixes some long standing bugs.
E.g. when `Show Seconds` is enabled, you zoom in and pan the view.
Or that the step size between displayed frame numbers was
always `>= 2`, no matter how close you zoom in.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D4776
2019-05-02 12:00:12 +02:00
|
|
|
|
2019-04-22 00:18:34 +10:00
|
|
|
/* TODO: perhaps we should have 1.0 frames
|
|
|
|
|
* as upper limit so that curves don't get too distorted? */
|
Refactor grid and scale indicator text drawing
This affects the timeline, dopesheet, graph editor, sequencer,
clip editor and nla editor.
Removed structs and enums: `V2D_ARG_DUMMY`, `eView2D_Units`,
`eView2D_Clamp`, `eView2D_Gridlines`, `View2DGrid`.
A main goal of this refactor is to get rid of the very generic
`View2DGrid` struct. The drawing code became very complex
because there were many different combinations of settings.
This refactor implements a different approach.
Instead of one very generic API, there are many slighly
different functions that do exactly, what we need in the
different editors. Only very little code is duplicated,
because the API functions compose some shared low level code.
This structure makes the code much easier to debug and change,
because every function has much fewer responsibilities.
Additionally, this refactor fixes some long standing bugs.
E.g. when `Show Seconds` is enabled, you zoom in and pan the view.
Or that the step size between displayed frame numbers was
always `>= 2`, no matter how close you zoom in.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D4776
2019-05-02 12:00:12 +02:00
|
|
|
float pixels_per_sample = 1.5f;
|
2020-09-09 18:41:07 +02:00
|
|
|
float samplefreq = pixels_per_sample / UI_view2d_scale_get_x(v2d);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-11-16 23:02:31 +13:00
|
|
|
if (sipo->flag & SIPO_BEAUTYDRAW_OFF) {
|
|
|
|
|
/* Low Precision = coarse lower-bound clamping
|
2018-06-04 09:31:30 +02:00
|
|
|
*
|
2014-11-16 23:02:31 +13:00
|
|
|
* Although the "Beauty Draw" flag was originally for AA'd
|
|
|
|
|
* line drawing, the sampling rate here has a much greater
|
|
|
|
|
* impact on performance (e.g. for T40372)!
|
|
|
|
|
*
|
|
|
|
|
* This one still amounts to 10 sample-frames for each 1-frame interval
|
|
|
|
|
* which should be quite a decent approximation in many situations.
|
|
|
|
|
*/
|
2019-04-22 09:19:45 +10:00
|
|
|
if (samplefreq < 0.1f) {
|
2014-11-16 23:02:31 +13:00
|
|
|
samplefreq = 0.1f;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2014-11-16 23:02:31 +13:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* "Higher Precision" but slower - especially on larger windows (e.g. T40372) */
|
2019-04-22 09:19:45 +10:00
|
|
|
if (samplefreq < 0.00001f) {
|
2014-11-16 23:02:31 +13:00
|
|
|
samplefreq = 0.00001f;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2014-11-16 23:02:31 +13:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-03-15 10:39:02 +00:00
|
|
|
/* the start/end times are simply the horizontal extents of the 'cur' rect */
|
2020-09-09 18:41:07 +02:00
|
|
|
float stime = v2d->cur.xmin;
|
2021-03-09 15:09:09 -05:00
|
|
|
float etime = v2d->cur.xmax;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-09 15:09:09 -05:00
|
|
|
AnimData *adt = use_nla_remap ? BKE_animdata_from_id(id) : NULL;
|
|
|
|
|
|
|
|
|
|
/* If not drawing extrapolation, then change fcurve drawing bounds to its keyframe bounds clamped
|
|
|
|
|
* by graph editor bounds. */
|
|
|
|
|
if (!draw_extrapolation) {
|
|
|
|
|
float fcu_start = 0;
|
|
|
|
|
float fcu_end = 0;
|
|
|
|
|
BKE_fcurve_calc_range(fcu_, &fcu_start, &fcu_end, false, false);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-09 15:09:09 -05:00
|
|
|
fcu_start = BKE_nla_tweakedit_remap(adt, fcu_start, NLATIME_CONVERT_MAP);
|
|
|
|
|
fcu_end = BKE_nla_tweakedit_remap(adt, fcu_end, NLATIME_CONVERT_MAP);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-09 15:09:09 -05:00
|
|
|
/* Account for reversed NLA strip effect. */
|
|
|
|
|
if (fcu_end < fcu_start) {
|
|
|
|
|
SWAP(float, fcu_start, fcu_end);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-09 15:09:09 -05:00
|
|
|
/* Clamp to graph editor rendering bounds. */
|
|
|
|
|
stime = max_ff(stime, fcu_start);
|
|
|
|
|
etime = min_ff(etime, fcu_end);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const int total_samples = roundf((etime - stime) / samplefreq);
|
|
|
|
|
if (total_samples <= 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-01-14 15:13:26 -05:00
|
|
|
|
2021-03-09 15:09:09 -05:00
|
|
|
/* NLA remapping is linear so we don't have to remap per iteration. */
|
|
|
|
|
const float eval_start = BKE_nla_tweakedit_remap(adt, stime, NLATIME_CONVERT_UNMAP);
|
|
|
|
|
const float eval_freq = BKE_nla_tweakedit_remap(adt, stime + samplefreq, NLATIME_CONVERT_UNMAP) -
|
|
|
|
|
eval_start;
|
|
|
|
|
const float eval_end = BKE_nla_tweakedit_remap(adt, etime, NLATIME_CONVERT_UNMAP);
|
|
|
|
|
|
|
|
|
|
immBegin(GPU_PRIM_LINE_STRIP, (total_samples + 1));
|
|
|
|
|
|
|
|
|
|
/* At each sampling interval, add a new vertex.
|
|
|
|
|
*
|
|
|
|
|
* Apply the unit correction factor to the calculated values so that the displayed values appear
|
|
|
|
|
* correctly in the viewport.
|
|
|
|
|
*/
|
|
|
|
|
for (int i = 0; i < total_samples; i++) {
|
|
|
|
|
const float ctime = stime + i * samplefreq;
|
|
|
|
|
float eval_time = eval_start + i * eval_freq;
|
|
|
|
|
|
|
|
|
|
/* Prevent drawing past bounds, due to floating point problems.
|
|
|
|
|
* User-wise, prevent visual flickering.
|
|
|
|
|
*
|
|
|
|
|
* This is to cover the case where:
|
|
|
|
|
* eval_start + total_samples * eval_freq > eval_end
|
|
|
|
|
* due to floating point problems.
|
|
|
|
|
*/
|
|
|
|
|
if (eval_time > eval_end) {
|
|
|
|
|
eval_time = eval_end;
|
2017-03-08 02:30:51 -03:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-09 15:09:09 -05:00
|
|
|
immVertex2f(pos, ctime, (evaluate_fcurve(&fcurve_for_draw, eval_time) + offset) * unitFac);
|
2014-07-01 13:22:55 +06:00
|
|
|
}
|
2021-03-09 15:09:09 -05:00
|
|
|
|
|
|
|
|
/* Ensure we include end boundary point.
|
|
|
|
|
* User-wise, prevent visual flickering.
|
|
|
|
|
*
|
|
|
|
|
* This is to cover the case where:
|
|
|
|
|
* eval_start + total_samples * eval_freq < eval_end
|
|
|
|
|
* due to floating point problems.
|
|
|
|
|
*/
|
|
|
|
|
immVertex2f(pos, etime, (evaluate_fcurve(&fcurve_for_draw, eval_end) + offset) * unitFac);
|
|
|
|
|
|
|
|
|
|
immEnd();
|
2009-03-15 10:39:02 +00:00
|
|
|
}
|
|
|
|
|
|
2009-03-01 11:47:29 +00:00
|
|
|
/* helper func - draw a samples-based F-Curve */
|
2021-03-09 15:09:09 -05:00
|
|
|
static void draw_fcurve_curve_samples(bAnimContext *ac,
|
|
|
|
|
ID *id,
|
|
|
|
|
FCurve *fcu,
|
|
|
|
|
View2D *v2d,
|
|
|
|
|
const uint shdr_pos,
|
|
|
|
|
const bool draw_extrapolation)
|
2009-03-01 11:47:29 +00:00
|
|
|
{
|
2021-03-09 15:09:09 -05:00
|
|
|
if (!draw_extrapolation && fcu->totvert == 1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
FPoint *prevfpt = fcu->fpt;
|
|
|
|
|
FPoint *fpt = prevfpt + 1;
|
2009-03-01 11:47:29 +00:00
|
|
|
float fac, v[2];
|
2017-04-04 19:36:07 -04:00
|
|
|
int b = fcu->totvert;
|
|
|
|
|
float unit_scale, offset;
|
|
|
|
|
short mapping_flag = ANIM_get_normalization_flags(ac);
|
2017-03-08 02:30:51 -03:00
|
|
|
int count = fcu->totvert;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-09 15:09:09 -05:00
|
|
|
const bool extrap_left = draw_extrapolation && prevfpt->vec[0] > v2d->cur.xmin;
|
|
|
|
|
if (extrap_left) {
|
2017-03-08 02:30:51 -03:00
|
|
|
count++;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-09 15:09:09 -05:00
|
|
|
const bool extrap_right = draw_extrapolation && (prevfpt + b - 1)->vec[0] < v2d->cur.xmax;
|
|
|
|
|
if (extrap_right) {
|
2017-03-08 02:30:51 -03:00
|
|
|
count++;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-01-26 03:16:14 +00:00
|
|
|
/* apply unit mapping */
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_push();
|
2017-04-04 19:36:07 -04:00
|
|
|
unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_scale_2f(1.0f, unit_scale);
|
|
|
|
|
GPU_matrix_translate_2f(0.0f, offset);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINE_STRIP, count);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-03-15 10:39:02 +00:00
|
|
|
/* extrapolate to left? - left-side of view comes before first keyframe? */
|
2021-03-09 15:09:09 -05:00
|
|
|
if (extrap_left) {
|
2012-05-08 20:18:33 +00:00
|
|
|
v[0] = v2d->cur.xmin;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-03-15 10:39:02 +00:00
|
|
|
/* y-value depends on the interpolation */
|
2012-05-08 20:18:33 +00:00
|
|
|
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) ||
|
|
|
|
|
(fcu->totvert == 1)) {
|
2009-03-15 10:39:02 +00:00
|
|
|
/* just extend across the first keyframe's value */
|
2012-05-08 20:18:33 +00:00
|
|
|
v[1] = prevfpt->vec[1];
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-03-15 10:39:02 +00:00
|
|
|
else {
|
2014-03-22 16:57:57 +13:00
|
|
|
/* extrapolate linear doesn't use the handle, use the next points center instead */
|
2012-05-08 20:18:33 +00:00
|
|
|
fac = (prevfpt->vec[0] - fpt->vec[0]) / (prevfpt->vec[0] - v[0]);
|
2019-04-22 09:19:45 +10:00
|
|
|
if (fac) {
|
2012-05-08 20:18:33 +00:00
|
|
|
fac = 1.0f / fac;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2012-05-08 20:18:33 +00:00
|
|
|
v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]);
|
2009-03-01 11:47:29 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-01 17:43:20 +02:00
|
|
|
immVertex2fv(shdr_pos, v);
|
2009-03-01 11:47:29 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-03-01 11:47:29 +00:00
|
|
|
/* loop over samples, drawing segments */
|
|
|
|
|
/* draw curve between first and last keyframe (if there are enough to do so) */
|
|
|
|
|
while (b--) {
|
|
|
|
|
/* Linear interpolation: just add one point (which should add a new line segment) */
|
2017-05-01 17:43:20 +02:00
|
|
|
immVertex2fv(shdr_pos, prevfpt->vec);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-03-01 11:47:29 +00:00
|
|
|
/* get next pointers */
|
2017-03-08 02:30:51 -03:00
|
|
|
if (b > 0) {
|
|
|
|
|
prevfpt++;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2017-03-08 02:30:51 -03:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-03-01 11:47:29 +00:00
|
|
|
/* extrapolate to right? (see code for left-extrapolation above too) */
|
2021-03-09 15:09:09 -05:00
|
|
|
if (extrap_right) {
|
2012-05-08 20:18:33 +00:00
|
|
|
v[0] = v2d->cur.xmax;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-03-15 10:39:02 +00:00
|
|
|
/* y-value depends on the interpolation */
|
2012-05-08 20:18:33 +00:00
|
|
|
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) ||
|
|
|
|
|
(fcu->totvert == 1)) {
|
2009-03-15 10:39:02 +00:00
|
|
|
/* based on last keyframe's value */
|
2012-05-08 20:18:33 +00:00
|
|
|
v[1] = prevfpt->vec[1];
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-03-15 10:39:02 +00:00
|
|
|
else {
|
2014-03-22 16:57:57 +13:00
|
|
|
/* extrapolate linear doesn't use the handle, use the previous points center instead */
|
2012-05-08 20:18:33 +00:00
|
|
|
fpt = prevfpt - 1;
|
|
|
|
|
fac = (prevfpt->vec[0] - fpt->vec[0]) / (prevfpt->vec[0] - v[0]);
|
2019-04-22 09:19:45 +10:00
|
|
|
if (fac) {
|
2012-05-08 20:18:33 +00:00
|
|
|
fac = 1.0f / fac;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2012-05-08 20:18:33 +00:00
|
|
|
v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]);
|
2009-03-01 11:47:29 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-01 17:43:20 +02:00
|
|
|
immVertex2fv(shdr_pos, v);
|
2009-03-01 11:47:29 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-08 02:30:51 -03:00
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_pop();
|
2009-03-01 11:47:29 +00:00
|
|
|
}
|
|
|
|
|
|
2018-06-04 09:31:30 +02:00
|
|
|
/* helper func - check if the F-Curve only contains easily drawable segments
|
2018-06-01 18:19:39 +02:00
|
|
|
* (i.e. no easing equation interpolations)
|
2014-11-16 23:32:23 +13:00
|
|
|
*/
|
|
|
|
|
static bool fcurve_can_use_simple_bezt_drawing(FCurve *fcu)
|
|
|
|
|
{
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
int i;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2014-11-16 23:32:23 +13:00
|
|
|
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
|
|
|
|
|
if (ELEM(bezt->ipo, BEZT_IPO_CONST, BEZT_IPO_LIN, BEZT_IPO_BEZ) == false) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2014-11-16 23:32:23 +13:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* helper func - draw one repeat of an F-Curve (using Bezier curve approximations) */
|
2021-03-09 15:09:09 -05:00
|
|
|
static void draw_fcurve_curve_bezts(
|
|
|
|
|
bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d, uint pos, const bool draw_extrapolation)
|
2009-01-09 06:25:14 +00:00
|
|
|
{
|
2021-03-09 15:09:09 -05:00
|
|
|
if (!draw_extrapolation && fcu->totvert == 1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
BezTriple *prevbezt = fcu->bezt;
|
|
|
|
|
BezTriple *bezt = prevbezt + 1;
|
2009-01-09 06:25:14 +00:00
|
|
|
float v1[2], v2[2], v3[2], v4[2];
|
2017-04-04 19:36:07 -04:00
|
|
|
float *fp, data[120];
|
2012-05-08 20:18:33 +00:00
|
|
|
float fac = 0.0f;
|
2017-04-04 19:36:07 -04:00
|
|
|
int b = fcu->totvert - 1;
|
|
|
|
|
int resol;
|
|
|
|
|
float unit_scale, offset;
|
|
|
|
|
short mapping_flag = ANIM_get_normalization_flags(ac);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-01-26 03:16:14 +00:00
|
|
|
/* apply unit mapping */
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_push();
|
2017-04-04 19:36:07 -04:00
|
|
|
unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_scale_2f(1.0f, unit_scale);
|
|
|
|
|
GPU_matrix_translate_2f(0.0f, offset);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-08 02:30:51 -03:00
|
|
|
/* For now, this assumes the worst case scenario, where all the keyframes have
|
|
|
|
|
* bezier interpolation, and are drawn at full res.
|
|
|
|
|
* This is tricky to optimize, but maybe can be improved at some point... */
|
2018-07-18 00:12:21 +02:00
|
|
|
immBeginAtMost(GPU_PRIM_LINE_STRIP, (b * 32 + 3));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-09 06:25:14 +00:00
|
|
|
/* extrapolate to left? */
|
2021-03-09 15:09:09 -05:00
|
|
|
if (draw_extrapolation && prevbezt->vec[1][0] > v2d->cur.xmin) {
|
2009-01-09 06:25:14 +00:00
|
|
|
/* left-side of view comes before first keyframe, so need to extend as not cyclic */
|
2012-05-08 20:18:33 +00:00
|
|
|
v1[0] = v2d->cur.xmin;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-03-15 10:39:02 +00:00
|
|
|
/* y-value depends on the interpolation */
|
2012-05-08 20:18:33 +00:00
|
|
|
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (prevbezt->ipo == BEZT_IPO_CONST) ||
|
|
|
|
|
(fcu->totvert == 1)) {
|
2009-03-15 10:39:02 +00:00
|
|
|
/* just extend across the first keyframe's value */
|
2012-05-08 20:18:33 +00:00
|
|
|
v1[1] = prevbezt->vec[1][1];
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2012-05-08 20:18:33 +00:00
|
|
|
else if (prevbezt->ipo == BEZT_IPO_LIN) {
|
2019-08-01 13:53:25 +10:00
|
|
|
/* extrapolate linear doesn't use the handle, use the next points center instead */
|
2012-05-08 20:18:33 +00:00
|
|
|
fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
|
2019-04-22 09:19:45 +10:00
|
|
|
if (fac) {
|
2012-05-08 20:18:33 +00:00
|
|
|
fac = 1.0f / fac;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2012-05-08 20:18:33 +00:00
|
|
|
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-03-15 10:39:02 +00:00
|
|
|
else {
|
|
|
|
|
/* based on angle of handle 1 (relative to keyframe) */
|
2012-05-08 20:18:33 +00:00
|
|
|
fac = (prevbezt->vec[0][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
|
2019-04-22 09:19:45 +10:00
|
|
|
if (fac) {
|
2012-05-08 20:18:33 +00:00
|
|
|
fac = 1.0f / fac;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2012-05-08 20:18:33 +00:00
|
|
|
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[0][1] - prevbezt->vec[1][1]);
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2fv(pos, v1);
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-09 06:25:14 +00:00
|
|
|
/* if only one keyframe, add it now */
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
if (fcu->totvert == 1) {
|
2012-05-08 20:18:33 +00:00
|
|
|
v1[0] = prevbezt->vec[1][0];
|
|
|
|
|
v1[1] = prevbezt->vec[1][1];
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2fv(pos, v1);
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-09 06:25:14 +00:00
|
|
|
/* draw curve between first and last keyframe (if there are enough to do so) */
|
2012-10-20 20:20:02 +00:00
|
|
|
/* TODO: optimize this to not have to calc stuff out of view too? */
|
2009-01-09 06:25:14 +00:00
|
|
|
while (b--) {
|
2012-05-08 20:18:33 +00:00
|
|
|
if (prevbezt->ipo == BEZT_IPO_CONST) {
|
2019-01-15 23:24:20 +11:00
|
|
|
/* Constant-Interpolation: draw segment between previous keyframe and next,
|
|
|
|
|
* but holding same value */
|
2012-05-08 20:18:33 +00:00
|
|
|
v1[0] = prevbezt->vec[1][0];
|
|
|
|
|
v1[1] = prevbezt->vec[1][1];
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2fv(pos, v1);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
v1[0] = bezt->vec[1][0];
|
|
|
|
|
v1[1] = prevbezt->vec[1][1];
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2fv(pos, v1);
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
2012-05-08 20:18:33 +00:00
|
|
|
else if (prevbezt->ipo == BEZT_IPO_LIN) {
|
2009-01-09 06:25:14 +00:00
|
|
|
/* Linear interpolation: just add one point (which should add a new line segment) */
|
2012-05-08 20:18:33 +00:00
|
|
|
v1[0] = prevbezt->vec[1][0];
|
|
|
|
|
v1[1] = prevbezt->vec[1][1];
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2fv(pos, v1);
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
2014-11-16 23:32:23 +13:00
|
|
|
else if (prevbezt->ipo == BEZT_IPO_BEZ) {
|
2018-06-04 09:31:30 +02:00
|
|
|
/* Bezier-Interpolation: draw curve as series of segments between keyframes
|
2018-11-14 12:53:15 +11:00
|
|
|
* - resol determines number of points to sample in between keyframes
|
2017-04-04 19:36:07 -04:00
|
|
|
*/
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-15 23:24:20 +11:00
|
|
|
/* resol depends on distance between points
|
|
|
|
|
* (not just horizontal) OR is a fixed high res */
|
2012-10-20 20:20:02 +00:00
|
|
|
/* TODO: view scale should factor into this someday too... */
|
2014-11-16 23:32:23 +13:00
|
|
|
if (fcu->driver) {
|
2012-05-08 20:18:33 +00:00
|
|
|
resol = 32;
|
2014-11-16 23:32:23 +13:00
|
|
|
}
|
|
|
|
|
else {
|
2012-05-08 20:18:33 +00:00
|
|
|
resol = (int)(5.0f * len_v2v2(bezt->vec[1], prevbezt->vec[1]));
|
2014-11-16 23:32:23 +13:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-09 06:25:14 +00:00
|
|
|
if (resol < 2) {
|
|
|
|
|
/* only draw one */
|
2012-05-08 20:18:33 +00:00
|
|
|
v1[0] = prevbezt->vec[1][0];
|
|
|
|
|
v1[1] = prevbezt->vec[1][1];
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2fv(pos, v1);
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* clamp resolution to max of 32 */
|
2012-10-20 20:20:02 +00:00
|
|
|
/* NOTE: higher values will crash */
|
2019-04-22 09:19:45 +10:00
|
|
|
if (resol > 32) {
|
2012-05-08 20:18:33 +00:00
|
|
|
resol = 32;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
v1[0] = prevbezt->vec[1][0];
|
|
|
|
|
v1[1] = prevbezt->vec[1][1];
|
|
|
|
|
v2[0] = prevbezt->vec[2][0];
|
|
|
|
|
v2[1] = prevbezt->vec[2][1];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
v3[0] = bezt->vec[0][0];
|
|
|
|
|
v3[1] = bezt->vec[0][1];
|
|
|
|
|
v4[0] = bezt->vec[1][0];
|
|
|
|
|
v4[1] = bezt->vec[1][1];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-10-15 19:38:20 +02:00
|
|
|
BKE_fcurve_correct_bezpart(v1, v2, v3, v4);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-08 13:29:21 +10:00
|
|
|
BKE_curve_forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float[3]));
|
2012-05-08 20:18:33 +00:00
|
|
|
BKE_curve_forward_diff_bezier(
|
2020-08-08 13:29:21 +10:00
|
|
|
v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float[3]));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-04-04 19:36:07 -04:00
|
|
|
for (fp = data; resol; resol--, fp += 3) {
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2fv(pos, fp);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2017-03-08 02:30:51 -03:00
|
|
|
}
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-09 06:25:14 +00:00
|
|
|
/* get next pointers */
|
2012-05-08 20:18:33 +00:00
|
|
|
prevbezt = bezt;
|
2009-01-09 06:25:14 +00:00
|
|
|
bezt++;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-09 06:25:14 +00:00
|
|
|
/* last point? */
|
|
|
|
|
if (b == 0) {
|
2012-05-08 20:18:33 +00:00
|
|
|
v1[0] = prevbezt->vec[1][0];
|
|
|
|
|
v1[1] = prevbezt->vec[1][1];
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2fv(pos, v1);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-09 06:25:14 +00:00
|
|
|
/* extrapolate to right? (see code for left-extrapolation above too) */
|
2021-03-09 15:09:09 -05:00
|
|
|
if (draw_extrapolation && prevbezt->vec[1][0] < v2d->cur.xmax) {
|
2012-05-08 20:18:33 +00:00
|
|
|
v1[0] = v2d->cur.xmax;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-03-15 10:39:02 +00:00
|
|
|
/* y-value depends on the interpolation */
|
2012-05-08 20:18:33 +00:00
|
|
|
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) ||
|
|
|
|
|
(prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) {
|
2009-03-15 10:39:02 +00:00
|
|
|
/* based on last keyframe's value */
|
2012-05-08 20:18:33 +00:00
|
|
|
v1[1] = prevbezt->vec[1][1];
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2012-05-08 20:18:33 +00:00
|
|
|
else if (prevbezt->ipo == BEZT_IPO_LIN) {
|
2019-07-31 14:25:09 +02:00
|
|
|
/* extrapolate linear doesn't use the handle, use the previous points center instead */
|
2012-05-08 20:18:33 +00:00
|
|
|
bezt = prevbezt - 1;
|
|
|
|
|
fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
|
2019-04-22 09:19:45 +10:00
|
|
|
if (fac) {
|
2012-05-08 20:18:33 +00:00
|
|
|
fac = 1.0f / fac;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2012-05-08 20:18:33 +00:00
|
|
|
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-03-15 10:39:02 +00:00
|
|
|
else {
|
|
|
|
|
/* based on angle of handle 1 (relative to keyframe) */
|
2012-05-08 20:18:33 +00:00
|
|
|
fac = (prevbezt->vec[2][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
|
2019-04-22 09:19:45 +10:00
|
|
|
if (fac) {
|
2012-05-08 20:18:33 +00:00
|
|
|
fac = 1.0f / fac;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2012-05-08 20:18:33 +00:00
|
|
|
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[2][1] - prevbezt->vec[1][1]);
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-08 02:30:51 -03:00
|
|
|
immVertex2fv(pos, v1);
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-08 02:30:51 -03:00
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_pop();
|
2014-03-22 02:50:24 +13:00
|
|
|
}
|
2009-01-09 06:25:14 +00:00
|
|
|
|
2020-09-17 11:30:41 -05:00
|
|
|
static void draw_fcurve(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, bAnimListElem *ale)
|
|
|
|
|
{
|
|
|
|
|
FCurve *fcu = (FCurve *)ale->key_data;
|
|
|
|
|
FModifier *fcm = find_active_fmodifier(&fcu->modifiers);
|
|
|
|
|
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
|
|
|
|
|
|
|
|
|
|
/* map keyframes for drawing if scaled F-Curve */
|
|
|
|
|
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,
|
|
|
|
|
* so we need to check which method should be used
|
|
|
|
|
* - controls from active modifier take precedence over keyframes
|
|
|
|
|
* (XXX! editing tools need to take this into account!)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* 1) draw curve line */
|
|
|
|
|
if (((fcu->modifiers.first) || (fcu->flag & FCURVE_INT_VALUES)) ||
|
|
|
|
|
(((fcu->bezt) || (fcu->fpt)) && (fcu->totvert))) {
|
|
|
|
|
/* set color/drawing style for curve itself */
|
|
|
|
|
/* draw active F-Curve thicker than the rest to make it stand out */
|
|
|
|
|
if (fcu->flag & FCURVE_ACTIVE) {
|
|
|
|
|
GPU_line_width(2.5);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
GPU_line_width(1.0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* anti-aliased lines for less jagged appearance */
|
|
|
|
|
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
|
|
|
|
|
GPU_line_smooth(true);
|
|
|
|
|
}
|
|
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
|
|
|
|
|
|
|
|
|
const uint shdr_pos = GPU_vertformat_attr_add(
|
|
|
|
|
immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
|
|
|
|
|
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
|
|
|
|
|
|
|
|
|
float viewport_size[4];
|
|
|
|
|
GPU_viewport_size_get_f(viewport_size);
|
|
|
|
|
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
|
|
|
|
|
|
|
|
|
immUniform1i("colors_len", 0); /* Simple dashes. */
|
|
|
|
|
|
|
|
|
|
if (BKE_fcurve_is_protected(fcu)) {
|
|
|
|
|
/* protected curves (non editable) are drawn with dotted lines */
|
|
|
|
|
immUniform1f("dash_width", 4.0f);
|
|
|
|
|
immUniform1f("dash_factor", 0.5f);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
immUniform1f("dash_factor", 2.0f); /* solid line */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (((fcu->grp) && (fcu->grp->flag & AGRP_MUTED)) || (fcu->flag & FCURVE_MUTED)) {
|
|
|
|
|
/* muted curves are drawn in a grayish hue */
|
|
|
|
|
/* XXX should we have some variations? */
|
|
|
|
|
immUniformThemeColorShade(TH_HEADER, 50);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* set whatever color the curve has set
|
|
|
|
|
* - unselected curves draw less opaque to help distinguish the selected ones
|
|
|
|
|
*/
|
|
|
|
|
immUniformColor3fvAlpha(fcu->color, fcurve_display_alpha(fcu));
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-09 15:09:09 -05:00
|
|
|
const bool draw_extrapolation = (sipo->flag & SIPO_NO_DRAW_EXTRAPOLATION) == 0;
|
2020-09-17 11:30:41 -05:00
|
|
|
/* draw F-Curve */
|
|
|
|
|
if ((fcu->modifiers.first) || (fcu->flag & FCURVE_INT_VALUES)) {
|
|
|
|
|
/* draw a curve affected by modifiers or only allowed to have integer values
|
|
|
|
|
* by sampling it at various small-intervals over the visible region
|
|
|
|
|
*/
|
2021-01-14 15:13:26 -05:00
|
|
|
if (adt) {
|
|
|
|
|
/** We have to do this mapping dance since the keyframes were remapped but the Fmodifier
|
|
|
|
|
* evaluations are not.
|
|
|
|
|
*
|
|
|
|
|
* So we undo the keyframe remapping and instead remap the evaluation time when drawing the
|
|
|
|
|
* curve itself. Afterward, we go back and redo the keyframe remapping so the controls are
|
|
|
|
|
* drawn properly. */
|
|
|
|
|
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, true, false);
|
2021-03-09 15:09:09 -05:00
|
|
|
draw_fcurve_curve(ac, ale->id, fcu, ®ion->v2d, shdr_pos, true, draw_extrapolation);
|
2021-01-14 15:13:26 -05:00
|
|
|
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, false, false);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2021-03-09 15:09:09 -05:00
|
|
|
draw_fcurve_curve(ac, ale->id, fcu, ®ion->v2d, shdr_pos, false, draw_extrapolation);
|
2021-01-14 15:13:26 -05:00
|
|
|
}
|
2020-09-17 11:30:41 -05:00
|
|
|
}
|
|
|
|
|
else if (((fcu->bezt) || (fcu->fpt)) && (fcu->totvert)) {
|
|
|
|
|
/* just draw curve based on defined data (i.e. no modifiers) */
|
|
|
|
|
if (fcu->bezt) {
|
|
|
|
|
if (fcurve_can_use_simple_bezt_drawing(fcu)) {
|
2021-03-09 15:09:09 -05:00
|
|
|
draw_fcurve_curve_bezts(ac, ale->id, fcu, ®ion->v2d, shdr_pos, draw_extrapolation);
|
2020-09-17 11:30:41 -05:00
|
|
|
}
|
|
|
|
|
else {
|
2021-03-09 15:09:09 -05:00
|
|
|
draw_fcurve_curve(ac, ale->id, fcu, ®ion->v2d, shdr_pos, false, draw_extrapolation);
|
2020-09-17 11:30:41 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (fcu->fpt) {
|
2021-03-09 15:09:09 -05:00
|
|
|
draw_fcurve_curve_samples(ac, ale->id, fcu, ®ion->v2d, shdr_pos, draw_extrapolation);
|
2020-09-17 11:30:41 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
immUnbindProgram();
|
|
|
|
|
|
|
|
|
|
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
|
|
|
|
|
GPU_line_smooth(false);
|
|
|
|
|
}
|
|
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 2) draw handles and vertices as appropriate based on active
|
|
|
|
|
* - If the option to only show controls if the F-Curve is selected is enabled,
|
|
|
|
|
* we must obey this.
|
|
|
|
|
*/
|
|
|
|
|
if (!(sipo->flag & SIPO_SELCUVERTSONLY) || (fcu->flag & FCURVE_SELECTED)) {
|
|
|
|
|
if (!BKE_fcurve_are_keyframes_usable(fcu) && !(fcu->fpt && fcu->totvert)) {
|
|
|
|
|
/* only draw controls if this is the active modifier */
|
|
|
|
|
if ((fcu->flag & FCURVE_ACTIVE) && (fcm)) {
|
|
|
|
|
switch (fcm->type) {
|
|
|
|
|
case FMODIFIER_TYPE_ENVELOPE: /* envelope */
|
2021-01-14 15:13:26 -05:00
|
|
|
draw_fcurve_modifier_controls_envelope(fcm, ®ion->v2d, adt);
|
2020-09-17 11:30:41 -05:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (((fcu->bezt) || (fcu->fpt)) && (fcu->totvert)) {
|
|
|
|
|
short mapping_flag = ANIM_get_normalization_flags(ac);
|
|
|
|
|
float offset;
|
|
|
|
|
float unit_scale = ANIM_unit_mapping_get_factor(
|
|
|
|
|
ac->scene, ale->id, fcu, mapping_flag, &offset);
|
|
|
|
|
|
|
|
|
|
/* apply unit-scaling to all values via OpenGL */
|
|
|
|
|
GPU_matrix_push();
|
|
|
|
|
GPU_matrix_scale_2f(1.0f, unit_scale);
|
|
|
|
|
GPU_matrix_translate_2f(0.0f, offset);
|
|
|
|
|
|
|
|
|
|
/* Set this once and for all -
|
|
|
|
|
* all handles and handle-verts should use the same thickness. */
|
|
|
|
|
GPU_line_width(1.0);
|
|
|
|
|
|
|
|
|
|
if (fcu->bezt) {
|
|
|
|
|
bool do_handles = draw_fcurve_handles_check(sipo, fcu);
|
|
|
|
|
|
|
|
|
|
if (do_handles) {
|
|
|
|
|
/* only draw handles/vertices on keyframes */
|
|
|
|
|
draw_fcurve_handles(sipo, fcu);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
draw_fcurve_vertices(region, fcu, do_handles, (sipo->flag & SIPO_SELVHANDLESONLY));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* samples: only draw two indicators at either end as indicators */
|
|
|
|
|
draw_fcurve_samples(sipo, region, fcu);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPU_matrix_pop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 3) draw driver debugging stuff */
|
|
|
|
|
if ((ac->datatype == ANIMCONT_DRIVERS) && (fcu->flag & FCURVE_ACTIVE)) {
|
|
|
|
|
graph_draw_driver_debug(ac, ale->id, fcu);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* undo mapping of keyframes for drawing if scaled F-Curve */
|
|
|
|
|
if (adt) {
|
|
|
|
|
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-22 02:28:55 +00:00
|
|
|
/* Debugging -------------------------------- */
|
|
|
|
|
|
2018-06-04 09:31:30 +02:00
|
|
|
/* Draw indicators which show the value calculated from the driver,
|
2013-03-22 02:28:55 +00:00
|
|
|
* and how this is mapped to the value that comes out of it. This
|
|
|
|
|
* is handy for helping users better understand how to interpret
|
2018-06-01 18:19:39 +02:00
|
|
|
* the graphs, and also facilitates debugging.
|
2013-03-22 02:28:55 +00:00
|
|
|
*/
|
|
|
|
|
static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
|
|
|
|
|
{
|
|
|
|
|
ChannelDriver *driver = fcu->driver;
|
2020-03-06 16:56:42 +01:00
|
|
|
View2D *v2d = &ac->region->v2d;
|
2017-04-04 19:36:07 -04:00
|
|
|
short mapping_flag = ANIM_get_normalization_flags(ac);
|
2015-04-13 15:57:46 +02:00
|
|
|
float offset;
|
2017-04-04 19:36:07 -04:00
|
|
|
float unitfac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
const uint shdr_pos = GPU_vertformat_attr_add(
|
|
|
|
|
immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2017-07-13 16:44:02 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
2017-05-01 17:43:20 +02:00
|
|
|
|
|
|
|
|
float viewport_size[4];
|
2018-07-02 18:27:05 +02:00
|
|
|
GPU_viewport_size_get_f(viewport_size);
|
2017-05-01 17:43:20 +02:00
|
|
|
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
|
|
|
|
|
2018-07-01 08:42:16 +02:00
|
|
|
immUniform1i("colors_len", 0); /* Simple dashes. */
|
2017-03-08 02:30:51 -03:00
|
|
|
|
2016-07-16 17:48:57 +10:00
|
|
|
/* No curve to modify/visualize the result?
|
2018-06-04 09:31:30 +02:00
|
|
|
* => We still want to show the 1-1 default...
|
2013-03-22 02:28:55 +00:00
|
|
|
*/
|
2014-02-08 06:07:10 +11:00
|
|
|
if ((fcu->totvert == 0) && BLI_listbase_is_empty(&fcu->modifiers)) {
|
2017-04-04 19:36:07 -04:00
|
|
|
float t;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-22 02:28:55 +00:00
|
|
|
/* draw with thin dotted lines in style of what curve would have been */
|
2017-03-08 02:30:51 -03:00
|
|
|
immUniformColor3fv(fcu->color);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2017-05-01 17:43:20 +02:00
|
|
|
immUniform1f("dash_width", 40.0f);
|
|
|
|
|
immUniform1f("dash_factor", 0.5f);
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_width(2.0f);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
|
|
|
|
/* draw 1-1 line, stretching just past the screen limits
|
2013-03-22 02:28:55 +00:00
|
|
|
* NOTE: we need to scale the y-values to be valid for the units
|
|
|
|
|
*/
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 2);
|
2017-03-08 02:30:51 -03:00
|
|
|
|
2017-04-04 19:36:07 -04:00
|
|
|
t = v2d->cur.xmin;
|
2017-05-01 17:43:20 +02:00
|
|
|
immVertex2f(shdr_pos, t, (t + offset) * unitfac);
|
2017-03-08 02:30:51 -03:00
|
|
|
|
|
|
|
|
t = v2d->cur.xmax;
|
2017-05-01 17:43:20 +02:00
|
|
|
immVertex2f(shdr_pos, t, (t + offset) * unitfac);
|
2017-03-08 02:30:51 -03:00
|
|
|
|
|
|
|
|
immEnd();
|
2013-03-22 02:28:55 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-22 02:28:55 +00:00
|
|
|
/* draw driver only if actually functional */
|
|
|
|
|
if ((driver->flag & DRIVER_FLAG_INVALID) == 0) {
|
|
|
|
|
/* grab "coordinates" for driver outputs */
|
|
|
|
|
float x = driver->curval;
|
|
|
|
|
float y = fcu->curval * unitfac;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-22 02:28:55 +00:00
|
|
|
/* only draw indicators if the point is in range*/
|
2013-03-22 03:25:31 +00:00
|
|
|
if (x >= v2d->cur.xmin) {
|
2013-03-22 02:28:55 +00:00
|
|
|
float co[2];
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-22 02:28:55 +00:00
|
|
|
/* draw dotted lines leading towards this point from both axes ....... */
|
2017-03-08 02:30:51 -03:00
|
|
|
immUniformColor3f(0.9f, 0.9f, 0.9f);
|
2017-05-01 17:43:20 +02:00
|
|
|
immUniform1f("dash_width", 10.0f);
|
|
|
|
|
immUniform1f("dash_factor", 0.5f);
|
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, (y >= v2d->cur.ymin) ? 4 : 2);
|
2017-03-08 02:30:51 -03:00
|
|
|
|
|
|
|
|
/* x-axis lookup */
|
|
|
|
|
co[0] = x;
|
|
|
|
|
|
|
|
|
|
if (y >= v2d->cur.ymin) {
|
|
|
|
|
co[1] = v2d->cur.ymin - 1.0f;
|
2017-05-01 17:43:20 +02:00
|
|
|
immVertex2fv(shdr_pos, co);
|
2017-03-08 02:30:51 -03:00
|
|
|
|
2013-03-22 02:28:55 +00:00
|
|
|
co[1] = y;
|
2017-05-01 17:43:20 +02:00
|
|
|
immVertex2fv(shdr_pos, co);
|
2015-01-31 17:23:30 +11:00
|
|
|
}
|
2017-03-08 02:30:51 -03:00
|
|
|
|
|
|
|
|
/* y-axis lookup */
|
|
|
|
|
co[1] = y;
|
|
|
|
|
|
|
|
|
|
co[0] = v2d->cur.xmin - 1.0f;
|
2017-05-01 17:43:20 +02:00
|
|
|
immVertex2fv(shdr_pos, co);
|
2017-03-08 02:30:51 -03:00
|
|
|
|
|
|
|
|
co[0] = x;
|
2017-05-01 17:43:20 +02:00
|
|
|
immVertex2fv(shdr_pos, co);
|
2017-03-08 02:30:51 -03:00
|
|
|
|
|
|
|
|
immEnd();
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2017-05-01 17:43:20 +02:00
|
|
|
immUnbindProgram();
|
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
/* GPU_PRIM_POINTS do not survive dashed line geometry shader... */
|
2017-05-01 17:43:20 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
|
2013-03-22 02:28:55 +00:00
|
|
|
/* x marks the spot .................................................... */
|
|
|
|
|
/* -> outer frame */
|
2017-03-08 02:30:51 -03:00
|
|
|
immUniformColor3f(0.9f, 0.9f, 0.9f);
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_point_size(7.0);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_POINTS, 1);
|
2017-05-01 17:43:20 +02:00
|
|
|
immVertex2f(shdr_pos, x, y);
|
2017-03-08 02:30:51 -03:00
|
|
|
immEnd();
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-22 02:28:55 +00:00
|
|
|
/* inner frame */
|
2017-03-08 02:30:51 -03:00
|
|
|
immUniformColor3f(0.9f, 0.0f, 0.0f);
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_point_size(3.0);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_POINTS, 1);
|
2017-05-01 17:43:20 +02:00
|
|
|
immVertex2f(shdr_pos, x, y);
|
2017-03-08 02:30:51 -03:00
|
|
|
immEnd();
|
2013-03-22 02:28:55 +00:00
|
|
|
}
|
|
|
|
|
}
|
2017-03-08 02:30:51 -03:00
|
|
|
|
|
|
|
|
immUnbindProgram();
|
2013-03-22 02:28:55 +00:00
|
|
|
}
|
|
|
|
|
|
2009-03-15 10:39:02 +00:00
|
|
|
/* Public Curve-Drawing API ---------------- */
|
|
|
|
|
|
2018-06-04 09:31:30 +02:00
|
|
|
/* Draw the 'ghost' F-Curves (i.e. snapshots of the curve)
|
2010-01-26 03:16:14 +00:00
|
|
|
* NOTE: unit mapping has already been applied to the values, so do not try and apply again
|
|
|
|
|
*/
|
2020-03-06 16:56:42 +01:00
|
|
|
void graph_draw_ghost_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *region)
|
2009-04-08 01:07:46 +00:00
|
|
|
{
|
2017-04-04 19:36:07 -04:00
|
|
|
FCurve *fcu;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-04-08 01:07:46 +00:00
|
|
|
/* draw with thick dotted lines */
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_width(3.0f);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-04-08 01:07:46 +00:00
|
|
|
/* anti-aliased lines for less jagged appearance */
|
2017-05-01 17:43:20 +02:00
|
|
|
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_smooth(true);
|
2017-05-01 17:43:20 +02:00
|
|
|
}
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2017-03-08 02:30:51 -03:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
const uint shdr_pos = GPU_vertformat_attr_add(
|
|
|
|
|
immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2017-05-01 17:43:20 +02:00
|
|
|
|
2017-07-13 16:44:02 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
2017-05-01 17:43:20 +02:00
|
|
|
|
|
|
|
|
float viewport_size[4];
|
2018-07-02 18:27:05 +02:00
|
|
|
GPU_viewport_size_get_f(viewport_size);
|
2017-05-01 17:43:20 +02:00
|
|
|
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
|
|
|
|
|
2018-07-01 08:42:16 +02:00
|
|
|
immUniform1i("colors_len", 0); /* Simple dashes. */
|
2017-05-01 17:43:20 +02:00
|
|
|
immUniform1f("dash_width", 20.0f);
|
|
|
|
|
immUniform1f("dash_factor", 0.5f);
|
2017-03-08 02:30:51 -03:00
|
|
|
|
2021-03-09 15:09:09 -05:00
|
|
|
const bool draw_extrapolation = (sipo->flag & SIPO_NO_DRAW_EXTRAPOLATION) == 0;
|
2018-12-10 11:46:36 +11:00
|
|
|
/* the ghost curves are simply sampled F-Curves stored in sipo->runtime.ghost_curves */
|
|
|
|
|
for (fcu = sipo->runtime.ghost_curves.first; fcu; fcu = fcu->next) {
|
2018-06-04 09:31:30 +02:00
|
|
|
/* set whatever color the curve has set
|
2018-11-14 12:53:15 +11:00
|
|
|
* - this is set by the function which creates these
|
|
|
|
|
* - draw with a fixed opacity of 2
|
2009-04-08 01:07:46 +00:00
|
|
|
*/
|
2017-04-16 13:44:34 -04:00
|
|
|
immUniformColor3fvAlpha(fcu->color, 0.5f);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-04-08 01:07:46 +00:00
|
|
|
/* simply draw the stored samples */
|
2021-03-09 15:09:09 -05:00
|
|
|
draw_fcurve_curve_samples(ac, NULL, fcu, ®ion->v2d, shdr_pos, draw_extrapolation);
|
2009-04-08 01:07:46 +00:00
|
|
|
}
|
2017-03-08 02:30:51 -03:00
|
|
|
|
|
|
|
|
immUnbindProgram();
|
|
|
|
|
|
2017-05-01 17:43:20 +02:00
|
|
|
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_smooth(false);
|
2017-05-01 17:43:20 +02:00
|
|
|
}
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2009-04-08 01:07:46 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
/* This is called twice from space_graph.c -> graph_main_region_draw()
|
2009-04-08 01:07:46 +00:00
|
|
|
* Unselected then selected F-Curves are drawn so that they do not occlude each other.
|
|
|
|
|
*/
|
2020-03-06 16:56:42 +01:00
|
|
|
void graph_draw_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, short sel)
|
2009-01-09 06:25:14 +00:00
|
|
|
{
|
2017-04-04 15:39:38 -04:00
|
|
|
ListBase anim_data = {NULL, NULL};
|
2017-04-04 19:36:07 -04:00
|
|
|
bAnimListElem *ale;
|
|
|
|
|
int filter;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-04-04 19:36:07 -04:00
|
|
|
/* build list of curves to draw */
|
|
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE);
|
|
|
|
|
filter |= ((sel) ? (ANIMFILTER_SEL) : (ANIMFILTER_UNSEL));
|
2009-02-15 10:58:24 +00:00
|
|
|
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
/* for each curve:
|
2018-11-14 12:53:15 +11:00
|
|
|
* draw curve, then handle-lines, and finally vertices in this order so that
|
|
|
|
|
* the data will be layered correctly
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
*/
|
2020-10-07 08:27:58 -05:00
|
|
|
bAnimListElem *ale_active_fcurve = NULL;
|
2017-04-04 19:36:07 -04:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
2020-10-07 08:27:58 -05:00
|
|
|
const FCurve *fcu = (FCurve *)ale->key_data;
|
|
|
|
|
if (fcu->flag & FCURVE_ACTIVE) {
|
|
|
|
|
ale_active_fcurve = ale;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2020-09-17 11:30:41 -05:00
|
|
|
draw_fcurve(ac, sipo, region, ale);
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-10-07 08:27:58 -05:00
|
|
|
/* Draw the active FCurve last so that it (especially the active keyframe)
|
|
|
|
|
* shows on top of the other curves. */
|
|
|
|
|
if (ale_active_fcurve != NULL) {
|
|
|
|
|
draw_fcurve(ac, sipo, region, ale_active_fcurve);
|
|
|
|
|
}
|
|
|
|
|
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
/* free list of curves */
|
2014-05-19 00:24:45 +10:00
|
|
|
ANIM_animdata_freelist(&anim_data);
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
}
|
|
|
|
|
|
2020-09-17 13:14:47 -05:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Channel List
|
|
|
|
|
* \{ */
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
|
|
|
|
|
/* left hand part */
|
2020-03-06 16:56:42 +01:00
|
|
|
void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
{
|
2017-04-04 19:36:07 -04:00
|
|
|
ListBase anim_data = {NULL, NULL};
|
|
|
|
|
bAnimListElem *ale;
|
|
|
|
|
int filter;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
View2D *v2d = ®ion->v2d;
|
2019-05-03 13:00:18 +02:00
|
|
|
float height;
|
2017-04-04 19:36:07 -04:00
|
|
|
size_t items;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
/* build list of channels to draw */
|
2017-04-04 19:36:07 -04:00
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
|
|
|
|
|
items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
/* Update max-extent of channels here (taking into account scrollers):
|
2018-11-14 12:53:15 +11:00
|
|
|
* - this is done to allow the channel list to be scrollable, but must be done here
|
2019-05-03 13:00:18 +02:00
|
|
|
* to avoid regenerating the list again and/or also because channels list is drawn first */
|
|
|
|
|
height = ACHANNEL_TOT_HEIGHT(ac, items);
|
|
|
|
|
v2d->tot.ymin = -height;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
/* loop through channels, and set up drawing depending on their type */
|
2012-05-08 20:18:33 +00:00
|
|
|
{ /* first pass: just the standard GL-drawing for backdrop + text */
|
2015-04-04 01:38:56 +13:00
|
|
|
size_t channel_index = 0;
|
2019-05-03 13:00:18 +02:00
|
|
|
float ymax = ACHANNEL_FIRST_TOP(ac);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-03 13:00:18 +02:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac), channel_index++) {
|
|
|
|
|
float ymin = ymax - ACHANNEL_HEIGHT(ac);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-08-16 02:21:43 +00:00
|
|
|
/* check if visible */
|
2019-05-03 13:00:18 +02:00
|
|
|
if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
|
|
|
|
|
IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) {
|
2009-08-16 02:21:43 +00:00
|
|
|
/* draw all channels using standard channel-drawing API */
|
2019-05-03 13:00:18 +02:00
|
|
|
ANIM_channel_draw(ac, ale, ymin, ymax, channel_index);
|
2009-08-16 02:21:43 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-05-08 20:18:33 +00:00
|
|
|
{ /* second pass: widgets */
|
2020-03-06 16:56:42 +01:00
|
|
|
uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);
|
Animation channels can now be renamed by Ctrl-Clicking on them, as in
the Outliner
Channels which can be renamed include:
- Scenes, Objects, World, Material, Texture, etc. (i.e. "ID-blocks",
or the dark and light blue channels)
- Action Groups (green channels)
- Action expanders (i.e. "CubeAction", "WorldAction", etc.)
- Grease Pencil stuff
Channels which CANNOT be renamed, as they mostly use hardcoded values
or otherwise include:
- Drivers expander
- FCurves (they don't technically have a "name"; what is shown is just
a user-friendly representation of their rna_paths)
2011-08-03 01:22:31 +00:00
|
|
|
size_t channel_index = 0;
|
2019-05-03 13:00:18 +02:00
|
|
|
float ymax = ACHANNEL_FIRST_TOP(ac);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-08-18 11:48:34 +00:00
|
|
|
/* set blending again, as may not be set in previous step */
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-03 13:00:18 +02:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac), channel_index++) {
|
|
|
|
|
float ymin = ymax - ACHANNEL_HEIGHT(ac);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-08-16 02:21:43 +00:00
|
|
|
/* check if visible */
|
2019-05-03 13:00:18 +02:00
|
|
|
if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
|
|
|
|
|
IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) {
|
2009-08-16 02:21:43 +00:00
|
|
|
/* draw all channels using standard channel-drawing API */
|
2019-03-18 17:28:36 +01:00
|
|
|
rctf channel_rect;
|
2019-05-03 13:00:18 +02:00
|
|
|
BLI_rctf_init(&channel_rect, 0, v2d->cur.xmax - V2D_SCROLL_WIDTH, ymin, ymax);
|
2019-03-18 17:28:36 +01:00
|
|
|
ANIM_channel_draw_widgets(C, ac, ale, block, &channel_rect, channel_index);
|
2009-08-16 02:21:43 +00:00
|
|
|
}
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_end(C, block);
|
|
|
|
|
UI_block_draw(C, block);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
/* free tempolary channels */
|
2014-05-19 00:24:45 +10:00
|
|
|
ANIM_animdata_freelist(&anim_data);
|
2009-01-09 06:25:14 +00:00
|
|
|
}
|
2020-09-17 13:14:47 -05:00
|
|
|
|
|
|
|
|
/** \} */
|