From 251a6dc7ca391b1bdafed360ef422e70d8fa4dd2 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Fri, 19 Aug 2022 22:49:07 -0600 Subject: [PATCH] testmaps: add a more minimal q1_rocks that's just a cube --- testmaps/q1_rocks_structural_cube.map | 77 +++++++++++++++++++++++++++ tests/test_qbsp.cc | 51 +++++++++++------- 2 files changed, 110 insertions(+), 18 deletions(-) create mode 100644 testmaps/q1_rocks_structural_cube.map diff --git a/testmaps/q1_rocks_structural_cube.map b/testmaps/q1_rocks_structural_cube.map new file mode 100644 index 00000000..37ad58dd --- /dev/null +++ b/testmaps/q1_rocks_structural_cube.map @@ -0,0 +1,77 @@ +// Game: Quake +// Format: Valve +// entity 0 +{ +"mapversion" "220" +"classname" "worldspawn" +"wad" "deprecated/free_wad.wad;deprecated/hintskip.wad" +// brush 0 +{ +( -336 -64 -16 ) ( -336 -63 -16 ) ( -336 -64 -15 ) skip [ 0 -1 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( -64 -128 -16 ) ( -64 -128 -15 ) ( -63 -128 -16 ) skip [ 1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( -64 -64 -16 ) ( -63 -64 -16 ) ( -64 -63 -16 ) skip [ -1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1 +( 64 64 16 ) ( 64 65 16 ) ( 65 64 16 ) grass6 [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1 +( 64 816 16 ) ( 65 816 16 ) ( 64 816 17 ) skip [ -1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( 432 64 16 ) ( 432 64 17 ) ( 432 65 16 ) skip [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1 +} +// brush 1 +{ +( 416 816 368 ) ( 416 -128 368 ) ( 416 816 16 ) grass [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( 432 -128 16 ) ( 416 -128 16 ) ( 432 -128 368 ) skip [ 1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( 432 816 16 ) ( 416 816 16 ) ( 432 -128 16 ) skip [ -1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1 +( 432 -128 368 ) ( 416 -128 368 ) ( 432 816 368 ) skip [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1 +( 432 816 368 ) ( 416 816 368 ) ( 432 816 16 ) skip [ -1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( 432 -128 368 ) ( 432 816 368 ) ( 432 -128 16 ) skip [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1 +} +// brush 2 +{ +( -336 -128 16 ) ( -336 816 16 ) ( -336 -128 368 ) skip [ 0 -1 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( -336 -128 368 ) ( -320 -128 368 ) ( -336 -128 16 ) skip [ 1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( -336 -128 16 ) ( -320 -128 16 ) ( -336 816 16 ) skip [ -1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1 +( -336 816 368 ) ( -320 816 368 ) ( -336 -128 368 ) skip [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1 +( -336 816 16 ) ( -320 816 16 ) ( -336 816 368 ) skip [ -1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( -320 -128 16 ) ( -320 -128 368 ) ( -320 816 16 ) grass3 [ 0 -1 0 0 ] [ 0 0 -1 0 ] 0 1 1 +} +// brush 3 +{ +( -320 816 368 ) ( -320 800 368 ) ( -320 816 16 ) skip [ 0 -1 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( 416 800 368 ) ( 416 800 16 ) ( -320 800 368 ) grass4 [ -1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( -320 816 16 ) ( -320 800 16 ) ( 416 816 16 ) skip [ -1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1 +( 416 816 368 ) ( 416 800 368 ) ( -320 816 368 ) skip [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1 +( 416 816 368 ) ( -320 816 368 ) ( 416 816 16 ) skip [ -1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( 416 816 16 ) ( 416 800 16 ) ( 416 816 368 ) skip [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1 +} +// brush 4 +{ +( -320 -128 16 ) ( -320 -112 16 ) ( -320 -128 368 ) skip [ 0 -1 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( 416 -128 16 ) ( -320 -128 16 ) ( 416 -128 368 ) skip [ 1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( 416 -128 16 ) ( 416 -112 16 ) ( -320 -128 16 ) skip [ -1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1 +( -320 -128 368 ) ( -320 -112 368 ) ( 416 -128 368 ) skip [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1 +( -320 -112 16 ) ( 416 -112 16 ) ( -320 -112 368 ) grass2 [ 1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( 416 -128 368 ) ( 416 -112 368 ) ( 416 -128 16 ) skip [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1 +} +// brush 5 +{ +( -320 -112 368 ) ( -320 -112 352 ) ( -320 800 368 ) sky3 [ 0 -1 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( 416 -112 368 ) ( 416 -112 352 ) ( -320 -112 368 ) sky3 [ 1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( 416 800 352 ) ( -320 800 352 ) ( 416 -112 352 ) sky3 [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1 +( 416 800 368 ) ( 416 -112 368 ) ( -320 800 368 ) sky3 [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1 +( -320 800 368 ) ( -320 800 352 ) ( 416 800 368 ) sky3 [ -1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( 416 800 368 ) ( 416 800 352 ) ( 416 -112 368 ) sky3 [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1 +} +// brush 6 +{ +( -64 208 176 ) ( -64 432 16 ) ( -64 432 176 ) medbrick1 [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( 160 208 176 ) ( -64 208 16 ) ( -64 208 176 ) medbrick2 [ 1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( 160 432 16 ) ( -64 208 16 ) ( 160 208 16 ) skip [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1 +( 160 432 176 ) ( -64 208 176 ) ( -64 432 176 ) sbrick1 [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1 +( 160 432 176 ) ( -64 432 16 ) ( 160 432 16 ) gray_brick [ 1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1 +( 160 432 176 ) ( 160 208 16 ) ( 160 208 176 ) brown_brick [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1 +} +} +// entity 1 +{ +"classname" "info_player_start" +"origin" "128 16 75" +"angle" "0" +} diff --git a/tests/test_qbsp.cc b/tests/test_qbsp.cc index df54ee47..9c5ecfd0 100644 --- a/tests/test_qbsp.cc +++ b/tests/test_qbsp.cc @@ -1854,35 +1854,50 @@ TEST_CASE("q1_merge_maps", "[testmaps_q1]") { */ TEST_CASE("q1_rocks", "[testmaps_q1][!mayfail]") { - const auto mapname = GENERATE( + constexpr auto* q1_rocks_structural_cube = "q1_rocks_structural_cube.map"; + + const auto mapnames = { "q1_rocks.map", // box room with a func_detail "mountain" of tetrahedrons with a hollow inside "q1_rocks_merged.map", // same as above but the mountain has been merged in the .map file into 1 brush "q1_rocks_structural.map", // same as q1_rocks.map but without the use of func_detail - "q1_rocks_structural_merged.map" - ); - INFO(mapname); + "q1_rocks_structural_merged.map", + q1_rocks_structural_cube // simpler version where the mountain is just a cube + }; + for (auto *mapname : mapnames) { + DYNAMIC_SECTION(mapname) { + INFO(mapname); + const auto [bsp, bspx, prt] = LoadTestmapQ1(mapname); - const auto [bsp, bspx, prt] = LoadTestmapQ1(mapname); + CHECK(GAME_QUAKE == bsp.loadversion->game->id); - CHECK(GAME_QUAKE == bsp.loadversion->game->id); + const qvec3d point{48, 320, 88}; - const qvec3d point {48, 320, 88}; + CHECK(CONTENTS_SOLID == BSP_FindContentsAtPoint(&bsp, 0, &bsp.dmodels[0], point)); + CHECK(CONTENTS_SOLID == BSP_FindContentsAtPoint(&bsp, 1, &bsp.dmodels[0], point)); + CHECK(CONTENTS_SOLID == BSP_FindContentsAtPoint(&bsp, 2, &bsp.dmodels[0], point)); - CHECK(CONTENTS_SOLID == BSP_FindContentsAtPoint(&bsp, 0, &bsp.dmodels[0], point)); - CHECK(CONTENTS_SOLID == BSP_FindContentsAtPoint(&bsp, 1, &bsp.dmodels[0], point)); - CHECK(CONTENTS_SOLID == BSP_FindContentsAtPoint(&bsp, 2, &bsp.dmodels[0], point)); + for (int i = 1; i < 2; ++i) { + INFO("hull " << i); - for (int i = 1; i < 2; ++i) { - INFO("hull " << i); + const auto clipnodes = CountClipnodeLeafsByContentType(bsp, 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()); - REQUIRE(clipnodes.size() == 2); - REQUIRE(clipnodes.find(CONTENTS_SOLID) != clipnodes.end()); - REQUIRE(clipnodes.find(CONTENTS_EMPTY) != clipnodes.end()); + // 6 for the walls of the box, and 1 for the rock structure, which is convex + CHECK(clipnodes.at(CONTENTS_SOLID) == 7); - // 6 for the walls of the box, and 1 for the rock structure, which is convex - CHECK(clipnodes.at(CONTENTS_SOLID) == 7); + if (std::string(q1_rocks_structural_cube) == mapname) { + CHECK((5 + 6) == CountClipnodeNodes(bsp, i)); + } + } + + // for completion's sake, check the nodes + if (std::string(q1_rocks_structural_cube) == mapname) { + CHECK((5 + 6) == bsp.dnodes.size()); + } + } } }