Curve Batch Cache: Fix issue with cd_used
authorClément Foucault <foucault.clem@gmail.com>
Sun, 16 Dec 2018 14:46:14 +0000 (15:46 +0100)
committerClément Foucault <foucault.clem@gmail.com>
Mon, 17 Dec 2018 16:05:57 +0000 (17:05 +0100)
cd_used needs to be the combination of generated data.

source/blender/draw/intern/draw_cache_impl_curve.c

index f8508a546616e984b67a062e65254fd5c8180506..ecdbdcf094fe455052694e6debae868f16da2c96 100644 (file)
@@ -909,7 +909,10 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
                        memset(cache->surf_per_mat[i], 0, sizeof(*cache->surf_per_mat[i]));
                }
        }
-       cache->cd_used = cache->cd_needed;
+       if ((cache->cd_used & cache->cd_needed) != cache->cd_needed) {
+               cache->cd_used |= cache->cd_needed;
+               cache->cd_needed = 0;
+       }
 
        /* Init batches and request VBOs & IBOs */
        if (DRW_batch_requested(cache->batch.surfaces, GPU_PRIM_TRIS)) {
@@ -1021,14 +1024,14 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
                curve_create_edit_curves_nor(rdata, cache->edit.curves_nor);
        }
 
+       curve_render_data_free(rdata);
+
 #ifdef DEBUG
        /* Make sure all requested batches have been setup. */
        for (int i = 0; i < sizeof(cache->batch) / sizeof(void *); ++i) {
                BLI_assert(!DRW_batch_requested(((GPUBatch **)&cache->batch)[i], 0));
        }
 #endif
-
-       curve_render_data_free(rdata);
 }
 
 /** \} */