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-19 18:55:20 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-10-20 14:28:58 +0300
commit9001dd7f29a2f22534cf5549bc500422b1243c97 (patch)
tree4722af399c6b7144d2db49222dd08e4ce623c01a /source/blender/editors/include
parent690e1baf722c6c79ec6a7eaa548cff4c0538f5d3 (diff)
View3D: Cursor Snap Refactor
Make the snap system consistent with the placement tool and leak-safe. **Changes:** - Store `SnapCursorDataIntern` in a `static` variable; - Initialize (lazily) `SnapCursorDataIntern` only once (for the keymap). - Move setup members of `V3DSnapCursorData` to a new struct `V3DSnapCursorState` - Merge `ED_view3d_cursor_snap_activate_point` and `ED_view3d_cursor_snap_activate_plane` into `state = ED_view3d_cursor_snap_active()` - Merge `ED_view3d_cursor_snap_deactivate_point` and `ED_view3d_cursor_snap_deactivate_plane` into `ED_view3d_cursor_snap_deactive(state)` - Be sure to free the snap context when closing via `ED_view3d_cursor_snap_exit` - Use RNA properties callbacks to update the properties of the `"Add Primitive Object"` operator
Diffstat (limited to 'source/blender/editors/include')
-rw-r--r--source/blender/editors/include/ED_view3d.h48
1 files changed, 26 insertions, 22 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 078ebb5e020..67c470a005f 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -257,18 +257,6 @@ typedef enum {
} eV3DPlaceOrient;
typedef struct V3DSnapCursorData {
- /* Setup. */
- eV3DSnapCursor flag;
- eV3DPlaceDepth plane_depth;
- eV3DPlaceOrient plane_orient;
- uchar color_line[4];
- uchar color_point[4];
- float *prevpoint;
- short snap_elem_force; /* If zero, use scene settings. */
- short plane_axis;
- bool use_plane_axis_auto;
-
- /* Return values. */
short snap_elem;
float loc[3];
float nor[3];
@@ -281,16 +269,31 @@ typedef struct V3DSnapCursorData {
bool is_enabled;
} V3DSnapCursorData;
-V3DSnapCursorData *ED_view3d_cursor_snap_data_get(void);
-void ED_view3d_cursor_snap_activate_point(void);
-void ED_view3d_cursor_snap_activate_plane(void);
-void ED_view3d_cursor_snap_deactivate_point(void);
-void ED_view3d_cursor_snap_deactivate_plane(void);
-void ED_view3d_cursor_snap_prevpoint_set(const float prev_point[3]);
-void ED_view3d_cursor_snap_update(const struct bContext *C,
- const int x,
- const int y,
- V3DSnapCursorData *snap_data);
+typedef struct V3DSnapCursorState {
+ /* Setup. */
+ eV3DSnapCursor flag;
+ eV3DPlaceDepth plane_depth;
+ eV3DPlaceOrient plane_orient;
+ uchar color_line[4];
+ uchar color_point[4];
+ float *prevpoint;
+ short snap_elem_force; /* If zero, use scene settings. */
+ short plane_axis;
+ bool use_plane_axis_auto;
+ bool draw_point;
+ bool draw_plane;
+} V3DSnapCursorState;
+
+void ED_view3d_cursor_snap_state_default_set(V3DSnapCursorState *state);
+V3DSnapCursorState *ED_view3d_cursor_snap_state_get(void);
+V3DSnapCursorState *ED_view3d_cursor_snap_active(void);
+void ED_view3d_cursor_snap_deactive(V3DSnapCursorState *state);
+void ED_view3d_cursor_snap_prevpoint_set(V3DSnapCursorState *state, const float prev_point[3]);
+V3DSnapCursorData *ED_view3d_cursor_snap_data_get(V3DSnapCursorState *state,
+ const struct bContext *C,
+ const int x,
+ const int y);
+
struct SnapObjectContext *ED_view3d_cursor_snap_context_ensure(struct Scene *scene);
void ED_view3d_cursor_snap_draw_util(struct RegionView3D *rv3d,
const float loc_prev[3],
@@ -299,6 +302,7 @@ void ED_view3d_cursor_snap_draw_util(struct RegionView3D *rv3d,
const uchar color_line[4],
const uchar color_point[4],
const short snap_elem_type);
+void ED_view3d_cursor_snap_exit(void);
/* view3d_iterators.c */