diff --git a/source/blender/blenkernel/BKE_paint.hh b/source/blender/blenkernel/BKE_paint.hh index 58a8a0a7d22..03725f1ca68 100644 --- a/source/blender/blenkernel/BKE_paint.hh +++ b/source/blender/blenkernel/BKE_paint.hh @@ -403,7 +403,6 @@ struct SculptSession : blender::NonCopyable, blender::NonMovable { /* TODO(jbakker): Replace rv3d and v3d with ViewContext */ RegionView3D *rv3d = nullptr; View3D *v3d = nullptr; - Scene *scene = nullptr; /* Dynamic mesh preview */ blender::Array preview_verts; diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index fc3eca43be3..c839c159f19 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -1977,8 +1977,6 @@ static void sculpt_update_object(Depsgraph *depsgraph, ss.building_vp_handle = false; - ss.scene = scene; - ss.shapekey_active = (mmd == nullptr) ? BKE_keyblock_from_object(ob) : nullptr; /* NOTE: Weight pPaint require mesh info for loop lookup, but it never uses multires code path, diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 08441b3d714..22521796b4d 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -3658,7 +3658,8 @@ static void do_brush_action(const Depsgraph &depsgraph, do_displacement_smear_brush(depsgraph, sd, ob, node_mask); break; case SCULPT_BRUSH_TYPE_PAINT: - color::do_paint_brush(depsgraph, paint_mode_settings, sd, ob, node_mask, texnode_mask); + color::do_paint_brush( + scene, depsgraph, paint_mode_settings, sd, ob, node_mask, texnode_mask); break; case SCULPT_BRUSH_TYPE_SMEAR: color::do_smear_brush(depsgraph, sd, ob, node_mask); @@ -5686,7 +5687,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent int ignore_background_click; int retval; Object &ob = *CTX_data_active_object(C); - + Scene &scene = *CTX_data_scene(C); const View3D *v3d = CTX_wm_view3d(C); const Base *base = CTX_data_active_base(C); /* Test that ob is visible; otherwise we won't be able to get evaluated data @@ -5709,7 +5710,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent return OPERATOR_CANCELLED; } if (SCULPT_brush_type_is_mask(brush.sculpt_brush_type)) { - MultiresModifierData *mmd = BKE_sculpt_multires_active(ss.scene, &ob); + MultiresModifierData *mmd = BKE_sculpt_multires_active(&scene, &ob); BKE_sculpt_mask_layers_ensure(CTX_data_depsgraph_pointer(C), CTX_data_main(C), &ob, mmd); } if (!SCULPT_brush_type_is_attribute_only(brush.sculpt_brush_type) && diff --git a/source/blender/editors/sculpt_paint/sculpt_color.hh b/source/blender/editors/sculpt_paint/sculpt_color.hh index ff11d92196c..1641cca5aa3 100644 --- a/source/blender/editors/sculpt_paint/sculpt_color.hh +++ b/source/blender/editors/sculpt_paint/sculpt_color.hh @@ -61,7 +61,8 @@ float4 color_vert_get(OffsetIndices faces, bke::GAttributeReader active_color_attribute(const Mesh &mesh); bke::GSpanAttributeWriter active_color_attribute_for_write(Mesh &mesh); -void do_paint_brush(const Depsgraph &depsgraph, +void do_paint_brush(const Scene &scene, + const Depsgraph &depsgraph, PaintModeSettings &paint_mode_settings, const Sculpt &sd, Object &ob, diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.cc b/source/blender/editors/sculpt_paint/sculpt_expand.cc index bf69e07b7cb..aa58e1bf6eb 100644 --- a/source/blender/editors/sculpt_paint/sculpt_expand.cc +++ b/source/blender/editors/sculpt_paint/sculpt_expand.cc @@ -2478,13 +2478,14 @@ static void cache_initial_config_set(bContext *C, wmOperator *op, Cache &expand_ expand_cache.brush_gradient = false; /* Texture and color data from the active Brush. */ + Scene &scene = *CTX_data_scene(C); Object &ob = *CTX_data_active_object(C); const Sculpt &sd = *CTX_data_tool_settings(C)->sculpt; SculptSession &ss = *ob.sculpt; expand_cache.brush = BKE_paint_brush_for_read(&sd.paint); BKE_curvemapping_init(expand_cache.brush->curve); copy_v4_fl(expand_cache.fill_color, 1.0f); - copy_v3_v3(expand_cache.fill_color, BKE_brush_color_get(ss.scene, expand_cache.brush)); + copy_v3_v3(expand_cache.fill_color, BKE_brush_color_get(&scene, expand_cache.brush)); IMB_colormanagement_srgb_to_scene_linear_v3(expand_cache.fill_color, expand_cache.fill_color); expand_cache.scene = CTX_data_scene(C); @@ -2584,7 +2585,8 @@ static int sculpt_expand_invoke(bContext *C, wmOperator *op, const wmEvent *even } if (ss.expand_cache->target == TargetType::Mask) { - MultiresModifierData *mmd = BKE_sculpt_multires_active(ss.scene, &ob); + Scene &scene = *CTX_data_scene(C); + MultiresModifierData *mmd = BKE_sculpt_multires_active(&scene, &ob); BKE_sculpt_mask_layers_ensure(depsgraph, CTX_data_main(C), &ob, mmd); if (RNA_boolean_get(op->ptr, "use_auto_mask")) { diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.hh b/source/blender/editors/sculpt_paint/sculpt_intern.hh index c2497189a1b..bcf2892ab17 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.hh +++ b/source/blender/editors/sculpt_paint/sculpt_intern.hh @@ -911,7 +911,8 @@ bool SCULPT_paint_image_canvas_get(PaintModeSettings &paint_mode_settings, Object &ob, Image **r_image, ImageUser **r_image_user) ATTR_NONNULL(); -void SCULPT_do_paint_brush_image(const Depsgraph &depsgraph, +void SCULPT_do_paint_brush_image(const Scene &scene, + const Depsgraph &depsgraph, PaintModeSettings &paint_mode_settings, const Sculpt &sd, Object &ob, diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.cc b/source/blender/editors/sculpt_paint/sculpt_paint_color.cc index 9133b367c50..f6450d01088 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_color.cc +++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.cc @@ -337,7 +337,8 @@ static void do_color_smooth_task(const Depsgraph &depsgraph, } } -static void do_paint_brush_task(const Depsgraph &depsgraph, +static void do_paint_brush_task(const Scene &scene, + const Depsgraph &depsgraph, Object &object, const Span vert_positions, const Span vert_normals, @@ -357,7 +358,7 @@ static void do_paint_brush_task(const Depsgraph &depsgraph, const Mesh &mesh = *static_cast(object.data); const float bstrength = fabsf(ss.cache->bstrength); - const float alpha = BKE_brush_alpha_get(ss.scene, &brush); + const float alpha = BKE_brush_alpha_get(&scene, &brush); const Span verts = node.verts(); @@ -407,9 +408,8 @@ static void do_paint_brush_task(const Depsgraph &depsgraph, } } - const float3 brush_color_rgb = ss.cache->invert ? - BKE_brush_secondary_color_get(ss.scene, &brush) : - BKE_brush_color_get(ss.scene, &brush); + const float3 brush_color_rgb = ss.cache->invert ? BKE_brush_secondary_color_get(&scene, &brush) : + BKE_brush_color_get(&scene, &brush); float4 brush_color(brush_color_rgb, 1.0f); IMB_colormanagement_srgb_to_scene_linear_v3(brush_color, brush_color); @@ -520,7 +520,8 @@ static void do_sample_wet_paint_task(const Object &object, } } -void do_paint_brush(const Depsgraph &depsgraph, +void do_paint_brush(const Scene &scene, + const Depsgraph &depsgraph, PaintModeSettings &paint_mode_settings, const Sculpt &sd, Object &ob, @@ -528,7 +529,7 @@ void do_paint_brush(const Depsgraph &depsgraph, const IndexMask &texnode_mask) { if (SCULPT_use_image_paint_brush(paint_mode_settings, ob)) { - SCULPT_do_paint_brush_image(depsgraph, paint_mode_settings, sd, ob, texnode_mask); + SCULPT_do_paint_brush_image(scene, depsgraph, paint_mode_settings, sd, ob, texnode_mask); return; } @@ -654,7 +655,8 @@ void do_paint_brush(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { ColorPaintLocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - do_paint_brush_task(depsgraph, + do_paint_brush_task(scene, + depsgraph, ob, vert_positions, vert_normals, diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc index 7b604626c56..96ff8eb56f6 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc +++ b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc @@ -250,7 +250,8 @@ static BitVector<> init_uv_primitives_brush_test(SculptSession &ss, return brush_test; } -static void do_paint_pixels(const Depsgraph &depsgraph, +static void do_paint_pixels(const Scene &scene, + const Depsgraph &depsgraph, Object &object, const Brush &brush, ImageData image_data, @@ -279,8 +280,8 @@ static void do_paint_pixels(const Depsgraph &depsgraph, brush_color[2] = float((hash >> 16) & 255) / 255.0f; #else copy_v3_v3(brush_color, - ss.cache->invert ? BKE_brush_secondary_color_get(ss.scene, &brush) : - BKE_brush_color_get(ss.scene, &brush)); + ss.cache->invert ? BKE_brush_secondary_color_get(&scene, &brush) : + BKE_brush_color_get(&scene, &brush)); #endif brush_color[3] = 1.0f; @@ -496,7 +497,8 @@ bool SCULPT_use_image_paint_brush(PaintModeSettings &settings, Object &ob) return BKE_paint_canvas_image_get(&settings, &ob, &image, &image_user); } -void SCULPT_do_paint_brush_image(const Depsgraph &depsgraph, +void SCULPT_do_paint_brush_image(const Scene &scene, + const Depsgraph &depsgraph, PaintModeSettings &paint_mode_settings, const Sculpt &sd, Object &ob, @@ -517,7 +519,7 @@ void SCULPT_do_paint_brush_image(const Depsgraph &depsgraph, do_push_undo_tile(*image_data.image, *image_data.image_user, nodes[i]); }); node_mask.foreach_index(GrainSize(1), [&](const int i) { - do_paint_pixels(depsgraph, ob, *brush, image_data, nodes[i]); + do_paint_pixels(scene, depsgraph, ob, *brush, image_data, nodes[i]); }); fix_non_manifold_seam_bleeding(ob, *image_data.image, *image_data.image_user, nodes, node_mask);