[Bf-blender-cvs] [325105ee6f6] master: Sculpt: add support for curves sculpt to paint_init_pivot

Joseph Eagar noreply at git.blender.org
Sat Jan 14 05:01:31 CET 2023


Commit: 325105ee6f68ed21cfa85e89922f9ec669d74efa
Author: Joseph Eagar
Date:   Fri Jan 13 19:58:42 2023 -0800
Branches: master
https://developer.blender.org/rB325105ee6f68ed21cfa85e89922f9ec669d74efa

Sculpt: add support for curves sculpt to paint_init_pivot

Uses BKE_object_boundbox_get.

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

M	source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
M	source/blender/editors/sculpt_paint/paint_image.cc

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

diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
index 797b57dd0ca..f12b94aea8f 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
@@ -286,6 +286,7 @@ static void curves_sculptmode_enter(bContext *C)
   ob->mode = OB_MODE_SCULPT_CURVES;
 
   ED_paint_cursor_start(&curves_sculpt->paint, CURVES_SCULPT_mode_poll_view3d);
+  paint_init_pivot(ob, scene);
 
   /* Necessary to change the object mode on the evaluated object. */
   DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
diff --git a/source/blender/editors/sculpt_paint/paint_image.cc b/source/blender/editors/sculpt_paint/paint_image.cc
index a57287b924b..d5efb4fe9c6 100644
--- a/source/blender/editors/sculpt_paint/paint_image.cc
+++ b/source/blender/editors/sculpt_paint/paint_image.cc
@@ -759,23 +759,47 @@ void PAINT_OT_sample_color(wmOperatorType *ot)
 
 /******************** texture paint toggle operator ********************/
 
-void paint_init_pivot(Object *ob, Scene *scene)
+static void paint_init_pivot_mesh(Object *ob, Scene *scene, float location[3])
 {
-  UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
-
   const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob);
   if (!me_eval) {
     me_eval = (const Mesh *)ob->data;
   }
 
-  float location[3] = {FLT_MAX, FLT_MAX, FLT_MAX}, max[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX};
+  float min[3] = {FLT_MAX, FLT_MAX, FLT_MAX}, max[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX};
 
-  if (!BKE_mesh_minmax(me_eval, location, max)) {
+  if (!BKE_mesh_minmax(me_eval, min, max)) {
     zero_v3(location);
     zero_v3(max);
   }
 
-  interp_v3_v3v3(location, location, max, 0.5f);
+  interp_v3_v3v3(location, min, max, 0.5f);
+}
+
+static void paint_init_pivot_curves(Object *ob, Scene *scene, float location[3])
+{
+  const BoundBox *bbox = BKE_object_boundbox_get(ob);
+  interp_v3_v3v3(location, bbox->vec[0], bbox->vec[6], 0.5f);
+}
+
+void paint_init_pivot(Object *ob, Scene *scene)
+{
+  UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
+  float location[3];
+
+  switch (ob->type) {
+    case OB_MESH:
+      paint_init_pivot_mesh(ob, scene, location);
+      break;
+    case OB_CURVES:
+      paint_init_pivot_curves(ob, scene, location);
+      break;
+    default:
+      BLI_assert_unreachable();
+      ups->last_stroke_valid = false;
+      return;
+  }
+
   mul_m4_v3(ob->object_to_world, location);
 
   ups->last_stroke_valid = true;



More information about the Bf-blender-cvs mailing list