Revision: 14326
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14326
Author: campbellbarton
Date: 2008-04-04 17:06:50 +0200 (Fri, 04 Apr 2008)
Log Message:
-----------
Restore bezier handles to their original flag if the transform is canceled, for
IPO's and curve edit mode.
Also retopo was running of curve transform was canceled.
Modified Paths:
--------------
trunk/blender/source/blender/include/transform.h
trunk/blender/source/blender/src/editipo.c
trunk/blender/source/blender/src/transform_conversions.c
trunk/blender/source/blender/src/transform_generics.c
Modified: trunk/blender/source/blender/include/transform.h
===================================================================
--- trunk/blender/source/blender/include/transform.h 2008-04-04 12:33:01 UTC
(rev 14325)
+++ trunk/blender/source/blender/include/transform.h 2008-04-04 15:06:50 UTC
(rev 14326)
@@ -137,6 +137,13 @@
float *loc2d; /* Pointer to real 2d location of data */
} TransData2D;
+/* we need to store 2 handles for each transdata incase the other handle wasnt
selected */
+typedef struct TransDataCurveHandleFlags {
+ short ih1, ih2;
+ short *h1, *h2;
+} TransDataCurveHandleFlags;
+
+
typedef struct TransData {
float dist; /* Distance needed to affect element (for
Proportionnal Editing) */
float rdist; /* Distance to the nearest element (for
Proportionnal Editing) */
@@ -153,7 +160,11 @@
struct bConstraint *con; /* for objects/bones, the first
constraint in its constraint stack */
TransDataExtension *ext; /* for objects, poses. 1 single malloc
per TransInfo! */
TransDataIpokey *tdi; /* for objects, ipo keys. per transdata
a malloc */
- void *tdmir; /* mirrored element pointer, in editmode mesh
to EditVert */
+ union {
+ void *tdmir; /* mirrored element pointer, in
editmode mesh to EditVert */
+ TransDataCurveHandleFlags *hdata;
+ } misc;
+
short flag; /* Various flags */
short protectflag; /* If set, copy of Object or PoseChannel
protection */
/*#ifdef WITH_VERSE*/
@@ -289,6 +300,7 @@
#define TD_NOCENTER (1 << 9)
#define TD_NO_EXT (1 << 10) /* ext abused for
particle key timing */
#define TD_SKIP (1 << 11) /* don't
transform this data */
+#define TD_BEZTRIPLE (1 << 12) /* if this is a bez triple, we
need to restore the handles, if this is set transdata->misc.hdata needs freeing
*/
/* transsnap->status */
#define SNAP_ON 1
Modified: trunk/blender/source/blender/src/editipo.c
===================================================================
--- trunk/blender/source/blender/src/editipo.c 2008-04-04 12:33:01 UTC (rev
14325)
+++ trunk/blender/source/blender/src/editipo.c 2008-04-04 15:06:50 UTC (rev
14326)
@@ -5066,7 +5066,7 @@
td2d->loc[2] = 0.0f;
td2d->loc2d = loc;
- td->flag = 0;
+ /*td->flag = 0;*/ /* can be set beforehand, else make sure its
set to 0 */
td->loc = td2d->loc;
VECCOPY(td->center, cent);
VECCOPY(td->iloc, td->loc);
@@ -5077,7 +5077,7 @@
td2d->loc[2] = 0.0f;
td2d->loc2d = loc;
- td->flag = 0;
+ /*td->flag = 0;*/ /* can be set beforehand, else make sure its
set to 0 */
td->loc = td2d->loc;
VECCOPY(td->center, cent);
VECCOPY(td->iloc, td->loc);
@@ -5168,19 +5168,51 @@
bezt= ei->icu->bezt;
for (b=0; b < ei->icu->totvert;
b++, bezt++) {
+
TransDataCurveHandleFlags *hdata = NULL;
/* only include handles
if selected, and interpolaton mode uses beztriples */
if
(ei->icu->ipo==IPO_BEZ) {
- if (bezt->f1 &
SELECT)
+ 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;
+
bezt_to_transdata(td++, td2d++, bezt->vec[0], bezt->vec[1], 1, onlytime);
- if (bezt->f3 &
SELECT)
+ }
+ 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;
+ }
bezt_to_transdata(td++, td2d++, bezt->vec[2], bezt->vec[1], 1, onlytime);
+ }
}
/* only include main
vert if selected */
if (bezt->f2 & SELECT) {
+
+ 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;
+ }
+ }
+
bezt_to_transdata(td++, td2d++, bezt->vec[1], bezt->vec[1], 1, onlytime);
}
}
+ /* Sets handles based on the
selection */
+ testhandles_ipocurve(ei->icu);
}
}
}
Modified: trunk/blender/source/blender/src/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/src/transform_conversions.c 2008-04-04
12:33:01 UTC (rev 14325)
+++ trunk/blender/source/blender/src/transform_conversions.c 2008-04-04
15:06:50 UTC (rev 14326)
@@ -1281,7 +1281,7 @@
Mat3CpyMat4(mtx, G.obedit->obmat);
Mat3Inv(smtx, mtx);
-
+
td = t->data;
for(nu= editNurb.first; nu; nu= nu->next) {
if((nu->type & 7)==CU_BEZIER) {
@@ -1289,6 +1289,7 @@
head = tail = td;
for(a=0, bezt= nu->bezt; a<nu->pntsu; a++, bezt++) {
if(bezt->hide==0) {
+ TransDataCurveHandleFlags *hdata = NULL;
if( propmode ||
((bezt->f2 & SELECT) &&
(G.f & G_HIDDENHANDLES)) ||
@@ -1307,6 +1308,13 @@
td->ext = NULL;
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;
Mat3CpyMat3(td->smtx, smtx);
Mat3CpyMat3(td->mtx, mtx);
@@ -1338,7 +1346,18 @@
Mat3CpyMat3(td->smtx, smtx);
Mat3CpyMat3(td->mtx, mtx);
-
+
+ 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;
+ }
+
td++;
count++;
tail++;
@@ -1361,6 +1380,15 @@
td->tdi = NULL;
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;
+ }
+
Mat3CpyMat3(td->smtx, smtx);
Mat3CpyMat3(td->mtx, mtx);
@@ -1376,6 +1404,8 @@
}
if (propmode && head != tail)
calc_distanceCurveVerts(head, tail-1);
+
+ testhandlesNurb(nu); /* sets the handles based on their
selection, do this after the data is copied to the TransData */
}
else {
TransData *head, *tail;
@@ -1789,7 +1819,7 @@
td->ext = NULL;
td->tdi = NULL;
td->val = NULL;
- td->tdmir= NULL;
+ td->misc.tdmir= NULL;
if (BIF_GetTransInfo()->mode == TFM_BWEIGHT) {
td->val = &(eve->bweight);
td->ival = eve->bweight;
@@ -2142,7 +2172,7 @@
/* Mirror? */
if( (mirror>0 && tob->iloc[0]>0.0f) ||
(mirror<0 && tob->iloc[0]<0.0f)) {
EditVert *vmir=
editmesh_get_x_mirror_vert(G.obedit, tob->iloc); /* initializes octree
on first call */
- if(vmir!=eve) tob->tdmir= vmir;
+ if(vmir!=eve) tob->misc.tdmir= vmir;
}
tob++;
}
Modified: trunk/blender/source/blender/src/transform_generics.c
===================================================================
--- trunk/blender/source/blender/src/transform_generics.c 2008-04-04
12:33:01 UTC (rev 14325)
+++ trunk/blender/source/blender/src/transform_generics.c 2008-04-04
15:06:50 UTC (rev 14326)
@@ -255,7 +255,7 @@
if (td->flag & TD_SKIP)
continue;
- eve= td->tdmir;
+ eve= td->misc.tdmir;
if(eve) {
eve->co[0]= -td->loc[0];
eve->co[1]= td->loc[1];
@@ -325,8 +325,11 @@
if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
/* watch it: if the time is wrong: do not
correct handles */
- if (test_time_ipocurve(ei->icu)) dosort++;
- else testhandles_ipocurve(ei->icu);
+ if (test_time_ipocurve(ei->icu)) {
+ dosort++;
+ } else {
+ calchandles_ipocurve(ei->icu);
+ }
}
}
@@ -398,13 +401,20 @@
Nurb *nu= editNurb.first;
DAG_object_flush_update(G.scene, G.obedit,
OB_RECALC_DATA); /* sets recalc flags */
- while(nu) {
- test2DNurb(nu);
- testhandlesNurb(nu); /* test for bezier too */
- nu= nu->next;
+ if (t->state == TRANS_CANCEL) {
+ while(nu) {
+ calchandlesNurb(nu); /* Cant do
testhandlesNurb here, it messes up the h1 and h2 flags */
+ nu= nu->next;
+ }
+ } else {
+ /* Normal updating */
+ while(nu) {
+ test2DNurb(nu);
+ calchandlesNurb(nu);
+ nu= nu->next;
+ }
+ retopo_do_all();
}
-
- retopo_do_all();
}
else if(G.obedit->type==OB_ARMATURE){ /* no recalc flag, does
pose */
bArmature *arm= G.obedit->data;
@@ -711,6 +721,7 @@
/* since ipokeys are optional on objects, we mallocced them per
trans-data */
for(a=0, td= t->data; a<t->total; a++, td++) {
if(td->tdi) MEM_freeN(td->tdi);
+ if (td->flag & TD_BEZTRIPLE) MEM_freeN(td->misc.hdata);
}
MEM_freeN(t->data);
}
@@ -774,6 +785,12 @@
}
}
}
+
+ if (td->flag & TD_BEZTRIPLE) {
+ *(td->misc.hdata->h1) = td->misc.hdata->ih1;
+ *(td->misc.hdata->h2) = td->misc.hdata->ih2;
+ }
+
if(td->tdi) {
TransDataIpokey *tdi= td->tdi;
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs