Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jeroen@blender.org>2020-11-03 12:55:18 +0300
committerJeroen Bakker <jeroen@blender.org>2020-11-04 16:08:03 +0300
commit7a7f2949406764a17cfcb77345dbec7989c13e37 (patch)
tree3dbe26e5ccc9e02c9bda64476a0387c7a6ed5ffa /source/blender/draw/intern/draw_cache_extract_mesh.c
parent27648ed53788bf03cb803dd4d7c7397dce1c4cac (diff)
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
Diffstat (limited to 'source/blender/draw/intern/draw_cache_extract_mesh.c')
-rw-r--r--source/blender/draw/intern/draw_cache_extract_mesh.c12
1 files changed, 8 insertions, 4 deletions
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];