NumInput is now applied correctly to constraints and prints correctly in the header.
What that means is that you can grab/resize an object, press Xkey, type 2 (to resize/move by 2 on the x axis) and then press Ykey and the numeric value will be applied to the transformation on the Y axis. Fixed a small glitch where constraint center wasn't readjusted for edit mode when using MMB (graphical bug only).
This commit is contained in:
@@ -1505,11 +1505,11 @@ void initWarp(TransInfo *t)
|
|||||||
Mat4MulVecfl(G.obedit->obmat, max);
|
Mat4MulVecfl(G.obedit->obmat, max);
|
||||||
Mat4MulVecfl(G.vd->viewmat, max);
|
Mat4MulVecfl(G.vd->viewmat, max);
|
||||||
|
|
||||||
t->center[0]= (min[0]+max[0])/2.0;
|
t->center[0]= (min[0]+max[0])/2.0f;
|
||||||
t->center[1]= (min[1]+max[1])/2.0;
|
t->center[1]= (min[1]+max[1])/2.0f;
|
||||||
t->center[2]= (min[2]+max[2])/2.0;
|
t->center[2]= (min[2]+max[2])/2.0f;
|
||||||
|
|
||||||
t->val= (max[0]-min[0])/2.0; // t->val is free variable
|
t->val= (max[0]-min[0])/2.0f; // t->val is free variable
|
||||||
|
|
||||||
Mat4Invert(G.obedit->imat, G.obedit->obmat);
|
Mat4Invert(G.obedit->imat, G.obedit->obmat);
|
||||||
}
|
}
|
||||||
@@ -1690,6 +1690,34 @@ void initResize(TransInfo *t)
|
|||||||
t->transform = Resize;
|
t->transform = Resize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void headerResize(TransInfo *t, float vec[3], char *str) {
|
||||||
|
char tvec[60];
|
||||||
|
if (hasNumInput(&t->num)) {
|
||||||
|
outputNumInput(&(t->num), tvec);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sprintf(&tvec[0], "%.4f", vec[0]);
|
||||||
|
sprintf(&tvec[20], "%.4f", vec[1]);
|
||||||
|
sprintf(&tvec[40], "%.4f", vec[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t->con.mode & CON_APPLY) {
|
||||||
|
switch(t->num.idx_max) {
|
||||||
|
case 0:
|
||||||
|
sprintf(str, "Size: %s%s %s", &tvec[0], t->con.text, t->proptext);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
sprintf(str, "Size: %s : %s%s %s", &tvec[0], &tvec[20], t->con.text, t->proptext);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
sprintf(str, "Size: %s : %s : %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sprintf(str, "Size X: %s Y: %s Z: %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int Resize(TransInfo *t, short mval[2])
|
int Resize(TransInfo *t, short mval[2])
|
||||||
{
|
{
|
||||||
TransData *td = t->data;
|
TransData *td = t->data;
|
||||||
@@ -1710,7 +1738,10 @@ int Resize(TransInfo *t, short mval[2])
|
|||||||
|
|
||||||
snapGrid(t, size);
|
snapGrid(t, size);
|
||||||
|
|
||||||
applyNumInput(&t->num, size);
|
if (hasNumInput(&t->num)) {
|
||||||
|
applyNumInput(&t->num, size);
|
||||||
|
constraintNumInput(t, size);
|
||||||
|
}
|
||||||
|
|
||||||
SizeToMat3(size, mat);
|
SizeToMat3(size, mat);
|
||||||
|
|
||||||
@@ -1718,19 +1749,8 @@ int Resize(TransInfo *t, short mval[2])
|
|||||||
t->con.applySize(t, NULL, mat);
|
t->con.applySize(t, NULL, mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* header print for NumInput */
|
headerResize(t, size, str);
|
||||||
if (hasNumInput(&t->num)) {
|
|
||||||
char c[60];
|
|
||||||
|
|
||||||
outputNumInput(&(t->num), c);
|
|
||||||
|
|
||||||
sprintf(str, "Size X: %s Y: %s Z: %s %s", &c[0], &c[20], &c[40], t->proptext);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* default header print */
|
|
||||||
sprintf(str, "Size X: %.3f Y: %.3f Z: %.3f %s", size[0], size[1], size[2], t->proptext);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i = 0 ; i < t->total; i++, td++) {
|
for(i = 0 ; i < t->total; i++, td++) {
|
||||||
float smat[3][3];
|
float smat[3][3];
|
||||||
if (td->flag & TD_NOACTION)
|
if (td->flag & TD_NOACTION)
|
||||||
|
|||||||
@@ -114,8 +114,46 @@ void recalcData();
|
|||||||
/* ************************** CONSTRAINTS ************************* */
|
/* ************************** CONSTRAINTS ************************* */
|
||||||
void getConstraintMatrix(TransInfo *t);
|
void getConstraintMatrix(TransInfo *t);
|
||||||
|
|
||||||
|
void constraintNumInput(TransInfo *t, float vec[3])
|
||||||
|
{
|
||||||
|
int mode = t->con.mode;
|
||||||
|
float nval = (t->num.flags & NULLONE)?1.0f:0.0f;
|
||||||
|
|
||||||
|
if (getConstraintSpaceDimension(t) == 2) {
|
||||||
|
if (mode & (CON_AXIS0|CON_AXIS1)) {
|
||||||
|
vec[2] = nval;
|
||||||
|
}
|
||||||
|
else if (mode & (CON_AXIS1|CON_AXIS2)) {
|
||||||
|
vec[2] = vec[1];
|
||||||
|
vec[1] = vec[0];
|
||||||
|
vec[0] = nval;
|
||||||
|
}
|
||||||
|
else if (mode & (CON_AXIS0|CON_AXIS2)) {
|
||||||
|
vec[2] = vec[1];
|
||||||
|
vec[1] = nval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (getConstraintSpaceDimension(t) == 1) {
|
||||||
|
if (mode & CON_AXIS0) {
|
||||||
|
vec[1] = nval;
|
||||||
|
vec[2] = nval;
|
||||||
|
}
|
||||||
|
else if (mode & CON_AXIS1) {
|
||||||
|
vec[1] = vec[0];
|
||||||
|
vec[0] = nval;
|
||||||
|
vec[2] = nval;
|
||||||
|
}
|
||||||
|
else if (mode & CON_AXIS2) {
|
||||||
|
vec[2] = vec[0];
|
||||||
|
vec[0] = nval;
|
||||||
|
vec[1] = nval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) {
|
static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
Mat3MulVecfl(t->con.imtx, vec);
|
Mat3MulVecfl(t->con.imtx, vec);
|
||||||
|
|
||||||
snapGrid(t, vec);
|
snapGrid(t, vec);
|
||||||
@@ -131,7 +169,10 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) {
|
|||||||
vec[2] = 1.0f;
|
vec[2] = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
applyNumInput(&t->num, vec);
|
if (hasNumInput(&t->num)) {
|
||||||
|
applyNumInput(&t->num, vec);
|
||||||
|
constraintNumInput(t, vec);
|
||||||
|
}
|
||||||
|
|
||||||
if (t->con.mode & CON_AXIS0) {
|
if (t->con.mode & CON_AXIS0) {
|
||||||
pvec[i++] = vec[0];
|
pvec[i++] = vec[0];
|
||||||
@@ -498,7 +539,7 @@ void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[])
|
|||||||
getConstraintMatrix(t);
|
getConstraintMatrix(t);
|
||||||
|
|
||||||
VECCOPY(t->con.center, t->center);
|
VECCOPY(t->con.center, t->center);
|
||||||
if (G.obedit) {
|
if (t->flag & T_EDIT) {
|
||||||
Mat4MulVecfl(G.obedit->obmat, t->con.center);
|
Mat4MulVecfl(G.obedit->obmat, t->con.center);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,7 +552,7 @@ void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setLocalConstraint(TransInfo *t, int mode, const char text[]) {
|
void setLocalConstraint(TransInfo *t, int mode, const char text[]) {
|
||||||
if (G.obedit) {
|
if (t->flag & T_EDIT) {
|
||||||
float obmat[3][3];
|
float obmat[3][3];
|
||||||
Mat3CpyMat4(obmat, G.obedit->obmat);
|
Mat3CpyMat4(obmat, G.obedit->obmat);
|
||||||
setConstraint(t, obmat, mode, text);
|
setConstraint(t, obmat, mode, text);
|
||||||
@@ -527,9 +568,6 @@ void setLocalConstraint(TransInfo *t, int mode, const char text[]) {
|
|||||||
getConstraintMatrix(t);
|
getConstraintMatrix(t);
|
||||||
|
|
||||||
VECCOPY(t->con.center, t->center);
|
VECCOPY(t->con.center, t->center);
|
||||||
if (G.obedit) {
|
|
||||||
Mat4MulVecfl(G.obedit->obmat, t->con.center);
|
|
||||||
}
|
|
||||||
|
|
||||||
startConstraint(t);
|
startConstraint(t);
|
||||||
|
|
||||||
@@ -671,9 +709,11 @@ void initSelectConstraint(TransInfo *t)
|
|||||||
t->con.mode |= CON_APPLY;
|
t->con.mode |= CON_APPLY;
|
||||||
t->con.mode |= CON_SELECT;
|
t->con.mode |= CON_SELECT;
|
||||||
VECCOPY(t->con.center, t->center);
|
VECCOPY(t->con.center, t->center);
|
||||||
if (G.obedit) {
|
|
||||||
|
if (t->flag & T_EDIT) {
|
||||||
Mat4MulVecfl(G.obedit->obmat, t->con.center);
|
Mat4MulVecfl(G.obedit->obmat, t->con.center);
|
||||||
}
|
}
|
||||||
|
|
||||||
setNearestAxis(t);
|
setNearestAxis(t);
|
||||||
t->con.drawExtra = NULL;
|
t->con.drawExtra = NULL;
|
||||||
t->con.applyVec = applyAxisConstraintVec;
|
t->con.applyVec = applyAxisConstraintVec;
|
||||||
@@ -696,10 +736,6 @@ void postSelectConstraint(TransInfo *t)
|
|||||||
|
|
||||||
setNearestAxis(t);
|
setNearestAxis(t);
|
||||||
|
|
||||||
t->con.mode |= CON_APPLY;
|
|
||||||
VECCOPY(t->con.center, t->center);
|
|
||||||
|
|
||||||
getConstraintMatrix(t);
|
|
||||||
startConstraint(t);
|
startConstraint(t);
|
||||||
t->redraw = 1;
|
t->redraw = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ void getConstraintMatrix(TransInfo *t);
|
|||||||
void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]);
|
void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]);
|
||||||
void setLocalConstraint(TransInfo *t, int mode, const char text[]);
|
void setLocalConstraint(TransInfo *t, int mode, const char text[]);
|
||||||
|
|
||||||
|
void constraintNumInput(TransInfo *t, float vec[3]);
|
||||||
|
|
||||||
//void drawConstraint(TransCon *t);
|
//void drawConstraint(TransCon *t);
|
||||||
void drawConstraint();
|
void drawConstraint();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user