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:
authorCampbell Barton <ideasman42@gmail.com>2020-05-28 07:34:17 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-05-28 08:08:58 +0300
commit122cb1aea82362d1b2ff3dda4fc7d309933308be (patch)
tree516bffb58226cd128f2ed029e51739f9938ef94f /source/blender/editors/gizmo_library
parent16943c01464c7119480cae7cf5d089e1c597d8ab (diff)
Object: new add object tool, currently for primitive types
- Interactively adding primitives with two clicks. - Scene orientation used for new objects. - Depth [view-plane, axis-plane, surface] - Origin [base, center] - Primitive types [cube, cylinder, cone, uv-sphere, ico-sphere ] - Settings for object types in the top-bar. Shortcuts: - Snapping (Ctrl). - Constrain 1:1 aspect (Shift). - Toggle center (Alt). Part of T57210 design task.
Diffstat (limited to 'source/blender/editors/gizmo_library')
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c41
1 files changed, 35 insertions, 6 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 8c03fe764c2..19370f345fd 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
@@ -74,6 +74,7 @@ typedef struct SnapGizmo3D {
int snap_on;
bool invert_snap;
#endif
+ int use_snap_override;
} SnapGizmo3D;
#ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
@@ -211,6 +212,23 @@ SnapObjectContext *ED_gizmotypes_snap_3d_context_ensure(Scene *scene,
return gizmo_snap->snap_context_v3d;
}
+bool ED_gizmotypes_snap_3d_invert_snap_get(struct wmGizmo *gz)
+{
+ SnapGizmo3D *gizmo_snap = (SnapGizmo3D *)gz;
+ return gizmo_snap->invert_snap;
+}
+void ED_gizmotypes_snap_3d_toggle_set(wmGizmo *gz, bool enable)
+{
+ SnapGizmo3D *gizmo_snap = (SnapGizmo3D *)gz;
+ gizmo_snap->use_snap_override = (int)enable;
+}
+
+void ED_gizmotypes_snap_3d_toggle_clear(wmGizmo *gz)
+{
+ SnapGizmo3D *gizmo_snap = (SnapGizmo3D *)gz;
+ gizmo_snap->use_snap_override = -1;
+}
+
short ED_gizmotypes_snap_3d_update(wmGizmo *gz,
struct Depsgraph *depsgraph,
const ARegion *region,
@@ -221,21 +239,30 @@ short ED_gizmotypes_snap_3d_update(wmGizmo *gz,
float r_nor[3])
{
SnapGizmo3D *gizmo_snap = (SnapGizmo3D *)gz;
+ Scene *scene = DEG_get_input_scene(depsgraph);
float co[3], no[3];
short snap_elem = 0;
int snap_elem_index[3] = {-1, -1, -1};
int index = -1;
+ if (gizmo_snap->use_snap_override != -1) {
+ if (gizmo_snap->use_snap_override == false) {
+ gizmo_snap->snap_elem = 0;
+ return 0;
+ }
+ }
+
#ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
if (wm) {
gizmo_snap->invert_snap = invert_snap(gz, wm, wm->winactive->eventstate);
}
- Scene *scene = DEG_get_input_scene(depsgraph);
- const ToolSettings *ts = scene->toolsettings;
- if (gizmo_snap->invert_snap != !(ts->snap_flag & SCE_SNAP)) {
- gizmo_snap->snap_elem = 0;
- return 0;
+ if (gizmo_snap->use_snap_override == -1) {
+ const ToolSettings *ts = scene->toolsettings;
+ if (gizmo_snap->invert_snap != !(ts->snap_flag & SCE_SNAP)) {
+ gizmo_snap->snap_elem = 0;
+ return 0;
+ }
}
#else
UNUSED_VARS(wm);
@@ -328,6 +355,8 @@ static void gizmo_snap_setup(wmGizmo *gz)
gizmo_snap->prop_elem_index = RNA_struct_find_property(gz->ptr, "snap_elem_index");
gizmo_snap->prop_snap_force = RNA_struct_find_property(gz->ptr, "snap_elements_force");
+ gizmo_snap->use_snap_override = -1;
+
/* Prop fallback. */
WM_gizmo_target_property_def_rna(gz, "snap_elements", gz->ptr, "snap_elements_force", -1);
@@ -381,7 +410,7 @@ static int gizmo_snap_test_select(bContext *C, wmGizmo *gz, const int mval[2])
SnapGizmo3D *gizmo_snap = (SnapGizmo3D *)gz;
#ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
wmWindowManager *wm = CTX_wm_manager(C);
- bool invert = invert_snap(gz, wm, wm->winactive->eventstate);
+ const bool invert = invert_snap(gz, wm, wm->winactive->eventstate);
if (gizmo_snap->invert_snap == invert && gizmo_snap->mval[0] == mval[0] &&
gizmo_snap->mval[1] == mval[1]) {
/* Performance, do not update. */