A few Graph Editor tweaks:
* Tiny tweak of GL commands used when drawing F-Curves (single GL_LINES instead of multiple GL_LINE_STRIPS) to hopefully improve the performance with heaps of handles drawn a bit * Spelling fix for initTransDataCurveHandes -> initTransDataCurveHandles
This commit is contained in:
@@ -155,7 +155,7 @@ static void draw_fcurve_modifier_controls_envelope (FCurve *fcu, FModifier *fcm,
|
||||
glVertex2f(fed->time, fed->max);
|
||||
}
|
||||
}
|
||||
bglEnd();
|
||||
bglEnd(); // GL_POINTS
|
||||
|
||||
glPointSize(1.0f);
|
||||
}
|
||||
@@ -198,7 +198,7 @@ static void draw_fcurve_vertices_keyframes (FCurve *fcu, View2D *v2d, short edit
|
||||
}
|
||||
}
|
||||
|
||||
bglEnd();
|
||||
bglEnd(); // GL_POINTS
|
||||
}
|
||||
|
||||
|
||||
@@ -333,21 +333,24 @@ void draw_fcurve_vertices (SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
|
||||
static void draw_fcurve_handles (SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
|
||||
{
|
||||
extern unsigned int nurbcol[];
|
||||
unsigned int *col;
|
||||
int sel, b;
|
||||
|
||||
/* don't draw handle lines if handles are not shown */
|
||||
if ((sipo->flag & SIPO_NOHANDLES) || (fcu->flag & FCURVE_PROTECTED) || (fcu->flag & FCURVE_INT_VALUES))
|
||||
return;
|
||||
|
||||
/* 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 everytime we
|
||||
* want a single line
|
||||
*/
|
||||
glBegin(GL_LINES);
|
||||
|
||||
/* slightly hacky, but we want to draw unselected points before selected ones */
|
||||
for (sel= 0; sel < 2; sel++) {
|
||||
BezTriple *bezt=fcu->bezt, *prevbezt=NULL;
|
||||
unsigned int *col= (sel)? (nurbcol+4) : (nurbcol);
|
||||
float *fp;
|
||||
|
||||
if (sel) col= nurbcol+4;
|
||||
else col= nurbcol;
|
||||
|
||||
for (b= 0; b < fcu->totvert; b++, prevbezt=bezt, bezt++) {
|
||||
if ((bezt->f2 & SELECT)==sel) {
|
||||
fp= bezt->vec[0];
|
||||
@@ -356,19 +359,15 @@ static void draw_fcurve_handles (SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
|
||||
if ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) )
|
||||
{
|
||||
cpackA(col[(unsigned char)bezt->h1], drawFCurveFade(fcu));
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2fv(fp); glVertex2fv(fp+3);
|
||||
glEnd();
|
||||
|
||||
glVertex2fv(fp); glVertex2fv(fp+3);
|
||||
}
|
||||
|
||||
/* only draw second handle if this segment is bezier */
|
||||
if (bezt->ipo == BEZT_IPO_BEZ)
|
||||
{
|
||||
cpackA(col[(unsigned char)bezt->h2], drawFCurveFade(fcu));
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2fv(fp+3); glVertex2fv(fp+6);
|
||||
glEnd();
|
||||
glVertex2fv(fp+3); glVertex2fv(fp+6);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -379,9 +378,7 @@ static void draw_fcurve_handles (SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
|
||||
fp= bezt->vec[0];
|
||||
cpackA(col[(unsigned char)bezt->h1], drawFCurveFade(fcu));
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2fv(fp); glVertex2fv(fp+3);
|
||||
glEnd();
|
||||
glVertex2fv(fp); glVertex2fv(fp+3);
|
||||
}
|
||||
|
||||
/* only draw second handle if this segment is bezier, and selection is ok */
|
||||
@@ -391,13 +388,13 @@ static void draw_fcurve_handles (SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
|
||||
fp= bezt->vec[1];
|
||||
cpackA(col[(unsigned char)bezt->h2], drawFCurveFade(fcu));
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2fv(fp); glVertex2fv(fp+3);
|
||||
glEnd();
|
||||
glVertex2fv(fp); glVertex2fv(fp+3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glEnd(); // GL_LINES
|
||||
}
|
||||
|
||||
/* Samples ---------------- */
|
||||
|
||||
@@ -1334,7 +1334,7 @@ static void calc_distanceCurveVerts(TransData *head, TransData *tail) {
|
||||
}
|
||||
|
||||
/* Utility function for getting the handle data from bezier's */
|
||||
TransDataCurveHandleFlags *initTransDataCurveHandes(TransData *td, struct BezTriple *bezt) {
|
||||
TransDataCurveHandleFlags *initTransDataCurveHandles(TransData *td, struct BezTriple *bezt) {
|
||||
TransDataCurveHandleFlags *hdata;
|
||||
td->flag |= TD_BEZTRIPLE;
|
||||
hdata = td->hdata = MEM_mallocN(sizeof(TransDataCurveHandleFlags), "CuHandle Data");
|
||||
@@ -1424,7 +1424,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
|
||||
td->ext = NULL;
|
||||
td->val = NULL;
|
||||
|
||||
hdata = initTransDataCurveHandes(td, bezt);
|
||||
hdata = initTransDataCurveHandles(td, bezt);
|
||||
|
||||
Mat3CpyMat3(td->smtx, smtx);
|
||||
Mat3CpyMat3(td->mtx, mtx);
|
||||
@@ -1459,7 +1459,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
|
||||
if ((bezt->f1&SELECT)==0 && (bezt->f3&SELECT)==0)
|
||||
/* If the middle is selected but the sides arnt, this is needed */
|
||||
if (hdata==NULL) { /* if the handle was not saved by the previous handle */
|
||||
hdata = initTransDataCurveHandes(td, bezt);
|
||||
hdata = initTransDataCurveHandles(td, bezt);
|
||||
}
|
||||
|
||||
td++;
|
||||
@@ -1484,7 +1484,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
|
||||
td->val = NULL;
|
||||
|
||||
if (hdata==NULL) { /* if the handle was not saved by the previous handle */
|
||||
hdata = initTransDataCurveHandes(td, bezt);
|
||||
hdata = initTransDataCurveHandles(td, bezt);
|
||||
}
|
||||
|
||||
Mat3CpyMat3(td->smtx, smtx);
|
||||
@@ -1503,7 +1503,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
|
||||
if (propmode && head != tail)
|
||||
calc_distanceCurveVerts(head, tail-1);
|
||||
|
||||
/* TODO - in the case of tilt and radius we can also avoid allocating the initTransDataCurveHandes
|
||||
/* TODO - in the case of tilt and radius we can also avoid allocating the initTransDataCurveHandles
|
||||
* but for now just dont change handle types */
|
||||
if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_TILT) == 0)
|
||||
testhandlesNurb(nu); /* sets the handles based on their selection, do this after the data is copied to the TransData */
|
||||
@@ -3452,14 +3452,14 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
|
||||
|
||||
/* only include handles if selected, irrespective of the interpolation modes */
|
||||
if (bezt->f1 & SELECT) {
|
||||
hdata = initTransDataCurveHandes(td, bezt);
|
||||
hdata = initTransDataCurveHandles(td, bezt);
|
||||
bezt_to_transdata(td++, td2d++, adt, bezt->vec[0], bezt->vec[1], 1, 1, intvals);
|
||||
}
|
||||
else
|
||||
h1= 0;
|
||||
if (bezt->f3 & SELECT) {
|
||||
if (hdata==NULL)
|
||||
hdata = initTransDataCurveHandes(td, bezt);
|
||||
hdata = initTransDataCurveHandles(td, bezt);
|
||||
bezt_to_transdata(td++, td2d++, adt, bezt->vec[2], bezt->vec[1], 1, 1, intvals);
|
||||
}
|
||||
else
|
||||
@@ -3472,13 +3472,13 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
|
||||
/* if handles were not selected, store their selection status */
|
||||
if (!(bezt->f1 & SELECT) && !(bezt->f3 & SELECT)) {
|
||||
if (hdata == NULL)
|
||||
hdata = initTransDataCurveHandes(td, bezt);
|
||||
hdata = initTransDataCurveHandles(td, bezt);
|
||||
}
|
||||
|
||||
bezt_to_transdata(td++, td2d++, adt, bezt->vec[1], bezt->vec[1], 1, 0, intvals);
|
||||
}
|
||||
|
||||
/* special hack (must be done after initTransDataCurveHandes(), as that stores handle settings to restore...):
|
||||
/* special hack (must be done after initTransDataCurveHandles(), as that stores handle settings to restore...):
|
||||
* - Check if we've got entire BezTriple selected and we're scaling/rotating that point,
|
||||
* then check if we're using auto-handles.
|
||||
* - If so, change them auto-handles to aligned handles so that handles get affected too
|
||||
|
||||
Reference in New Issue
Block a user