[Bf-blender-cvs] [355faeb4739] soc-2021-knife-tools: Knife: New default snapping angle + code refactor
Cian Jinks
noreply at git.blender.org
Mon Jun 7 19:21:12 CEST 2021
Commit: 355faeb4739a169fbb9b8eab70d7891348ab7127
Author: Cian Jinks
Date: Mon Jun 7 18:16:43 2021 +0100
Branches: soc-2021-knife-tools
https://developer.blender.org/rB355faeb4739a169fbb9b8eab70d7891348ab7127
Knife: New default snapping angle + code refactor
Set the default snapping angle to 30 degrees and refactored number input for angle snapping code.
===================================================================
M release/scripts/presets/keyconfig/keymap_data/blender_default.py
M source/blender/editors/mesh/editmesh_knife.c
===================================================================
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index c3d47ad0b8c..3165a3aa980 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -4711,9 +4711,9 @@ def km_mesh(params):
("mesh.dissolve_mode", {"type": 'X', "value": 'PRESS', "ctrl": True}, None),
("mesh.dissolve_mode", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None),
("mesh.knife_tool", {"type": 'K', "value": 'PRESS'},
- {"properties": [("use_occlude_geometry", True), ("only_selected", False), ("angle_snapping_increment", 5.0)]}),
+ {"properties": [("use_occlude_geometry", True), ("only_selected", False), ("angle_snapping_increment", 30.0)]}),
("mesh.knife_tool", {"type": 'K', "value": 'PRESS', "shift": True},
- {"properties": [("use_occlude_geometry", False), ("only_selected", True), ("angle_snapping_increment", 5.0)]}),
+ {"properties": [("use_occlude_geometry", False), ("only_selected", True), ("angle_snapping_increment", 30.0)]}),
("object.vertex_parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None),
# Menus.
op_menu("VIEW3D_MT_edit_mesh_faces", {"type": 'F', "value": 'PRESS', "ctrl": True}),
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index dee5d433f42..d21d672d83e 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -89,7 +89,7 @@
#define KNIFE_FLT_EPS_PX_EDGE 0.05f
#define KNIFE_FLT_EPS_PX_FACE 0.05f
-#define KNIFE_DEFAULT_ANGLE_SNAPPING_INCREMENT 5.0f
+#define KNIFE_DEFAULT_ANGLE_SNAPPING_INCREMENT 30.0f
#define KNIFE_MIN_ANGLE_SNAPPING_INCREMENT 0.0f
#define KNIFE_MAX_ANGLE_SNAPPING_INCREMENT 90.0f
@@ -2920,11 +2920,20 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
bool handled = false;
+ float snapping_increment_temp;
+
if (kcd->angle_snapping) {
+ /* Modal numinput active, try to handle numeric inputs first... */
if (event->val == KM_PRESS && hasNumInput(&kcd->num) && handleNumInput(C, &kcd->num, event)) {
- applyNumInput(&kcd->num, &kcd->angle_snapping_increment);
- knife_update_header(C, op, kcd);
handled = true;
+ applyNumInput(&kcd->num, &snapping_increment_temp);
+ /* Restrict number key input to 0 - 90 degree range */
+ if (snapping_increment_temp > KNIFE_MIN_ANGLE_SNAPPING_INCREMENT &&
+ snapping_increment_temp < KNIFE_MAX_ANGLE_SNAPPING_INCREMENT) {
+ kcd->angle_snapping_increment = snapping_increment_temp;
+ }
+ knife_update_header(C, op, kcd);
+ return OPERATOR_RUNNING_MODAL;
}
}
@@ -3098,9 +3107,16 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
if (kcd->angle_snapping) {
+ /* Modal numinput inactive, try to handle numeric inputs last... */
if (!handled && event->val == KM_PRESS && handleNumInput(C, &kcd->num, event)) {
- applyNumInput(&kcd->num, &kcd->angle_snapping_increment);
+ applyNumInput(&kcd->num, &snapping_increment_temp);
+ /* Restrict number key input to 0 - 90 degree range */
+ if (snapping_increment_temp > KNIFE_MIN_ANGLE_SNAPPING_INCREMENT &&
+ snapping_increment_temp < KNIFE_MAX_ANGLE_SNAPPING_INCREMENT) {
+ kcd->angle_snapping_increment = snapping_increment_temp;
+ }
knife_update_header(C, op, kcd);
+ return OPERATOR_RUNNING_MODAL;
}
}
More information about the Bf-blender-cvs
mailing list