Warp was acting weird if the cursor wasn't centered in the data space, that is fixed.
Helpline for warp was wrong in edit mode if the object wasn't centered on global space. Boundbox calculation for warp is done in view space now, so it is always maximised since aligned with the view. Switch the negative/positive switch for Shrink/Fatten from horizontal motion to vertical motion. Pull down to shrink, pull up to fatten. This could still use some work. BugFix: Constraint center was wrong with MMB (was bypassing the fix I commited the other day). BugFix: Changing modes while in transform and switching to local constraints in edit mode crashed. This was due to resetting the TransInfo flag in initTransModeFlags. Now done correctly in initTrans.
This commit is contained in:
@@ -1231,7 +1231,6 @@ static void createTransData(TransInfo *t)
|
|||||||
createTransPose();
|
createTransPose();
|
||||||
}
|
}
|
||||||
else if (G.obedit) {
|
else if (G.obedit) {
|
||||||
t->flag |= T_EDIT;
|
|
||||||
if (G.obedit->type == OB_MESH) {
|
if (G.obedit->type == OB_MESH) {
|
||||||
createTransEditVerts();
|
createTransEditVerts();
|
||||||
}
|
}
|
||||||
@@ -1256,7 +1255,7 @@ static void createTransData(TransInfo *t)
|
|||||||
set_prop_dist(t);
|
set_prop_dist(t);
|
||||||
sort_trans_data_dist(t);
|
sort_trans_data_dist(t);
|
||||||
}
|
}
|
||||||
|
t->flag |= T_EDIT;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
createTransObject();
|
createTransObject();
|
||||||
@@ -1351,7 +1350,7 @@ void Transform(int mode)
|
|||||||
Trans.redraw = 1;
|
Trans.redraw = 1;
|
||||||
|
|
||||||
while (ret_val == 0) {
|
while (ret_val == 0) {
|
||||||
|
|
||||||
getmouseco_areawin(mval);
|
getmouseco_areawin(mval);
|
||||||
|
|
||||||
if (mval[0] != pmval[0] || mval[1] != pmval[1]) {
|
if (mval[0] != pmval[0] || mval[1] != pmval[1]) {
|
||||||
@@ -1549,10 +1548,8 @@ void Transform(int mode)
|
|||||||
BIF_undo_push("Transform");
|
BIF_undo_push("Transform");
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf("before postrans\n");
|
|
||||||
/* free data, reset vars */
|
/* free data, reset vars */
|
||||||
postTrans(&Trans);
|
postTrans(&Trans);
|
||||||
// printf("after postrans\n");
|
|
||||||
|
|
||||||
/* mess from old transform, just for now (ton) */
|
/* mess from old transform, just for now (ton) */
|
||||||
{
|
{
|
||||||
@@ -1722,41 +1719,55 @@ void initWarp(TransInfo *t)
|
|||||||
|
|
||||||
/* we need min/max in view space */
|
/* we need min/max in view space */
|
||||||
for(i = 0; i < t->total; i++) {
|
for(i = 0; i < t->total; i++) {
|
||||||
|
float center[3];
|
||||||
|
VECCOPY(center, t->data[i].center);
|
||||||
|
Mat3MulVecfl(t->data[i].mtx, center);
|
||||||
|
Mat4MulVecfl(G.vd->viewmat, center);
|
||||||
|
VecSubf(center, center, G.vd->viewmat[3]);
|
||||||
if (i)
|
if (i)
|
||||||
MinMax3(min, max, t->data[i].center);
|
MinMax3(min, max, center);
|
||||||
else {
|
else {
|
||||||
VECCOPY(max, t->data[i].center);
|
VECCOPY(max, center);
|
||||||
VECCOPY(min, t->data[i].center);
|
VECCOPY(min, center);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t->flag & T_EDIT) {
|
|
||||||
Mat4MulVecfl(G.obedit->obmat, min);
|
|
||||||
Mat4MulVecfl(G.obedit->obmat, max);
|
|
||||||
}
|
|
||||||
Mat4MulVecfl(G.vd->viewmat, min);
|
|
||||||
Mat4MulVecfl(G.vd->viewmat, max);
|
|
||||||
|
|
||||||
t->center[0]= (min[0]+max[0])/2.0f;
|
t->center[0]= (min[0]+max[0])/2.0f;
|
||||||
t->center[1]= (min[1]+max[1])/2.0f;
|
t->center[1]= (min[1]+max[1])/2.0f;
|
||||||
t->center[2]= (min[2]+max[2])/2.0f;
|
t->center[2]= (min[2]+max[2])/2.0f;
|
||||||
|
|
||||||
t->val= (max[0]-min[0])/2.0f; // t->val is free variable
|
t->val= (max[0]-min[0])/2.0f; // t->val is free variable
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Warp(TransInfo *t, short mval[2])
|
int Warp(TransInfo *t, short mval[2])
|
||||||
{
|
{
|
||||||
TransData *td = t->data;
|
TransData *td = t->data;
|
||||||
float vec[3], circumfac, dist, phi0, co, si, *curs, cursor[3];
|
float vec[3], circumfac, dist, phi0, co, si, *curs, cursor[3], gcursor[3];
|
||||||
int i;
|
int i;
|
||||||
char str[50];
|
char str[50];
|
||||||
|
|
||||||
curs= give_cursor();
|
curs= give_cursor();
|
||||||
|
/*
|
||||||
|
* gcursor is the one used for helpline.
|
||||||
|
* It has to be in the same space as the drawing loop
|
||||||
|
* (that means it needs to be in the object's space when in edit mode and
|
||||||
|
* in global space in object mode)
|
||||||
|
*
|
||||||
|
* cursor is used for calculations.
|
||||||
|
* It needs to be in view space, but we need to take object's offset
|
||||||
|
* into account if in Edit mode.
|
||||||
|
*/
|
||||||
VECCOPY(cursor, curs);
|
VECCOPY(cursor, curs);
|
||||||
|
VECCOPY(gcursor, cursor);
|
||||||
|
if (t->flag & T_EDIT) {
|
||||||
|
VecSubf(cursor, cursor, G.obedit->obmat[3]);
|
||||||
|
VecSubf(gcursor, gcursor, G.obedit->obmat[3]);
|
||||||
|
Mat3MulVecfl(t->data->smtx, gcursor);
|
||||||
|
}
|
||||||
Mat4MulVecfl(G.vd->viewmat, cursor);
|
Mat4MulVecfl(G.vd->viewmat, cursor);
|
||||||
|
VecSubf(cursor, cursor, G.vd->viewmat[3]);
|
||||||
|
|
||||||
// amount of degrees for warp, 450 = allow to create 360 degree warp
|
// amount of degrees for warp, 450 = allow to create 360 degree warp
|
||||||
circumfac= 450.0f*(mval[1] - t->imval[1]) / (float)(curarea->winy);
|
circumfac= 450.0f*(mval[1] - t->imval[1]) / (float)(curarea->winy);
|
||||||
circumfac+= 90.0f;
|
circumfac+= 90.0f;
|
||||||
@@ -1787,24 +1798,25 @@ int Warp(TransInfo *t, short mval[2])
|
|||||||
/* translate point to centre, rotate in such a way that outline==distance */
|
/* translate point to centre, rotate in such a way that outline==distance */
|
||||||
|
|
||||||
VECCOPY(vec, td->iloc);
|
VECCOPY(vec, td->iloc);
|
||||||
Mat3MulVecfl(td->smtx, vec);
|
Mat3MulVecfl(td->mtx, vec);
|
||||||
Mat4MulVecfl(G.vd->viewmat, vec);
|
Mat4MulVecfl(G.vd->viewmat, vec);
|
||||||
|
VecSubf(vec, vec, G.vd->viewmat[3]);
|
||||||
|
|
||||||
dist= vec[0]-cursor[0];
|
dist= vec[0]-cursor[0];
|
||||||
|
|
||||||
phi0= (circumfac*dist/t->val); // t->val is X dimension projected boundbox
|
phi0= (circumfac*dist/t->val); // t->val is X dimension projected boundbox
|
||||||
|
|
||||||
vec[0]= (-cursor[0]);
|
|
||||||
vec[1]= (vec[1]-cursor[1]);
|
vec[1]= (vec[1]-cursor[1]);
|
||||||
|
|
||||||
co= (float)cos(phi0);
|
co= (float)cos(phi0);
|
||||||
si= (float)sin(phi0);
|
si= (float)sin(phi0);
|
||||||
loc[0]= co*vec[0]-si*vec[1]+cursor[0];
|
loc[0]= -si*vec[1]+cursor[0];
|
||||||
loc[1]= si*vec[0]+co*vec[1]+cursor[1];
|
loc[1]= co*vec[1]+cursor[1];
|
||||||
loc[2]= vec[2];
|
loc[2]= vec[2];
|
||||||
|
|
||||||
Mat4MulVecfl(G.vd->viewinv, loc);
|
Mat4MulVecfl(G.vd->viewinv, loc);
|
||||||
Mat3MulVecfl(td->mtx, loc);
|
VecSubf(loc, loc, G.vd->viewinv[3]);
|
||||||
|
Mat3MulVecfl(td->smtx, loc);
|
||||||
|
|
||||||
VecSubf(loc, loc, td->iloc);
|
VecSubf(loc, loc, td->iloc);
|
||||||
VecMulf(loc, td->factor);
|
VecMulf(loc, td->factor);
|
||||||
@@ -1817,7 +1829,7 @@ int Warp(TransInfo *t, short mval[2])
|
|||||||
|
|
||||||
force_draw(0);
|
force_draw(0);
|
||||||
|
|
||||||
helpline(curs);
|
helpline(gcursor);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -2647,7 +2659,7 @@ int ShrinkFatten(TransInfo *t, short mval[2])
|
|||||||
if (ratio < 0.0f)
|
if (ratio < 0.0f)
|
||||||
ratio = 0.0f;
|
ratio = 0.0f;
|
||||||
|
|
||||||
if (mval[0] < t->center2d[0])
|
if (mval[1] < t->center2d[1])
|
||||||
ratio *= -1;
|
ratio *= -1;
|
||||||
|
|
||||||
snapGrid(t, &ratio);
|
snapGrid(t, &ratio);
|
||||||
|
|||||||
@@ -726,11 +726,6 @@ void initSelectConstraint(TransInfo *t)
|
|||||||
Mat3One(t->con.pmtx);
|
Mat3One(t->con.pmtx);
|
||||||
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);
|
|
||||||
|
|
||||||
if (t->flag & T_EDIT) {
|
|
||||||
Mat4MulVecfl(G.obedit->obmat, t->con.center);
|
|
||||||
}
|
|
||||||
|
|
||||||
setNearestAxis(t);
|
setNearestAxis(t);
|
||||||
t->con.drawExtra = NULL;
|
t->con.drawExtra = NULL;
|
||||||
@@ -742,6 +737,7 @@ void initSelectConstraint(TransInfo *t)
|
|||||||
void selectConstraint(TransInfo *t) {
|
void selectConstraint(TransInfo *t) {
|
||||||
if (t->con.mode & CON_SELECT) {
|
if (t->con.mode & CON_SELECT) {
|
||||||
setNearestAxis(t);
|
setNearestAxis(t);
|
||||||
|
startConstraint(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -764,7 +760,7 @@ void postSelectConstraint(TransInfo *t)
|
|||||||
void setNearestAxis(TransInfo *t)
|
void setNearestAxis(TransInfo *t)
|
||||||
{
|
{
|
||||||
short coord[2];
|
short coord[2];
|
||||||
float mvec[3], axis[3], center[3], proj[3];
|
float mvec[3], axis[3], proj[3];
|
||||||
float len[3];
|
float len[3];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -772,24 +768,14 @@ void setNearestAxis(TransInfo *t)
|
|||||||
t->con.mode &= ~CON_AXIS1;
|
t->con.mode &= ~CON_AXIS1;
|
||||||
t->con.mode &= ~CON_AXIS2;
|
t->con.mode &= ~CON_AXIS2;
|
||||||
|
|
||||||
VECCOPY(center, t->center);
|
|
||||||
if (G.obedit) {
|
|
||||||
Mat4MulVecfl(G.obedit->obmat, center);
|
|
||||||
}
|
|
||||||
|
|
||||||
getmouseco_areawin(coord);
|
getmouseco_areawin(coord);
|
||||||
#if 1
|
|
||||||
mvec[0] = (float)(coord[0] - t->con.imval[0]);
|
mvec[0] = (float)(coord[0] - t->con.imval[0]);
|
||||||
mvec[1] = (float)(coord[1] - t->con.imval[1]);
|
mvec[1] = (float)(coord[1] - t->con.imval[1]);
|
||||||
#else
|
|
||||||
mvec[0] = (float)(coord[0] - t->center2d[0]);
|
|
||||||
mvec[1] = (float)(coord[1] - t->center2d[1]);
|
|
||||||
#endif
|
|
||||||
mvec[2] = 0.0f;
|
mvec[2] = 0.0f;
|
||||||
|
|
||||||
for (i = 0; i<3; i++) {
|
for (i = 0; i<3; i++) {
|
||||||
VECCOPY(axis, t->con.mtx[i]);
|
VECCOPY(axis, t->con.mtx[i]);
|
||||||
VecAddf(axis, axis, center);
|
VecAddf(axis, axis, t->con.center);
|
||||||
project_short_noclip(axis, coord);
|
project_short_noclip(axis, coord);
|
||||||
axis[0] = (float)(coord[0] - t->center2d[0]);
|
axis[0] = (float)(coord[0] - t->center2d[0]);
|
||||||
axis[1] = (float)(coord[1] - t->center2d[1]);
|
axis[1] = (float)(coord[1] - t->center2d[1]);
|
||||||
|
|||||||
@@ -314,7 +314,6 @@ void recalcData(TransInfo *t)
|
|||||||
|
|
||||||
void initTransModeFlags(TransInfo *t, int mode)
|
void initTransModeFlags(TransInfo *t, int mode)
|
||||||
{
|
{
|
||||||
t->flag = 0;
|
|
||||||
t->num.flag = 0;
|
t->num.flag = 0;
|
||||||
t->mode = mode;
|
t->mode = mode;
|
||||||
|
|
||||||
@@ -383,6 +382,7 @@ void initTrans (TransInfo *t)
|
|||||||
t->ext = NULL;
|
t->ext = NULL;
|
||||||
|
|
||||||
getmouseco_areawin(t->imval);
|
getmouseco_areawin(t->imval);
|
||||||
|
t->flag = 0;
|
||||||
t->con.imval[0] = t->imval[0];
|
t->con.imval[0] = t->imval[0];
|
||||||
t->con.imval[1] = t->imval[1];
|
t->con.imval[1] = t->imval[1];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user