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
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')
-rw-r--r--source/blender/editors/curves/CMakeLists.txt1
-rw-r--r--source/blender/editors/curves/intern/curves_ops.cc7
-rw-r--r--source/blender/editors/include/ED_curves_sculpt.h17
-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
-rw-r--r--source/blender/editors/space_api/spacetypes.c2
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c6
-rw-r--r--source/blender/editors/util/CMakeLists.txt1
10 files changed, 142 insertions, 0 deletions
diff --git a/source/blender/editors/curves/CMakeLists.txt b/source/blender/editors/curves/CMakeLists.txt
index d2b7dacbc20..93b21a46916 100644
--- a/source/blender/editors/curves/CMakeLists.txt
+++ b/source/blender/editors/curves/CMakeLists.txt
@@ -6,6 +6,7 @@ set(INC
../../blenlib
../../blentranslation
../../depsgraph
+ ../../functions
../../makesdna
../../makesrna
../../windowmanager
diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc
index fdda8e636f7..0aa8c4b253e 100644
--- a/source/blender/editors/curves/intern/curves_ops.cc
+++ b/source/blender/editors/curves/intern/curves_ops.cc
@@ -10,9 +10,13 @@
#include "ED_object.h"
#include "WM_api.h"
+#include "WM_toolsystem.h"
#include "WM_types.h"
#include "BKE_context.h"
+#include "BKE_paint.h"
+
+#include "DNA_scene_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -32,6 +36,7 @@ static bool curves_sculptmode_toggle_poll(bContext *C)
static int curves_sculptmode_toggle_exec(bContext *C, wmOperator *op)
{
+ Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
const bool is_mode_set = ob->mode == OB_MODE_SCULPT_CURVES;
@@ -45,9 +50,11 @@ static int curves_sculptmode_toggle_exec(bContext *C, wmOperator *op)
ob->mode = OB_MODE_OBJECT;
}
else {
+ BKE_paint_ensure(scene->toolsettings, (Paint **)&scene->toolsettings->curves_sculpt);
ob->mode = OB_MODE_SCULPT_CURVES;
}
+ WM_toolsystem_update_from_context_view3d(C);
WM_event_add_notifier(C, NC_SCENE | ND_MODE, nullptr);
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/include/ED_curves_sculpt.h b/source/blender/editors/include/ED_curves_sculpt.h
new file mode 100644
index 00000000000..8aab1533e25
--- /dev/null
+++ b/source/blender/editors/include/ED_curves_sculpt.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+/** \file
+ * \ingroup editors
+ */
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void ED_operatortypes_sculpt_curves(void);
+
+#ifdef __cplusplus
+}
+#endif
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);
}
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 897091731a4..d53fe2efb03 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -29,6 +29,7 @@
#include "ED_clip.h"
#include "ED_curve.h"
#include "ED_curves.h"
+#include "ED_curves_sculpt.h"
#include "ED_fileselect.h"
#include "ED_geometry.h"
#include "ED_gizmo_library.h"
@@ -96,6 +97,7 @@ void ED_spacetypes_init(void)
ED_operatortypes_mesh();
ED_operatortypes_geometry();
ED_operatortypes_sculpt();
+ ED_operatortypes_sculpt_curves();
ED_operatortypes_uvedit();
ED_operatortypes_paint();
ED_operatortypes_physics();
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 7addda0f8c3..056e8953c81 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -413,6 +413,9 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *region)
keymap = WM_keymap_ensure(wm->defaultconf, "Particle", 0, 0);
WM_event_add_keymap_handler(&region->handlers, keymap);
+ keymap = WM_keymap_ensure(wm->defaultconf, "Sculpt Curves", 0, 0);
+ WM_event_add_keymap_handler(&region->handlers, keymap);
+
/* editfont keymap swallows all... */
keymap = WM_keymap_ensure(wm->defaultconf, "Font", 0, 0);
WM_event_add_keymap_handler(&region->handlers, keymap);
@@ -1523,6 +1526,9 @@ void ED_view3d_buttons_region_layout_ex(const bContext *C,
case CTX_MODE_VERTEX_GPENCIL:
ARRAY_SET_ITEMS(contexts, ".greasepencil_vertex");
break;
+ case CTX_MODE_SCULPT_CURVES:
+ ARRAY_SET_ITEMS(contexts, ".curves_sculpt");
+ break;
default:
break;
}
diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt
index 2300e664dfa..7b4551fdb0c 100644
--- a/source/blender/editors/util/CMakeLists.txt
+++ b/source/blender/editors/util/CMakeLists.txt
@@ -40,6 +40,7 @@ set(SRC
../include/ED_clip.h
../include/ED_curve.h
../include/ED_curves.h
+ ../include/ED_curves_sculpt.h
../include/ED_datafiles.h
../include/ED_file_indexer.h
../include/ED_fileselect.h