From 69943865e76b1287b0eb4eeaabcb30dc5098130b Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Fri, 29 Oct 2021 17:49:06 -0600 Subject: [PATCH] decompile: fix not finding faces (Q2). Unsure of exact location of the previous bug. --- bsputil/decompile.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/bsputil/decompile.cpp b/bsputil/decompile.cpp index 8507a700..bdf26cef 100644 --- a/bsputil/decompile.cpp +++ b/bsputil/decompile.cpp @@ -386,27 +386,23 @@ static std::vector BuildDecompFacesOnPlane(const mbsp_t *bs // If we don't specify a node (Q2) automatically discover // faces by comparing their plane values. - DecompRecurseNodesLeaves(bsp, &bsp->dnodes[task.model->headnode[0]], [&plane, bsp, &result](auto node, auto front) { + for (int i = task.model->firstface; i < task.model->firstface + task.model->numfaces; ++i) { + const mface_t &face = bsp->dfaces[i]; - for (auto i = 0; i < node->numfaces; i++) { - const mface_t &face = bsp->dfaces[node->firstface + i]; - - // Don't ever try pulling textures from nodraw faces (mostly only Q2RTX stuff) - if (face.texinfo != -1 && (BSP_GetTexinfo(bsp, face.texinfo)->flags.native & Q2_SURF_NODRAW)) { - continue; - } - - qplane3d face_plane = *BSP_GetPlane(bsp, face.planenum); - - if (!qv::epsilonEqual(plane, face_plane, DEFAULT_ON_EPSILON) && !qv::epsilonEqual(-plane, face_plane, DEFAULT_ON_EPSILON)) { - continue; - } - - result.emplace_back(bsp, &face); + // Don't ever try pulling textures from nodraw faces (mostly only Q2RTX stuff) + if (face.texinfo != -1 && (BSP_GetTexinfo(bsp, face.texinfo)->flags.native & Q2_SURF_NODRAW)) { + continue; } - return true; - }, nullptr); + qplane3d face_plane = *BSP_GetPlane(bsp, face.planenum); + + if (!qv::epsilonEqual(plane, face_plane, DEFAULT_ON_EPSILON) && + !qv::epsilonEqual(-plane, face_plane, DEFAULT_ON_EPSILON)) { + continue; + } + + result.emplace_back(bsp, &face); + } } } else { const bsp2_dnode_t *node = plane.node;