diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-04-04 19:22:19 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-04-04 19:22:19 +0400 |
commit | e8e100738674cba65f70c7be49e0fb210645c06a (patch) | |
tree | 63c62be7935c1641cab4e63fefb9a3be30c83fa9 /source/blender | |
parent | 6b6e5eb4c979e050478baa39d7402c03bcc73c80 (diff) |
moved some duplicate lines into their own function
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/include/transform.h | 4 | ||||
-rw-r--r-- | source/blender/src/editipo.c | 22 | ||||
-rw-r--r-- | source/blender/src/transform_conversions.c | 33 |
3 files changed, 21 insertions, 38 deletions
diff --git a/source/blender/include/transform.h b/source/blender/include/transform.h index dc8521990f6..2fa277d0443 100644 --- a/source/blender/include/transform.h +++ b/source/blender/include/transform.h @@ -46,7 +46,7 @@ struct View3D; struct ScrArea; struct bPose; struct bConstraint; - +struct BezTriple; typedef struct NDofInput { int flag; @@ -472,6 +472,8 @@ void postTrans (TransInfo *t); void drawLine(float *center, float *dir, char axis, short options); +TransDataCurveHandleFlags *initTransDataCurveHandes(TransData *td, struct BezTriple *bezt); + /* DRAWLINE options flags */ #define DRAWLIGHT 1 #define DRAWDASHED 2 diff --git a/source/blender/src/editipo.c b/source/blender/src/editipo.c index c0a6330b9f0..fb8a3e5f769 100644 --- a/source/blender/src/editipo.c +++ b/source/blender/src/editipo.c @@ -5172,23 +5172,12 @@ void make_ipo_transdata (TransInfo *t) /* only include handles if selected, and interpolaton mode uses beztriples */ if (ei->icu->ipo==IPO_BEZ) { if (bezt->f1 & SELECT) { - 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; - + hdata = initTransDataCurveHandes(td, bezt); bezt_to_transdata(td++, td2d++, bezt->vec[0], bezt->vec[1], 1, onlytime); } if (bezt->f3 & SELECT) { if (hdata==NULL) { - 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; + hdata = initTransDataCurveHandes(td, bezt); } 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 (hdata==NULL) { - 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; + hdata = initTransDataCurveHandes(td, bezt); } } diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c index a93e43b0f3f..a21ba1fa210 100644 --- a/source/blender/src/transform_conversions.c +++ b/source/blender/src/transform_conversions.c @@ -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) { TransData *td = NULL; @@ -1309,12 +1321,7 @@ static void createTransCurveVerts(TransInfo *t) td->tdi = NULL; td->val = NULL; - 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; + hdata = initTransDataCurveHandes(td, bezt); Mat3CpyMat3(td->smtx, smtx); Mat3CpyMat3(td->mtx, mtx); @@ -1350,12 +1357,7 @@ static void createTransCurveVerts(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 */ - 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; + hdata = initTransDataCurveHandes(td, bezt); } td++; @@ -1381,12 +1383,7 @@ static void createTransCurveVerts(TransInfo *t) td->val = NULL; if (hdata==NULL) { /* if the handle was not saved by the previous handle */ - 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; + hdata = initTransDataCurveHandes(td, bezt); } Mat3CpyMat3(td->smtx, smtx); |