From 70ece6d5bb5511ab39d93f475255202b9270e0f5 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 25 May 2022 20:08:36 +0900 Subject: [PATCH] [vulkan] Work around buggy maps with broken brushes Conflagrant Rodent has a sub-model with 0 faces (double bit error?) causing simply counting faces to get out of sync with actual model starts thus breaking *all* brush models that come after it (including other maps). Thus be a little less lazy in figuring out model start faces. --- libs/video/renderer/vulkan/vulkan_bsp.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libs/video/renderer/vulkan/vulkan_bsp.c b/libs/video/renderer/vulkan/vulkan_bsp.c index 899d50ab5..15f946bb1 100644 --- a/libs/video/renderer/vulkan/vulkan_bsp.c +++ b/libs/video/renderer/vulkan/vulkan_bsp.c @@ -393,12 +393,20 @@ Vulkan_BuildDisplayLists (model_t **models, int num_models, vulkan_ctx_t *ctx) face_base = 0; for (int i = 0; i < num_models; i++) { - if (models[i] && models[i]->type == mod_brush) { - bsp_model_t *m = &bctx->models[models[i]->render_id]; - m->first_face = face_base; - m->face_count = models[i]->brush.nummodelsurfaces; - face_base += m->face_count; + if (!models[i] || models[i]->type != mod_brush) { + continue; } + int num_faces = models[i]->brush.numsurfaces; + bsp_model_t *m = &bctx->models[models[i]->render_id]; + m->first_face = face_base + models[i]->brush.firstmodelsurface; + m->face_count = models[i]->brush.nummodelsurfaces; + while (models[i + 1] && models[i + 1]->path[0] == '*') { + i++; + m = &bctx->models[models[i]->render_id]; + m->first_face = face_base + models[i]->brush.firstmodelsurface; + m->face_count = models[i]->brush.nummodelsurfaces; + } + face_base += num_faces;; } // All usable surfaces have been chained to the (base) texture they use.