Cleanup: use float2 for wmTabletData::tilt & PaintStroke::tilt
This commit is contained in:
@@ -119,8 +119,7 @@ struct PaintStroke {
|
||||
bool pen_flip;
|
||||
|
||||
/* Tilt, as read from the event. */
|
||||
float x_tilt;
|
||||
float y_tilt;
|
||||
float2 tilt;
|
||||
|
||||
/* line constraint */
|
||||
bool constrain_line;
|
||||
@@ -644,8 +643,8 @@ static void paint_brush_stroke_add_step(
|
||||
/* Original mouse coordinates. */
|
||||
RNA_float_set_array(&itemptr, "mouse_event", mval);
|
||||
RNA_float_set(&itemptr, "pressure", pressure);
|
||||
RNA_float_set(&itemptr, "x_tilt", stroke->x_tilt);
|
||||
RNA_float_set(&itemptr, "y_tilt", stroke->y_tilt);
|
||||
RNA_float_set(&itemptr, "x_tilt", stroke->tilt.x);
|
||||
RNA_float_set(&itemptr, "y_tilt", stroke->tilt.y);
|
||||
|
||||
stroke->update_step(C, op, stroke, &itemptr);
|
||||
|
||||
@@ -1506,8 +1505,7 @@ wmOperatorStatus paint_stroke_modal(bContext *C,
|
||||
|
||||
/* Tilt. */
|
||||
if (WM_event_is_tablet(event)) {
|
||||
stroke->x_tilt = event->tablet.x_tilt;
|
||||
stroke->y_tilt = event->tablet.y_tilt;
|
||||
stroke->tilt = event->tablet.tilt;
|
||||
}
|
||||
|
||||
#ifdef WITH_INPUT_NDOF
|
||||
|
||||
@@ -700,10 +700,11 @@ struct wmTabletData {
|
||||
int active;
|
||||
/** Range 0.0 (not touching) to 1.0 (full pressure). */
|
||||
float pressure;
|
||||
/** range -1.0 (left) to +1.0 (right). */
|
||||
float x_tilt;
|
||||
/** range -1.0 (away from user) to +1.0 (toward user). */
|
||||
float y_tilt;
|
||||
/**
|
||||
* X axis range: -1.0 (left) to +1.0 (right).
|
||||
* Y axis range: -1.0 (away from user) to +1.0 (toward user).
|
||||
*/
|
||||
blender::float2 tilt;
|
||||
/** Interpret mouse motion as absolute as typical for tablets. */
|
||||
char is_motion_absolute;
|
||||
};
|
||||
|
||||
@@ -153,8 +153,8 @@ static void wm_paintcursor_draw(bContext *C, ScrArea *area, ARegion *region)
|
||||
pc->draw(C,
|
||||
xy[0],
|
||||
xy[1],
|
||||
win->eventstate->tablet.x_tilt,
|
||||
win->eventstate->tablet.y_tilt,
|
||||
win->eventstate->tablet.tilt.x,
|
||||
win->eventstate->tablet.tilt.y,
|
||||
pc->customdata);
|
||||
GPU_scissor_test(false);
|
||||
}
|
||||
|
||||
@@ -168,8 +168,8 @@ void WM_event_print(const wmEvent *event)
|
||||
printf(", tablet: active: %d, pressure %.4f, tilt: (%.4f %.4f)",
|
||||
wmtab->active,
|
||||
wmtab->pressure,
|
||||
wmtab->x_tilt,
|
||||
wmtab->y_tilt);
|
||||
wmtab->tilt.x,
|
||||
wmtab->tilt.y);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
@@ -585,8 +585,7 @@ float wm_pressure_curve(float raw_pressure)
|
||||
float WM_event_tablet_data(const wmEvent *event, bool *r_pen_flip, float r_tilt[2])
|
||||
{
|
||||
if (r_tilt) {
|
||||
r_tilt[0] = event->tablet.x_tilt;
|
||||
r_tilt[1] = event->tablet.y_tilt;
|
||||
copy_v2_v2(r_tilt, event->tablet.tilt);
|
||||
}
|
||||
|
||||
if (r_pen_flip) {
|
||||
|
||||
@@ -5546,8 +5546,8 @@ constexpr wmTabletData wm_event_tablet_data_default()
|
||||
wmTabletData tablet_data{};
|
||||
tablet_data.active = EVT_TABLET_NONE;
|
||||
tablet_data.pressure = 1.0f;
|
||||
tablet_data.x_tilt = 0.0f;
|
||||
tablet_data.y_tilt = 0.0f;
|
||||
tablet_data.tilt.x = 0.0f;
|
||||
tablet_data.tilt.y = 0.0f;
|
||||
tablet_data.is_motion_absolute = false;
|
||||
return tablet_data;
|
||||
}
|
||||
@@ -5562,8 +5562,7 @@ void wm_tablet_data_from_ghost(const GHOST_TabletData *tablet_data, wmTabletData
|
||||
if ((tablet_data != nullptr) && tablet_data->Active != GHOST_kTabletModeNone) {
|
||||
wmtab->active = int(tablet_data->Active);
|
||||
wmtab->pressure = wm_pressure_curve(tablet_data->Pressure);
|
||||
wmtab->x_tilt = tablet_data->Xtilt;
|
||||
wmtab->y_tilt = tablet_data->Ytilt;
|
||||
wmtab->tilt = blender::float2(tablet_data->Xtilt, tablet_data->Ytilt);
|
||||
/* We could have a preference to support relative tablet motion (we can't detect that). */
|
||||
wmtab->is_motion_absolute = true;
|
||||
// printf("%s: using tablet %.5f\n", __func__, wmtab->pressure);
|
||||
@@ -5952,8 +5951,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm,
|
||||
wmEvent *event_new = wm_event_add_mousemove(win, &event);
|
||||
copy_v2_v2_int(event_state->xy, event_new->xy);
|
||||
event_state->tablet.is_motion_absolute = event_new->tablet.is_motion_absolute;
|
||||
event_state->tablet.x_tilt = event.tablet.x_tilt;
|
||||
event_state->tablet.y_tilt = event.tablet.y_tilt;
|
||||
event_state->tablet.tilt = event.tablet.tilt;
|
||||
}
|
||||
|
||||
/* Also add to other window if event is there, this makes overdraws disappear nicely. */
|
||||
|
||||
Reference in New Issue
Block a user