Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2005-03-07 05:21:04 +0300
committerMartin Poirier <theeth@yahoo.com>2005-03-07 05:21:04 +0300
commit7b081fe3b7527a77fce9cd69f6a1d27dc19b4596 (patch)
tree42e035210209aacd93811b4fa50019ce2455dfe1 /source
parentb3b96acc73d2aa9c556fd7b17d47ee9feb19cc44 (diff)
Local axis constraint started.
Works with edit data and in object mode with single selections (only one object selected). Also started adding constraint stuff in headerprints. Only for Translation for now. Pressing X,Y,Z (and the Ctrl versions) toggle between global, local and off like it used to do.
Diffstat (limited to 'source')
-rwxr-xr-xsource/blender/src/transform.c91
-rwxr-xr-xsource/blender/src/transform_constraints.c54
-rwxr-xr-xsource/blender/src/transform_constraints.h3
-rwxr-xr-xsource/blender/src/transform_generics.c2
4 files changed, 114 insertions, 36 deletions
diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c
index 207ce5bab29..745aff06279 100755
--- a/source/blender/src/transform.c
+++ b/source/blender/src/transform.c
@@ -1196,6 +1196,7 @@ void Transform(int mode)
short pmval[2] = {0, 0}, mval[2], val;
float mati[3][3];
unsigned short event;
+ char cmode = '\0';
/*joeedh -> hopefully may be what makes the old transform() constant*/
/* ton: I doubt, but it doesnt harm for now. shouldnt be needed though */
@@ -1313,24 +1314,72 @@ void Transform(int mode)
restoreTransObjects(&Trans);
break;
case XKEY:
- if (G.qual == 0)
- setConstraint(&Trans, mati, (CON_APPLY|CON_AXIS0));
- else if (G.qual == LR_CTRLKEY)
- setConstraint(&Trans, mati, (CON_APPLY|CON_AXIS1|CON_AXIS2));
- break;
+ if (cmode == 'X') {
+ Trans.con.mode &= ~CON_APPLY;
+ cmode = '\0';
+ }
+ else if(cmode == 'x') {
+ if (G.qual == 0)
+ setLocalConstraint(&Trans, (CON_APPLY|CON_AXIS0), "along local X");
+ else if (G.qual == LR_CTRLKEY)
+ setLocalConstraint(&Trans, (CON_APPLY|CON_AXIS1|CON_AXIS2), "locking local X");
+
+ cmode = 'X';
+ }
+ else {
+ if (G.qual == 0)
+ setConstraint(&Trans, mati, (CON_APPLY|CON_AXIS0), "along global X");
+ else if (G.qual == LR_CTRLKEY)
+ setConstraint(&Trans, mati, (CON_APPLY|CON_AXIS1|CON_AXIS2), "locking global X");
+
+ cmode = 'x';
+ }
Trans.redraw = 1;
- case YKEY:
- if (G.qual == 0)
- setConstraint(&Trans, mati, (CON_APPLY|CON_AXIS1));
- else if (G.qual == LR_CTRLKEY)
- setConstraint(&Trans, mati, (CON_APPLY|CON_AXIS0|CON_AXIS2));
break;
+ case YKEY:
+ if (cmode == 'Y') {
+ Trans.con.mode &= ~CON_APPLY;
+ cmode = '\0';
+ }
+ else if(cmode == 'y') {
+ if (G.qual == 0)
+ setLocalConstraint(&Trans, (CON_APPLY|CON_AXIS1), "along global Y");
+ else if (G.qual == LR_CTRLKEY)
+ setLocalConstraint(&Trans, (CON_APPLY|CON_AXIS0|CON_AXIS2), "locking global Y");
+
+ cmode = 'Y';
+ }
+ else {
+ if (G.qual == 0)
+ setConstraint(&Trans, mati, (CON_APPLY|CON_AXIS1), "along local Y");
+ else if (G.qual == LR_CTRLKEY)
+ setConstraint(&Trans, mati, (CON_APPLY|CON_AXIS0|CON_AXIS2), "locking local Y");
+
+ cmode = 'y';
+ }
Trans.redraw = 1;
+ break;
case ZKEY:
- if (G.qual == 0)
- setConstraint(&Trans, mati, (CON_APPLY|CON_AXIS2));
- else if (G.qual == LR_CTRLKEY)
- setConstraint(&Trans, mati, (CON_APPLY|CON_AXIS0|CON_AXIS1));
+ if (cmode == 'Z') {
+ Trans.con.mode &= ~CON_APPLY;
+ cmode = '\0';
+ }
+ else if(cmode == 'z') {
+ if (G.qual == 0)
+ setLocalConstraint(&Trans, (CON_APPLY|CON_AXIS2), "along local Z");
+ else if (G.qual == LR_CTRLKEY)
+ setLocalConstraint(&Trans, (CON_APPLY|CON_AXIS0|CON_AXIS1), "locking local Z");
+
+ cmode = 'Z';
+ }
+ else {
+ if (G.qual == 0)
+ setConstraint(&Trans, mati, (CON_APPLY|CON_AXIS2), "along global Z");
+ else if (G.qual == LR_CTRLKEY)
+ setConstraint(&Trans, mati, (CON_APPLY|CON_AXIS0|CON_AXIS1), "locking global Z");
+
+ cmode = 'z';
+ }
Trans.redraw = 1;
break;
case OKEY:
@@ -1395,7 +1444,7 @@ void Transform(int mode)
if(mode==TFM_RESIZE) cmode= 's';
else if(mode==TFM_ROTATION) cmode= 'r';
/* aftertrans does displists, ipos and action channels */
- special_aftertrans_update(cmode, 0, ret_val == TRANS_CANCEL, 0 /*keyflags*/);
+ special_aftertrans_update(cmode, 0, (short)(ret_val == TRANS_CANCEL), 0 /*keyflags*/);
if(G.obedit==NULL && G.obpose==NULL)
clear_trans_object_base_flags();
@@ -1965,7 +2014,7 @@ int Translation(TransInfo *t, short mval[2])
{
float vec[3], tvec[3];
int i;
- char str[70];
+ char str[200];
TransData *td = t->data;
window_to_3d(vec, (short)(mval[0] - t->imval[0]), (short)(mval[1] - t->imval[1]));
@@ -1985,11 +2034,17 @@ int Translation(TransInfo *t, short mval[2])
outputNumInput(&(t->num), c);
- sprintf(str, "Dx: %s Dy: %s Dz: %s %s", &c[0], &c[20], &c[40], t->proptext);
+ if (t->con.mode & CON_APPLY)
+ sprintf(str, "Dx: %s Dy: %s Dz: %s %s %s", &c[0], &c[20], &c[40], t->con.text, t->proptext);
+ else
+ sprintf(str, "Dx: %s Dy: %s Dz: %s %s", &c[0], &c[20], &c[40], t->proptext);
}
else {
/* default header print */
- sprintf(str, "Dx: %.4f Dy: %.4f Dz: %.4f %s", vec[0], vec[1], vec[2], t->proptext);
+ if (t->con.mode & CON_APPLY)
+ sprintf(str, "Dx: %.4f Dy: %.4f Dz: %.4f %s %s", vec[0], vec[1], vec[2], t->con.text, t->proptext);
+ else
+ sprintf(str, "Dx: %.4f Dy: %.4f Dz: %.4f %s", vec[0], vec[1], vec[2], t->proptext);
}
diff --git a/source/blender/src/transform_constraints.c b/source/blender/src/transform_constraints.c
index d0d2a54c159..5a48620d272 100755
--- a/source/blender/src/transform_constraints.c
+++ b/source/blender/src/transform_constraints.c
@@ -337,20 +337,10 @@ int getConstraintSpaceDimension(TransInfo *t)
*/
}
-void BIF_setSingleAxisConstraint(float vec[3]) {
- TransInfo *t = BIF_GetTransInfo();
- float space[3][3], v[3];
- VECCOPY(space[0], vec);
-
- v[0] = vec[2];
- v[1] = vec[0];
- v[2] = vec[1];
-
- Crossf(space[1], vec, v);
- Crossf(space[2], vec, space[1]);
-
+void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]) {
+ strcpy(t->con.text, text);
Mat3CpyMat3(t->con.mtx, space);
- t->con.mode = (CON_AXIS0|CON_APPLY);
+ t->con.mode = mode;
getConstraintMatrix(t);
VECCOPY(t->con.center, t->center);
@@ -364,9 +354,35 @@ void BIF_setSingleAxisConstraint(float vec[3]) {
t->redraw = 1;
}
-void setConstraint(TransInfo *t, float space[3][3], int mode) {
+void setLocalConstraint(TransInfo *t, int mode, const char text[]) {
+ if (G.obedit) {
+ float obmat[3][3];
+ Mat3CpyMat4(obmat, G.obedit->obmat);
+ setConstraint(t, obmat, mode, text);
+ }
+ else {
+ if (t->total == 1) {
+ float obmat[3][3];
+ Mat3CpyMat4(obmat, t->data->ob->obmat);
+ setConstraint(t, obmat, mode, text);
+ }
+ }
+}
+
+void BIF_setSingleAxisConstraint(float vec[3]) {
+ TransInfo *t = BIF_GetTransInfo();
+ float space[3][3], v[3];
+ VECCOPY(space[0], vec);
+
+ v[0] = vec[2];
+ v[1] = vec[0];
+ v[2] = vec[1];
+
+ Crossf(space[1], vec, v);
+ Crossf(space[2], vec, space[1]);
+
Mat3CpyMat3(t->con.mtx, space);
- t->con.mode = mode;
+ t->con.mode = (CON_AXIS0|CON_APPLY);
getConstraintMatrix(t);
VECCOPY(t->con.center, t->center);
@@ -386,7 +402,7 @@ void BIF_drawConstraint()
TransInfo *t = BIF_GetTransInfo();
TransCon *tc = &(t->con);
- if (tc->mode == 0)
+ if (!(tc->mode & CON_APPLY))
return;
if (tc->mode & CON_SELECT) {
@@ -544,25 +560,31 @@ void setNearestAxis(TransInfo *t)
if (len[0] < len[1] && len[0] < len[2]) {
if (G.qual == LR_CTRLKEY) {
t->con.mode |= (CON_AXIS1|CON_AXIS2);
+ strcpy(t->con.text, "locking global X");
}
else {
t->con.mode |= CON_AXIS0;
+ strcpy(t->con.text, "along global X");
}
}
else if (len[1] < len[0] && len[1] < len[2]) {
if (G.qual == LR_CTRLKEY) {
t->con.mode |= (CON_AXIS0|CON_AXIS2);
+ strcpy(t->con.text, "locking global Y");
}
else {
t->con.mode |= CON_AXIS1;
+ strcpy(t->con.text, "along global Y");
}
}
else if (len[2] < len[1] && len[2] < len[0]) {
if (G.qual == LR_CTRLKEY) {
t->con.mode |= (CON_AXIS0|CON_AXIS1);
+ strcpy(t->con.text, "locking global Z");
}
else {
t->con.mode |= CON_AXIS2;
+ strcpy(t->con.text, "along global Z");
}
}
getConstraintMatrix(t);
diff --git a/source/blender/src/transform_constraints.h b/source/blender/src/transform_constraints.h
index 9719319e502..7ac5817e980 100755
--- a/source/blender/src/transform_constraints.h
+++ b/source/blender/src/transform_constraints.h
@@ -36,7 +36,8 @@
#include "transform.h"
void getConstraintMatrix(TransInfo *t);
-void setConstraint(TransInfo *t, float space[3][3], int mode);
+void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]);
+void setLocalConstraint(TransInfo *t, int mode, const char text[]);
//void drawConstraint(TransCon *t);
void drawConstraint();
diff --git a/source/blender/src/transform_generics.c b/source/blender/src/transform_generics.c
index a90b025a2dd..966d44868a3 100755
--- a/source/blender/src/transform_generics.c
+++ b/source/blender/src/transform_generics.c
@@ -635,7 +635,7 @@ void calculatePropRatio(TransInfo *t)
if (G.f & G_PROPORTIONAL) {
for(i = 0 ; i < t->total; i++, td++) {
- if (td->dist == 0.0f) {
+ if (td->flag & TD_SELECTED) {
td->factor = 1.0f;
}
else if (td->dist > t->propsize) {