[Bf-blender-cvs] [7a7f2949406] blender-v2.91-release: Fix T81775: Object Disappears During Texture Painting

Jeroen Bakker noreply at git.blender.org
Wed Nov 4 14:08:44 CET 2020


Commit: 7a7f2949406764a17cfcb77345dbec7989c13e37
Author: Jeroen Bakker
Date:   Tue Nov 3 10:55:18 2020 +0100
Branches: blender-v2.91-release
https://developer.blender.org/rB7a7f2949406764a17cfcb77345dbec7989c13e37

Fix T81775: Object Disappears During Texture Painting

Issue was that the `tris_per_mat` are not created when the first batch is drawn
during select operator and then is not created when needed by the workbench pass
since they are not tracked by mesh_buffer_cache_create_requested.

This change will create the `tris_per_mat` just in case they are needed later.
Solution by Clément Foucault

Differential Revision: https://developer.blender.org/D9430

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

M	source/blender/draw/intern/draw_cache_extract_mesh.c

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

diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c
index 56633a6fecc..ce3a89ae45c 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.c
@@ -902,12 +902,16 @@ static void extract_tris_finish(const MeshRenderData *mr,
   MeshExtract_Tri_Data *data = _data;
   GPU_indexbuf_build_in_place(&data->elb, ibo);
 
-  /* HACK: Create ibo sub-ranges and assign them to each #GPUBatch. */
-  /* The `surface_per_mat` tests are there when object shading type is set to Wire or Bounds. In
-   * these cases there isn't a surface per material. */
-  if (mr->use_final_mesh && cache->surface_per_mat && cache->surface_per_mat[0]) {
+  /* Create ibo sub-ranges. Always do this to avoid error when the standard surface batch
+   * is created before the surfaces-per-material. */
+  if (mr->use_final_mesh && cache->final.tris_per_mat) {
     MeshBufferCache *mbc = &cache->final;
     for (int i = 0; i < mr->mat_len; i++) {
+      /* Theses IBOs have not been queried yet but we create them just in case they are needed
+       * later since they are not tracked by mesh_buffer_cache_create_requested(). */
+      if (mbc->tris_per_mat[i] == NULL) {
+        mbc->tris_per_mat[i] = GPU_indexbuf_calloc();
+      }
       /* Multiply by 3 because these are triangle indices. */
       const int mat_start = data->tri_mat_start[i];
       const int mat_end = data->tri_mat_end[i];



More information about the Bf-blender-cvs mailing list