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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_graph/graph_draw.c')
-rw-r--r--source/blender/editors/space_graph/graph_draw.c384
1 files changed, 192 insertions, 192 deletions
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index f6e182e02ec..9a94bb9072b 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -61,7 +61,7 @@
/* *************************** */
/* Utility Drawing Defines */
-/* determine the alpha value that should be used when
+/* determine the alpha value that should be used when
* drawing components for some F-Curve (fcu)
* - selected F-Curves should be more visible than partially visible ones
*/
@@ -82,27 +82,27 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
FCM_EnvelopeData *fed;
const float fac = 0.05f * BLI_rctf_size_x(&v2d->cur);
int i;
-
+
/* draw two black lines showing the standard reference levels */
glColor3f(0.0f, 0.0f, 0.0f);
glLineWidth(1);
setlinestyle(5);
-
+
glBegin(GL_LINES);
glVertex2f(v2d->cur.xmin, env->midval + env->min);
glVertex2f(v2d->cur.xmax, env->midval + env->min);
-
+
glVertex2f(v2d->cur.xmin, env->midval + env->max);
glVertex2f(v2d->cur.xmax, env->midval + env->max);
glEnd();
setlinestyle(0);
-
+
/* set size of vertices (non-adjustable for now) */
glPointSize(2.0f);
-
+
/* for now, point color is fixed, and is white */
glColor3f(1.0f, 1.0f, 1.0f);
-
+
glBegin(GL_POINTS);
for (i = 0, fed = env->data; i < env->totvert; i++, fed++) {
/* only draw if visible
@@ -127,18 +127,18 @@ static void draw_fcurve_vertices_keyframes(FCurve *fcu, SpaceIpo *UNUSED(sipo),
BezTriple *bezt = fcu->bezt;
const float fac = 0.05f * BLI_rctf_size_x(&v2d->cur);
int i;
-
+
glBegin(GL_POINTS);
-
+
for (i = 0; i < fcu->totvert; i++, bezt++) {
- /* as an optimization step, only draw those in view
+ /* 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
*/
if (IN_RANGE(bezt->vec[1][0], (v2d->cur.xmin - fac), (v2d->cur.xmax + fac))) {
if (edit) {
/* 'Keyframe' vertex only, as handle lines and handles have already been drawn
* - only draw those with correct selection state for the current drawing color
- * -
+ * -
*/
if ((bezt->f2 & SELECT) == sel)
glVertex3fv(bezt->vec[1]);
@@ -150,41 +150,41 @@ static void draw_fcurve_vertices_keyframes(FCurve *fcu, SpaceIpo *UNUSED(sipo),
}
}
}
-
+
glEnd();
}
-/* helper func - draw handle vertex for an F-Curve as a round unfilled circle
+/* helper func - draw handle vertex for an F-Curve as a round unfilled circle
* NOTE: the caller MUST HAVE GL_LINE_SMOOTH & GL_BLEND ENABLED, otherwise, the controls don't
* have a consistent appearance (due to off-pixel alignments)...
*/
static void draw_fcurve_handle_control(float x, float y, float xscale, float yscale, float hsize)
{
static GLuint displist = 0;
-
+
/* initialize round circle shape */
if (displist == 0) {
GLUquadricObj *qobj;
-
+
displist = glGenLists(1);
glNewList(displist, GL_COMPILE);
-
+
qobj = gluNewQuadric();
- gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
+ gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
gluDisk(qobj, 0, 0.7, 8, 1);
- gluDeleteQuadric(qobj);
-
+ gluDeleteQuadric(qobj);
+
glEndList();
}
-
+
/* adjust view transform before starting */
glTranslatef(x, y, 0.0f);
glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f);
-
+
/* draw! */
glCallList(displist);
-
+
/* restore view transform */
glScalef(xscale / hsize, yscale / hsize, 1.0);
glTranslatef(-x, -y, 0.0f);
@@ -197,24 +197,24 @@ static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2
BezTriple *prevbezt = NULL;
float hsize, xscale, yscale;
int i;
-
+
/* get view settings */
hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE) * U.pixelsize;
UI_view2d_scale_get(v2d, &xscale, &yscale);
/* Compensate OGL scale sued for unit mapping, so circle will be circle, not ellipse */
yscale *= units_scale;
-
+
/* set handle color */
if (sel) UI_ThemeColor(TH_HANDLE_VERTEX_SELECT);
else UI_ThemeColor(TH_HANDLE_VERTEX);
-
+
/* anti-aliased lines for more consistent appearance */
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
-
+
for (i = 0; i < fcu->totvert; i++, prevbezt = bezt, bezt++) {
- /* Draw the editmode handles for a bezier curve (others don't have handles)
+ /* Draw the editmode handles for a bezier curve (others don't have handles)
* if their selection status matches the selection status we're drawing for
* - first handle only if previous beztriple was bezier-mode
* - second handle only if current beztriple is bezier-mode
@@ -227,14 +227,14 @@ static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2
if ((bezt->f1 & SELECT) == sel) /* && v2d->cur.xmin < bezt->vec[0][0] < v2d->cur.xmax)*/
draw_fcurve_handle_control(bezt->vec[0][0], bezt->vec[0][1], xscale, yscale, hsize);
}
-
+
if (bezt->ipo == BEZT_IPO_BEZ) {
if ((bezt->f3 & SELECT) == sel) /* && v2d->cur.xmin < bezt->vec[2][0] < v2d->cur.xmax)*/
draw_fcurve_handle_control(bezt->vec[2][0], bezt->vec[2][1], xscale, yscale, hsize);
}
}
}
-
+
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
}
@@ -244,11 +244,11 @@ static void set_fcurve_vertex_color(FCurve *fcu, short sel)
{
/* Fade the 'intensity' of the vertices based on the selection of the curves too */
int alphaOffset = (int)((fcurve_display_alpha(fcu) - 1.0f) * 255);
-
+
/* 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 */
- if (sel) UI_ThemeColorShadeAlpha(TH_VERTEX_SELECT, 0, alphaOffset);
+ if (sel) UI_ThemeColorShadeAlpha(TH_VERTEX_SELECT, 0, alphaOffset);
else UI_ThemeColorShadeAlpha(TH_VERTEX, 0, alphaOffset);
}
else {
@@ -262,29 +262,29 @@ static void set_fcurve_vertex_color(FCurve *fcu, short sel)
static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short do_handles, short sel_handle_only, float units_scale)
{
View2D *v2d = &ar->v2d;
-
- /* only draw points if curve is visible
+
+ /* only draw points if curve is visible
* - draw unselected points before selected points as separate passes to minimize color-changing overhead
- * (XXX dunno if this is faster than drawing all in one pass though)
+ * (XXX dunno if this is faster than drawing all in one pass though)
* and also to make sure in the case of overlapping points that the selected is always visible
* - draw handles before keyframes, so that keyframes will overlap handles (keyframes are more important for users)
*/
-
+
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
-
+
/* draw the two handles first (if they're shown, the curve doesn't have just a single keyframe, and the curve is being edited) */
if (do_handles) {
set_fcurve_vertex_color(fcu, 0);
draw_fcurve_vertices_handles(fcu, sipo, v2d, 0, sel_handle_only, units_scale);
-
+
set_fcurve_vertex_color(fcu, 1);
draw_fcurve_vertices_handles(fcu, sipo, v2d, 1, sel_handle_only, units_scale);
}
-
+
/* draw keyframes over the handles */
set_fcurve_vertex_color(fcu, 0);
draw_fcurve_vertices_keyframes(fcu, sipo, v2d, !(fcu->flag & FCURVE_PROTECTED), 0);
-
+
set_fcurve_vertex_color(fcu, 1);
draw_fcurve_vertices_keyframes(fcu, sipo, v2d, !(fcu->flag & FCURVE_PROTECTED), 1);
}
@@ -315,14 +315,14 @@ static bool draw_fcurve_handles_check(SpaceIpo *sipo, FCurve *fcu)
static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
{
int sel, b;
-
+
/* a single call to GL_LINES here around these calls should be sufficient to still
* get separate line segments, but which aren't wrapped with GL_LINE_STRIP every time we
* want a single line
*/
glBegin(GL_LINES);
-
- /* slightly hacky, but we want to draw unselected points before selected ones
+
+ /* slightly hacky, but we want to draw unselected points before selected ones
* so that selected points are clearly visible
*/
for (sel = 0; sel < 2; sel++) {
@@ -330,35 +330,35 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
int basecol = (sel) ? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE;
const float *fp;
unsigned char col[4];
-
+
for (b = 0; b < fcu->totvert; b++, prevbezt = bezt, bezt++) {
- /* if only selected keyframes can get their handles shown,
+ /* if only selected keyframes can get their handles shown,
* check that keyframe is selected
*/
if (sipo->flag & SIPO_SELVHANDLESONLY) {
if (BEZT_ISSEL_ANY(bezt) == 0)
continue;
}
-
+
/* draw handle with appropriate set of colors if selection is ok */
if ((bezt->f2 & SELECT) == sel) {
fp = bezt->vec[0];
-
+
/* only draw first handle if previous segment had handles */
if ((!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) {
UI_GetThemeColor3ubv(basecol + bezt->h1, col);
col[3] = fcurve_display_alpha(fcu) * 255;
glColor4ubv((GLubyte *)col);
-
+
glVertex2fv(fp); glVertex2fv(fp + 3);
}
-
+
/* only draw second handle if this segment is bezier */
if (bezt->ipo == BEZT_IPO_BEZ) {
UI_GetThemeColor3ubv(basecol + bezt->h2, col);
col[3] = fcurve_display_alpha(fcu) * 255;
glColor4ubv((GLubyte *)col);
-
+
glVertex2fv(fp + 3); glVertex2fv(fp + 6);
}
}
@@ -371,10 +371,10 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
UI_GetThemeColor3ubv(basecol + bezt->h1, col);
col[3] = fcurve_display_alpha(fcu) * 255;
glColor4ubv((GLubyte *)col);
-
+
glVertex2fv(fp); glVertex2fv(fp + 3);
}
-
+
/* only draw second handle if this segment is bezier, and selection is ok */
if (((bezt->f3 & SELECT) == sel) &&
(bezt->ipo == BEZT_IPO_BEZ))
@@ -383,49 +383,49 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
UI_GetThemeColor3ubv(basecol + bezt->h2, col);
col[3] = fcurve_display_alpha(fcu) * 255;
glColor4ubv((GLubyte *)col);
-
+
glVertex2fv(fp); glVertex2fv(fp + 3);
}
}
}
}
-
+
glEnd(); /* GL_LINES */
}
/* Samples ---------------- */
-/* helper func - draw sample-range marker for an F-Curve as a cross
+/* helper func - draw sample-range marker for an F-Curve as a cross
* NOTE: the caller MUST HAVE GL_LINE_SMOOTH & GL_BLEND ENABLED, otherwise, the controls don't
* have a consistent appearance (due to off-pixel alignments)...
*/
static void draw_fcurve_sample_control(float x, float y, float xscale, float yscale, float hsize)
{
static GLuint displist = 0;
-
+
/* initialize X shape */
if (displist == 0) {
displist = glGenLists(1);
glNewList(displist, GL_COMPILE);
-
+
glBegin(GL_LINES);
glVertex2f(-0.7f, -0.7f);
glVertex2f(+0.7f, +0.7f);
-
+
glVertex2f(-0.7f, +0.7f);
glVertex2f(+0.7f, -0.7f);
glEnd(); /* GL_LINES */
-
+
glEndList();
}
-
+
/* adjust view transform before starting */
glTranslatef(x, y, 0.0f);
glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f);
-
+
/* draw! */
glCallList(displist);
-
+
/* restore view transform */
glScalef(xscale / hsize, yscale / hsize, 1.0);
glTranslatef(-x, -y, 0.0f);
@@ -436,28 +436,28 @@ static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
{
FPoint *first, *last;
float hsize, xscale, yscale;
-
+
/* get view settings */
hsize = UI_GetThemeValuef(TH_VERTEX_SIZE);
UI_view2d_scale_get(&ar->v2d, &xscale, &yscale);
-
+
/* set vertex color */
if (fcu->flag & (FCURVE_ACTIVE | FCURVE_SELECTED)) UI_ThemeColor(TH_TEXT_HI);
else UI_ThemeColor(TH_TEXT);
-
+
/* get verts */
first = fcu->fpt;
last = (first) ? (first + (fcu->totvert - 1)) : (NULL);
-
+
/* draw */
if (first && last) {
/* anti-aliased lines for more consistent appearance */
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
-
+
draw_fcurve_sample_control(first->vec[0], first->vec[1], xscale, yscale, hsize);
draw_fcurve_sample_control(last->vec[0], last->vec[1], xscale, yscale, hsize);
-
+
glDisable(GL_BLEND);
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH);
}
@@ -487,10 +487,10 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d
/* disable any drivers temporarily */
driver = fcu->driver;
fcu->driver = NULL;
-
+
/* compute unit correction factor */
unitFac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
-
+
/* Note about sampling frequency:
* 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,
@@ -506,10 +506,10 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d
/* grid->dx represents the number of 'frames' between gridlines, but we divide by U.v2d_min_gridsize to get pixels-steps */
/* TODO: perhaps we should have 1.0 frames as upper limit so that curves don't get too distorted? */
samplefreq = dx / (U.v2d_min_gridsize * U.pixelsize);
-
+
if (sipo->flag & SIPO_BEAUTYDRAW_OFF) {
/* Low Precision = coarse lower-bound clamping
- *
+ *
* 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)!
@@ -525,27 +525,27 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d
if (samplefreq < 0.00001f)
samplefreq = 0.00001f;
}
-
-
+
+
/* the start/end times are simply the horizontal extents of the 'cur' rect */
stime = v2d->cur.xmin;
etime = v2d->cur.xmax + samplefreq; /* + samplefreq here so that last item gets included... */
-
-
- /* at each sampling interval, add a new vertex
- * - apply the unit correction factor to the calculated values so that
+
+
+ /* 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
*/
glBegin(GL_LINE_STRIP);
-
+
n = (etime - stime) / samplefreq + 0.5f;
for (i = 0; i <= n; i++) {
float ctime = stime + i * samplefreq;
glVertex2f(ctime, (evaluate_fcurve(fcu, ctime) + offset) * unitFac);
}
-
+
glEnd();
-
+
/* restore driver */
fcu->driver = driver;
}
@@ -567,11 +567,11 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
glTranslatef(0.0f, offset, 0.0f);
glBegin(GL_LINE_STRIP);
-
+
/* extrapolate to left? - left-side of view comes before first keyframe? */
if (prevfpt->vec[0] > v2d->cur.xmin) {
v[0] = v2d->cur.xmin;
-
+
/* y-value depends on the interpolation */
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert == 1)) {
/* just extend across the first keyframe's value */
@@ -583,33 +583,33 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
if (fac) fac = 1.0f / fac;
v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]);
}
-
+
glVertex2fv(v);
}
-
+
/* if only one sample, add it now */
if (fcu->totvert == 1)
glVertex2fv(prevfpt->vec);
-
+
/* 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) */
glVertex2fv(prevfpt->vec);
-
+
/* get next pointers */
prevfpt = fpt;
fpt++;
-
+
/* last point? */
if (b == 0)
glVertex2fv(prevfpt->vec);
}
-
+
/* extrapolate to right? (see code for left-extrapolation above too) */
if (prevfpt->vec[0] < v2d->cur.xmax) {
v[0] = v2d->cur.xmax;
-
+
/* y-value depends on the interpolation */
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert == 1)) {
/* based on last keyframe's value */
@@ -622,28 +622,28 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
if (fac) fac = 1.0f / fac;
v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]);
}
-
+
glVertex2fv(v);
}
-
+
glEnd();
glPopMatrix();
}
-/* helper func - check if the F-Curve only contains easily drawable segments
+/* helper func - check if the F-Curve only contains easily drawable segments
* (i.e. no easing equation interpolations)
*/
static bool fcurve_can_use_simple_bezt_drawing(FCurve *fcu)
{
BezTriple *bezt;
int i;
-
+
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;
}
}
-
+
return true;
}
@@ -659,7 +659,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
int resol;
float unit_scale, offset;
short mapping_flag = ANIM_get_normalization_flags(ac);
-
+
/* apply unit mapping */
glPushMatrix();
unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
@@ -667,12 +667,12 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
glTranslatef(0.0f, offset, 0.0f);
glBegin(GL_LINE_STRIP);
-
+
/* extrapolate to left? */
if (prevbezt->vec[1][0] > v2d->cur.xmin) {
/* left-side of view comes before first keyframe, so need to extend as not cyclic */
v1[0] = v2d->cur.xmin;
-
+
/* y-value depends on the interpolation */
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) {
/* just extend across the first keyframe's value */
@@ -690,17 +690,17 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
if (fac) fac = 1.0f / fac;
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[0][1] - prevbezt->vec[1][1]);
}
-
+
glVertex2fv(v1);
}
-
+
/* if only one keyframe, add it now */
if (fcu->totvert == 1) {
v1[0] = prevbezt->vec[1][0];
v1[1] = prevbezt->vec[1][1];
glVertex2fv(v1);
}
-
+
/* draw curve between first and last keyframe (if there are enough to do so) */
/* TODO: optimize this to not have to calc stuff out of view too? */
while (b--) {
@@ -709,7 +709,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
v1[0] = prevbezt->vec[1][0];
v1[1] = prevbezt->vec[1][1];
glVertex2fv(v1);
-
+
v1[0] = bezt->vec[1][0];
v1[1] = prevbezt->vec[1][1];
glVertex2fv(v1);
@@ -721,10 +721,10 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
glVertex2fv(v1);
}
else if (prevbezt->ipo == BEZT_IPO_BEZ) {
- /* Bezier-Interpolation: draw curve as series of segments between keyframes
+ /* Bezier-Interpolation: draw curve as series of segments between keyframes
* - resol determines number of points to sample in between keyframes
*/
-
+
/* resol depends on distance between points (not just horizontal) OR is a fixed high res */
/* TODO: view scale should factor into this someday too... */
if (fcu->driver) {
@@ -733,7 +733,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
else {
resol = (int)(5.0f * len_v2v2(bezt->vec[1], prevbezt->vec[1]));
}
-
+
if (resol < 2) {
/* only draw one */
v1[0] = prevbezt->vec[1][0];
@@ -744,31 +744,31 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
/* clamp resolution to max of 32 */
/* NOTE: higher values will crash */
if (resol > 32) resol = 32;
-
+
v1[0] = prevbezt->vec[1][0];
v1[1] = prevbezt->vec[1][1];
v2[0] = prevbezt->vec[2][0];
v2[1] = prevbezt->vec[2][1];
-
+
v3[0] = bezt->vec[0][0];
v3[1] = bezt->vec[0][1];
v4[0] = bezt->vec[1][0];
v4[1] = bezt->vec[1][1];
-
+
correct_bezpart(v1, v2, v3, v4);
-
+
BKE_curve_forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float) * 3);
BKE_curve_forward_diff_bezier(v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float) * 3);
-
+
for (fp = data; resol; resol--, fp += 3)
glVertex2fv(fp);
}
}
-
+
/* get next pointers */
prevbezt = bezt;
bezt++;
-
+
/* last point? */
if (b == 0) {
v1[0] = prevbezt->vec[1][0];
@@ -776,11 +776,11 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
glVertex2fv(v1);
}
}
-
+
/* extrapolate to right? (see code for left-extrapolation above too) */
if (prevbezt->vec[1][0] < v2d->cur.xmax) {
v1[0] = v2d->cur.xmax;
-
+
/* y-value depends on the interpolation */
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) {
/* based on last keyframe's value */
@@ -799,17 +799,17 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
if (fac) fac = 1.0f / fac;
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[2][1] - prevbezt->vec[1][1]);
}
-
+
glVertex2fv(v1);
}
-
+
glEnd();
glPopMatrix();
}
/* Debugging -------------------------------- */
-/* Draw indicators which show the value calculated from the driver,
+/* Draw indicators which show the value calculated from the driver,
* and how this is mapped to the value that comes out of it. This
* is handy for helping users better understand how to interpret
* the graphs, and also facilitates debugging.
@@ -821,93 +821,93 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
short mapping_flag = ANIM_get_normalization_flags(ac);
float offset;
float unitfac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
-
+
/* for now, only show when debugging driver... */
//if ((driver->flag & DRIVER_FLAG_SHOWDEBUG) == 0)
// return;
-
+
/* No curve to modify/visualize the result?
- * => We still want to show the 1-1 default...
+ * => We still want to show the 1-1 default...
*/
if ((fcu->totvert == 0) && BLI_listbase_is_empty(&fcu->modifiers)) {
float t;
-
+
/* draw with thin dotted lines in style of what curve would have been */
glColor3fv(fcu->color);
-
+
setlinestyle(20);
glLineWidth(2.0f);
-
- /* draw 1-1 line, stretching just past the screen limits
+
+ /* draw 1-1 line, stretching just past the screen limits
* NOTE: we need to scale the y-values to be valid for the units
*/
glBegin(GL_LINES);
{
t = v2d->cur.xmin;
glVertex2f(t, (t + offset) * unitfac);
-
+
t = v2d->cur.xmax;
glVertex2f(t, (t + offset) * unitfac);
}
glEnd();
-
+
/* cleanup line drawing */
setlinestyle(0);
}
-
+
/* 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;
-
+
/* only draw indicators if the point is in range*/
if (x >= v2d->cur.xmin) {
float co[2];
-
+
/* draw dotted lines leading towards this point from both axes ....... */
glColor3f(0.9f, 0.9f, 0.9f);
setlinestyle(5);
-
+
glBegin(GL_LINES);
{
/* x-axis lookup */
co[0] = x;
-
+
if (y >= v2d->cur.ymin) {
co[1] = v2d->cur.ymin - 1.0f;
glVertex2fv(co);
-
+
co[1] = y;
glVertex2fv(co);
}
-
+
/* y-axis lookup */
co[1] = y;
-
+
co[0] = v2d->cur.xmin - 1.0f;
glVertex2fv(co);
-
+
co[0] = x;
glVertex2fv(co);
}
glEnd();
-
+
setlinestyle(0);
-
+
/* x marks the spot .................................................... */
/* -> outer frame */
glColor3f(0.9f, 0.9f, 0.9f);
glPointSize(7.0);
-
+
glBegin(GL_POINTS);
glVertex2f(x, y);
glEnd();
-
+
/* inner frame */
glColor3f(0.9f, 0.0f, 0.0f);
glPointSize(3.0);
-
+
glBegin(GL_POINTS);
glVertex2f(x, y);
glEnd();
@@ -917,36 +917,36 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
/* Public Curve-Drawing API ---------------- */
-/* Draw the 'ghost' F-Curves (i.e. snapshots of the curve)
+/* Draw the 'ghost' F-Curves (i.e. snapshots of the curve)
* NOTE: unit mapping has already been applied to the values, so do not try and apply again
*/
void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
{
FCurve *fcu;
-
+
/* draw with thick dotted lines */
setlinestyle(10);
glLineWidth(3.0f);
-
+
/* anti-aliased lines for less jagged appearance */
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
-
+
/* the ghost curves are simply sampled F-Curves stored in sipo->ghostCurves */
for (fcu = sipo->ghostCurves.first; fcu; fcu = fcu->next) {
- /* set whatever color the curve has set
+ /* set whatever color the curve has set
* - this is set by the function which creates these
* - draw with a fixed opacity of 2
*/
glColor4f(fcu->color[0], fcu->color[1], fcu->color[2], 0.5f);
-
+
/* simply draw the stored samples */
draw_fcurve_curve_samples(ac, NULL, fcu, &ar->v2d);
}
-
+
/* restore settings */
setlinestyle(0);
-
+
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
}
@@ -959,32 +959,32 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* build list of curves to draw */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE);
filter |= ((sel) ? (ANIMFILTER_SEL) : (ANIMFILTER_UNSEL));
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* for each curve:
- * draw curve, then handle-lines, and finally vertices in this order so that
+ * draw curve, then handle-lines, and finally vertices in this order so that
* the data will be layered correctly
*/
for (ale = anim_data.first; ale; ale = ale->next) {
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);
-
+ 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 */
{
/* set color/drawing style for curve itself */
@@ -998,12 +998,12 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
UI_ThemeColorShade(TH_HEADER, 50);
}
else {
- /* set whatever color the curve has set
+ /* set whatever color the curve has set
* - unselected curves draw less opaque to help distinguish the selected ones
*/
glColor4f(fcu->color[0], fcu->color[1], fcu->color[2], fcurve_display_alpha(fcu));
}
-
+
/* draw active F-Curve thicker than the rest to make it stand out */
if (fcu->flag & FCURVE_ACTIVE) {
glLineWidth(2.0);
@@ -1011,15 +1011,15 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
else {
glLineWidth(1.0);
}
-
+
/* anti-aliased lines for less jagged appearance */
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
-
+
/* 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
+ /* draw a curve affected by modifiers or only allowed to have integer values
+ * by sampling it at various small-intervals over the visible region
*/
draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, grid);
}
@@ -1035,15 +1035,15 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
draw_fcurve_curve_samples(ac, ale->id, fcu, &ar->v2d);
}
}
-
+
/* restore settings */
setlinestyle(0);
-
+
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
}
-
- /* 2) draw handles and vertices as appropriate based on active
+
+ /* 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)) {
@@ -1061,46 +1061,46 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
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 */
glPushMatrix();
glScalef(1.0f, unit_scale, 1.0f);
glTranslatef(0.0f, offset, 0.0f);
-
+
/* set this once and for all - all handles and handle-verts should use the same thickness */
glLineWidth(1.0);
-
+
if (fcu->bezt) {
bool do_handles = draw_fcurve_handles_check(sipo, fcu);
-
+
if (do_handles) {
/* only draw handles/vertices on keyframes */
glEnable(GL_BLEND);
draw_fcurve_handles(sipo, fcu);
glDisable(GL_BLEND);
}
-
+
draw_fcurve_vertices(sipo, ar, fcu, do_handles, (sipo->flag & SIPO_SELVHANDLESONLY), unit_scale);
}
else {
/* samples: only draw two indicators at either end as indicators */
draw_fcurve_samples(sipo, ar, fcu);
}
-
+
glPopMatrix();
}
}
-
+
/* 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);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
}
-
+
/* free list of curves */
ANIM_animdata_freelist(&anim_data);
}
@@ -1109,40 +1109,40 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
/* Channel List */
/* left hand part */
-void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
+void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
View2D *v2d = &ar->v2d;
float y = 0.0f, height;
size_t items;
int i = 0;
-
+
/* 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);
-
+
/* Update max-extent of channels here (taking into account scrollers):
* - this is done to allow the channel list to be scrollable, but must be done here
* to avoid regenerating the list again and/or also because channels list is drawn first
- * - offset of ACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for
+ * - offset of ACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for
* start of list offset, and the second is as a correction for the scrollers.
*/
height = (float)((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac) * 2));
UI_view2d_totRect_set(v2d, BLI_rcti_size_x(&ar->v2d.mask), height);
-
+
/* loop through channels, and set up drawing depending on their type */
{ /* first pass: just the standard GL-drawing for backdrop + text */
size_t channel_index = 0;
-
+
y = (float)ACHANNEL_FIRST(ac);
-
+
for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) {
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) )
@@ -1150,7 +1150,7 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
/* draw all channels using standard channel-drawing API */
ANIM_channel_draw(ac, ale, yminc, ymaxc, channel_index);
}
-
+
/* adjust y-position for next one */
y -= ACHANNEL_STEP(ac);
channel_index++;
@@ -1159,17 +1159,17 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
{ /* second pass: widgets */
uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
size_t channel_index = 0;
-
+
y = (float)ACHANNEL_FIRST(ac);
-
+
/* set blending again, as may not be set in previous step */
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
-
+
for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) {
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) )
@@ -1177,18 +1177,18 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
/* draw all channels using standard channel-drawing API */
ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index);
}
-
+
/* adjust y-position for next one */
y -= ACHANNEL_STEP(ac);
channel_index++;
}
-
+
UI_block_end(C, block);
UI_block_draw(C, block);
-
+
glDisable(GL_BLEND);
}
-
+
/* free tempolary channels */
ANIM_animdata_freelist(&anim_data);
}