[Bf-blender-cvs] [7f2beb79c65] master: Cleanup: move curves sculpt mode toggle operator to sculpt/paint module

Jacques Lucke noreply at git.blender.org
Mon Feb 21 11:58:00 CET 2022


Commit: 7f2beb79c656bcacc7d0492da13df8379cf44311
Author: Jacques Lucke
Date:   Mon Feb 21 11:57:43 2022 +0100
Branches: master
https://developer.blender.org/rB7f2beb79c656bcacc7d0492da13df8379cf44311

Cleanup: move curves sculpt mode toggle operator to sculpt/paint module

This is necessary, because the operator will have to use functions that
are currently private within this module. E.g. `paint_cursor_start`.

===================================================================

M	source/blender/editors/curves/intern/curves_ops.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_ops.cc

===================================================================

diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc
index 0aa8c4b253e..52a55ae1760 100644
--- a/source/blender/editors/curves/intern/curves_ops.cc
+++ b/source/blender/editors/curves/intern/curves_ops.cc
@@ -4,74 +4,8 @@
  * \ingroup edcurves
  */
 
-#include "BLI_utildefines.h"
-
 #include "ED_curves.h"
-#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"
-#include "RNA_types.h"
-
-static bool curves_sculptmode_toggle_poll(bContext *C)
-{
-  Object *ob = CTX_data_active_object(C);
-  if (ob == nullptr) {
-    return false;
-  }
-  if (ob->type != OB_CURVES) {
-    return false;
-  }
-  return true;
-}
-
-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;
-
-  if (is_mode_set) {
-    if (!ED_object_mode_compat_set(C, ob, OB_MODE_SCULPT_CURVES, op->reports)) {
-      return OPERATOR_CANCELLED;
-    }
-  }
-
-  if (is_mode_set) {
-    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;
-}
-
-static void CURVES_OT_sculptmode_toggle(wmOperatorType *ot)
-{
-  ot->name = "Curve Sculpt Mode Toggle";
-  ot->idname = "CURVES_OT_sculptmode_toggle";
-  ot->description = "Enter/Exit sculpt mode for curves";
-
-  ot->exec = curves_sculptmode_toggle_exec;
-  ot->poll = curves_sculptmode_toggle_poll;
-
-  ot->flag = OPTYPE_UNDO | OPTYPE_REGISTER;
-}
 
 void ED_operatortypes_curves()
 {
-  WM_operatortype_append(CURVES_OT_sculptmode_toggle);
 }
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
index c4421210379..137a43ea661 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
@@ -6,8 +6,10 @@
 #include "BKE_paint.h"
 
 #include "WM_api.h"
+#include "WM_toolsystem.h"
 
 #include "ED_curves_sculpt.h"
+#include "ED_object.h"
 
 #include "curves_sculpt_intern.h"
 #include "paint_intern.h"
@@ -84,7 +86,57 @@ static void SCULPT_CURVES_OT_brush_stroke(struct wmOperatorType *ot)
   paint_stroke_operator_properties(ot);
 }
 
+static bool curves_sculptmode_toggle_poll(bContext *C)
+{
+  Object *ob = CTX_data_active_object(C);
+  if (ob == nullptr) {
+    return false;
+  }
+  if (ob->type != OB_CURVES) {
+    return false;
+  }
+  return true;
+}
+
+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;
+
+  if (is_mode_set) {
+    if (!ED_object_mode_compat_set(C, ob, OB_MODE_SCULPT_CURVES, op->reports)) {
+      return OPERATOR_CANCELLED;
+    }
+  }
+
+  if (is_mode_set) {
+    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;
+}
+
+static void CURVES_OT_sculptmode_toggle(wmOperatorType *ot)
+{
+  ot->name = "Curve Sculpt Mode Toggle";
+  ot->idname = "CURVES_OT_sculptmode_toggle";
+  ot->description = "Enter/Exit sculpt mode for curves";
+
+  ot->exec = curves_sculptmode_toggle_exec;
+  ot->poll = curves_sculptmode_toggle_poll;
+
+  ot->flag = OPTYPE_UNDO | OPTYPE_REGISTER;
+}
+
 void ED_operatortypes_sculpt_curves()
 {
   WM_operatortype_append(SCULPT_CURVES_OT_brush_stroke);
+  WM_operatortype_append(CURVES_OT_sculptmode_toggle);
 }



More information about the Bf-blender-cvs mailing list