[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14869] branches/apricot/source/blender/ src/transform.c: Centralize handling of individual center for rotations
Martin Poirier
theeth at yahoo.com
Fri May 16 17:00:21 CEST 2008
Revision: 14869
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14869
Author: theeth
Date: 2008-05-16 17:00:21 +0200 (Fri, 16 May 2008)
Log Message:
-----------
Centralize handling of individual center for rotations
Modified Paths:
--------------
branches/apricot/source/blender/src/transform.c
Modified: branches/apricot/source/blender/src/transform.c
===================================================================
--- branches/apricot/source/blender/src/transform.c 2008-05-16 13:13:20 UTC (rev 14868)
+++ branches/apricot/source/blender/src/transform.c 2008-05-16 15:00:21 UTC (rev 14869)
@@ -2392,15 +2392,28 @@
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];
-
+ 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) {
Mat3MulMat3(totmat, mat, td->mtx);
Mat3MulMat3(smat, td->smtx, totmat);
- VecSubf(vec, td->iloc, t->center);
+ VecSubf(vec, td->iloc, center);
Mat3MulVecfl(smat, vec);
- VecAddf(td->loc, vec, t->center);
+ VecAddf(td->loc, vec, center);
VecSubf(vec,td->loc,td->iloc);
protectedTransBits(td->protectflag, vec);
@@ -2437,13 +2450,13 @@
Mat3CpyMat4(pmtx, t->poseobj->obmat);
Mat3Inv(imtx, pmtx);
- VecSubf(vec, td->center, t->center);
+ VecSubf(vec, td->center, center);
Mat3MulVecfl(pmtx, vec); // To Global space
Mat3MulVecfl(mat, vec); // Applying rotation
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 */
VecSubf(vec, vec, td->center); // Translation needed from the initial location
@@ -2472,9 +2485,9 @@
}
else {
/* translation */
- VecSubf(vec, td->center, t->center);
+ VecSubf(vec, td->center, center);
Mat3MulVecfl(mat, vec);
- VecAddf(vec, vec, t->center);
+ VecAddf(vec, vec, center);
/* vec now is the location where the object has to be */
VecSubf(vec, vec, td->center);
Mat3MulVecfl(td->smtx, vec);
@@ -2563,17 +2576,9 @@
static void applyRotation(TransInfo *t, float angle, float axis[3])
{
TransData *td = t->data;
- float mat[3][3], center[3];
+ float mat[3][3];
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);
for(i = 0 ; i < t->total; i++, td++) {
@@ -2584,18 +2589,6 @@
if (td->flag & TD_SKIP)
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) {
t->con.applyRot(t, td, axis);
VecRotToMat3(axis, angle * td->factor, mat);
@@ -2606,11 +2599,6 @@
ElementRotation(t, td, mat);
}
-
- /* restoring original center */
- if (t->around == V3D_LOCAL) {
- VECCOPY(t->center, center);
- }
}
int Rotation(TransInfo *t, short mval[2])
@@ -2707,7 +2695,6 @@
{
TransData *td = t->data;
float mat[3][3], smat[3][3], totmat[3][3];
- float center[3];
int i;
VecRotToMat3(axis1, angles[0], smat);
@@ -2722,20 +2709,6 @@
if (td->flag & TD_SKIP)
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) {
VecRotToMat3(axis1, td->factor * angles[0], smat);
VecRotToMat3(axis2, td->factor * angles[1], totmat);
@@ -2744,8 +2717,6 @@
}
ElementRotation(t, td, mat);
-
- VECCOPY(t->center, center);
}
}
More information about the Bf-blender-cvs
mailing list