diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-01-16 03:29:57 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-01-16 03:36:55 +0300 |
commit | cdfa3feb911164118fcc5b574b3e1a35c8f99c72 (patch) | |
tree | 779a402ab25b3d4c95f8e96983f164545511057b /source/blender/editors/gizmo_library | |
parent | c4bbe44e472b97911127ce354954ff7e9e290a3d (diff) |
Add Object Tool: support incremental snapping
This adds a "Snap to" option that allows using all the scenes snap
settings which includes incremental & absolute grid snapping options.
This is optional because always following scene snapping would not
snap to geometry by default (which seems to be the most useful default).
Diffstat (limited to 'source/blender/editors/gizmo_library')
-rw-r--r-- | source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c index 8755dea51e1..b8ee1722cb3 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c @@ -80,6 +80,9 @@ typedef struct SnapGizmo3D { #endif int use_snap_override; short snap_elem; + + /** Enabled when snap is activated, even if it didn't find anything. */ + bool is_enabled; } SnapGizmo3D; /* Checks if the current event is different from the one captured in the last update. */ @@ -284,6 +287,12 @@ void ED_gizmotypes_snap_3d_toggle_clear(wmGizmo *gz) snap_gizmo->use_snap_override = -1; } +bool ED_gizmotypes_snap_3d_is_enabled(wmGizmo *gz) +{ + SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz; + return snap_gizmo->is_enabled; +} + short ED_gizmotypes_snap_3d_update(wmGizmo *gz, struct Depsgraph *depsgraph, const ARegion *region, @@ -294,6 +303,8 @@ short ED_gizmotypes_snap_3d_update(wmGizmo *gz, float r_nor[3]) { SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz; + snap_gizmo->is_enabled = false; + if (snap_gizmo->use_snap_override != -1) { if (snap_gizmo->use_snap_override == false) { snap_gizmo->snap_elem = 0; @@ -318,6 +329,8 @@ short ED_gizmotypes_snap_3d_update(wmGizmo *gz, } #endif + snap_gizmo->is_enabled = true; + float co[3], no[3]; short snap_elem = 0; int snap_elem_index[3] = {-1, -1, -1}; |