Fix #122947: Curve stroke on duplicate object doesn't update normals

When a mesh is shared between multiple objects, sculpting with a brush
with the Curve stroke type doesnt update normal values for the affected
nodes when using PBVH drawing. This is because when reevaluating the
depsgraph for the objects, the shared PBVH is destroyed and the nodes
are recalculated, losing the existing node flag updates.

This only occurs for the Curve stroke type because all of its stroke
steps are performed within a single call to the overall operator when
the user presses enter, unlike other brush strokes which apply on each
mouse movement.

To fix this, we simply force update the normals before destroying the
PBVH at the end of the stroke step.

Pull Request: https://projects.blender.org/blender/blender/pulls/124268
This commit is contained in:
Sean Kim
2024-07-08 21:36:28 +02:00
committed by Sean Kim
parent 9a26bfcd5f
commit d527e3a6bd

View File

@@ -1855,6 +1855,12 @@ void BKE_sculpt_update_object_before_eval(Object *ob_eval)
if (ss && ss->building_vp_handle == false) {
if (!ss->cache && !ss->filter_cache && !ss->expand_cache) {
if (ss->pbvh) {
/* PBVH nodes may contain dirty normal tags. To avoid losing that information when the PBVH
* is deleted, make sure all tagged geometry normals are up to date.
* See #122947 for more information. */
blender::bke::pbvh::update_normals(*ss->pbvh, ss->subdiv_ccg);
}
/* We free pbvh on changes, except in the middle of drawing a stroke
* since it can't deal with changing PVBH node organization, we hope
* topology does not change in the meantime .. weak. */