Transform: Replace t->imval w/ t->mouse.imval
Initial mouse position was saved in two different places D1588 by @mauge
This commit is contained in:
parent
d1e18c35d3
commit
e0c60985b6
Notes:
blender-bot
2023-02-14 06:46:23 +01:00
Referenced by commit 37fbabc64b
, Fix T46647: Crash when using redo panel after extrude individual faces
|
@ -2160,7 +2160,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
|||
calculatePropRatio(t);
|
||||
calculateCenter(t);
|
||||
|
||||
initMouseInput(t, &t->mouse, t->center2d, t->imval);
|
||||
initMouseInput(t, &t->mouse, t->center2d, event->mval);
|
||||
|
||||
switch (mode) {
|
||||
case TFM_TRANSLATION:
|
||||
|
@ -3386,7 +3386,7 @@ static void applyResize(TransInfo *t, const int mval[2])
|
|||
|
||||
/* for manipulator, center handle, the scaling can't be done relative to center */
|
||||
if ((t->flag & T_USES_MANIPULATOR) && t->con.mode == 0) {
|
||||
ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1])) / 100.0f;
|
||||
ratio = 1.0f - ((t->mouse.imval[0] - mval[0]) + (t->mouse.imval[1] - mval[1])) / 100.0f;
|
||||
}
|
||||
else {
|
||||
ratio = t->values[0];
|
||||
|
@ -5185,7 +5185,7 @@ static void applyBoneSize(TransInfo *t, const int mval[2])
|
|||
// TRANSFORM_FIX_ME MOVE TO MOUSE INPUT
|
||||
/* for manipulator, center handle, the scaling can't be done relative to center */
|
||||
if ((t->flag & T_USES_MANIPULATOR) && t->con.mode == 0) {
|
||||
ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1])) / 100.0f;
|
||||
ratio = 1.0f - ((t->mouse.imval[0] - mval[0]) + (t->mouse.imval[1] - mval[1])) / 100.0f;
|
||||
}
|
||||
else {
|
||||
ratio = t->values[0];
|
||||
|
@ -6955,7 +6955,7 @@ static void calcVertSlideCustomPoints(struct TransInfo *t)
|
|||
ED_view3d_project_float_v2_m4(t->ar, co_orig_3d, co_orig_2d, sld->proj_mat);
|
||||
ED_view3d_project_float_v2_m4(t->ar, co_curr_3d, co_curr_2d, sld->proj_mat);
|
||||
|
||||
ARRAY_SET_ITEMS(mval_ofs, t->imval[0] - co_orig_2d[0], t->imval[1] - co_orig_2d[1]);
|
||||
ARRAY_SET_ITEMS(mval_ofs, t->mouse.imval[0] - co_orig_2d[0], t->mouse.imval[1] - co_orig_2d[1]);
|
||||
ARRAY_SET_ITEMS(mval_start, co_orig_2d[0] + mval_ofs[0], co_orig_2d[1] + mval_ofs[1]);
|
||||
ARRAY_SET_ITEMS(mval_end, co_curr_2d[0] + mval_ofs[0], co_curr_2d[1] + mval_ofs[1]);
|
||||
|
||||
|
@ -7005,7 +7005,7 @@ static void calcVertSlideMouseActiveVert(struct TransInfo *t, const int mval[2])
|
|||
static void calcVertSlideMouseActiveEdges(struct TransInfo *t, const int mval[2])
|
||||
{
|
||||
VertSlideData *sld = t->customData;
|
||||
float imval_fl[2] = {UNPACK2(t->imval)};
|
||||
float imval_fl[2] = {UNPACK2(t->mouse.imval)};
|
||||
float mval_fl[2] = {UNPACK2(mval)};
|
||||
|
||||
float dir[3];
|
||||
|
@ -7369,16 +7369,16 @@ static void drawVertSlide(TransInfo *t)
|
|||
glDisable(GL_BLEND);
|
||||
|
||||
/* direction from active vertex! */
|
||||
if ((t->mval[0] != t->imval[0]) ||
|
||||
(t->mval[1] != t->imval[1]))
|
||||
if ((t->mval[0] != t->mouse.imval[0]) ||
|
||||
(t->mval[1] != t->mouse.imval[1]))
|
||||
{
|
||||
float zfac;
|
||||
float mval_ofs[2];
|
||||
float co_orig_3d[3];
|
||||
float co_dest_3d[3];
|
||||
|
||||
mval_ofs[0] = t->mval[0] - t->imval[0];
|
||||
mval_ofs[1] = t->mval[1] - t->imval[1];
|
||||
mval_ofs[0] = t->mval[0] - t->mouse.imval[0];
|
||||
mval_ofs[1] = t->mval[1] - t->mouse.imval[1];
|
||||
|
||||
mul_v3_m4v3(co_orig_3d, t->obedit->obmat, curr_sv->co_orig_3d);
|
||||
zfac = ED_view3d_calc_zfac(t->ar->regiondata, co_orig_3d, NULL);
|
||||
|
@ -8158,7 +8158,7 @@ static void applyTimeTranslate(TransInfo *t, const int mval[2])
|
|||
if (t->flag & T_MODAL) {
|
||||
float cval[2], sval[2];
|
||||
UI_view2d_region_to_view(v2d, mval[0], mval[0], &cval[0], &cval[1]);
|
||||
UI_view2d_region_to_view(v2d, t->imval[0], t->imval[0], &sval[0], &sval[1]);
|
||||
UI_view2d_region_to_view(v2d, t->mouse.imval[0], t->mouse.imval[0], &sval[0], &sval[1]);
|
||||
|
||||
/* we only need to calculate effect for time (applyTimeTranslate only needs that) */
|
||||
t->values[0] = cval[0] - sval[0];
|
||||
|
@ -8299,7 +8299,7 @@ static void applyTimeSlide(TransInfo *t, const int mval[2])
|
|||
|
||||
/* calculate mouse co-ordinates */
|
||||
UI_view2d_region_to_view(v2d, mval[0], mval[1], &cval[0], &cval[1]);
|
||||
UI_view2d_region_to_view(v2d, t->imval[0], t->imval[1], &sval[0], &sval[1]);
|
||||
UI_view2d_region_to_view(v2d, t->mouse.imval[0], t->mouse.imval[1], &sval[0], &sval[1]);
|
||||
|
||||
/* t->values[0] stores cval[0], which is the current mouse-pointer location (in frames) */
|
||||
// XXX Need to be able to repeat this
|
||||
|
@ -8344,10 +8344,10 @@ static void initTimeScale(TransInfo *t)
|
|||
* what is used in time scale */
|
||||
t->center[0] = t->scene->r.cfra;
|
||||
projectFloatView(t, t->center, center);
|
||||
center[1] = t->imval[1];
|
||||
center[1] = t->mouse.imval[1];
|
||||
|
||||
/* force a reinit with the center2d used here */
|
||||
initMouseInput(t, &t->mouse, center, t->imval);
|
||||
initMouseInput(t, &t->mouse, center, t->mouse.imval);
|
||||
|
||||
initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
|
||||
|
||||
|
|
|
@ -365,7 +365,6 @@ typedef struct TransInfo {
|
|||
float center[3]; /* center of transformation (in local-space) */
|
||||
float center_global[3]; /* center of transformation (in global-space) */
|
||||
float center2d[2]; /* center in screen coordinates */
|
||||
int imval[2]; /* initial mouse position */
|
||||
short event_type; /* event->type used to invoke transform */
|
||||
short idx_max; /* maximum index on the input vector */
|
||||
float snap[3]; /* Snapping Gears */
|
||||
|
|
|
@ -3027,7 +3027,7 @@ static void createTransNlaData(bContext *C, TransInfo *t)
|
|||
/* only side on which mouse is gets transformed */
|
||||
float xmouse, ymouse;
|
||||
|
||||
UI_view2d_region_to_view(&ac.ar->v2d, t->imval[0], t->imval[1], &xmouse, &ymouse);
|
||||
UI_view2d_region_to_view(&ac.ar->v2d, t->mouse.imval[0], t->mouse.imval[1], &xmouse, &ymouse);
|
||||
t->frame_side = (xmouse > CFRA) ? 'R' : 'L';
|
||||
}
|
||||
else {
|
||||
|
@ -3664,7 +3664,7 @@ static void createTransActionData(bContext *C, TransInfo *t)
|
|||
/* only side on which mouse is gets transformed */
|
||||
float xmouse, ymouse;
|
||||
|
||||
UI_view2d_region_to_view(&ac.ar->v2d, t->imval[0], t->imval[1], &xmouse, &ymouse);
|
||||
UI_view2d_region_to_view(&ac.ar->v2d, t->mouse.imval[0], t->mouse.imval[1], &xmouse, &ymouse);
|
||||
t->frame_side = (xmouse > CFRA) ? 'R' : 'L'; // XXX use t->frame_side
|
||||
}
|
||||
else {
|
||||
|
@ -4063,7 +4063,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
|
|||
/* only side on which mouse is gets transformed */
|
||||
float xmouse, ymouse;
|
||||
|
||||
UI_view2d_region_to_view(v2d, t->imval[0], t->imval[1], &xmouse, &ymouse);
|
||||
UI_view2d_region_to_view(v2d, t->mouse.imval[0], t->mouse.imval[1], &xmouse, &ymouse);
|
||||
t->frame_side = (xmouse > CFRA) ? 'R' : 'L'; // XXX use t->frame_side
|
||||
}
|
||||
else {
|
||||
|
@ -5108,7 +5108,7 @@ static void createTransSeqData(bContext *C, TransInfo *t)
|
|||
|
||||
t->customFree = freeSeqData;
|
||||
|
||||
xmouse = (int)UI_view2d_region_to_view_x(v2d, t->imval[0]);
|
||||
xmouse = (int)UI_view2d_region_to_view_x(v2d, t->mouse.imval[0]);
|
||||
|
||||
/* which side of the current frame should be allowed */
|
||||
if (t->mode == TFM_TIME_EXTEND) {
|
||||
|
|
|
@ -1112,19 +1112,18 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
|||
t->redraw = TREDRAW_HARD; /* redraw first time */
|
||||
|
||||
if (event) {
|
||||
copy_v2_v2_int(t->imval, event->mval);
|
||||
t->event_type = event->type;
|
||||
}
|
||||
else {
|
||||
t->imval[0] = 0;
|
||||
t->imval[1] = 0;
|
||||
t->mouse.imval[0] = 0;
|
||||
t->mouse.imval[1] = 0;
|
||||
}
|
||||
|
||||
t->con.imval[0] = t->imval[0];
|
||||
t->con.imval[1] = t->imval[1];
|
||||
t->con.imval[0] = t->mouse.imval[0];
|
||||
t->con.imval[1] = t->mouse.imval[1];
|
||||
|
||||
t->mval[0] = t->imval[0];
|
||||
t->mval[1] = t->imval[1];
|
||||
t->mval[0] = t->mouse.imval[0];
|
||||
t->mval[1] = t->mouse.imval[1];
|
||||
|
||||
t->transform = NULL;
|
||||
t->handleEvent = NULL;
|
||||
|
|
|
@ -53,11 +53,11 @@ static void InputVector(TransInfo *t, MouseInput *mi, const int mval[2], float o
|
|||
/* calculate the main translation and the precise one separate */
|
||||
convertViewVec(t, dvec, (mval[0] - mi->precision_mval[0]), (mval[1] - mi->precision_mval[1]));
|
||||
mul_v3_fl(dvec, 0.1f);
|
||||
convertViewVec(t, vec, (mi->precision_mval[0] - t->imval[0]), (mi->precision_mval[1] - t->imval[1]));
|
||||
convertViewVec(t, vec, (mi->precision_mval[0] - t->mouse.imval[0]), (mi->precision_mval[1] - t->mouse.imval[1]));
|
||||
add_v3_v3v3(output, vec, dvec);
|
||||
}
|
||||
else {
|
||||
convertViewVec(t, output, (mval[0] - t->imval[0]), (mval[1] - t->imval[1]));
|
||||
convertViewVec(t, output, (mval[0] - t->mouse.imval[0]), (mval[1] - t->mouse.imval[1]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -958,8 +958,8 @@ static void draw_manipulator_rotate(
|
|||
|
||||
if (is_moving) {
|
||||
float vec[3];
|
||||
vec[0] = 0; // XXX (float)(t->imval[0] - t->center2d[0]);
|
||||
vec[1] = 0; // XXX (float)(t->imval[1] - t->center2d[1]);
|
||||
vec[0] = 0; // XXX (float)(t->mouse.imval[0] - t->center2d[0]);
|
||||
vec[1] = 0; // XXX (float)(t->mouse.imval[1] - t->center2d[1]);
|
||||
vec[2] = 0.0f;
|
||||
normalize_v3(vec);
|
||||
mul_v3_fl(vec, 1.2f * size);
|
||||
|
@ -1476,8 +1476,8 @@ static void draw_manipulator_rotate_cyl(
|
|||
|
||||
if (is_moving) {
|
||||
float vec[3];
|
||||
vec[0] = 0; // XXX (float)(t->imval[0] - t->center2d[0]);
|
||||
vec[1] = 0; // XXX (float)(t->imval[1] - t->center2d[1]);
|
||||
vec[0] = 0; // XXX (float)(t->mouse.imval[0] - t->center2d[0]);
|
||||
vec[1] = 0; // XXX (float)(t->mouse.imval[1] - t->center2d[1]);
|
||||
vec[2] = 0.0f;
|
||||
normalize_v3(vec);
|
||||
mul_v3_fl(vec, 1.2f * size);
|
||||
|
|
Loading…
Reference in New Issue