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/curves_sculpt_ops.cc
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/curves_sculpt_ops.cc')
-rw-r--r--source/blender/editors/sculpt_paint/curves_sculpt_ops.cc85
1 files changed, 85 insertions, 0 deletions
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);
+}