From dc0ea62a0e61ed65b8e33cfec3e8add02cdd50cc Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 8 Jan 2023 15:27:07 -0700 Subject: [PATCH] vis: migrate CalcPHS from DecompressRow to Mod_Q1BSP_DecompressVis --- common/bsputils.cc | 31 ------------------------------- include/common/bsputils.hh | 1 - vis/soundpvs.cc | 17 +++++++---------- 3 files changed, 7 insertions(+), 42 deletions(-) diff --git a/common/bsputils.cc b/common/bsputils.cc index f3fa9a3b..5bddcd03 100644 --- a/common/bsputils.cc +++ b/common/bsputils.cc @@ -594,37 +594,6 @@ void CompressRow(const uint8_t *vis, const size_t numbytes, std::back_insert_ite } } -/* -=================== -DecompressRow -=================== -*/ -void DecompressRow(const uint8_t *in, const int numbytes, uint8_t *decompressed) -{ - int c; - uint8_t *out; - int row; - - row = numbytes; - out = decompressed; - - do { - if (*in) { - *out++ = *in++; - continue; - } - - c = in[1]; - if (!c) - FError("0 repeat"); - in += 2; - while (c) { - *out++ = 0; - c--; - } - } while (out - decompressed < row); -} - size_t DecompressedVisSize(const mbsp_t *bsp) { if (bsp->loadversion->game->id == GAME_QUAKE_II) { diff --git a/include/common/bsputils.hh b/include/common/bsputils.hh index b104223b..6d2cea29 100644 --- a/include/common/bsputils.hh +++ b/include/common/bsputils.hh @@ -106,7 +106,6 @@ qvec3f Face_Centroid(const mbsp_t *bsp, const mface_t *face); void Face_DebugPrint(const mbsp_t *bsp, const mface_t *face); void CompressRow(const uint8_t *vis, const size_t numbytes, std::back_insert_iterator> it); -void DecompressRow(const uint8_t *in, const int numbytes, uint8_t *decompressed); size_t DecompressedVisSize(const mbsp_t *bsp); void Mod_Q1BSP_DecompressVis(const uint8_t *in, const uint8_t *inend, uint8_t *out, uint8_t *outend); diff --git a/vis/soundpvs.cc b/vis/soundpvs.cc index b5908322..1d82ab99 100644 --- a/vis/soundpvs.cc +++ b/vis/soundpvs.cc @@ -168,21 +168,15 @@ void CalcPHS(mbsp_t *bsp) std::vector compressed(leafbytes * 2); std::vector uncompressed_orig(leafbytes); - std::vector uncompressed_test(leafbytes); - int32_t count = 0; for (int32_t i = 0; i < portalleafs; i++) { const uint8_t *scan = bsp->dvis.bits.data() + bsp->dvis.get_bit_offset(VIS_PVS, i); - DecompressRow(scan, leafbytes, uncompressed.data()); - std::copy(uncompressed.begin(), uncompressed.end(), uncompressed_orig.begin()); - - // migrating to this... for now, just check it produces the same value as the legacy function Mod_Q1BSP_DecompressVis(scan, bsp->dvis.bits.data() + bsp->dvis.bits.size(), - uncompressed_test.data(), - uncompressed_test.data() + uncompressed_test.size()); - Q_assert(uncompressed_test == uncompressed); + uncompressed.data(), + uncompressed.data() + uncompressed.size()); + std::copy(uncompressed.begin(), uncompressed.end(), uncompressed_orig.begin()); scan = uncompressed_orig.data(); @@ -198,7 +192,10 @@ void CalcPHS(mbsp_t *bsp) if (index >= portalleafs) FError("Bad bit in PVS"); // pad bits should be 0 const uint8_t *src_compressed = bsp->dvis.bits.data() + bsp->dvis.get_bit_offset(VIS_PVS, index); - DecompressRow(src_compressed, leafbytes, uncompressed_2.data()); + Mod_Q1BSP_DecompressVis(src_compressed, + bsp->dvis.bits.data() + bsp->dvis.bits.size(), + uncompressed_2.data(), + uncompressed_2.data() + uncompressed_2.size()); const long *src = reinterpret_cast(uncompressed_2.data()); long *dest = reinterpret_cast(uncompressed.data()); for (int32_t l = 0; l < leaflongs; l++)