DRW: Mesh Batch Cache: Fix error in loop custom data layer checking
authorClément Foucault <foucault.clem@gmail.com>
Wed, 3 Apr 2019 21:46:32 +0000 (23:46 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Wed, 3 Apr 2019 21:51:00 +0000 (23:51 +0200)
source/blender/draw/intern/draw_cache_impl_mesh.c

index ddb36c62682000ffe3d7a89741909bbab93d2f58..84d2805de7306a4d3f98cb880cb273ccc76daf6a 100644 (file)
@@ -4628,6 +4628,13 @@ void DRW_mesh_batch_cache_create_requested(
        if (cd_overlap == false) {
                for (int type = 0; type < CD_NUMTYPES; ++type) {
                        if ((cache->cd_vused[type] & cache->cd_vneeded[type]) != cache->cd_vneeded[type]) {
+                               switch (type) {
+                                       case CD_ORCO:
+                                               GPU_VERTBUF_DISCARD_SAFE(cache->ordered.loop_orco);
+                                               break;
+                               }
+                       }
+                       if ((cache->cd_lused[type] & cache->cd_lneeded[type]) != cache->cd_lneeded[type]) {
                                switch (type) {
                                        case CD_MLOOPUV:
                                        case CD_TANGENT:
@@ -4636,9 +4643,6 @@ void DRW_mesh_batch_cache_create_requested(
                                        case CD_MLOOPCOL:
                                                GPU_VERTBUF_DISCARD_SAFE(cache->ordered.loop_vcol);
                                                break;
-                                       case CD_ORCO:
-                                               GPU_VERTBUF_DISCARD_SAFE(cache->ordered.loop_orco);
-                                               break;
                                }
                        }
                }