OpenGL: draw keyframe markers as point sprites
Also some conversion to new imm mode (T49043). Multiple editors affected. We could push this even further & draw all keyframes in an editor with a single draw call. Something is strange with keyframe markers in blender2.8 -- they're not showing up before or after this commit. They do appear in master. This commit probably needs some follow-up work after keyframes are showing again. Better to share this code now instead of sitting on it.
This commit is contained in:
parent
a161d45cfb
commit
bbc31e8929
|
@ -52,7 +52,7 @@
|
|||
|
||||
#include "BKE_fcurve.h"
|
||||
|
||||
#include "BIF_gl.h"
|
||||
#include "GPU_immediate.h"
|
||||
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
@ -463,49 +463,15 @@ bool actkeyblock_is_valid(ActKeyBlock *ab, DLRBT_Tree *keys)
|
|||
|
||||
/* *************************** Keyframe Drawing *************************** */
|
||||
|
||||
/* coordinates for diamond shape */
|
||||
static const float _unit_diamond_shape[4][2] = {
|
||||
{0.0f, 1.0f}, /* top vert */
|
||||
{1.0f, 0.0f}, /* mid-right */
|
||||
{0.0f, -1.0f}, /* bottom vert */
|
||||
{-1.0f, 0.0f} /* mid-left */
|
||||
};
|
||||
|
||||
/* draw a simple diamond shape with OpenGL */
|
||||
void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, short key_type, short mode, float alpha)
|
||||
void draw_keyframe_shape(float x, float y, float size, bool sel, short key_type, short mode, float alpha,
|
||||
unsigned int pos_id, unsigned int size_id, unsigned int color_id, unsigned int outline_color_id)
|
||||
{
|
||||
static GLuint displist1 = 0;
|
||||
static GLuint displist2 = 0;
|
||||
|
||||
/* initialize 2 display lists for diamond shape - one empty, one filled */
|
||||
if (displist1 == 0) {
|
||||
displist1 = glGenLists(1);
|
||||
glNewList(displist1, GL_COMPILE);
|
||||
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2fv(_unit_diamond_shape[0]);
|
||||
glVertex2fv(_unit_diamond_shape[1]);
|
||||
glVertex2fv(_unit_diamond_shape[2]);
|
||||
glVertex2fv(_unit_diamond_shape[3]);
|
||||
glEnd();
|
||||
bool draw_fill = ELEM(mode, KEYFRAME_SHAPE_INSIDE, KEYFRAME_SHAPE_BOTH);
|
||||
bool draw_outline = ELEM(mode, KEYFRAME_SHAPE_FRAME, KEYFRAME_SHAPE_BOTH);
|
||||
|
||||
glEndList();
|
||||
}
|
||||
if (displist2 == 0) {
|
||||
displist2 = glGenLists(1);
|
||||
glNewList(displist2, GL_COMPILE);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2fv(_unit_diamond_shape[0]);
|
||||
glVertex2fv(_unit_diamond_shape[1]);
|
||||
glVertex2fv(_unit_diamond_shape[2]);
|
||||
glVertex2fv(_unit_diamond_shape[3]);
|
||||
glEnd();
|
||||
if (!(draw_fill || draw_outline)) return; /* TODO: assert this? */
|
||||
|
||||
glEndList();
|
||||
}
|
||||
|
||||
/* tweak size of keyframe shape according to type of keyframe
|
||||
/* tweak size of keyframe shape according to type of keyframe
|
||||
* - 'proper' keyframes have key_type = 0, so get drawn at full size
|
||||
*/
|
||||
switch (key_type) {
|
||||
|
@ -513,120 +479,93 @@ void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel,
|
|||
break;
|
||||
|
||||
case BEZT_KEYTYPE_BREAKDOWN: /* slightly smaller than normal keyframe */
|
||||
hsize *= 0.85f;
|
||||
size *= 0.85f;
|
||||
break;
|
||||
|
||||
case BEZT_KEYTYPE_MOVEHOLD: /* slightly smaller than normal keyframes (but by less than for breakdowns) */
|
||||
//hsize *= 0.72f;
|
||||
hsize *= 0.95f;
|
||||
//size *= 0.72f;
|
||||
size *= 0.95f;
|
||||
break;
|
||||
|
||||
case BEZT_KEYTYPE_EXTREME: /* slightly larger */
|
||||
hsize *= 1.2f;
|
||||
size *= 1.2f;
|
||||
break;
|
||||
|
||||
default:
|
||||
hsize -= 0.5f * key_type;
|
||||
break;
|
||||
size -= 0.5f * key_type;
|
||||
}
|
||||
|
||||
/* adjust view transform before starting */
|
||||
glTranslatef(x, y, 0.0f);
|
||||
glScalef(1.0f / xscale * hsize, hsize, 1.0f);
|
||||
|
||||
/* anti-aliased lines for more consistent appearance */
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
|
||||
unsigned char fill_col[4];
|
||||
unsigned char outline_col[4];
|
||||
|
||||
/* draw! */
|
||||
if (ELEM(mode, KEYFRAME_SHAPE_INSIDE, KEYFRAME_SHAPE_BOTH)) {
|
||||
float inner_col[4];
|
||||
|
||||
if (draw_fill) {
|
||||
/* get interior colors from theme (for selected and unselected only) */
|
||||
switch (key_type) {
|
||||
case BEZT_KEYTYPE_BREAKDOWN: /* bluish frames (default theme) */
|
||||
{
|
||||
if (sel) UI_GetThemeColor4fv(TH_KEYTYPE_BREAKDOWN_SELECT, inner_col);
|
||||
else UI_GetThemeColor4fv(TH_KEYTYPE_BREAKDOWN, inner_col);
|
||||
UI_GetThemeColor4ubv(sel ? TH_KEYTYPE_BREAKDOWN_SELECT : TH_KEYTYPE_BREAKDOWN, fill_col);
|
||||
break;
|
||||
}
|
||||
case BEZT_KEYTYPE_EXTREME: /* reddish frames (default theme) */
|
||||
{
|
||||
if (sel) UI_GetThemeColor4fv(TH_KEYTYPE_EXTREME_SELECT, inner_col);
|
||||
else UI_GetThemeColor4fv(TH_KEYTYPE_EXTREME, inner_col);
|
||||
UI_GetThemeColor4ubv(sel ? TH_KEYTYPE_EXTREME_SELECT : TH_KEYTYPE_EXTREME, fill_col);
|
||||
break;
|
||||
}
|
||||
case BEZT_KEYTYPE_JITTER: /* greenish frames (default theme) */
|
||||
{
|
||||
if (sel) UI_GetThemeColor4fv(TH_KEYTYPE_JITTER_SELECT, inner_col);
|
||||
else UI_GetThemeColor4fv(TH_KEYTYPE_JITTER, inner_col);
|
||||
UI_GetThemeColor4ubv(sel ? TH_KEYTYPE_JITTER_SELECT : TH_KEYTYPE_JITTER, fill_col);
|
||||
break;
|
||||
}
|
||||
case BEZT_KEYTYPE_MOVEHOLD: /* similar to traditional keyframes, but different... */
|
||||
{
|
||||
/* XXX: Should these get their own theme options instead? */
|
||||
if (sel) UI_GetThemeColorShade4fv(TH_STRIP_SELECT, 35, inner_col);
|
||||
else UI_GetThemeColorShade4fv(TH_STRIP, 50, inner_col);
|
||||
|
||||
inner_col[3] = 1.0f; /* full opacity, to avoid problems with visual glitches */
|
||||
if (sel) UI_GetThemeColorShade3ubv(TH_STRIP_SELECT, 35, fill_col);
|
||||
else UI_GetThemeColorShade3ubv(TH_STRIP, 50, fill_col);
|
||||
fill_col[3] = 255; /* full opacity, to avoid problems with visual glitches */
|
||||
break;
|
||||
}
|
||||
case BEZT_KEYTYPE_KEYFRAME: /* traditional yellowish frames (default theme) */
|
||||
default:
|
||||
{
|
||||
if (sel) UI_GetThemeColor4fv(TH_KEYTYPE_KEYFRAME_SELECT, inner_col);
|
||||
else UI_GetThemeColor4fv(TH_KEYTYPE_KEYFRAME, inner_col);
|
||||
break;
|
||||
}
|
||||
UI_GetThemeColor4ubv(sel ? TH_KEYTYPE_KEYFRAME_SELECT : TH_KEYTYPE_KEYFRAME, fill_col);
|
||||
}
|
||||
|
||||
/* NOTE: we don't use the straight alpha from the theme, or else effects such as
|
||||
* graying out protected/muted channels doesn't work correctly!
|
||||
*/
|
||||
inner_col[3] *= alpha;
|
||||
glColor4fv(inner_col);
|
||||
|
||||
/* draw the "filled in" interior poly now */
|
||||
glCallList(displist2);
|
||||
fill_col[3] *= alpha;
|
||||
|
||||
if (!draw_outline) {
|
||||
/* force outline color to match */
|
||||
outline_col[0] = fill_col[0];
|
||||
outline_col[1] = fill_col[1];
|
||||
outline_col[2] = fill_col[2];
|
||||
outline_col[3] = fill_col[3];
|
||||
}
|
||||
}
|
||||
|
||||
if (ELEM(mode, KEYFRAME_SHAPE_FRAME, KEYFRAME_SHAPE_BOTH)) {
|
||||
float border_col[4];
|
||||
|
||||
|
||||
if (draw_outline) {
|
||||
/* exterior - black frame */
|
||||
if (sel) UI_GetThemeColor4fv(TH_KEYBORDER_SELECT, border_col);
|
||||
else UI_GetThemeColor4fv(TH_KEYBORDER, border_col);
|
||||
|
||||
border_col[3] *= alpha;
|
||||
glColor4fv(border_col);
|
||||
|
||||
glCallList(displist1);
|
||||
UI_GetThemeColor4ubv(sel ? TH_KEYBORDER_SELECT : TH_KEYBORDER, outline_col);
|
||||
outline_col[3] *= alpha;
|
||||
|
||||
if (!draw_fill) {
|
||||
/* fill color needs to be (outline.rgb, 0) */
|
||||
fill_col[0] = outline_col[0];
|
||||
fill_col[1] = outline_col[1];
|
||||
fill_col[2] = outline_col[2];
|
||||
fill_col[3] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
|
||||
/* restore view transform */
|
||||
glScalef(xscale / hsize, 1.0f / hsize, 1.0f);
|
||||
glTranslatef(-x, -y, 0.0f);
|
||||
|
||||
immAttrib1f(size_id, size);
|
||||
immAttrib4ubv(color_id, fill_col);
|
||||
immAttrib4ubv(outline_color_id, outline_col);
|
||||
immVertex2f(pos_id, x, y);
|
||||
}
|
||||
|
||||
static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, float ypos, float yscale_fac, bool channelLocked)
|
||||
{
|
||||
ActKeyColumn *ak;
|
||||
ActKeyBlock *ab;
|
||||
float alpha;
|
||||
float xscale;
|
||||
|
||||
const float iconsize = (U.widget_unit / 4.0f) * yscale_fac;
|
||||
const float mhsize = iconsize * 0.7f;
|
||||
const float iconsize = U.widget_unit * 0.25f * yscale_fac;
|
||||
const float mhsize = iconsize * 0.7f;
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
/* get View2D scaling factor */
|
||||
UI_view2d_scale_get(v2d, &xscale, NULL);
|
||||
|
||||
/* locked channels are less strongly shown, as feedback for locked channels in DopeSheet */
|
||||
/* TODO: allow this opacity factor to be themed? */
|
||||
alpha = (channelLocked) ? 0.25f : 1.0f;
|
||||
float alpha = channelLocked ? 0.25f : 1.0f;
|
||||
|
||||
/* draw keyblocks */
|
||||
if (blocks) {
|
||||
|
@ -644,45 +583,57 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
|
|||
sel_mhcol[3] *= 0.8f;
|
||||
copy_v4_v4(unsel_mhcol, unsel_color);
|
||||
unsel_mhcol[3] *= 0.8f;
|
||||
|
||||
|
||||
unsigned int pos_id = add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
/* NOTE: the tradeoff for changing colors between each draw is dwarfed by the cost of checking validity */
|
||||
for (ab = blocks->first; ab; ab = ab->next) {
|
||||
for (ActKeyBlock *ab = blocks->first; ab; ab = ab->next) {
|
||||
if (actkeyblock_is_valid(ab, keys)) {
|
||||
if (ab->flag & ACTKEYBLOCK_FLAG_MOVING_HOLD) {
|
||||
/* draw "moving hold" long-keyframe block - slightly smaller */
|
||||
if (ab->sel)
|
||||
glColor4fv(sel_mhcol);
|
||||
else
|
||||
glColor4fv(unsel_mhcol);
|
||||
|
||||
glRectf(ab->start, ypos - mhsize, ab->end, ypos + mhsize);
|
||||
immUniformColor4fv(ab->sel ? sel_mhcol : unsel_mhcol);
|
||||
immRectf(pos_id, ab->start, ypos - mhsize, ab->end, ypos + mhsize);
|
||||
}
|
||||
else {
|
||||
/* draw standard long-keyframe block */
|
||||
if (ab->sel)
|
||||
glColor4fv(sel_color);
|
||||
else
|
||||
glColor4fv(unsel_color);
|
||||
|
||||
glRectf(ab->start, ypos - iconsize, ab->end, ypos + iconsize);
|
||||
immUniformColor4fv(ab->sel ? sel_color : unsel_color);
|
||||
immRectf(pos_id, ab->start, ypos - iconsize, ab->end, ypos + iconsize);
|
||||
}
|
||||
}
|
||||
}
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
/* draw keys */
|
||||
if (keys) {
|
||||
for (ak = keys->first; ak; ak = ak->next) {
|
||||
/* count keys */
|
||||
unsigned int key_ct = 0;
|
||||
for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) {
|
||||
/* optimization: if keyframe doesn't appear within 5 units (screenspace) in visible area, don't draw
|
||||
* - this might give some improvements, since we current have to flip between view/region matrices
|
||||
*/
|
||||
if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax) == 0)
|
||||
continue;
|
||||
|
||||
/* draw using OpenGL - uglier but faster */
|
||||
/* NOTE1: a previous version of this didn't work nice for some intel cards
|
||||
* NOTE2: if we wanted to go back to icons, these are icon = (ak->sel & SELECT) ? ICON_SPACE2 : ICON_SPACE3; */
|
||||
draw_keyframe_shape(ak->cfra, ypos, xscale, iconsize, (ak->sel & SELECT), ak->key_type, KEYFRAME_SHAPE_BOTH, alpha);
|
||||
if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax))
|
||||
key_ct++;
|
||||
}
|
||||
|
||||
if (key_ct > 0) {
|
||||
/* draw keys */
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos_id = add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int size_id = add_attrib(format, "size", COMP_F32, 1, KEEP_FLOAT);
|
||||
unsigned int color_id = add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
unsigned int outline_color_id = add_attrib(format, "outlineColor", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
|
||||
immBegin(PRIM_POINTS, key_ct);
|
||||
|
||||
for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) {
|
||||
if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax)) {
|
||||
draw_keyframe_shape(ak->cfra, ypos, iconsize, (ak->sel & SELECT), ak->key_type, KEYFRAME_SHAPE_BOTH, alpha,
|
||||
pos_id, size_id, color_id, outline_color_id);
|
||||
}
|
||||
}
|
||||
|
||||
immEnd();
|
||||
immUnbindProgram();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,8 +108,10 @@ typedef enum eKeyframeShapeDrawOpts {
|
|||
KEYFRAME_SHAPE_BOTH
|
||||
} eKeyframeShapeDrawOpts;
|
||||
|
||||
/* draw simple diamond-shape keyframe (with OpenGL) */
|
||||
void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, short key_type, short mode, float alpha);
|
||||
/* draw simple diamond-shape keyframe */
|
||||
/* caller should set up vertex format, bind GPU_SHADER_KEYFRAME_DIAMOND, immBegin(PRIM_POINTS, n), then call this n times */
|
||||
void draw_keyframe_shape(float x, float y, float size, bool sel, short key_type, short mode, float alpha,
|
||||
unsigned int pos_id, unsigned int size_id, unsigned int color_id, unsigned int outline_color_id);
|
||||
|
||||
/* ******************************* Methods ****************************** */
|
||||
|
||||
|
|
|
@ -225,13 +225,17 @@ static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float
|
|||
viconutil_set_point(pts[1], cx - d2, cy - d);
|
||||
viconutil_set_point(pts[2], cx + d2, cy);
|
||||
|
||||
glColor4f(0.2f, 0.2f, 0.2f, alpha);
|
||||
unsigned int pos = add_attrib(immVertexFormat(), "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4f(0.2f, 0.2f, 0.2f, alpha);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex2iv(pts[0]);
|
||||
glVertex2iv(pts[1]);
|
||||
glVertex2iv(pts[2]);
|
||||
glEnd();
|
||||
immBegin(PRIM_TRIANGLES, 3);
|
||||
immVertex2iv(pos, pts[0]);
|
||||
immVertex2iv(pos, pts[1]);
|
||||
immVertex2iv(pos, pts[2]);
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha, short key_type)
|
||||
|
@ -240,7 +244,6 @@ static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha,
|
|||
* (since we're doing this offscreen, free from any particular space_id)
|
||||
*/
|
||||
struct bThemeState theme_state;
|
||||
int xco, yco;
|
||||
|
||||
UI_Theme_Store(&theme_state);
|
||||
UI_SetTheme(SPACE_ACTION, RGN_TYPE_WINDOW);
|
||||
|
@ -249,16 +252,28 @@ static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha,
|
|||
* while the draw_keyframe_shape() function needs the midpoint for
|
||||
* the keyframe
|
||||
*/
|
||||
xco = x + w / 2;
|
||||
yco = y + h / 2;
|
||||
int xco = x + w / 2;
|
||||
int yco = y + h / 2;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos_id = add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int size_id = add_attrib(format, "size", COMP_F32, 1, KEEP_FLOAT);
|
||||
unsigned int color_id = add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
unsigned int outline_color_id = add_attrib(format, "outlineColor", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
|
||||
immBegin(PRIM_POINTS, 1);
|
||||
|
||||
/* draw keyframe
|
||||
* - xscale: 1.0 (since there's no timeline scaling to compensate for)
|
||||
* - yscale: 0.3 * h (found out experimentally... dunno why!)
|
||||
* - size: 0.3 * h (found out experimentally... dunno why!)
|
||||
* - sel: true (so that "keyframe" state shows the iconic yellow icon)
|
||||
*/
|
||||
draw_keyframe_shape(xco, yco, 1.0f, 0.3f * h, true, key_type, KEYFRAME_SHAPE_BOTH, alpha);
|
||||
|
||||
draw_keyframe_shape(xco, yco, 0.3f * h, true, key_type, KEYFRAME_SHAPE_BOTH, alpha,
|
||||
pos_id, size_id, color_id, outline_color_id);
|
||||
|
||||
immEnd();
|
||||
immUnbindProgram();
|
||||
|
||||
UI_Theme_Restore(&theme_state);
|
||||
}
|
||||
|
||||
|
@ -291,7 +306,7 @@ static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNU
|
|||
{
|
||||
bTheme *btheme = UI_GetTheme();
|
||||
ThemeWireColor *cs = &btheme->tarm[index];
|
||||
|
||||
|
||||
/* Draw three bands of color: One per color
|
||||
* x-----a-----b-----c
|
||||
* | N | S | A |
|
||||
|
@ -300,19 +315,24 @@ static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNU
|
|||
const int a = x + w / 3;
|
||||
const int b = x + w / 3 * 2;
|
||||
const int c = x + w;
|
||||
|
||||
|
||||
unsigned int pos = add_attrib(immVertexFormat(), "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
/* XXX: Include alpha into this... */
|
||||
/* normal */
|
||||
glColor3ubv((unsigned char *)cs->solid);
|
||||
glRecti(x, y, a, y + h);
|
||||
|
||||
immUniformColor3ubv((unsigned char *)cs->solid);
|
||||
immRecti(pos, x, y, a, y + h);
|
||||
|
||||
/* selected */
|
||||
glColor3ubv((unsigned char *)cs->select);
|
||||
glRecti(a, y, b, y + h);
|
||||
|
||||
immUniformColor3ubv((unsigned char *)cs->select);
|
||||
immRecti(pos, a, y, b, y + h);
|
||||
|
||||
/* active */
|
||||
glColor3ubv((unsigned char *)cs->active);
|
||||
glRecti(b, y, c, y + h);
|
||||
immUniformColor3ubv((unsigned char *)cs->active);
|
||||
immRecti(pos, b, y, c, y + h);
|
||||
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
#define DEF_VICON_COLORSET_DRAW_NTH(prefix, index) \
|
||||
|
@ -1034,8 +1054,8 @@ static void icon_draw_texture(
|
|||
unsigned texCoord = add_attrib(format, "texCoord", GL_FLOAT, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
if (rgb) immUniform4f("color", rgb[0], rgb[1], rgb[2], alpha);
|
||||
else immUniform4f("color", alpha, alpha, alpha, alpha);
|
||||
if (rgb) immUniformColor3fvAlpha(rgb, alpha);
|
||||
else immUniformColor4f(alpha, alpha, alpha, alpha);
|
||||
|
||||
immUniform1i("image", 0);
|
||||
|
||||
|
|
|
@ -157,15 +157,12 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
|
|||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
View2D *v2d = &ar->v2d;
|
||||
bDopeSheet *ads = &saction->ads;
|
||||
AnimData *adt = NULL;
|
||||
|
||||
float act_start, act_end, y;
|
||||
size_t items;
|
||||
int height;
|
||||
|
||||
unsigned char col1[3], col2[3];
|
||||
unsigned char col1a[3], col2a[3];
|
||||
|
@ -195,10 +192,10 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
|
|||
}
|
||||
|
||||
/* build list of channels to draw */
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
|
||||
items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
|
||||
size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
height = ((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac)));
|
||||
int height = ((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac)));
|
||||
/* don't use totrect set, as the width stays the same
|
||||
* (NOTE: this is ok here, the configuration is pretty straightforward)
|
||||
*/
|
||||
|
@ -332,18 +329,29 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
|
|||
y -= ACHANNEL_STEP(ac);
|
||||
}
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
/* Draw keyframes
|
||||
|
||||
/* black line marking 'current frame' for Time-Slide transform mode */
|
||||
if (saction->flag & SACTION_MOVING) {
|
||||
immUniformColor3f(0.0f, 0.0f, 0.0f);
|
||||
|
||||
immBegin(GL_LINES, 2);
|
||||
immVertex2f(pos, saction->timeslide, v2d->cur.ymin - EXTRA_SCROLL_PAD);
|
||||
immVertex2f(pos, saction->timeslide, v2d->cur.ymax);
|
||||
immEnd();
|
||||
}
|
||||
immUnbindProgram();
|
||||
|
||||
/* Draw keyframes
|
||||
* 1) Only channels that are visible in the Action Editor get drawn/evaluated.
|
||||
* This is to try to optimize this for heavier data sets
|
||||
* 2) Keyframes which are out of view horizontally are disregarded
|
||||
*/
|
||||
y = (float)(-ACHANNEL_HEIGHT(ac));
|
||||
|
||||
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
|
||||
const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
|
||||
|
||||
|
||||
/* check if visible */
|
||||
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
|
||||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
|
||||
|
@ -351,7 +359,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
|
|||
/* check if anything to show for this channel */
|
||||
if (ale->datatype != ALE_NONE) {
|
||||
adt = ANIM_nla_mapping_get(ac, ale);
|
||||
|
||||
|
||||
/* draw 'keyframes' for each specific datatype */
|
||||
switch (ale->datatype) {
|
||||
case ALE_ALL:
|
||||
|
@ -381,21 +389,10 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
y -= ACHANNEL_STEP(ac);
|
||||
}
|
||||
|
||||
/* free tempolary channels used for drawing */
|
||||
|
||||
/* free temporary channels used for drawing */
|
||||
ANIM_animdata_freelist(&anim_data);
|
||||
|
||||
/* black line marking 'current frame' for Time-Slide transform mode */
|
||||
if (saction->flag & SACTION_MOVING) {
|
||||
immUniformColor3f(0.0f, 0.0f, 0.0f);
|
||||
|
||||
immBegin(GL_LINES, 2);
|
||||
immVertex2f(pos, saction->timeslide, v2d->cur.ymin - EXTRA_SCROLL_PAD);
|
||||
immVertex2f(pos, saction->timeslide, v2d->cur.ymax);
|
||||
immEnd();
|
||||
}
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
|
|
@ -74,71 +74,25 @@ static void track_channel_color(MovieTrackingTrack *track, float default_color[3
|
|||
}
|
||||
}
|
||||
|
||||
static void draw_keyframe_shape(float x, float y, float xscale, float yscale, bool sel, float alpha)
|
||||
static void draw_keyframe_shape(float x, float y, bool sel, float alpha,
|
||||
unsigned int pos_id, unsigned int color_id)
|
||||
{
|
||||
/* coordinates for diamond shape */
|
||||
static const float _unit_diamond_shape[4][2] = {
|
||||
{0.0f, 1.0f}, /* top vert */
|
||||
{1.0f, 0.0f}, /* mid-right */
|
||||
{0.0f, -1.0f}, /* bottom vert */
|
||||
{-1.0f, 0.0f} /* mid-left */
|
||||
};
|
||||
float color[4] = { 0.91f, 0.91f, 0.91f, alpha };
|
||||
if (sel) {
|
||||
UI_GetThemeColorShadeAlpha4fv(TH_STRIP_SELECT, 50, -255 * (1.0f - alpha), color);
|
||||
}
|
||||
|
||||
int hsize = STRIP_HEIGHT_HALF;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
/* adjust view transform before starting */
|
||||
glTranslatef(x, y, 0.0f);
|
||||
glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f);
|
||||
|
||||
/* anti-aliased lines for more consistent appearance */
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
/* interior */
|
||||
if (sel)
|
||||
immUniformThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255 * (1.0f - alpha));
|
||||
else
|
||||
immUniformColor4f(0.91f, 0.91f, 0.91f, alpha);
|
||||
|
||||
immBegin(GL_QUADS, 4);
|
||||
immVertex2fv(pos, _unit_diamond_shape[0]);
|
||||
immVertex2fv(pos, _unit_diamond_shape[1]);
|
||||
immVertex2fv(pos, _unit_diamond_shape[2]);
|
||||
immVertex2fv(pos, _unit_diamond_shape[3]);
|
||||
immEnd();
|
||||
|
||||
/* exterior - black frame */
|
||||
immUniformColor4f(0.0f, 0.0f, 0.0f, alpha);
|
||||
immBegin(GL_LINE_LOOP, 4);
|
||||
immVertex2fv(pos, _unit_diamond_shape[0]);
|
||||
immVertex2fv(pos, _unit_diamond_shape[1]);
|
||||
immVertex2fv(pos, _unit_diamond_shape[2]);
|
||||
immVertex2fv(pos, _unit_diamond_shape[3]);
|
||||
immEnd();
|
||||
immUnbindProgram();
|
||||
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
|
||||
/* restore view transform */
|
||||
glPopMatrix();
|
||||
immAttrib4fv(color_id, color);
|
||||
immVertex2f(pos_id, x, y);
|
||||
}
|
||||
|
||||
static void clip_draw_dopesheet_background(ARegion *ar, MovieClip *clip)
|
||||
static void clip_draw_dopesheet_background(ARegion *ar, MovieClip *clip, unsigned int pos_id)
|
||||
{
|
||||
View2D *v2d = &ar->v2d;
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
|
||||
MovieTrackingDopesheetCoverageSegment *coverage_segment;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
for (coverage_segment = dopesheet->coverage_segments.first;
|
||||
coverage_segment;
|
||||
coverage_segment = coverage_segment->next)
|
||||
|
@ -150,13 +104,13 @@ static void clip_draw_dopesheet_background(ARegion *ar, MovieClip *clip)
|
|||
if (coverage_segment->coverage == TRACKING_COVERAGE_BAD) {
|
||||
immUniformColor4f(1.0f, 0.0f, 0.0f, 0.07f);
|
||||
}
|
||||
else
|
||||
else {
|
||||
immUniformColor4f(1.0f, 1.0f, 0.0f, 0.07f);
|
||||
}
|
||||
|
||||
immRectf(pos, start_frame, v2d->cur.ymin, end_frame, v2d->cur.ymax);
|
||||
immRectf(pos_id, start_frame, v2d->cur.ymin, end_frame, v2d->cur.ymax);
|
||||
}
|
||||
}
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
|
||||
|
@ -171,21 +125,21 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
|
|||
MovieTracking *tracking = &clip->tracking;
|
||||
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
|
||||
MovieTrackingDopesheetChannel *channel;
|
||||
float y, xscale, yscale;
|
||||
float strip[4], selected_strip[4];
|
||||
float height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT);
|
||||
|
||||
|
||||
unsigned int keyframe_ct = 0;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
|
||||
unsigned int pos_id = add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
/* don't use totrect set, as the width stays the same
|
||||
* (NOTE: this is ok here, the configuration is pretty straightforward)
|
||||
*/
|
||||
v2d->tot.ymin = (float)(-height);
|
||||
|
||||
y = (float) CHANNEL_FIRST;
|
||||
|
||||
UI_view2d_scale_get(v2d, &xscale, &yscale);
|
||||
float y = (float) CHANNEL_FIRST;
|
||||
|
||||
/* setup colors for regular and selected strips */
|
||||
UI_GetThemeColor3fv(TH_STRIP, strip);
|
||||
|
@ -196,7 +150,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
|
|||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
clip_draw_dopesheet_background(ar, clip);
|
||||
clip_draw_dopesheet_background(ar, clip, pos_id);
|
||||
|
||||
for (channel = dopesheet->channels.first; channel; channel = channel->next) {
|
||||
float yminc = (float) (y - CHANNEL_HEIGHT_HALF);
|
||||
|
@ -207,7 +161,6 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
|
|||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax))
|
||||
{
|
||||
MovieTrackingTrack *track = channel->track;
|
||||
float alpha;
|
||||
int i;
|
||||
bool sel = (track->flag & TRACK_DOPE_SEL) != 0;
|
||||
|
||||
|
@ -217,37 +170,26 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
|
|||
float default_color[4] = {0.8f, 0.93f, 0.8f, 0.3f};
|
||||
|
||||
track_channel_color(track, default_color, color);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4fv(color);
|
||||
|
||||
immRectf(pos, v2d->cur.xmin, (float) y - CHANNEL_HEIGHT_HALF,
|
||||
v2d->cur.xmax + EXTRA_SCROLL_PAD, (float) y + CHANNEL_HEIGHT_HALF);
|
||||
immUnbindProgram();
|
||||
immRectf(pos_id, v2d->cur.xmin, (float) y - CHANNEL_HEIGHT_HALF,
|
||||
v2d->cur.xmax + EXTRA_SCROLL_PAD, (float) y + CHANNEL_HEIGHT_HALF);
|
||||
}
|
||||
|
||||
alpha = (track->flag & TRACK_LOCKED) ? 0.5f : 1.0f;
|
||||
|
||||
/* tracked segments */
|
||||
for (i = 0; i < channel->tot_segment; i++) {
|
||||
int start_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, channel->segments[2 * i]);
|
||||
int end_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, channel->segments[2 * i + 1]);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
if (sel)
|
||||
immUniformColor4fv(selected_strip);
|
||||
else
|
||||
immUniformColor4fv(strip);
|
||||
immUniformColor4fv(sel ? selected_strip : strip);
|
||||
|
||||
if (start_frame != end_frame) {
|
||||
immRectf(pos, start_frame, (float) y - STRIP_HEIGHT_HALF,
|
||||
end_frame, (float) y + STRIP_HEIGHT_HALF);
|
||||
immUnbindProgram();
|
||||
draw_keyframe_shape(start_frame, y, xscale, yscale, sel, alpha);
|
||||
draw_keyframe_shape(end_frame, y, xscale, yscale, sel, alpha);
|
||||
immRectf(pos_id, start_frame, (float) y - STRIP_HEIGHT_HALF,
|
||||
end_frame, (float) y + STRIP_HEIGHT_HALF);
|
||||
keyframe_ct += 2;
|
||||
}
|
||||
else {
|
||||
immUnbindProgram();
|
||||
draw_keyframe_shape(start_frame, y, xscale, yscale, sel, alpha);
|
||||
keyframe_ct++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,9 +199,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
|
|||
MovieTrackingMarker *marker = &track->markers[i];
|
||||
|
||||
if ((marker->flag & (MARKER_DISABLED | MARKER_TRACKED)) == 0) {
|
||||
int framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, marker->framenr);
|
||||
|
||||
draw_keyframe_shape(framenr, y, xscale, yscale, sel, alpha);
|
||||
keyframe_ct++;
|
||||
}
|
||||
|
||||
i++;
|
||||
|
@ -270,6 +210,75 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
|
|||
y -= CHANNEL_STEP;
|
||||
}
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
if (keyframe_ct > 0) {
|
||||
/* draw keyframe markers */
|
||||
format = immVertexFormat();
|
||||
pos_id = add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int size_id = add_attrib(format, "size", COMP_F32, 1, KEEP_FLOAT);
|
||||
unsigned int color_id = add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
unsigned int outline_color_id = add_attrib(format, "outlineColor", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
|
||||
|
||||
immBegin(PRIM_POINTS, keyframe_ct);
|
||||
|
||||
/* all same size with black outline */
|
||||
immAttrib1f(size_id, 2.0f * STRIP_HEIGHT_HALF);
|
||||
immAttrib3ub(outline_color_id, 0, 0, 0);
|
||||
|
||||
y = (float) CHANNEL_FIRST; /* start again at the top */
|
||||
for (channel = dopesheet->channels.first; channel; channel = channel->next) {
|
||||
float yminc = (float) (y - CHANNEL_HEIGHT_HALF);
|
||||
float ymaxc = (float) (y + CHANNEL_HEIGHT_HALF);
|
||||
|
||||
/* check if visible */
|
||||
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
|
||||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax))
|
||||
{
|
||||
MovieTrackingTrack *track = channel->track;
|
||||
int i;
|
||||
bool sel = (track->flag & TRACK_DOPE_SEL) != 0;
|
||||
float alpha = (track->flag & TRACK_LOCKED) ? 0.5f : 1.0f;
|
||||
|
||||
/* tracked segments */
|
||||
for (i = 0; i < channel->tot_segment; i++) {
|
||||
int start_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, channel->segments[2 * i]);
|
||||
int end_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, channel->segments[2 * i + 1]);
|
||||
|
||||
if (start_frame != end_frame) {
|
||||
draw_keyframe_shape(start_frame, y, sel, alpha, pos_id, color_id);
|
||||
draw_keyframe_shape(end_frame, y, sel, alpha, pos_id, color_id);
|
||||
}
|
||||
else {
|
||||
draw_keyframe_shape(start_frame, y, sel, alpha, pos_id, color_id);
|
||||
}
|
||||
}
|
||||
|
||||
/* keyframes */
|
||||
i = 0;
|
||||
while (i < track->markersnr) {
|
||||
MovieTrackingMarker *marker = &track->markers[i];
|
||||
|
||||
if ((marker->flag & (MARKER_DISABLED | MARKER_TRACKED)) == 0) {
|
||||
int framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, marker->framenr);
|
||||
|
||||
draw_keyframe_shape(framenr, y, sel, alpha, pos_id, color_id);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
/* adjust y-position for next one */
|
||||
y -= CHANNEL_STEP;
|
||||
}
|
||||
|
||||
immEnd();
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
|
@ -283,25 +292,15 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar)
|
|||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
View2D *v2d = &ar->v2d;
|
||||
MovieClip *clip = ED_space_clip_get_clip(sc);
|
||||
MovieTracking *tracking;
|
||||
MovieTrackingDopesheet *dopesheet;
|
||||
MovieTrackingDopesheetChannel *channel;
|
||||
uiStyle *style = UI_style_get();
|
||||
uiBlock *block;
|
||||
int fontid = style->widget.uifont_id;
|
||||
int height;
|
||||
float y;
|
||||
PropertyRNA *chan_prop_lock;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
|
||||
|
||||
if (!clip)
|
||||
return;
|
||||
|
||||
tracking = &clip->tracking;
|
||||
dopesheet = &tracking->dopesheet;
|
||||
height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
|
||||
int height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT);
|
||||
|
||||
if (height > BLI_rcti_size_y(&v2d->mask)) {
|
||||
/* don't use totrect set, as the width stays the same
|
||||
|
@ -316,6 +315,37 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar)
|
|||
/* loop through channels, and set up drawing depending on their type
|
||||
* first pass: just the standard GL-drawing for backdrop + text
|
||||
*/
|
||||
float y = (float) CHANNEL_FIRST;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
MovieTrackingDopesheetChannel *channel;
|
||||
for (channel = dopesheet->channels.first; channel; channel = channel->next) {
|
||||
float yminc = (float) (y - CHANNEL_HEIGHT_HALF);
|
||||
float ymaxc = (float) (y + CHANNEL_HEIGHT_HALF);
|
||||
|
||||
/* check if visible */
|
||||
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
|
||||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax))
|
||||
{
|
||||
MovieTrackingTrack *track = channel->track;
|
||||
float color[3];
|
||||
track_channel_color(track, NULL, color);
|
||||
immUniformColor3fv(color);
|
||||
|
||||
immRectf(pos, v2d->cur.xmin, (float) y - CHANNEL_HEIGHT_HALF,
|
||||
v2d->cur.xmax + EXTRA_SCROLL_PAD, (float) y + CHANNEL_HEIGHT_HALF);
|
||||
}
|
||||
|
||||
/* adjust y-position for next one */
|
||||
y -= CHANNEL_STEP;
|
||||
}
|
||||
immUnbindProgram();
|
||||
|
||||
/* second pass: text */
|
||||
y = (float) CHANNEL_FIRST;
|
||||
|
||||
BLF_size(fontid, 11.0f * U.pixelsize, U.dpi);
|
||||
|
@ -329,20 +359,11 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar)
|
|||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax))
|
||||
{
|
||||
MovieTrackingTrack *track = channel->track;
|
||||
float font_height, color[3];
|
||||
bool sel = (track->flag & TRACK_DOPE_SEL) != 0;
|
||||
|
||||
track_channel_color(track, NULL, color);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor3fv(color);
|
||||
|
||||
immRectf(pos, v2d->cur.xmin, (float) y - CHANNEL_HEIGHT_HALF,
|
||||
v2d->cur.xmax + EXTRA_SCROLL_PAD, (float) y + CHANNEL_HEIGHT_HALF);
|
||||
immUnbindProgram();
|
||||
|
||||
UI_FontThemeColor(fontid, sel ? TH_TEXT_HI : TH_TEXT);
|
||||
|
||||
font_height = BLF_height(fontid, channel->name, sizeof(channel->name));
|
||||
float font_height = BLF_height(fontid, channel->name, sizeof(channel->name));
|
||||
BLF_position(fontid, v2d->cur.xmin + CHANNEL_PAD,
|
||||
y - font_height / 2.0f, 0.0f);
|
||||
BLF_draw(fontid, channel->name, strlen(channel->name));
|
||||
|
@ -352,12 +373,12 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar)
|
|||
y -= CHANNEL_STEP;
|
||||
}
|
||||
|
||||
/* second pass: widgets */
|
||||
block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
|
||||
/* third pass: widgets */
|
||||
uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
|
||||
y = (float) CHANNEL_FIRST;
|
||||
|
||||
/* get RNA properties (once) */
|
||||
chan_prop_lock = RNA_struct_type_find_property(&RNA_MovieTrackingTrack, "lock");
|
||||
PropertyRNA *chan_prop_lock = RNA_struct_type_find_property(&RNA_MovieTrackingTrack, "lock");
|
||||
BLI_assert(chan_prop_lock);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
|
|
@ -101,50 +101,66 @@ void nla_action_get_color(AnimData *adt, bAction *act, float color[4])
|
|||
}
|
||||
|
||||
/* draw the keyframes in the specified Action */
|
||||
static void nla_action_draw_keyframes(AnimData *adt, bAction *act, View2D *v2d, float y, float ymin, float ymax)
|
||||
static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, float ymin, float ymax)
|
||||
{
|
||||
DLRBT_Tree keys;
|
||||
ActKeyColumn *ak;
|
||||
float xscale, f1, f2;
|
||||
float color[4];
|
||||
|
||||
/* get a list of the keyframes with NLA-scaling applied */
|
||||
DLRBT_Tree keys;
|
||||
BLI_dlrbTree_init(&keys);
|
||||
action_to_keylist(adt, act, &keys, NULL);
|
||||
BLI_dlrbTree_linkedlist_sync(&keys);
|
||||
|
||||
|
||||
if (ELEM(NULL, act, keys.first))
|
||||
return;
|
||||
|
||||
|
||||
/* draw a darkened region behind the strips
|
||||
* - get and reset the background color, this time without the alpha to stand out better
|
||||
* (amplified alpha is used instead)
|
||||
*/
|
||||
float color[4];
|
||||
nla_action_get_color(adt, act, color);
|
||||
color[3] *= 2.5f;
|
||||
|
||||
glColor4fv(color);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos_id = add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immUniformColor4fv(color);
|
||||
|
||||
/* - draw a rect from the first to the last frame (no extra overlaps for now)
|
||||
* that is slightly stumpier than the track background (hardcoded 2-units here)
|
||||
*/
|
||||
f1 = ((ActKeyColumn *)keys.first)->cfra;
|
||||
f2 = ((ActKeyColumn *)keys.last)->cfra;
|
||||
|
||||
glRectf(f1, ymin + 2, f2, ymax - 2);
|
||||
|
||||
|
||||
/* get View2D scaling factor */
|
||||
UI_view2d_scale_get(v2d, &xscale, NULL);
|
||||
|
||||
/* for now, color is hardcoded to be black */
|
||||
glColor3f(0.0f, 0.0f, 0.0f);
|
||||
|
||||
/* just draw each keyframe as a simple dot (regardless of the selection status)
|
||||
* - size is 3.0f which is smaller than the editable keyframes, so that there is a distinction
|
||||
*/
|
||||
for (ak = keys.first; ak; ak = ak->next)
|
||||
draw_keyframe_shape(ak->cfra, y, xscale, 3.0f, 0, ak->key_type, KEYFRAME_SHAPE_FRAME, 1.0f);
|
||||
|
||||
float f1 = ((ActKeyColumn *)keys.first)->cfra;
|
||||
float f2 = ((ActKeyColumn *)keys.last)->cfra;
|
||||
|
||||
immRectf(pos_id, f1, ymin + 2, f2, ymax - 2);
|
||||
immUnbindProgram();
|
||||
|
||||
/* count keys before drawing */
|
||||
unsigned int key_ct = 0;
|
||||
for (ActKeyColumn *ak = keys.first; ak; ak = ak->next) {
|
||||
key_ct++;
|
||||
}
|
||||
|
||||
if (key_ct > 0) {
|
||||
format = immVertexFormat();
|
||||
pos_id = add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int size_id = add_attrib(format, "size", COMP_F32, 1, KEEP_FLOAT);
|
||||
unsigned int color_id = add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
unsigned int outline_color_id = add_attrib(format, "outlineColor", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
|
||||
immBegin(PRIM_POINTS, key_ct);
|
||||
|
||||
/* - disregard the selection status of keyframes so they draw a certain way
|
||||
* - size is 3.0f which is smaller than the editable keyframes, so that there is a distinction
|
||||
*/
|
||||
for (ActKeyColumn *ak = keys.first; ak; ak = ak->next) {
|
||||
draw_keyframe_shape(ak->cfra, y, 3.0f, false, ak->key_type, KEYFRAME_SHAPE_FRAME, 1.0f,
|
||||
pos_id, size_id, color_id, outline_color_id);
|
||||
}
|
||||
|
||||
immEnd();
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
/* free icons */
|
||||
BLI_dlrbTree_free(&keys);
|
||||
}
|
||||
|
@ -174,7 +190,7 @@ static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymax
|
|||
/* Markers inside a NLA-Strip */
|
||||
static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc)
|
||||
{
|
||||
glLineWidth(2.0);
|
||||
glLineWidth(2.0f);
|
||||
|
||||
if (strip->type == NLASTRIP_TYPE_CLIP) {
|
||||
/* try not to be too conspicuous, while being visible enough when transforming */
|
||||
|
@ -660,7 +676,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
|
|||
glRectf(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP);
|
||||
|
||||
/* draw keyframes in the action */
|
||||
nla_action_draw_keyframes(adt, ale->data, v2d, y, yminc + NLACHANNEL_SKIP, ymaxc - NLACHANNEL_SKIP);
|
||||
nla_action_draw_keyframes(adt, ale->data, y, yminc + NLACHANNEL_SKIP, ymaxc - NLACHANNEL_SKIP);
|
||||
|
||||
/* draw 'embossed' lines above and below the strip for effect */
|
||||
/* white base-lines */
|
||||
|
|
Loading…
Reference in New Issue