Fix assert and memleak in recent Skin Root Display patch
authorClément Foucault <foucault.clem@gmail.com>
Wed, 16 Oct 2019 17:28:10 +0000 (19:28 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Wed, 16 Oct 2019 18:16:53 +0000 (20:16 +0200)
Caused by 4ddf3215a7df

source/blender/draw/intern/draw_cache_extract_mesh.c
source/blender/draw/intern/draw_cache_impl_mesh.c
source/blender/gpu/intern/gpu_batch.c

index 0479bdd4de7dd520381c402849346251c869cc05..fb439016a875f561c3ca358859e75e3a6335c148 100644 (file)
@@ -4354,6 +4354,7 @@ void mesh_buffer_cache_create_requested(MeshBatchCache *cache,
   TEST_ASSIGN(VBO, vbo, edge_idx);
   TEST_ASSIGN(VBO, vbo, vert_idx);
   TEST_ASSIGN(VBO, vbo, fdot_idx);
+  TEST_ASSIGN(VBO, vbo, skin_roots);
 
   TEST_ASSIGN(IBO, ibo, tris);
   TEST_ASSIGN(IBO, ibo, lines);
index 49db8bd9765b22ad45205d4c339c298d9a4a4e43..ca185fa7d7dfd5f653e8d4ca91a3c1754073958e 100644 (file)
@@ -1328,7 +1328,7 @@ void DRW_mesh_batch_cache_create_requested(
   }
   if (DRW_batch_requested(cache->batch.edit_skin_roots, GPU_PRIM_LINES)) {
     DRW_vbo_request(cache->batch.edit_skin_roots, &mbufcache->vbo.skin_roots);
-    /* HACK(fclem): This is a workaround the deferred batch init
+    /* HACK(fclem): This is to workaround the deferred batch init
      * that prevent drawing using DRW_shgroup_call_instances_with_attribs.
      * So we instead create the whole instancing batch here.
      * Note that we use GPU_PRIM_LINES instead of expected GPU_PRIM_LINE_STRIP
index fc578b4466cc4602adcf9e0d61538538ae48bb50..168d741f92a40de0a924d94f851c55f56578d3d4 100644 (file)
@@ -213,7 +213,9 @@ int GPU_batch_vertbuf_add_ex(GPUBatch *batch, GPUVertBuf *verts, bool own_vbo)
     if (batch->verts[v] == NULL) {
 #if TRUST_NO_ONE
       /* for now all VertexBuffers must have same vertex_len */
-      assert(verts->vertex_len == batch->verts[0]->vertex_len);
+      if (batch->verts[0] != NULL) {
+        assert(verts->vertex_len == batch->verts[0]->vertex_len);
+      }
 #endif
       batch->verts[v] = verts;
       /* TODO: mark dirty so we can keep attribute bindings up-to-date */