Fix #140309: Invalid normals when using external render engine in Sculpt Mode

External render engines, like Cycles, do not use the paint BVH for
rendering. As part of the stroke update process, normal caches are
tagged as dirty. These normals need to be recalculated to be valid on
the next stroke step.

This commit is a mitigation for the reported issue, but does not
fully fix the underlying issue that causes the cycles data to
be in this state.

Pull Request: https://projects.blender.org/blender/blender/pulls/140503
This commit is contained in:
Sean Kim
2025-07-03 22:58:16 +02:00
committed by Sean Kim
parent dd535aba68
commit 954dbedc57

View File

@@ -3222,6 +3222,19 @@ static void do_brush_action(const Depsgraph &depsgraph,
push_undo_nodes(depsgraph, ob, brush, node_mask);
}
/* There are issues with the underlying normals cache / mesh data that can cause the data to
* become out of date.
*
* For EEVEE and Workbench, this is partially mitigated by the fact that the Paint BVH is used
* to signal this update when drawing.
*
* TODO: See #141417
*/
const bool external_engine = ss.rv3d && ss.rv3d->view_render != nullptr;
if (external_engine) {
bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(ob);
bke::pbvh::update_normals(depsgraph, ob, pbvh);
}
if (sculpt_brush_needs_normal(ss, brush)) {
update_sculpt_normal(depsgraph, sd, ob, cursor_sample_result);
}
@@ -5105,7 +5118,7 @@ void flush_update_step(const bContext *C, const UpdateType update_type)
ED_region_tag_redraw(&region);
const bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(ob);
bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(ob);
if (update_type == UpdateType::Position && !ss.shapekey_active) {
if (pbvh.type() == bke::pbvh::Type::Mesh) {
tag_mesh_positions_changed(ob, use_pbvh_draw);