[Bf-blender-cvs] [bc06fcca47c] master: Sculpt: do not validate PBVH draw data in mesh_batch_cache_valid

Joseph Eagar noreply at git.blender.org
Sat Oct 15 00:00:48 CEST 2022


Commit: bc06fcca47caa182cad0818de6ccb8cde9ea215e
Author: Joseph Eagar
Date:   Fri Oct 14 14:58:40 2022 -0700
Branches: master
https://developer.blender.org/rBbc06fcca47caa182cad0818de6ccb8cde9ea215e

Sculpt: do not validate PBVH draw data in mesh_batch_cache_valid

Turns out PBVH drawing and normal mesh batches are not mutually
exclusive inside the draw cache; there are edge cases with modifiers
and instancing where you need both, and forcing one or the other
inside this function leads to memory corruption.

===================================================================

M	source/blender/draw/intern/draw_cache_impl_mesh.cc

===================================================================

diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.cc b/source/blender/draw/intern/draw_cache_impl_mesh.cc
index d3e071c14e7..5ce658abfe4 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.cc
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.cc
@@ -560,16 +560,7 @@ static bool mesh_batch_cache_valid(Object *object, Mesh *me)
     return false;
   }
 
-  if (object->sculpt && object->sculpt->pbvh) {
-    if (cache->pbvh_is_drawing != BKE_pbvh_is_drawing(object->sculpt->pbvh)) {
-      return false;
-    }
-
-    if (BKE_pbvh_is_drawing(object->sculpt->pbvh) &&
-        BKE_pbvh_draw_cache_invalid(object->sculpt->pbvh)) {
-      return false;
-    }
-  }
+  /* Note: PBVH draw data should not be checked here. */
 
   if (cache->is_editmode != (me->edit_mesh != nullptr)) {
     return false;
@@ -1443,7 +1434,6 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph,
       }
     }
 
-
     /* Verify that all surface batches have needed attribute layers.
      */
     /* TODO(fclem): We could be a bit smarter here and only do it per
@@ -1486,7 +1476,8 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph,
     mesh_cd_layers_type_merge(&cache->cd_used_over_time, cache->cd_needed);
     mesh_cd_layers_type_clear(&cache->cd_needed);
 
-    drw_attributes_merge(&cache->attr_used_over_time, &cache->attr_needed, me->runtime->render_mutex);
+    drw_attributes_merge(
+        &cache->attr_used_over_time, &cache->attr_needed, me->runtime->render_mutex);
     drw_attributes_clear(&cache->attr_needed);
   }



More information about the Bf-blender-cvs mailing list