diff options
author | Jiri Hnidek <jiri.hnidek@tul.cz> | 2005-03-29 14:03:30 +0400 |
---|---|---|
committer | Jiri Hnidek <jiri.hnidek@tul.cz> | 2005-03-29 14:03:30 +0400 |
commit | 53437f95368aac4263fc4c68d2691bf61d1dc353 (patch) | |
tree | 06e7240ff2934af98b50551500c2f875dfa1d846 | |
parent | ea92a5619384fe3d7365998c3c54394e4df7c76c (diff) |
- it is possible to rotate with MetaBalls in edit mode now
-rw-r--r-- | source/blender/blenkernel/intern/mball.c | 12 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_meta_types.h | 8 | ||||
-rw-r--r-- | source/blender/src/editmball.c | 4 | ||||
-rwxr-xr-x | source/blender/src/transform.c | 25 |
4 files changed, 33 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 4d3782e3a85..540c81b5fc4 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -1446,7 +1446,7 @@ float init_meta(Object *ob) /* return totsize */ MetaBall *mb; MetaElem *ml; float size, totsize, (*mat)[4] = NULL, (*imat)[4] = NULL, obinv[4][4], vec[3]; - float temp1[4][4], temp2[4][4], max=0.0; + float temp1[4][4], temp2[4][4], temp3[4][4], max=0.0; int a, obnr; char obname[32]; @@ -1485,10 +1485,16 @@ float init_meta(Object *ob) /* return totsize */ } while(ml) { if(!(ml->flag & MB_HIDE)) { + /* Rotation of MetaElem is stored in quat */ + QuatToMat4(ml->quat, temp3); + + /* Translation of MetaElem */ Mat4One(temp2); temp2[3][0]= ml->x; temp2[3][1]= ml->y; temp2[3][2]= ml->z; + + Mat4MulMat4(temp1, temp3, temp2); /* make a copy because of duplicates */ mainb[a]= new_pgn_element(sizeof(MetaElem)); @@ -1500,9 +1506,9 @@ float init_meta(Object *ob) /* return totsize */ /* mat is the matrix to transform from mball into the basis-mball */ Mat4Invert(obinv, ob->obmat); - Mat4MulMat4(temp1, bob->obmat, obinv); + Mat4MulMat4(temp2, bob->obmat, obinv); /* MetaBall transformation */ - Mat4MulMat4(mat, temp2, temp1); + Mat4MulMat4(mat, temp1, temp2); Mat4Invert(imat,mat); diff --git a/source/blender/makesdna/DNA_meta_types.h b/source/blender/makesdna/DNA_meta_types.h index 4562080a7c0..0760f35540b 100644 --- a/source/blender/makesdna/DNA_meta_types.h +++ b/source/blender/makesdna/DNA_meta_types.h @@ -50,9 +50,9 @@ typedef struct MetaElem { short type, lay, flag, selcol; float x, y, z; /* Position of centre of MetaElem */ - float expx, expy, expz; - float rad, rad2, s, len, maxrad2; - int pad; + float quat[4]; /* Rotation of MetaElem */ + float expx, expy, expz; /* dx, dy, dz parameters */ + float rad, rad2, s, len; float *mat, *imat; @@ -103,7 +103,7 @@ typedef struct MetaBall { /* ml->flag */ #define MB_NEGATIVE 2 -#define MB_HIDE 4 +#define MB_HIDE 8 #endif diff --git a/source/blender/src/editmball.c b/source/blender/src/editmball.c index e68d8665949..0cb3cb1b3b9 100644 --- a/source/blender/src/editmball.c +++ b/source/blender/src/editmball.c @@ -172,6 +172,10 @@ void add_primitiveMball(int dummy_argument) ml->x= cent[0]; ml->y= cent[1]; ml->z= cent[2]; + ml->quat[0]= 1.0; + ml->quat[1]= 0.0; + ml->quat[2]= 0.0; + ml->quat[3]= 0.0; ml->rad= 2.0; ml->lay= 1; ml->s= 2.0; diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c index 8b4fcde8e6e..990828bdcd4 100755 --- a/source/blender/src/transform.c +++ b/source/blender/src/transform.c @@ -494,7 +494,7 @@ static void createTransMBallVerts(void) int propmode = G.f & G_PROPORTIONAL; /* count totals */ - for(ml= editelems.first; ml; ml= ml->next) { + for(ml= editelems.first; ml; ml= ml->next) { if(ml->flag & SELECT) countsel++; if(propmode) count++; } @@ -512,13 +512,15 @@ static void createTransMBallVerts(void) Mat3Inv(smtx, mtx); td = Trans.data; - for(ml= editelems.first; ml; ml= ml->next) { + for(ml= editelems.first; ml; ml= ml->next) { if(propmode || (ml->flag & SELECT)) { td->loc= &ml->x; VECCOPY(td->iloc, td->loc); VECCOPY(td->center, td->loc); - if(ml->flag & SELECT) td->flag= TD_SELECTED; + + if(ml->flag & SELECT) td->flag= TD_SELECTED | TD_USEQUAT; else td->flag= 0; + Mat3CpyMat3(td->smtx, smtx); Mat3CpyMat3(td->mtx, mtx); @@ -531,6 +533,9 @@ static void createTransMBallVerts(void) tx->isize[1] = ml->expy; tx->isize[2] = ml->expz; + tx->quat = ml->quat; + QUATCOPY(tx->iquat, ml->quat); + tx->rot = NULL; td++; @@ -2353,6 +2358,8 @@ void initRotation(TransInfo *t) static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3]) { float vec[3], totmat[3][3], smat[3][3]; + float eul[3], fmat[3][3], quat[4]; + if (t->flag & T_EDIT) { Mat3MulMat3(totmat, mat, td->mtx); Mat3MulMat3(smat, td->smtx, totmat); @@ -2361,10 +2368,14 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3]) { Mat3MulVecfl(smat, vec); VecAddf(td->loc, vec, t->center); + + if(td->flag & TD_USEQUAT) { + Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); + Mat3ToQuat(fmat, quat); // Actual transform + QuatMul(td->ext->quat, quat, td->ext->iquat); + } } else { - float eul[3], fmat[3][3]; - /* translation */ VecSubf(vec, td->center, t->center); Mat3MulVecfl(mat, vec); @@ -2376,12 +2387,8 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3]) { VecAddf(td->loc, td->iloc, vec); if(td->flag & TD_USEQUAT) { - float quat[4]; - Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); - Mat3ToQuat(fmat, quat); // Actual transform - QuatMul(td->ext->quat, quat, td->ext->iquat); } else if ((G.vd->flag & V3D_ALIGN)==0) { // align mode doesn't rotate objects itself |