[Bf-blender-cvs] [2a97dd65b84] temp-vert-normals-cleanup: Fix crash with dynamic topology

Hans Goudey noreply at git.blender.org
Fri Nov 5 05:13:14 CET 2021


Commit: 2a97dd65b84e348188bf730fa126382fed21b598
Author: Hans Goudey
Date:   Thu Nov 4 23:13:04 2021 -0500
Branches: temp-vert-normals-cleanup
https://developer.blender.org/rB2a97dd65b84e348188bf730fa126382fed21b598

Fix crash with dynamic topology

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

M	source/blender/blenkernel/intern/pbvh.c

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

diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index e1d79b34a2b..32089670022 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -2965,9 +2965,6 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
   vi->vert_indices = vert_indices;
   vi->mverts = verts;
 
-  /* Sculpt/paint code can adjust normals when restoring mesh data. */
-  vi->vert_normals = (float(*)[3])BKE_mesh_ensure_vertex_normals(pbvh->mesh);
-
   if (pbvh->type == PBVH_BMESH) {
     BLI_gsetIterator_init(&vi->bm_unique_verts, node->bm_unique_verts);
     BLI_gsetIterator_init(&vi->bm_other_verts, node->bm_other_verts);
@@ -2982,6 +2979,9 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
 
   vi->mask = NULL;
   if (pbvh->type == PBVH_FACES) {
+    /* Cast awat const because sculpt/paint code can adjust normals when restoring mesh data. */
+    vi->vert_normals = (float(*)[3])BKE_mesh_ensure_vertex_normals(pbvh->mesh);
+
     vi->vmask = CustomData_get_layer(pbvh->vdata, CD_PAINT_MASK);
     vi->vcol = CustomData_get_layer(pbvh->vdata, CD_PROP_COLOR);
   }



More information about the Bf-blender-cvs mailing list