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:
authorJacques Lucke <jacques@blender.org>2022-02-18 11:12:41 +0300
committerJacques Lucke <jacques@blender.org>2022-02-18 11:14:54 +0300
commit61aaeb3745ad72c681c17f4535dd06ffaaf78c58 (patch)
treec843b445e3e68938aa8c1f5f704dc55eb2be5c6d /source/blender/editors/sculpt_paint
parent964d3a38fac8fd9ba90e6a94d26546f2d0651116 (diff)
Curves: initial brush system integration for curves sculpt mode
This adds the boilerplate code that is necessary to use the tool/brush/paint systems in the new sculpt curves mode. Two temporary dummy tools are part of this patch. They do nothing and only serve to test the boilerplate. When the first actual tool is added, those dummy tools will be removed. Differential Revision: https://developer.blender.org/D14117
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/CMakeLists.txt2
-rw-r--r--source/blender/editors/sculpt_paint/curves_sculpt_intern.h15
-rw-r--r--source/blender/editors/sculpt_paint/curves_sculpt_ops.cc85
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c6
4 files changed, 108 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt
index 55099e2e750..fcde780fc58 100644
--- a/source/blender/editors/sculpt_paint/CMakeLists.txt
+++ b/source/blender/editors/sculpt_paint/CMakeLists.txt
@@ -24,6 +24,7 @@ set(INC
)
set(SRC
+ curves_sculpt_ops.cc
paint_cursor.c
paint_curve.c
paint_curve_undo.c
@@ -66,6 +67,7 @@ set(SRC
sculpt_undo.c
sculpt_uv.c
+ curves_sculpt_intern.h
paint_intern.h
sculpt_intern.h
)
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_intern.h b/source/blender/editors/sculpt_paint/curves_sculpt_intern.h
new file mode 100644
index 00000000000..6a96a8e0e9f
--- /dev/null
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_intern.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#pragma once
+
+struct bContext;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool CURVES_SCULPT_mode_poll(struct bContext *C);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
new file mode 100644
index 00000000000..ead016174c9
--- /dev/null
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
@@ -0,0 +1,85 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include "BLI_utildefines.h"
+
+#include "BKE_context.h"
+#include "BKE_paint.h"
+
+#include "WM_api.h"
+
+#include "ED_curves_sculpt.h"
+
+#include "curves_sculpt_intern.h"
+#include "paint_intern.h"
+
+bool CURVES_SCULPT_mode_poll(struct bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+ return ob && ob->mode & OB_MODE_SCULPT_CURVES;
+}
+
+static bool stroke_get_location(bContext *C, float out[3], const float mouse[2])
+{
+ out[0] = mouse[0];
+ out[1] = mouse[1];
+ out[2] = 0;
+ UNUSED_VARS(C);
+ return true;
+}
+
+static bool stroke_test_start(bContext *C, struct wmOperator *op, const float mouse[2])
+{
+ UNUSED_VARS(C, op, mouse);
+ return true;
+}
+
+static void stroke_update_step(bContext *C, PaintStroke *stroke, PointerRNA *itemptr)
+{
+ UNUSED_VARS(C, stroke, itemptr);
+}
+
+static void stroke_done(const bContext *C, PaintStroke *stroke)
+{
+ UNUSED_VARS(C, stroke);
+}
+
+static int sculpt_curves_stroke_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ PaintStroke *stroke = paint_stroke_new(C,
+ op,
+ stroke_get_location,
+ stroke_test_start,
+ stroke_update_step,
+ nullptr,
+ stroke_done,
+ event->type);
+ op->customdata = stroke;
+
+ WM_event_add_modal_handler(C, op);
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static void sculpt_curves_stroke_cancel(bContext *C, wmOperator *op)
+{
+ paint_stroke_cancel(C, op);
+}
+
+static void SCULPT_CURVES_OT_brush_stroke(struct wmOperatorType *ot)
+{
+ ot->name = "Stroke Curves Sculpt";
+ ot->idname = "SCULPT_CURVES_OT_brush_stroke";
+ ot->description = "Sculpt curves using a brush";
+
+ ot->invoke = sculpt_curves_stroke_invoke;
+ ot->modal = paint_stroke_modal;
+ ot->cancel = sculpt_curves_stroke_cancel;
+
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ paint_stroke_operator_properties(ot);
+}
+
+void ED_operatortypes_sculpt_curves()
+{
+ WM_operatortype_append(SCULPT_CURVES_OT_brush_stroke);
+}
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 1b876235ad0..926a564184a 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -39,6 +39,7 @@
#include "RNA_access.h"
#include "RNA_define.h"
+#include "curves_sculpt_intern.h"
#include "paint_intern.h"
#include "sculpt_intern.h"
@@ -758,6 +759,7 @@ static const ePaintMode brush_select_paint_modes[] = {
PAINT_MODE_VERTEX_GPENCIL,
PAINT_MODE_SCULPT_GPENCIL,
PAINT_MODE_WEIGHT_GPENCIL,
+ PAINT_MODE_SCULPT_CURVES,
};
static int brush_select_exec(bContext *C, wmOperator *op)
@@ -1388,6 +1390,10 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
keymap = paint_stroke_modal_keymap(keyconf);
WM_modalkeymap_assign(keymap, "SCULPT_OT_brush_stroke");
+ /* Curves Sculpt mode. */
+ keymap = WM_keymap_ensure(keyconf, "Sculpt Curves", 0, 0);
+ keymap->poll = CURVES_SCULPT_mode_poll;
+
/* sculpt expand. */
sculpt_expand_modal_keymap(keyconf);
}