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:
authorPablo Dobarro <pablodp606@gmail.com>2020-10-21 18:44:00 +0300
committerDalai Felinto <dalai@blender.org>2020-10-21 19:17:36 +0300
commit7ff6bfd1e0af67d2e583d12ce5aee5d2bf8ef96e (patch)
tree44e6816f47bf51c0d019ef582f393510fb62cb29 /source/blender
parent1b577d0d6d4f6517ae2a22edd92a0c4cff4b2255 (diff)
UI: Allow changing the active side of line gestures
Line gesture use always the right side of the line as active (the area of the mesh that is going to be modified) by default. This adds the ability to change the active side when the line gesture is active by pressing the F key. This allows more freedom to position the line after starting the gestures, as it won't be required to cancel the operation or undo if the line was used in the wrong direction. Reviewed By: Severin Differential Revision: https://developer.blender.org/D9301
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c9
-rw-r--r--source/blender/windowmanager/WM_types.h3
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c8
-rw-r--r--source/blender/windowmanager/intern/wm_gesture_ops.c12
-rw-r--r--source/blender/windowmanager/intern/wm_operator_props.c2
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c1
-rw-r--r--source/blender/windowmanager/wm_event_types.h3
7 files changed, 35 insertions, 3 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index f130c2ee685..305347b46a7 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -248,6 +248,7 @@ typedef struct LassoGestureData {
typedef struct LineGestureData {
float true_plane[4];
float plane[4];
+ bool flip;
} LineGestureData;
struct SculptGestureOperation;
@@ -461,6 +462,8 @@ static SculptGestureContext *sculpt_gesture_init_from_line(bContext *C, wmOperat
line_points[1][0] = RNA_int_get(op->ptr, "xend");
line_points[1][1] = RNA_int_get(op->ptr, "yend");
+ sgcontext->line.flip = RNA_boolean_get(op->ptr, "flip");
+
float depth_point[3];
float plane_points[3][3];
@@ -481,6 +484,12 @@ static SculptGestureContext *sculpt_gesture_init_from_line(bContext *C, wmOperat
if (!sgcontext->vc.rv3d->is_persp) {
mul_v3_fl(normal, -1.0f);
}
+
+ /* Apply flip. */
+ if (sgcontext->line.flip) {
+ mul_v3_fl(normal, -1.0f);
+ }
+
mul_v3_mat3_m4v3(normal, sgcontext->vc.obact->imat, normal);
float plane_point_object_space[3];
mul_v3_m4v3(plane_point_object_space, sgcontext->vc.obact->imat, plane_points[0]);
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index b23446e0dce..1b693160e56 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -503,6 +503,9 @@ typedef struct wmGesture {
/** For gestures that support snapping, stores if snapping is enabled using the modal keymap
* toggle. */
uint use_snap : 1;
+ /** For gestures that support flip, stores if flip is enabled using the modal keymap
+ * toggle. */
+ uint use_flip : 1;
/**
* customdata
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index ae8b78876c2..4c1b403ac96 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -200,7 +200,7 @@ int wm_gesture_evaluate(wmGesture *gesture, const wmEvent *event)
/* ******************* gesture draw ******************* */
-static void wm_gesture_draw_line_active_side(rcti *rect)
+static void wm_gesture_draw_line_active_side(rcti *rect, const bool flip)
{
GPUVertFormat *format = immVertexFormat();
uint shdr_pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -222,7 +222,9 @@ static void wm_gesture_draw_line_active_side(rcti *rect)
sub_v2_v2v2(line_dir, line_end, line_start);
normalize_v2(line_dir);
ortho_v2_v2(gradient_dir, line_dir);
- mul_v2_fl(gradient_dir, -1.0f);
+ if (!flip) {
+ mul_v2_fl(gradient_dir, -1.0f);
+ }
mul_v2_fl(gradient_dir, gradient_length);
add_v2_v2v2(gradient_point[0], line_start, gradient_dir);
add_v2_v2v2(gradient_point[1], line_end, gradient_dir);
@@ -252,7 +254,7 @@ static void wm_gesture_draw_line(wmGesture *gt)
rcti *rect = (rcti *)gt->customdata;
if (gt->draw_active_side) {
- wm_gesture_draw_line_active_side(rect);
+ wm_gesture_draw_line_active_side(rect, gt->use_flip);
}
uint shdr_pos = GPU_vertformat_attr_add(
diff --git a/source/blender/windowmanager/intern/wm_gesture_ops.c b/source/blender/windowmanager/intern/wm_gesture_ops.c
index 00112e82771..edf9a3bc693 100644
--- a/source/blender/windowmanager/intern/wm_gesture_ops.c
+++ b/source/blender/windowmanager/intern/wm_gesture_ops.c
@@ -851,6 +851,7 @@ static bool gesture_straightline_apply(bContext *C, wmOperator *op)
RNA_int_set(op->ptr, "ystart", rect->ymin);
RNA_int_set(op->ptr, "xend", rect->xmax);
RNA_int_set(op->ptr, "yend", rect->ymax);
+ RNA_boolean_set(op->ptr, "flip", gesture->use_flip);
if (op->type->exec) {
int retval = op->type->exec(C, op);
@@ -892,6 +893,7 @@ int WM_gesture_straightline_active_side_invoke(bContext *C, wmOperator *op, cons
WM_gesture_straightline_invoke(C, op, event);
wmGesture *gesture = op->customdata;
gesture->draw_active_side = true;
+ gesture->use_flip = false;
return OPERATOR_RUNNING_MODAL;
}
@@ -950,6 +952,11 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *ev
gesture->use_snap = !gesture->use_snap;
break;
}
+ case GESTURE_MODAL_FLIP: {
+ /* Toggle snapping on/off. */
+ gesture->use_flip = !gesture->use_flip;
+ break;
+ }
case GESTURE_MODAL_SELECT: {
if (gesture_straightline_apply(C, op)) {
gesture_modal_end(C, op);
@@ -1029,6 +1036,11 @@ int WM_gesture_straightline_oneshot_modal(bContext *C, wmOperator *op, const wmE
gesture->use_snap = !gesture->use_snap;
break;
}
+ case GESTURE_MODAL_FLIP: {
+ /* Toggle flip on/off. */
+ gesture->use_flip = !gesture->use_flip;
+ break;
+ }
case GESTURE_MODAL_SELECT:
case GESTURE_MODAL_DESELECT:
case GESTURE_MODAL_IN:
diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c
index 78d8fc9a20d..62294d70306 100644
--- a/source/blender/windowmanager/intern/wm_operator_props.c
+++ b/source/blender/windowmanager/intern/wm_operator_props.c
@@ -498,6 +498,8 @@ void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor)
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
prop = RNA_def_int(ot->srna, "yend", 0, INT_MIN, INT_MAX, "Y End", "", INT_MIN, INT_MAX);
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna, "flip", false, "Flip", "");
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
if (cursor) {
prop = RNA_def_int(ot->srna,
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 5e4a45ea3be..613de5a9b17 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3807,6 +3807,7 @@ static void gesture_straightline_modal_keymap(wmKeyConfig *keyconf)
{GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""},
{GESTURE_MODAL_MOVE, "MOVE", 0, "Move", ""},
{GESTURE_MODAL_SNAP, "SNAP", 0, "Snap", ""},
+ {GESTURE_MODAL_FLIP, "FLIP", 0, "Flip", ""},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index 21662a4e83a..223f6cf543d 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -496,6 +496,9 @@ enum {
/** Toggle to activate snapping (angle snapping for straight line). */
GESTURE_MODAL_SNAP = 13,
+
+ /** Toggle to activate flip (flip the active side of a straight line). */
+ GESTURE_MODAL_FLIP = 14,
};
#ifdef __cplusplus