moved some duplicate lines into their own function

This commit is contained in:
2008-04-04 15:22:19 +00:00
parent 6b6e5eb4c9
commit e8e1007386
3 changed files with 21 additions and 38 deletions

View File

@@ -46,7 +46,7 @@ struct View3D;
struct ScrArea; struct ScrArea;
struct bPose; struct bPose;
struct bConstraint; struct bConstraint;
struct BezTriple;
typedef struct NDofInput { typedef struct NDofInput {
int flag; int flag;
@@ -472,6 +472,8 @@ void postTrans (TransInfo *t);
void drawLine(float *center, float *dir, char axis, short options); void drawLine(float *center, float *dir, char axis, short options);
TransDataCurveHandleFlags *initTransDataCurveHandes(TransData *td, struct BezTriple *bezt);
/* DRAWLINE options flags */ /* DRAWLINE options flags */
#define DRAWLIGHT 1 #define DRAWLIGHT 1
#define DRAWDASHED 2 #define DRAWDASHED 2

View File

@@ -5172,23 +5172,12 @@ void make_ipo_transdata (TransInfo *t)
/* only include handles if selected, and interpolaton mode uses beztriples */ /* only include handles if selected, and interpolaton mode uses beztriples */
if (ei->icu->ipo==IPO_BEZ) { if (ei->icu->ipo==IPO_BEZ) {
if (bezt->f1 & SELECT) { if (bezt->f1 & SELECT) {
td->flag |= TD_BEZTRIPLE; hdata = initTransDataCurveHandes(td, bezt);
hdata = td->misc.hdata = MEM_mallocN(sizeof(TransDataCurveHandleFlags), "CuHandle Data");
hdata->ih1 = bezt->h1;
hdata->h1 = &bezt->h1;
hdata->ih2 = bezt->h2; /* incase the second is not selected */
hdata->h2 = &bezt->h2;
bezt_to_transdata(td++, td2d++, bezt->vec[0], bezt->vec[1], 1, onlytime); bezt_to_transdata(td++, td2d++, bezt->vec[0], bezt->vec[1], 1, onlytime);
} }
if (bezt->f3 & SELECT) { if (bezt->f3 & SELECT) {
if (hdata==NULL) { if (hdata==NULL) {
td->flag |= TD_BEZTRIPLE; hdata = initTransDataCurveHandes(td, bezt);
hdata = td->misc.hdata = MEM_mallocN(sizeof(TransDataCurveHandleFlags), "CuHandle Data");
hdata->ih1 = bezt->h1;
hdata->h1 = &bezt->h1;
hdata->ih2 = bezt->h2; /* incase the second is not selected */
hdata->h2 = &bezt->h2;
} }
bezt_to_transdata(td++, td2d++, bezt->vec[2], bezt->vec[1], 1, onlytime); bezt_to_transdata(td++, td2d++, bezt->vec[2], bezt->vec[1], 1, onlytime);
} }
@@ -5199,12 +5188,7 @@ void make_ipo_transdata (TransInfo *t)
if ((bezt->f1&SELECT)==0 && (bezt->f3&SELECT)==0) { if ((bezt->f1&SELECT)==0 && (bezt->f3&SELECT)==0) {
if (hdata==NULL) { if (hdata==NULL) {
td->flag |= TD_BEZTRIPLE; hdata = initTransDataCurveHandes(td, bezt);
hdata = td->misc.hdata = MEM_mallocN(sizeof(TransDataCurveHandleFlags), "CuHandle Data");
hdata->ih1 = bezt->h1;
hdata->h1 = &bezt->h1;
hdata->ih2 = bezt->h2; /* incase the second is not selected */
hdata->h2 = &bezt->h2;
} }
} }

View File

@@ -1235,6 +1235,18 @@ 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 *hdata;
td->flag |= TD_BEZTRIPLE;
hdata = td->misc.hdata = MEM_mallocN(sizeof(TransDataCurveHandleFlags), "CuHandle Data");
hdata->ih1 = bezt->h1;
hdata->h1 = &bezt->h1;
hdata->ih2 = bezt->h2; /* incase the second is not selected */
hdata->h2 = &bezt->h2;
return hdata;
}
static void createTransCurveVerts(TransInfo *t) static void createTransCurveVerts(TransInfo *t)
{ {
TransData *td = NULL; TransData *td = NULL;
@@ -1309,12 +1321,7 @@ static void createTransCurveVerts(TransInfo *t)
td->tdi = NULL; td->tdi = NULL;
td->val = NULL; td->val = NULL;
td->flag |= TD_BEZTRIPLE; hdata = initTransDataCurveHandes(td, bezt);
hdata = td->misc.hdata = MEM_mallocN(sizeof(TransDataCurveHandleFlags), "CuHandle Data");
hdata->ih1 = bezt->h1;
hdata->h1 = &bezt->h1;
hdata->ih2 = bezt->h2; /* incase the second is not selected */
hdata->h2 = &bezt->h2;
Mat3CpyMat3(td->smtx, smtx); Mat3CpyMat3(td->smtx, smtx);
Mat3CpyMat3(td->mtx, mtx); Mat3CpyMat3(td->mtx, mtx);
@@ -1350,12 +1357,7 @@ static void createTransCurveVerts(TransInfo *t)
if ((bezt->f1&SELECT)==0 && (bezt->f3&SELECT)==0) if ((bezt->f1&SELECT)==0 && (bezt->f3&SELECT)==0)
/* If the middle is selected but the sides arnt, this is needed */ /* 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 */ if (hdata==NULL) { /* if the handle was not saved by the previous handle */
td->flag |= TD_BEZTRIPLE; hdata = initTransDataCurveHandes(td, bezt);
hdata = td->misc.hdata = MEM_mallocN(sizeof(TransDataCurveHandleFlags), "CuHandle Data");
hdata->ih1 = bezt->h1;
hdata->h1 = &bezt->h1;
hdata->ih2 = bezt->h2; /* incase the second is not selected */
hdata->h2 = &bezt->h2;
} }
td++; td++;
@@ -1381,12 +1383,7 @@ static void createTransCurveVerts(TransInfo *t)
td->val = NULL; td->val = NULL;
if (hdata==NULL) { /* if the handle was not saved by the previous handle */ if (hdata==NULL) { /* if the handle was not saved by the previous handle */
td->flag |= TD_BEZTRIPLE; hdata = initTransDataCurveHandes(td, bezt);
hdata = td->misc.hdata = MEM_mallocN(sizeof(TransDataCurveHandleFlags), "CuHandle Data");
hdata->ih1 = bezt->h1;
hdata->h1 = &bezt->h1;
hdata->ih2 = bezt->h2; /* incase the second is not selected */
hdata->h2 = &bezt->h2;
} }
Mat3CpyMat3(td->smtx, smtx); Mat3CpyMat3(td->smtx, smtx);