From 15e71f3d97ec495e623ddac92de83e317f71417e Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Wed, 20 Oct 2021 19:57:03 -0300 Subject: Cleanup: Set default snap cursor values during build time --- .../editors/space_view3d/view3d_cursor_snap.c | 39 ++++++++++++---------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'source/blender/editors/space_view3d') diff --git a/source/blender/editors/space_view3d/view3d_cursor_snap.c b/source/blender/editors/space_view3d/view3d_cursor_snap.c index 52b9f468ca0..1b513c0a9a7 100644 --- a/source/blender/editors/space_view3d/view3d_cursor_snap.c +++ b/source/blender/editors/space_view3d/view3d_cursor_snap.c @@ -94,7 +94,27 @@ typedef struct SnapCursorDataIntern { bool is_initiated; } SnapCursorDataIntern; -static SnapCursorDataIntern g_data_intern = {{0}}; +static void v3d_cursor_snap_state_init(V3DSnapCursorState *state) +{ + state->prevpoint = NULL; + state->snap_elem_force = (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_FACE | + SCE_SNAP_MODE_EDGE_PERPENDICULAR | SCE_SNAP_MODE_EDGE_MIDPOINT); + state->plane_axis = 2; + rgba_uchar_args_set(state->color_point, 255, 255, 255, 255); + rgba_uchar_args_set(state->color_line, 255, 255, 255, 128); + state->draw_point = true; + state->draw_plane = false; +} +static SnapCursorDataIntern g_data_intern = { + .state_default = {.prevpoint = NULL, + .snap_elem_force = (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | + SCE_SNAP_MODE_FACE | SCE_SNAP_MODE_EDGE_PERPENDICULAR | + SCE_SNAP_MODE_EDGE_MIDPOINT), + .plane_axis = 2, + .color_point = {255, 255, 255, 255}, + .color_line = {255, 255, 255, 128}, + .draw_point = true, + .draw_plane = false}}; /** * Calculate a 3x3 orientation matrix from the surface under the cursor. @@ -828,22 +848,10 @@ V3DSnapCursorState *ED_view3d_cursor_snap_state_get(void) return (V3DSnapCursorState *)&g_data_intern.state_intern[g_data_intern.state_active]; } -static void v3d_cursor_snap_state_init(V3DSnapCursorState *state) -{ - state->prevpoint = NULL; - state->snap_elem_force = (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_FACE | - SCE_SNAP_MODE_EDGE_PERPENDICULAR | SCE_SNAP_MODE_EDGE_MIDPOINT); - state->plane_axis = 2; - rgba_uchar_args_set(state->color_point, 255, 255, 255, 255); - UI_GetThemeColor3ubv(TH_TRANSFORM, state->color_line); - state->color_line[3] = 128; - state->draw_point = true; - state->draw_plane = false; -} - static void v3d_cursor_snap_activate(void) { SnapCursorDataIntern *data_intern = &g_data_intern; + if (!data_intern->handle) { if (!data_intern->is_initiated) { /* Only initiate intern data once. @@ -855,9 +863,6 @@ static void v3d_cursor_snap_activate(void) data_intern->keymap = WM_modalkeymap_find(keyconf, "Generic Gizmo Tweak Modal Map"); RNA_enum_value_from_id(data_intern->keymap->modal_items, "SNAP_ON", &data_intern->snap_on); #endif - V3DSnapCursorState *state_default = &data_intern->state_default; - v3d_cursor_snap_state_init(state_default); - data_intern->is_initiated = true; } -- cgit v1.2.3