Local axis constraint external call. Had to do it in a very hackish way which highlight a design problem in the code. To solve it (and would solve other problems too), we'd have to split off the initialisation function. Not terribly hard to do but I'm overwhelmed with work...
Push/Pull had a problem with constraints enabling/disabling. Fixed Restablished infinite line for constraint draw (when not using manipulator) as discussed in meeting.
This commit is contained in:
@@ -56,6 +56,7 @@
|
|||||||
#define CTX_EDGE 2
|
#define CTX_EDGE 2
|
||||||
#define CTX_NO_PET 4
|
#define CTX_NO_PET 4
|
||||||
#define CTX_NO_NOR_RECALC 8
|
#define CTX_NO_NOR_RECALC 8
|
||||||
|
#define CTX_SETLOCALCONST 16
|
||||||
|
|
||||||
/* TRANSFORM PROPORTIONAL FALLOFF MODES */
|
/* TRANSFORM PROPORTIONAL FALLOFF MODES */
|
||||||
#define PROP_SHARP 0
|
#define PROP_SHARP 0
|
||||||
@@ -74,6 +75,8 @@ struct ScrArea;
|
|||||||
struct TransInfo * BIF_GetTransInfo(void);
|
struct TransInfo * BIF_GetTransInfo(void);
|
||||||
void BIF_setSingleAxisConstraint(float vec[3], char *text);
|
void BIF_setSingleAxisConstraint(float vec[3], char *text);
|
||||||
void BIF_setDualAxisConstraint(float vec1[3], float vec2[3], char *text);
|
void BIF_setDualAxisConstraint(float vec1[3], float vec2[3], char *text);
|
||||||
|
void BIF_setLocalAxisConstraint(char axis, char *text);
|
||||||
|
void BIF_setLocalLockConstraint(char axis, char *text);
|
||||||
void BIF_drawConstraint(void);
|
void BIF_drawConstraint(void);
|
||||||
void BIF_drawPropCircle(void);
|
void BIF_drawPropCircle(void);
|
||||||
|
|
||||||
|
|||||||
@@ -1154,13 +1154,16 @@ void do_view3d_transform_moveaxismenu(void *arg, int event)
|
|||||||
Transform(TFM_TRANSLATION, CTX_NONE);
|
Transform(TFM_TRANSLATION, CTX_NONE);
|
||||||
break;
|
break;
|
||||||
case 3: /* X Local */
|
case 3: /* X Local */
|
||||||
// transform('g'*'x');
|
BIF_setLocalAxisConstraint('X', " X");
|
||||||
|
Transform(TFM_TRANSLATION, CTX_SETLOCALCONST);
|
||||||
break;
|
break;
|
||||||
case 4: /* Y Local */
|
case 4: /* Y Local */
|
||||||
// transform('g'*'y');
|
BIF_setLocalAxisConstraint('Y', " Y");
|
||||||
|
Transform(TFM_TRANSLATION, CTX_SETLOCALCONST);
|
||||||
break;
|
break;
|
||||||
case 5: /* Z Local */
|
case 5: /* Z Local */
|
||||||
// transform('g'*'z');
|
BIF_setLocalAxisConstraint('Z', " Z");
|
||||||
|
Transform(TFM_TRANSLATION, CTX_SETLOCALCONST);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
allqueue(REDRAWVIEW3D, 0);
|
allqueue(REDRAWVIEW3D, 0);
|
||||||
@@ -1211,13 +1214,16 @@ void do_view3d_transform_rotateaxismenu(void *arg, int event)
|
|||||||
Transform(TFM_ROTATION, CTX_NONE);
|
Transform(TFM_ROTATION, CTX_NONE);
|
||||||
break;
|
break;
|
||||||
case 3: /* X Local */
|
case 3: /* X Local */
|
||||||
// transform('r'*'x');
|
BIF_setLocalAxisConstraint('X', " X");
|
||||||
|
Transform(TFM_ROTATION, CTX_SETLOCALCONST);
|
||||||
break;
|
break;
|
||||||
case 4: /* Y Local */
|
case 4: /* Y Local */
|
||||||
// transform('r'*'y');
|
BIF_setLocalAxisConstraint('Y', " Y");
|
||||||
|
Transform(TFM_ROTATION, CTX_SETLOCALCONST);
|
||||||
break;
|
break;
|
||||||
case 5: /* Z Local */
|
case 5: /* Z Local */
|
||||||
// transform('r'*'z');
|
BIF_setLocalAxisConstraint('Z', " Z");
|
||||||
|
Transform(TFM_ROTATION, CTX_SETLOCALCONST);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
allqueue(REDRAWVIEW3D, 0);
|
allqueue(REDRAWVIEW3D, 0);
|
||||||
@@ -1268,13 +1274,16 @@ void do_view3d_transform_scaleaxismenu(void *arg, int event)
|
|||||||
Transform(TFM_RESIZE, CTX_NONE);
|
Transform(TFM_RESIZE, CTX_NONE);
|
||||||
break;
|
break;
|
||||||
case 3: /* X Local */
|
case 3: /* X Local */
|
||||||
|
BIF_setLocalAxisConstraint('X', " X");
|
||||||
|
Transform(TFM_RESIZE, CTX_SETLOCALCONST);
|
||||||
break;
|
break;
|
||||||
case 4: /* Y Local */
|
case 4: /* Y Local */
|
||||||
|
BIF_setLocalAxisConstraint('X', " X");
|
||||||
|
Transform(TFM_RESIZE, CTX_SETLOCALCONST);
|
||||||
break;
|
break;
|
||||||
case 5: /* Z Local */
|
case 5: /* Z Local */
|
||||||
|
BIF_setLocalAxisConstraint('X', " X");
|
||||||
|
Transform(TFM_RESIZE, CTX_SETLOCALCONST);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
allqueue(REDRAWVIEW3D, 0);
|
allqueue(REDRAWVIEW3D, 0);
|
||||||
|
|||||||
@@ -233,6 +233,16 @@ void Transform(int mode, int context)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* CHECKING FOR CTX_SETLOCALCONST CONTEXT FLAG */
|
||||||
|
/* EVIL, best would be to split off init, this way all the external constraint call could work like that:
|
||||||
|
initTransform(mode)
|
||||||
|
initconstraint(setup)
|
||||||
|
Transform()
|
||||||
|
*/
|
||||||
|
if (Trans.context & CTX_SETLOCALCONST) {
|
||||||
|
setLocalConstraint(&Trans, Trans.con.mode, Trans.con.text);
|
||||||
|
}
|
||||||
|
|
||||||
/* EVIL! posemode code can switch translation to rotate when 1 bone is selected. will be removed (ton) */
|
/* EVIL! posemode code can switch translation to rotate when 1 bone is selected. will be removed (ton) */
|
||||||
/* EVIL2: we gave as argument also texture space context bit... was cleared */
|
/* EVIL2: we gave as argument also texture space context bit... was cleared */
|
||||||
mode= Trans.mode;
|
mode= Trans.mode;
|
||||||
@@ -395,6 +405,7 @@ void Transform(int mode, int context)
|
|||||||
Trans.redraw= 1;
|
Trans.redraw= 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
cmode = '\0';
|
||||||
stopConstraint(&Trans);
|
stopConstraint(&Trans);
|
||||||
Trans.redraw = 1;
|
Trans.redraw = 1;
|
||||||
}
|
}
|
||||||
@@ -1899,7 +1910,7 @@ int PushPull(TransInfo *t, short mval[2])
|
|||||||
sprintf(str, "Push/Pull: %.4f%s %s", distance, t->con.text, t->proptext);
|
sprintf(str, "Push/Pull: %.4f%s %s", distance, t->con.text, t->proptext);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t->con.applyRot) {
|
if (t->con.applyRot && t->con.mode & CON_APPLY) {
|
||||||
t->con.applyRot(t, NULL, axis);
|
t->con.applyRot(t, NULL, axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1908,7 +1919,7 @@ int PushPull(TransInfo *t, short mval[2])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
VecSubf(vec, t->center, td->center);
|
VecSubf(vec, t->center, td->center);
|
||||||
if (t->con.applyRot) {
|
if (t->con.applyRot && t->con.mode & CON_APPLY) {
|
||||||
t->con.applyRot(t, td, axis);
|
t->con.applyRot(t, td, axis);
|
||||||
Projf(vec, vec, axis);
|
Projf(vec, vec, axis);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -541,6 +541,42 @@ void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[])
|
|||||||
t->redraw = 1;
|
t->redraw = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BIF_setLocalAxisConstraint(char axis, char *text) {
|
||||||
|
TransInfo *t = BIF_GetTransInfo();
|
||||||
|
|
||||||
|
strncpy(t->con.text, text, 48);
|
||||||
|
|
||||||
|
switch (axis) {
|
||||||
|
case 'X':
|
||||||
|
t->con.mode = (CON_AXIS0|CON_APPLY);
|
||||||
|
break;
|
||||||
|
case 'Y':
|
||||||
|
t->con.mode = (CON_AXIS1|CON_APPLY);
|
||||||
|
break;
|
||||||
|
case 'Z':
|
||||||
|
t->con.mode = (CON_AXIS2|CON_APPLY);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BIF_setLocalLockConstraint(char axis, char *text) {
|
||||||
|
TransInfo *t = BIF_GetTransInfo();
|
||||||
|
|
||||||
|
strncpy(t->con.text, text, 48);
|
||||||
|
|
||||||
|
switch (axis) {
|
||||||
|
case 'x':
|
||||||
|
t->con.mode = (CON_AXIS1|CON_AXIS2|CON_APPLY);
|
||||||
|
break;
|
||||||
|
case 'y':
|
||||||
|
t->con.mode = (CON_AXIS0|CON_AXIS2|CON_APPLY);
|
||||||
|
break;
|
||||||
|
case 'z':
|
||||||
|
t->con.mode = (CON_AXIS0|CON_AXIS1|CON_APPLY);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setLocalConstraint(TransInfo *t, int mode, const char text[]) {
|
void setLocalConstraint(TransInfo *t, int mode, const char text[]) {
|
||||||
if (t->flag & T_EDIT) {
|
if (t->flag & T_EDIT) {
|
||||||
float obmat[3][3];
|
float obmat[3][3];
|
||||||
@@ -650,11 +686,10 @@ void BIF_drawConstraint(void)
|
|||||||
window_to_3d(vec, (short)(mval[0] - t->con.imval[0]), (short)(mval[1] - t->con.imval[1]));
|
window_to_3d(vec, (short)(mval[0] - t->con.imval[0]), (short)(mval[1] - t->con.imval[1]));
|
||||||
VecAddf(vec, vec, tc->center);
|
VecAddf(vec, vec, tc->center);
|
||||||
|
|
||||||
// drawLine(tc->center, tc->mtx[0], 'x', 0);
|
drawLine(tc->center, tc->mtx[0], 'x', 0);
|
||||||
// drawLine(tc->center, tc->mtx[1], 'y', 0);
|
drawLine(tc->center, tc->mtx[1], 'y', 0);
|
||||||
// drawLine(tc->center, tc->mtx[2], 'z', 0);
|
drawLine(tc->center, tc->mtx[2], 'z', 0);
|
||||||
|
|
||||||
draw_manipulator_ext(curarea, t->mode, 'c', 2, tc->center, tc->mtx);
|
|
||||||
glColor3ubv(col2);
|
glColor3ubv(col2);
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
@@ -668,16 +703,13 @@ void BIF_drawConstraint(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tc->mode & CON_AXIS0) {
|
if (tc->mode & CON_AXIS0) {
|
||||||
draw_manipulator_ext(curarea, t->mode, 'x', 0, tc->center, tc->mtx);
|
drawLine(tc->center, tc->mtx[0], 'x', DRAWLIGHT);
|
||||||
// drawLine(tc->center, tc->mtx[0], 'x', DRAWLIGHT);
|
|
||||||
}
|
}
|
||||||
if (tc->mode & CON_AXIS1) {
|
if (tc->mode & CON_AXIS1) {
|
||||||
draw_manipulator_ext(curarea, t->mode, 'y', 0, tc->center, tc->mtx);
|
drawLine(tc->center, tc->mtx[1], 'y', DRAWLIGHT);
|
||||||
// drawLine(tc->center, tc->mtx[1], 'y', DRAWLIGHT);
|
|
||||||
}
|
}
|
||||||
if (tc->mode & CON_AXIS2) {
|
if (tc->mode & CON_AXIS2) {
|
||||||
draw_manipulator_ext(curarea, t->mode, 'z', 0, tc->center, tc->mtx);
|
drawLine(tc->center, tc->mtx[2], 'z', DRAWLIGHT);
|
||||||
// drawLine(tc->center, tc->mtx[2], 'z', DRAWLIGHT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user