diff options
author | Jiri Hnidek <jiri.hnidek@tul.cz> | 2005-04-11 23:31:05 +0400 |
---|---|---|
committer | Jiri Hnidek <jiri.hnidek@tul.cz> | 2005-04-11 23:31:05 +0400 |
commit | 78939c0cc06a67dbf2853ed7d030b9829b812e3f (patch) | |
tree | 4a1050d0c6f172bed54dea52d9faf91f2542e24c | |
parent | 52b7b978e319d7cef224601b57350cc63a99faaa (diff) |
- It is possible to scale radius of MetaElem again.
- It is possible to change dx, dy and dz params in 3Dview with manipulators
or with some shortcuts (S-X, S-Y, S-Z).
- User can scale stiffness when green circle is selected.
- MetaElem is selected with RMB click at green or red circle, then user can
grab or rotate with MetaElem as usual.
- Screenshot:
http://e-learning.vslib.cz/~hnidek/pics/scale_stiffness.jpg
- Captured video:
http://e-learning.vslib.cz/~hnidek/captured-videos/scale_stiffness.avi
-rwxr-xr-x | source/blender/include/transform.h | 3 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_meta_types.h | 3 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Metaball.c | 4 | ||||
-rw-r--r-- | source/blender/src/drawobject.c | 19 | ||||
-rw-r--r-- | source/blender/src/editmball.c | 19 | ||||
-rw-r--r-- | source/blender/src/editview.c | 9 | ||||
-rwxr-xr-x | source/blender/src/transform.c | 3 | ||||
-rwxr-xr-x | source/blender/src/transform_conversions.c | 15 |
8 files changed, 57 insertions, 18 deletions
diff --git a/source/blender/include/transform.h b/source/blender/include/transform.h index 7e54132939d..1d42861e07c 100755 --- a/source/blender/include/transform.h +++ b/source/blender/include/transform.h @@ -197,7 +197,8 @@ typedef struct TransInfo { #define TD_SELECTED 1 #define TD_NOACTION 2 #define TD_USEQUAT 4 -#define TD_NOTCONNECTED 8 +#define TD_NOTCONNECTED 8 +#define TD_SINGLESIZE 16 /* used for scaling of MetaElem->rad */ void initWarp(TransInfo *t); int Warp(TransInfo *t, short mval[2]); diff --git a/source/blender/makesdna/DNA_meta_types.h b/source/blender/makesdna/DNA_meta_types.h index 0760f35540b..f4c9c85c65b 100644 --- a/source/blender/makesdna/DNA_meta_types.h +++ b/source/blender/makesdna/DNA_meta_types.h @@ -48,7 +48,7 @@ typedef struct MetaElem { struct BoundBox *bb; /* Bound Box of MetaElem */ int i1,j1,k1, i2,j2,k2; /* corners of Bounding Box in lattice */ - short type, lay, flag, selcol; + short type, flag, selcol1, selcol2; float x, y, z; /* Position of centre of MetaElem */ float quat[4]; /* Rotation of MetaElem */ float expx, expy, expz; /* dx, dy, dz parameters */ @@ -104,6 +104,7 @@ typedef struct MetaBall { /* ml->flag */ #define MB_NEGATIVE 2 #define MB_HIDE 8 +#define MB_SCALE_RAD 16 #endif diff --git a/source/blender/python/api2_2x/Metaball.c b/source/blender/python/api2_2x/Metaball.c index 67645d61d2e..eb19cf47c6a 100644 --- a/source/blender/python/api2_2x/Metaball.c +++ b/source/blender/python/api2_2x/Metaball.c @@ -410,7 +410,7 @@ static PyObject *Metaball_addMetaelem( BPy_Metaball * self, PyObject * args ) { MetaElem *ml; PyObject *listargs = 0; - int type, lay; + int type; float x, y, z, rad, s, expx, expy, expz; if( !PyArg_ParseTuple( args, "O", &listargs ) ) return ( EXPP_ReturnPyObjError @@ -425,7 +425,6 @@ static PyObject *Metaball_addMetaelem( BPy_Metaball * self, PyObject * args ) y = PyFloat_AsDouble( PyList_GetItem( listargs, 2 ) ); z = PyFloat_AsDouble( PyList_GetItem( listargs, 3 ) ); rad = PyFloat_AsDouble( PyList_GetItem( listargs, 4 ) ); - lay = PyInt_AsLong( PyList_GetItem( listargs, 5 ) ); s = PyFloat_AsDouble( PyList_GetItem( listargs, 6 ) ); expx = PyFloat_AsDouble( PyList_GetItem( listargs, 7 ) ); expy = PyFloat_AsDouble( PyList_GetItem( listargs, 8 ) ); @@ -438,7 +437,6 @@ static PyObject *Metaball_addMetaelem( BPy_Metaball * self, PyObject * args ) ml->y = y; ml->z = z; ml->rad = rad; - ml->lay = lay; ml->s = s; ml->flag = SELECT; ml->type = type; diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index e8edfdb02ab..262bf839327 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -2979,17 +2979,30 @@ static void drawmball(Object *ob, int dt) Normalise(imat[1]); while(ml) { - + + /* draw radius */ if(ob==G.obedit) { - if(ml->flag & SELECT) cpack(0xA0A0F0); + if((ml->flag & SELECT) && (ml->flag & MB_SCALE_RAD)) cpack(0xA0A0F0); else cpack(0x3030A0); if(G.f & G_PICKSEL) { - ml->selcol= code; + ml->selcol1= code; glLoadName(code++); } } drawcircball(&(ml->x), ml->rad, imat); + + /* draw stiffness */ + if(ob==G.obedit) { + if((ml->flag & SELECT) && !(ml->flag & MB_SCALE_RAD)) cpack(0xA0F0A0); + else cpack(0x30A030); + + if(G.f & G_PICKSEL) { + ml->selcol2= code; + glLoadName(code++); + } + } + drawcircball(&(ml->x), ml->rad*atan(ml->s)/M_PI_2, imat); ml= ml->next; } diff --git a/source/blender/src/editmball.c b/source/blender/src/editmball.c index 39b4fd4b99b..598125db08f 100644 --- a/source/blender/src/editmball.c +++ b/source/blender/src/editmball.c @@ -177,9 +177,8 @@ void add_primitiveMball(int dummy_argument) ml->quat[2]= 0.0; ml->quat[3]= 0.0; ml->rad= 2.0; - ml->lay= 1; ml->s= 2.0; - ml->flag= SELECT; + ml->flag= SELECT | MB_SCALE_RAD; switch(dummy_argument) { case 1: @@ -258,13 +257,19 @@ void mouse_mball() if(hits>0) { ml= startelem; while(ml) { - /* if(base->lay & G.vd->lay) { */ - for(a=0; a<hits; a++) { - /* index converted for gl stuff */ - if(ml->selcol==buffer[ 4 * a + 3 ]) act= ml; + for(a=0; a<hits; a++) { + /* index converted for gl stuff */ + if(ml->selcol1==buffer[ 4 * a + 3 ]){ + ml->flag |= MB_SCALE_RAD; + act= ml; } - /* } */ + if(ml->selcol2==buffer[ 4 * a + 3 ]){ + ml->flag &= ~MB_SCALE_RAD; + act= ml; + } + + } if(act) break; diff --git a/source/blender/src/editview.c b/source/blender/src/editview.c index 7caeb5482c9..35642e8f25b 100644 --- a/source/blender/src/editview.c +++ b/source/blender/src/editview.c @@ -1400,7 +1400,14 @@ void borderselect(void) while(ml) { for(a=0; a<hits; a++) { - if(ml->selcol==buffer[ (4 * a) + 3 ]) { + if(ml->selcol1==buffer[ (4 * a) + 3 ]) { + ml->flag |= MB_SCALE_RAD; + if(val==LEFTMOUSE) ml->flag |= SELECT; + else ml->flag &= ~SELECT; + break; + } + if(ml->selcol2==buffer[ (4 * a) + 3 ]) { + ml->flag &= ~MB_SCALE_RAD; if(val==LEFTMOUSE) ml->flag |= SELECT; else ml->flag &= ~SELECT; break; diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c index 7358e68e4ff..525fea4ba3e 100755 --- a/source/blender/src/transform.c +++ b/source/blender/src/transform.c @@ -1021,6 +1021,9 @@ int Resize(TransInfo *t, short mval[2]) add_tdi_poin(tdi->sizez, tdi->oldsize+2, vec[2]); } + else if((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)){ + *td->val = td->ival * fsize[0] * td->factor; + } else { td->ext->size[0] = td->ext->isize[0] * (fsize[0]) * td->factor; td->ext->size[1] = td->ext->isize[1] * (fsize[1]) * td->factor; diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c index 9af53634dd5..2d2214b20b9 100755 --- a/source/blender/src/transform_conversions.c +++ b/source/blender/src/transform_conversions.c @@ -591,7 +591,7 @@ static void createTransMBallVerts(TransInfo *t) VECCOPY(td->iloc, td->loc); VECCOPY(td->center, td->loc); - if(ml->flag & SELECT) td->flag= TD_SELECTED | TD_USEQUAT; + if(ml->flag & SELECT) td->flag= TD_SELECTED | TD_USEQUAT | TD_SINGLESIZE; else td->flag= TD_USEQUAT; Mat3CpyMat3(td->smtx, smtx); @@ -599,13 +599,24 @@ static void createTransMBallVerts(TransInfo *t) td->ext = tx; td->tdi = NULL; - td->val = NULL; + /* Radius of MetaElem (mass of MetaElem influence) */ + if(ml->flag & MB_SCALE_RAD){ + td->val = &ml->rad; + td->ival = ml->rad; + } + else{ + td->val = &ml->s; + td->ival = ml->s; + } + + /* expx/expy/expz determine "shape" of some MetaElem types */ tx->size = &ml->expx; tx->isize[0] = ml->expx; tx->isize[1] = ml->expy; tx->isize[2] = ml->expz; + /* quat is used for rotation of MetaElem */ tx->quat = ml->quat; QUATCOPY(tx->iquat, ml->quat); |