Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <germano.costa@ig.com.br>2021-10-21 01:57:03 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-10-21 02:49:59 +0300
commit15e71f3d97ec495e623ddac92de83e317f71417e (patch)
tree7e2957044354ccae09dfe7b1be5cc0d94eabc7e4 /source/blender/editors/space_view3d/view3d_cursor_snap.c
parent6b761c59d25855080de683d15837f31172745f43 (diff)
Cleanup: Set default snap cursor values during build time
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_cursor_snap.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_cursor_snap.c39
1 files changed, 22 insertions, 17 deletions
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;
}