forked from bartvdbraak/blender
Revision 14869 merged from apricot
---------------------------------- Centralize handling of individual center for rotations
This commit is contained in:
parent
d5c80a3a1b
commit
8c68895741
@ -2415,15 +2415,28 @@ void initRotation(TransInfo *t)
|
|||||||
static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3]) {
|
static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3]) {
|
||||||
float vec[3], totmat[3][3], smat[3][3];
|
float vec[3], totmat[3][3], smat[3][3];
|
||||||
float eul[3], fmat[3][3], quat[4];
|
float eul[3], fmat[3][3], quat[4];
|
||||||
|
float *center = t->center;
|
||||||
|
|
||||||
|
/* local constraint shouldn't alter center */
|
||||||
|
if (t->around == V3D_LOCAL) {
|
||||||
|
if (t->flag & (T_OBJECT|T_POSE)) {
|
||||||
|
center = td->center;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(G.vd->around==V3D_LOCAL && (G.scene->selectmode & SCE_SELECT_FACE)) {
|
||||||
|
center = td->center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (t->flag & T_POINTS) {
|
if (t->flag & T_POINTS) {
|
||||||
Mat3MulMat3(totmat, mat, td->mtx);
|
Mat3MulMat3(totmat, mat, td->mtx);
|
||||||
Mat3MulMat3(smat, td->smtx, totmat);
|
Mat3MulMat3(smat, td->smtx, totmat);
|
||||||
|
|
||||||
VecSubf(vec, td->iloc, t->center);
|
VecSubf(vec, td->iloc, center);
|
||||||
Mat3MulVecfl(smat, vec);
|
Mat3MulVecfl(smat, vec);
|
||||||
|
|
||||||
VecAddf(td->loc, vec, t->center);
|
VecAddf(td->loc, vec, center);
|
||||||
|
|
||||||
VecSubf(vec,td->loc,td->iloc);
|
VecSubf(vec,td->loc,td->iloc);
|
||||||
protectedTransBits(td->protectflag, vec);
|
protectedTransBits(td->protectflag, vec);
|
||||||
@ -2460,13 +2473,13 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3]) {
|
|||||||
Mat3CpyMat4(pmtx, t->poseobj->obmat);
|
Mat3CpyMat4(pmtx, t->poseobj->obmat);
|
||||||
Mat3Inv(imtx, pmtx);
|
Mat3Inv(imtx, pmtx);
|
||||||
|
|
||||||
VecSubf(vec, td->center, t->center);
|
VecSubf(vec, td->center, center);
|
||||||
|
|
||||||
Mat3MulVecfl(pmtx, vec); // To Global space
|
Mat3MulVecfl(pmtx, vec); // To Global space
|
||||||
Mat3MulVecfl(mat, vec); // Applying rotation
|
Mat3MulVecfl(mat, vec); // Applying rotation
|
||||||
Mat3MulVecfl(imtx, vec); // To Local space
|
Mat3MulVecfl(imtx, vec); // To Local space
|
||||||
|
|
||||||
VecAddf(vec, vec, t->center);
|
VecAddf(vec, vec, center);
|
||||||
/* vec now is the location where the object has to be */
|
/* vec now is the location where the object has to be */
|
||||||
|
|
||||||
VecSubf(vec, vec, td->center); // Translation needed from the initial location
|
VecSubf(vec, vec, td->center); // Translation needed from the initial location
|
||||||
@ -2495,9 +2508,9 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3]) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* translation */
|
/* translation */
|
||||||
VecSubf(vec, td->center, t->center);
|
VecSubf(vec, td->center, center);
|
||||||
Mat3MulVecfl(mat, vec);
|
Mat3MulVecfl(mat, vec);
|
||||||
VecAddf(vec, vec, t->center);
|
VecAddf(vec, vec, center);
|
||||||
/* vec now is the location where the object has to be */
|
/* vec now is the location where the object has to be */
|
||||||
VecSubf(vec, vec, td->center);
|
VecSubf(vec, vec, td->center);
|
||||||
Mat3MulVecfl(td->smtx, vec);
|
Mat3MulVecfl(td->smtx, vec);
|
||||||
@ -2593,17 +2606,9 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3]) {
|
|||||||
static void applyRotation(TransInfo *t, float angle, float axis[3])
|
static void applyRotation(TransInfo *t, float angle, float axis[3])
|
||||||
{
|
{
|
||||||
TransData *td = t->data;
|
TransData *td = t->data;
|
||||||
float mat[3][3], center[3];
|
float mat[3][3];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* saving original center */
|
|
||||||
if (t->around == V3D_LOCAL) {
|
|
||||||
VECCOPY(center, t->center);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
center[0] = center[1] = center[2] = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
VecRotToMat3(axis, angle, mat);
|
VecRotToMat3(axis, angle, mat);
|
||||||
|
|
||||||
for(i = 0 ; i < t->total; i++, td++) {
|
for(i = 0 ; i < t->total; i++, td++) {
|
||||||
@ -2614,18 +2619,6 @@ static void applyRotation(TransInfo *t, float angle, float axis[3])
|
|||||||
if (td->flag & TD_SKIP)
|
if (td->flag & TD_SKIP)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* local constraint shouldn't alter center */
|
|
||||||
if (t->around == V3D_LOCAL) {
|
|
||||||
if (t->flag & (T_OBJECT|T_POSE)) {
|
|
||||||
VECCOPY(t->center, td->center);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(G.vd->around==V3D_LOCAL && (G.scene->selectmode & SCE_SELECT_FACE)) {
|
|
||||||
VECCOPY(t->center, td->center);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t->con.applyRot) {
|
if (t->con.applyRot) {
|
||||||
t->con.applyRot(t, td, axis);
|
t->con.applyRot(t, td, axis);
|
||||||
VecRotToMat3(axis, angle * td->factor, mat);
|
VecRotToMat3(axis, angle * td->factor, mat);
|
||||||
@ -2636,11 +2629,6 @@ static void applyRotation(TransInfo *t, float angle, float axis[3])
|
|||||||
|
|
||||||
ElementRotation(t, td, mat);
|
ElementRotation(t, td, mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* restoring original center */
|
|
||||||
if (t->around == V3D_LOCAL) {
|
|
||||||
VECCOPY(t->center, center);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Rotation(TransInfo *t, short mval[2])
|
int Rotation(TransInfo *t, short mval[2])
|
||||||
@ -2737,7 +2725,6 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a
|
|||||||
{
|
{
|
||||||
TransData *td = t->data;
|
TransData *td = t->data;
|
||||||
float mat[3][3], smat[3][3], totmat[3][3];
|
float mat[3][3], smat[3][3], totmat[3][3];
|
||||||
float center[3];
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
VecRotToMat3(axis1, angles[0], smat);
|
VecRotToMat3(axis1, angles[0], smat);
|
||||||
@ -2752,20 +2739,6 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a
|
|||||||
if (td->flag & TD_SKIP)
|
if (td->flag & TD_SKIP)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
VECCOPY(center, t->center);
|
|
||||||
|
|
||||||
if (t->around == V3D_LOCAL) {
|
|
||||||
/* local-mode shouldn't change center */
|
|
||||||
if (t->flag & (T_OBJECT|T_POSE)) {
|
|
||||||
VECCOPY(t->center, td->center);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(G.vd->around==V3D_LOCAL && (G.scene->selectmode & SCE_SELECT_FACE)) {
|
|
||||||
VECCOPY(t->center, td->center);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t->flag & T_PROP_EDIT) {
|
if (t->flag & T_PROP_EDIT) {
|
||||||
VecRotToMat3(axis1, td->factor * angles[0], smat);
|
VecRotToMat3(axis1, td->factor * angles[0], smat);
|
||||||
VecRotToMat3(axis2, td->factor * angles[1], totmat);
|
VecRotToMat3(axis2, td->factor * angles[1], totmat);
|
||||||
@ -2774,8 +2747,6 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a
|
|||||||
}
|
}
|
||||||
|
|
||||||
ElementRotation(t, td, mat);
|
ElementRotation(t, td, mat);
|
||||||
|
|
||||||
VECCOPY(t->center, center);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user