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 <mano-wii>2021-10-18 06:32:23 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-10-18 07:58:00 +0300
commit69d6222481b4342dc2a153e62752145aa37ea101 (patch)
treefe84a99c2cf3bc7b2ddce62a302e5498a126a9e4 /source/blender/editors/include
parentbe22e36692f0989e52b4a4f286d7d3d3fe8186bd (diff)
Snap and Placement Gizmo Refactor
Move most of the gizmo snap and placement code to `view_cursor_snap.c`. Simplify and extend the snap API. Differential Revision: https://developer.blender.org/D12868
Diffstat (limited to 'source/blender/editors/include')
-rw-r--r--source/blender/editors/include/ED_gizmo_library.h41
-rw-r--r--source/blender/editors/include/ED_transform_snap_object_context.h3
-rw-r--r--source/blender/editors/include/ED_view3d.h68
3 files changed, 79 insertions, 33 deletions
diff --git a/source/blender/editors/include/ED_gizmo_library.h b/source/blender/editors/include/ED_gizmo_library.h
index 9bef5a17d12..4d922162ee9 100644
--- a/source/blender/editors/include/ED_gizmo_library.h
+++ b/source/blender/editors/include/ED_gizmo_library.h
@@ -41,11 +41,7 @@ void ED_gizmotypes_primitive_3d(void);
void ED_gizmotypes_blank_3d(void);
void ED_gizmotypes_snap_3d(void);
-struct ARegion;
-struct Depsgraph;
struct Object;
-struct SnapObjectContext;
-struct View3D;
struct bContext;
struct wmGizmo;
struct wmWindowManager;
@@ -248,41 +244,22 @@ void ED_gizmotypes_dial_3d_draw_util(const float matrix_basis[4][4],
struct Dial3dParams *params);
/* snap3d_gizmo.c */
-#define USE_SNAP_DETECT_FROM_KEYMAP_HACK
-void ED_gizmotypes_snap_3d_draw_util(struct RegionView3D *rv3d,
- const float loc_prev[3],
- const float loc_curr[3],
- const float normal[3],
- const uchar color_line[4],
- const uchar color_point[4],
- const short snap_elem_type);
struct SnapObjectContext *ED_gizmotypes_snap_3d_context_ensure(struct Scene *scene,
struct wmGizmo *gz);
-typedef enum {
- ED_SNAPGIZMO_TOGGLE_ALWAYS_TRUE = 1 << 0,
- ED_SNAPGIZMO_OCCLUSION_ALWAYS_TRUE = 1 << 1,
- ED_SNAPGIZMO_OCCLUSION_ALWAYS_FALSE = 1 << 2, /* TODO. */
- ED_SNAPGIZMO_SNAP_ONLY_ACTIVE = 1 << 3,
- ED_SNAPGIZMO_SNAP_EDIT_GEOM_FINAL = 1 << 4,
- ED_SNAPGIZMO_SNAP_EDIT_GEOM_CAGE = 1 << 5,
-} eSnapGizmo;
-
-void ED_gizmotypes_snap_3d_flag_set(struct wmGizmo *gz, eSnapGizmo flag);
-void ED_gizmotypes_snap_3d_flag_clear(struct wmGizmo *gz, eSnapGizmo flag);
-bool ED_gizmotypes_snap_3d_flag_test(struct wmGizmo *gz, eSnapGizmo flag);
+void ED_gizmotypes_snap_3d_flag_set(struct wmGizmo *gz, int flag);
+void ED_gizmotypes_snap_3d_flag_clear(struct wmGizmo *gz, int flag);
+bool ED_gizmotypes_snap_3d_flag_test(struct wmGizmo *gz, int flag);
bool ED_gizmotypes_snap_3d_invert_snap_get(struct wmGizmo *gz);
bool ED_gizmotypes_snap_3d_is_enabled(const struct wmGizmo *gz);
-short ED_gizmotypes_snap_3d_update(struct wmGizmo *gz,
- struct Depsgraph *depsgraph,
- const struct ARegion *region,
- const struct View3D *v3d,
- const struct wmWindowManager *wm,
- const float mval_fl[2]);
-void ED_gizmotypes_snap_3d_data_get(
- struct wmGizmo *gz, float r_loc[3], float r_nor[3], int r_elem_index[3], int *r_snap_elem);
+void ED_gizmotypes_snap_3d_data_get(const struct bContext *C,
+ struct wmGizmo *gz,
+ float r_loc[3],
+ float r_nor[3],
+ int r_elem_index[3],
+ int *r_snap_elem);
#ifdef __cplusplus
}
diff --git a/source/blender/editors/include/ED_transform_snap_object_context.h b/source/blender/editors/include/ED_transform_snap_object_context.h
index 7311303d7cd..7002db163b6 100644
--- a/source/blender/editors/include/ED_transform_snap_object_context.h
+++ b/source/blender/editors/include/ED_transform_snap_object_context.h
@@ -139,7 +139,8 @@ short ED_transform_snap_object_project_view3d_ex(struct SnapObjectContext *sctx,
float r_no[3],
int *r_index,
struct Object **r_ob,
- float r_obmat[4][4]);
+ float r_obmat[4][4],
+ float r_face_nor[3]);
bool ED_transform_snap_object_project_view3d(struct SnapObjectContext *sctx,
struct Depsgraph *depsgraph,
const ARegion *region,
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index cf8dcbd7995..593d1be9444 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -52,6 +52,7 @@ struct RegionView3D;
struct RenderEngineType;
struct Scene;
struct ScrArea;
+struct SnapObjectContext;
struct View3D;
struct ViewContext;
struct ViewLayer;
@@ -228,6 +229,73 @@ typedef enum {
(V3D_PROJ_TEST_CLIP_CONTENT | V3D_PROJ_TEST_CLIP_NEAR | V3D_PROJ_TEST_CLIP_FAR | \
V3D_PROJ_TEST_CLIP_WIN)
+/* view3d_cursor_snap.c */
+#define USE_SNAP_DETECT_FROM_KEYMAP_HACK
+typedef enum {
+ V3D_SNAPCURSOR_TOGGLE_ALWAYS_TRUE = 1 << 0,
+ V3D_SNAPCURSOR_OCCLUSION_ALWAYS_TRUE = 1 << 1,
+ V3D_SNAPCURSOR_OCCLUSION_ALWAYS_FALSE = 1 << 2, /* TODO. */
+ V3D_SNAPCURSOR_SNAP_ONLY_ACTIVE = 1 << 3,
+ V3D_SNAPCURSOR_SNAP_EDIT_GEOM_FINAL = 1 << 4,
+ V3D_SNAPCURSOR_SNAP_EDIT_GEOM_CAGE = 1 << 5,
+} eV3DSnapCursor;
+
+typedef enum {
+ V3D_PLACE_DEPTH_SURFACE = 0,
+ V3D_PLACE_DEPTH_CURSOR_PLANE = 1,
+ V3D_PLACE_DEPTH_CURSOR_VIEW = 2,
+} eV3DPlaceDepth;
+
+typedef enum {
+ V3D_PLACE_ORIENT_SURFACE = 0,
+ V3D_PLACE_ORIENT_DEFAULT = 1,
+} 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];
+ float face_nor[3];
+ float obmat[4][4];
+ int elem_index[3];
+ float plane_omat[3][3];
+ bool is_snap_invert;
+
+ /** Enabled when snap is activated, even if it didn't find anything. */
+ 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_update(const struct bContext *C,
+ const int x,
+ const int y,
+ V3DSnapCursorData *snap_data);
+void ED_view3d_cursor_snap_prevpoint_set(const float prev_point[3]);
+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],
+ const float loc_curr[3],
+ const float normal[3],
+ const uchar color_line[4],
+ const uchar color_point[4],
+ const short snap_elem_type);
+
/* view3d_iterators.c */
/* foreach iterators */