testmaps: remove some accidental brushes in q1_hull_expansion_lip.map

testqbsp: more detailed q1_hull_expansion_lip tests for clipnodes

testqbsp: decompile hull1 of testmaps by default

testqbsp: corrections to the q1_hull_expansion_lip.map expectation

adjust gitignore
This commit is contained in:
Eric Wasylishen 2022-08-19 19:54:48 -06:00
parent c0c146d47c
commit 10051ceff5
3 changed files with 64 additions and 20 deletions

1
.gitignore vendored
View File

@ -6,6 +6,7 @@ CMakeFiles/
*.xcodeproj
.*/
testmaps/*.bsp
testmaps/*decompile*.map
testmaps/*.bsp.qbsplog
testmaps/*.log
testmaps/*.prt

View File

@ -61,31 +61,13 @@
}
// brush 6
{
( 192 592 0 ) ( 192 576 16 ) ( 192 512 0 ) __TB_empty [ 0 -1 0 0 ] [ 0 0 -1 0 ] 0 1 1
( 192 576 16 ) ( 240 576 32 ) ( 240 512 16 ) __TB_empty [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1
( 192 592 0 ) ( 240 592 16 ) ( 240 576 32 ) __TB_empty [ -1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1
( 192 512 0 ) ( 240 512 16 ) ( 240 512 0 ) __TB_empty [ 1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1
( 240 512 0 ) ( 240 592 16 ) ( 192 592 0 ) __TB_empty [ -1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1
( 240 576 32 ) ( 240 592 16 ) ( 240 512 0 ) __TB_empty [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1
}
// brush 7
{
( 192 576 16 ) ( 192 592 0 ) ( 192 640 0 ) __TB_empty [ 0 -1 0 0 ] [ 0 0 -1 0 ] 0 1 1
( 192 640 16 ) ( 240 640 32 ) ( 240 576 32 ) __TB_empty [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1
( 240 640 16 ) ( 240 640 32 ) ( 192 640 16 ) __TB_empty [ -1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1
( 240 576 32 ) ( 240 592 16 ) ( 192 592 0 ) __TB_empty [ 1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1
( 240 592 16 ) ( 240 640 16 ) ( 192 640 0 ) __TB_empty [ -1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1
( 240 576 32 ) ( 240 640 32 ) ( 240 640 16 ) __TB_empty [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1
}
// brush 8
{
( 96 272 52 ) ( 128 320 160 ) ( 48 208 160 ) skip [ -0.5812381937190964 -0.8137334712067349 0 0 ] [ 0.014011936247737871 -0.010008525891241337 -0.9998517365350094 0 ] 0 1 1
( 96 272 52 ) ( 160 288 16 ) ( 128 320 160 ) skip [ -0.9191450300180579 -0.3939192985791677 0 0 ] [ 0.1103411073357252 -0.2574625837833588 -0.9599676338208091 0 ] 0 1 1
( -320 -112 16 ) ( -320 -112 368 ) ( 416 -112 16 ) skip [ 1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1
( 64 64 16 ) ( 65 64 16 ) ( 64 65 16 ) skip [ -1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1
( 128 320 160 ) ( 160 288 16 ) ( 48 208 160 ) bally [ 0 0 1.0000000000000002 -60.324303 ] [ 0 -1.0000000000000002 0 0 ] 0 1 1
}
// brush 9
// brush 7
{
( 96 336 52 ) ( 48 432 160 ) ( 128 320 160 ) skip [ 0.5812381937190965 -0.813733471206735 0 0 ] [ -0.12463786013791102 -0.08902704295565074 -0.9882001768077232 0 ] 0 1 1
( 128 320 160 ) ( 160 288 16 ) ( 96 336 52 ) skip [ 0.813733471206735 -0.5812381937190964 0 0 ] [ -0.02999002997227586 -0.04198604196118621 -0.9986679980767861 0 ] 0 1 1

View File

@ -6,6 +6,7 @@
#include <qbsp/map.hh>
#include <common/fs.hh>
#include <common/bsputils.hh>
#include <common/decompile.hh>
#include <common/prtfile.hh>
#include <common/qvec.hh>
#include <testmaps.hh>
@ -226,6 +227,24 @@ static std::tuple<mbsp_t, bspxentries_t, std::optional<prtfile_t>> LoadTestmap(c
prtfile = {LoadPrtFile(prtpath, bspdata.loadversion)};
}
// decompile .bsp hulls
if (qbsp_options.target_game->id == GAME_QUAKE) {
fs::path decompiled_map_path = qbsp_options.bsp_path;
decompiled_map_path.replace_extension("");
decompiled_map_path.replace_filename(decompiled_map_path.stem().string() + "-decompiled-hull1");
decompiled_map_path.replace_extension(".map");
std::ofstream f(decompiled_map_path);
if (!f)
Error("couldn't open {} for writing\n", decompiled_map_path);
decomp_options options;
options.hullnum = 1;
DecompileBSP(&std::get<mbsp_t>(bspdata.bsp), options, f);
}
return std::make_tuple(std::move(std::get<mbsp_t>(bspdata.bsp)),
std::move(bspdata.bspx.entries),
std::move(prtfile));
@ -1843,10 +1862,32 @@ TEST_CASE("q1_rocks", "[testmaps_q1]")
CHECK(CONTENTS_SOLID == BSP_FindContentsAtPoint(&bsp, 2, &bsp.dmodels[0], point));
}
static void CountClipnodeLeafsByContentType_r(const mbsp_t& bsp, int clipnode, std::map<int, int> &result)
{
if (clipnode < 0) {
// we're in a leaf node and `clipnode` is actually the content type
++result[clipnode];
return;
}
auto &node = bsp.dclipnodes.at(clipnode);
CountClipnodeLeafsByContentType_r(bsp, node.children[0], result);
CountClipnodeLeafsByContentType_r(bsp, node.children[1], result);
}
static std::map<int, int> CountClipnodeLeafsByContentType(const mbsp_t& bsp, int hullnum)
{
int headnode = bsp.dmodels[0].headnode[hullnum];
std::map<int, int> result;
CountClipnodeLeafsByContentType_r(bsp, headnode, result);
return result;
}
/**
* Tests a bad hull expansion
*/
TEST_CASE("q1_hull_expansion_lip", "[testmaps_q1]")
TEST_CASE("q1_hull_expansion_lip", "[testmaps_q1][!mayfail]")
{
const auto [bsp, bspx, prt] = LoadTestmapQ1("q1_hull_expansion_lip.map");
@ -1854,6 +1895,26 @@ TEST_CASE("q1_hull_expansion_lip", "[testmaps_q1]")
const qvec3d point {174, 308, 42};
CHECK(CONTENTS_EMPTY == BSP_FindContentsAtPoint(&bsp, 1, &bsp.dmodels[0], point));
for (int i = 0; i < 2; ++i) {
INFO("hull " << i);
const auto clipnodes = CountClipnodeLeafsByContentType(bsp, i);
REQUIRE(clipnodes.size() == 2);
REQUIRE(clipnodes.find(CONTENTS_SOLID) != clipnodes.end());
REQUIRE(clipnodes.find(CONTENTS_EMPTY) != clipnodes.end());
// room shaped like:
//
// |\ /|
// | \__/ |
// |______|
//
// 6 solid leafs for the walls/floor, 3 for the empty regions inside
CHECK(clipnodes.at(CONTENTS_SOLID) == 6);
CHECK(clipnodes.at(CONTENTS_EMPTY) == 3);
}
}
TEST_CASE("q1_hull1_content_types", "[testmaps_q1]")