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:
authorJoseph Eagar <joeedh@gmail.com>2022-04-21 09:38:55 +0300
committerJoseph Eagar <joeedh@gmail.com>2022-04-21 09:38:55 +0300
commit6f190f7f43bb6c4a2c9dc52fdaae2dacf10f1d24 (patch)
treeea336d6d0c4a807d0da24ff6f1c7d19885ee221d /source/blender/editors/sculpt_paint/sculpt.c
parent575ade22d4de472ccf9e7d2dc1ffca37416c58f6 (diff)
Fix T97469: Sculpt colors crash in multiresolution or dynamic topology modes.
Sculpt paint tools now pop up an error message if dynamic topology or multires are enabled. Implementation notes: * SCULPT_vertex_colors_poll is now a static function in sculpt_ops.c. It is now used solely by the legacy color attribute conversion operators (SCULPT_OT_vertex_to_loop_colors and SCULPT_OT_loop_to_vertex_colors) and should be deleted when they are. * There is a new method, SCULPT_handles_colors_report, that returns true if the sculpt session can handle color attributes; otherwise it returns false and displays an error message to the user.
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt.c')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index ff13d755971..62f672ed383 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3914,16 +3914,6 @@ bool SCULPT_mode_poll(bContext *C)
return ob && ob->mode & OB_MODE_SCULPT;
}
-bool SCULPT_vertex_colors_poll(bContext *C)
-{
- if (!SCULPT_mode_poll(C)) {
- return false;
- }
-
- Object *ob = CTX_data_active_object(C);
- return ob->sculpt && SCULPT_has_colors(ob->sculpt);
-}
-
bool SCULPT_mode_poll_view3d(bContext *C)
{
return (SCULPT_mode_poll(C) && CTX_wm_region_view3d(C));
@@ -5256,6 +5246,24 @@ static bool over_mesh(bContext *C, struct wmOperator *UNUSED(op), float x, float
return SCULPT_stroke_get_location(C, co, mouse);
}
+bool SCULPT_handles_colors_report(SculptSession *ss, ReportList *reports)
+{
+ switch (BKE_pbvh_type(ss->pbvh)) {
+ case PBVH_FACES:
+ return true;
+ case PBVH_BMESH:
+ BKE_report(reports, RPT_ERROR, "Not supported in dynamic topology mode.");
+ return false;
+ case PBVH_GRIDS:
+ BKE_report(reports, RPT_ERROR, "Not supported in multiresolution mode.");
+ return false;
+ }
+
+ BLI_assert_msg(0, "PBVH corruption, type was invalid.");
+
+ return false;
+}
+
static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op, const float mouse[2])
{
/* Don't start the stroke until mouse goes over the mesh.
@@ -5438,6 +5446,12 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent
sculpt_brush_stroke_init(C, op);
+ Object *ob = CTX_data_active_object(C);
+
+ if (!SCULPT_handles_colors_report(ob->sculpt, op->reports)) {
+ return OPERATOR_CANCELLED;
+ }
+
stroke = paint_stroke_new(C,
op,
SCULPT_stroke_get_location,