diff options
Diffstat (limited to 'source/blender/editors/sculpt_paint')
8 files changed, 64 insertions, 25 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c index 337f7a1ef2b..9170c8b361a 100644 --- a/source/blender/editors/sculpt_paint/paint_curve.c +++ b/source/blender/editors/sculpt_paint/paint_curve.c @@ -40,6 +40,8 @@ #include "BKE_main.h" #include "BKE_paint.h" +#include "DEG_depsgraph.h" + #include "ED_paint.h" #include "ED_view3d.h" @@ -59,12 +61,14 @@ int paint_curve_poll(bContext *C) { + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); Object *ob = CTX_data_active_object(C); Paint *p; RegionView3D *rv3d = CTX_wm_region_view3d(C); SpaceImage *sima; - if (rv3d && !(ob && ((ob->mode & OB_MODE_ALL_PAINT) != 0))) + if (rv3d && !(ob && ((eval_ctx.object_mode & OB_MODE_ALL_PAINT) != 0))) return false; sima = CTX_wm_space_image(C); diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 4a14e985827..1343ab13999 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -5942,10 +5942,11 @@ static int add_simple_uvs_exec(bContext *C, wmOperator *UNUSED(op)) static int add_simple_uvs_poll(bContext *C) { Object *ob = CTX_data_active_object(C); - - if (!ob || ob->type != OB_MESH || ob->mode != OB_MODE_TEXTURE_PAINT) + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); + if (!ob || (ob->type != OB_MESH) || (eval_ctx.object_mode != OB_MODE_TEXTURE_PAINT)) { return false; - + } return true; } diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 004d2757a71..214b260250d 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -40,6 +40,8 @@ #include "BKE_paint.h" #include "BKE_main.h" +#include "DEG_depsgraph.h" + #include "ED_paint.h" #include "ED_screen.h" #include "ED_image.h" @@ -261,6 +263,8 @@ static void PALETTE_OT_color_delete(wmOperatorType *ot) static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op)) { + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); Paint *paint = BKE_paint_get_active_from_context(C); Brush *brush = BKE_paint_brush(paint); Object *ob = CTX_data_active_object(C); @@ -268,7 +272,7 @@ static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op)) if (!ob || !brush) return OPERATOR_CANCELLED; /* TODO: other modes */ - if (ob->mode & OB_MODE_SCULPT) { + if (eval_ctx.object_mode & OB_MODE_SCULPT) { BKE_brush_sculpt_reset(brush); } else { @@ -401,6 +405,8 @@ static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, static int brush_select_exec(bContext *C, wmOperator *op) { + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); Main *bmain = CTX_data_main(C); ToolSettings *toolsettings = CTX_data_tool_settings(C); Paint *paint = NULL; @@ -414,7 +420,7 @@ static int brush_select_exec(bContext *C, wmOperator *op) Object *ob = CTX_data_active_object(C); if (ob) { /* select current paint mode */ - paint_mode = ob->mode & OB_MODE_ALL_PAINT; + paint_mode = eval_ctx.object_mode & OB_MODE_ALL_PAINT; } else { return OPERATOR_CANCELLED; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index b536f42a54e..97b1ab46b0d 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -199,9 +199,13 @@ static void paint_last_stroke_update(Scene *scene, ARegion *ar, const float mval /* Returns true if vertex paint mode is active */ int vertex_paint_mode_poll(bContext *C) { + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); Object *ob = CTX_data_active_object(C); - - return ob && ob->mode == OB_MODE_VERTEX_PAINT && ((Mesh *)ob->data)->totpoly; + return (ob && + (ob->type == OB_MESH) && + ((Mesh *)ob->data)->totpoly && + (eval_ctx.object_mode & OB_MODE_VERTEX_PAINT)); } int vertex_paint_poll(bContext *C) @@ -221,18 +225,24 @@ int vertex_paint_poll(bContext *C) int weight_paint_mode_poll(bContext *C) { + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); Object *ob = CTX_data_active_object(C); - - return ob && ob->mode == OB_MODE_WEIGHT_PAINT && ((Mesh *)ob->data)->totpoly; + return (ob && + (ob->type == OB_MESH) && + ((Mesh *)ob->data)->totpoly && + (eval_ctx.object_mode == OB_MODE_WEIGHT_PAINT)); } int weight_paint_poll(bContext *C) { + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); Object *ob = CTX_data_active_object(C); ScrArea *sa; if ((ob != NULL) && - (ob->mode & OB_MODE_WEIGHT_PAINT) && + (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) && (BKE_paint_brush(&CTX_data_tool_settings(C)->wpaint->paint) != NULL) && (sa = CTX_wm_area(C)) && (sa->spacetype == SPACE_VIEW3D)) @@ -949,17 +959,18 @@ static void vertex_paint_init_session(const EvaluationContext *eval_ctx, Scene * } } -static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob) +static void vertex_paint_init_session_data( + const EvaluationContext *eval_ctx, const ToolSettings *ts, Object *ob) { /* Create maps */ struct SculptVertexPaintGeomMap *gmap = NULL; const Brush *brush = NULL; - if (ob->mode == OB_MODE_VERTEX_PAINT) { + if (eval_ctx->object_mode == OB_MODE_VERTEX_PAINT) { gmap = &ob->sculpt->mode.vpaint.gmap; brush = BKE_paint_brush(&ts->vpaint->paint); ob->sculpt->mode_type = OB_MODE_VERTEX_PAINT; } - else if (ob->mode == OB_MODE_WEIGHT_PAINT) { + else if (eval_ctx->object_mode == OB_MODE_WEIGHT_PAINT) { gmap = &ob->sculpt->mode.wpaint.gmap; brush = BKE_paint_brush(&ts->wpaint->paint); ob->sculpt->mode_type = OB_MODE_WEIGHT_PAINT; @@ -988,7 +999,7 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob) } /* Create average brush arrays */ - if (ob->mode == OB_MODE_VERTEX_PAINT) { + if (eval_ctx->object_mode == OB_MODE_VERTEX_PAINT) { if (!brush_use_accumulate(brush)) { if (ob->sculpt->mode.vpaint.previous_color == NULL) { ob->sculpt->mode.vpaint.previous_color = @@ -999,7 +1010,7 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob) MEM_SAFE_FREE(ob->sculpt->mode.vpaint.previous_color); } } - else if (ob->mode == OB_MODE_WEIGHT_PAINT) { + else if (eval_ctx->object_mode == OB_MODE_WEIGHT_PAINT) { if (!brush_use_accumulate(brush)) { if (ob->sculpt->mode.wpaint.alpha_weight == NULL) { ob->sculpt->mode.wpaint.alpha_weight = @@ -1396,7 +1407,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo /* If not previously created, create vertex/weight paint mode session data */ vertex_paint_init_session(&eval_ctx, scene, ob); vwpaint_update_cache_invariants(C, vp, ss, op, mouse); - vertex_paint_init_session_data(ts, ob); + vertex_paint_init_session_data(&eval_ctx, ts, ob); if (ob->sculpt->mode.wpaint.dvert_prev != NULL) { MDeformVert *dv = ob->sculpt->mode.wpaint.dvert_prev; @@ -1461,8 +1472,11 @@ static void precompute_weight_values( return; /* threaded loop over vertices */ + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); + SculptThreadedTaskData data = { - .C = C, .ob = ob, .wpd = wpd, .wpi = wpi, .me = me, + .C = C, .eval_ctx = &eval_ctx, .ob = ob, .wpd = wpd, .wpi = wpi, .me = me, }; ParallelRangeSettings settings; @@ -1834,8 +1848,12 @@ static void wpaint_paint_leaves( const Brush *brush = ob->sculpt->cache->brush; /* threaded loop over nodes */ + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); + SculptThreadedTaskData data = { - .sd = sd, .ob = ob, .brush = brush, .nodes = nodes, .vp = vp, .wpd = wpd, .wpi = wpi, .me = me, .C = C, + .C = C, .eval_ctx = &eval_ctx, .sd = sd, .ob = ob, .brush = brush, .nodes = nodes, + .vp = vp, .wpd = wpd, .wpi = wpi, .me = me, }; /* Use this so average can modify its weight without touching the brush. */ @@ -2420,7 +2438,7 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f /* If not previously created, create vertex/weight paint mode session data */ vertex_paint_init_session(&eval_ctx, scene, ob); vwpaint_update_cache_invariants(C, vp, ss, op, mouse); - vertex_paint_init_session_data(ts, ob); + vertex_paint_init_session_data(&eval_ctx, ts, ob); if (ob->sculpt->mode.vpaint.previous_color != NULL) { memset(ob->sculpt->mode.vpaint.previous_color, 0, sizeof(uint) * me->totloop); @@ -2873,9 +2891,12 @@ static void vpaint_paint_leaves( { const Brush *brush = ob->sculpt->cache->brush; + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); + SculptThreadedTaskData data = { - .sd = sd, .ob = ob, .brush = brush, .nodes = nodes, .vp = vp, .vpd = vpd, - .lcol = (uint *)me->mloopcol, .me = me, .C = C, + .C = C, .eval_ctx = &eval_ctx, .sd = sd, .ob = ob, .brush = brush, .nodes = nodes, .vp = vp, .vpd = vpd, + .lcol = (uint *)me->mloopcol, .me = me, }; ParallelRangeSettings settings; BLI_parallel_range_settings_defaults(&settings); diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c index d7668a48139..83407ba6765 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c @@ -51,9 +51,11 @@ static int vertex_weight_paint_mode_poll(bContext *C) { + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); Object *ob = CTX_data_active_object(C); Mesh *me = BKE_mesh_from_object(ob); - return (ob && (ob->mode == OB_MODE_VERTEX_PAINT || ob->mode == OB_MODE_WEIGHT_PAINT)) && + return (ob && ELEM(eval_ctx.object_mode, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT)) && (me && me->totpoly && me->dvert); } diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c index 1348847167c..b5d3a452d83 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c @@ -118,9 +118,11 @@ static void wpaint_prev_destroy(struct WPaintPrev *wpp) static int weight_from_bones_poll(bContext *C) { + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); Object *ob = CTX_data_active_object(C); - return (ob && (ob->mode & OB_MODE_WEIGHT_PAINT) && modifiers_isDeformedByArmature(ob)); + return (ob && (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) && modifiers_isDeformedByArmature(ob)); } static int weight_from_bones_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 2d71cc17a19..e121030da0c 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4082,8 +4082,10 @@ static void sculpt_update_tex(const Scene *scene, Sculpt *sd, SculptSession *ss) int sculpt_mode_poll(bContext *C) { + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); Object *ob = CTX_data_active_object(C); - return ob && ob->mode & OB_MODE_SCULPT; + return ob && eval_ctx.object_mode & OB_MODE_SCULPT; } int sculpt_mode_poll_view3d(bContext *C) diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index 5fb9eee805f..58fad870ab3 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -130,6 +130,7 @@ struct SculptRakeData { /* Single struct used by all BLI_task threaded callbacks, let's avoid adding 10's of those... */ typedef struct SculptThreadedTaskData { struct bContext *C; + const struct EvaluationContext *eval_ctx; struct Sculpt *sd; struct Object *ob; const struct Brush *brush; |