- it is possible to rotate with MetaBalls in edit mode now
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user