From 862d9bd5f2d17f55de5a157a81710365b3342fbf Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Thu, 30 Jun 2022 00:53:02 -0600 Subject: [PATCH] testqbsp: add q1_clip_func_wall Ensure submodels that are all "clip" get bounds set correctly --- qbsp/test_qbsp.cc | 26 ++++++++++ testmaps/qbsp_q1_clip_func_wall.map | 79 +++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 testmaps/qbsp_q1_clip_func_wall.map diff --git a/qbsp/test_qbsp.cc b/qbsp/test_qbsp.cc index 0577a599..03e1edd0 100644 --- a/qbsp/test_qbsp.cc +++ b/qbsp/test_qbsp.cc @@ -1003,6 +1003,32 @@ TEST_CASE("q1_cube", "[testmaps_q1]") CHECK(cube_bounds.grow(-1).maxs() == bsp.dmodels[0].maxs); } +/** + * Ensure submodels that are all "clip" get bounds set correctly + */ +TEST_CASE("q1_clip_func_wall", "[testmaps_q1]") +{ + const auto [bsp, bspx, prt] = LoadTestmapQ1("qbsp_q1_clip_func_wall.map"); + + REQUIRE(prt.has_value()); + + const aabb3d cube_bounds { + {64, 64, 48}, + {128, 128, 80} + }; + + REQUIRE(2 == bsp.dmodels.size()); + + // node bounds + auto &headnode = bsp.dnodes[bsp.dmodels[1].headnode[0]]; + CHECK(cube_bounds.grow(24).mins() == headnode.mins); + CHECK(cube_bounds.grow(24).maxs() == headnode.maxs); + + // model bounds are shrunk by 1 unit on each side for some reason + CHECK(cube_bounds.grow(-1).mins() == bsp.dmodels[1].mins); + CHECK(cube_bounds.grow(-1).maxs() == bsp.dmodels[1].maxs); +} + /** * Lots of features in one map, more for testing in game than automated testing */ diff --git a/testmaps/qbsp_q1_clip_func_wall.map b/testmaps/qbsp_q1_clip_func_wall.map new file mode 100644 index 00000000..5f2c39b5 --- /dev/null +++ b/testmaps/qbsp_q1_clip_func_wall.map @@ -0,0 +1,79 @@ +// Game: Quake +// Format: Standard +// entity 0 +{ +"classname" "worldspawn" +"wad" "deprecated/free_wad.wad" +// brush 0 +{ +( -304 32 16 ) ( -304 256 16 ) ( -304 32 192 ) bolt9 0 0 0 1 1 +( -304 32 192 ) ( -288 32 192 ) ( -304 32 16 ) bolt9 0 0 0 1 1 +( -304 32 16 ) ( -288 32 16 ) ( -304 256 16 ) bolt9 0 0 0 1 1 +( -304 256 192 ) ( -288 256 192 ) ( -304 32 192 ) bolt9 0 0 0 1 1 +( -304 256 16 ) ( -288 256 16 ) ( -304 256 192 ) bolt9 0 0 0 1 1 +( -288 32 16 ) ( -288 32 192 ) ( -288 256 16 ) bolt9 0 0 0 1 1 +} +// brush 1 +{ +( -288 256 192 ) ( -288 240 192 ) ( -288 256 16 ) bolt9 0 0 0 1 1 +( -64 240 192 ) ( -64 240 16 ) ( -288 240 192 ) bolt9 0 0 0 1 1 +( -288 256 16 ) ( -288 240 16 ) ( -64 256 16 ) bolt9 0 0 0 1 1 +( -64 256 192 ) ( -64 240 192 ) ( -288 256 192 ) bolt9 0 0 0 1 1 +( -64 256 192 ) ( -288 256 192 ) ( -64 256 16 ) bolt9 0 0 0 1 1 +( 224 256 16 ) ( 224 240 16 ) ( 224 256 192 ) bolt9 0 0 0 1 1 +} +// brush 2 +{ +( -288 32 16 ) ( -288 48 16 ) ( -288 32 192 ) bolt9 0 0 0 1 1 +( -64 32 16 ) ( -288 32 16 ) ( -64 32 192 ) bolt9 0 0 0 1 1 +( -64 32 16 ) ( -64 48 16 ) ( -288 32 16 ) bolt9 0 0 0 1 1 +( -288 32 192 ) ( -288 48 192 ) ( -64 32 192 ) bolt9 0 0 0 1 1 +( -288 48 16 ) ( -64 48 16 ) ( -288 48 192 ) bolt9 0 0 0 1 1 +( 224 32 192 ) ( 224 48 192 ) ( 224 32 16 ) bolt9 0 0 0 1 1 +} +// brush 3 +{ +( -288 48 192 ) ( -288 48 176 ) ( -288 240 192 ) bolt9 0 0 0 1 1 +( -64 48 192 ) ( -64 48 176 ) ( -288 48 192 ) bolt9 0 0 0 1 1 +( -64 240 176 ) ( -288 240 176 ) ( -64 48 176 ) bolt9 0 0 0 1 1 +( -64 240 192 ) ( -64 48 192 ) ( -288 240 192 ) bolt9 0 0 0 1 1 +( -288 240 192 ) ( -288 240 176 ) ( -64 240 192 ) bolt9 0 0 0 1 1 +( 224 240 192 ) ( 224 240 176 ) ( 224 48 192 ) bolt9 0 0 0 1 1 +} +// brush 4 +{ +( -288 240 16 ) ( -288 240 32 ) ( -288 48 16 ) bolt9 0 0 0 1 1 +( -288 48 16 ) ( -288 48 32 ) ( -64 48 16 ) bolt9 0 0 0 1 1 +( -288 240 16 ) ( -288 48 16 ) ( -64 240 16 ) bolt9 0 0 0 1 1 +( -288 48 32 ) ( -288 240 32 ) ( -64 48 32 ) bolt9 0 0 0 1 1 +( -64 240 16 ) ( -64 240 32 ) ( -288 240 16 ) bolt9 0 0 0 1 1 +( 224 48 16 ) ( 224 48 32 ) ( 224 240 16 ) bolt9 0 0 0 1 1 +} +// brush 5 +{ +( 208 48 32 ) ( 208 49 32 ) ( 208 48 33 ) bolt9 0 0 0 1 1 +( 208 48 32 ) ( 208 48 33 ) ( 209 48 32 ) bolt9 0 0 0 1 1 +( 208 48 32 ) ( 209 48 32 ) ( 208 49 32 ) bolt9 0 0 0 1 1 +( 224 240 192 ) ( 224 241 192 ) ( 225 240 192 ) bolt9 0 0 0 1 1 +( 224 240 40 ) ( 225 240 40 ) ( 224 240 41 ) bolt9 0 0 0 1 1 +( 224 240 40 ) ( 224 240 41 ) ( 224 241 40 ) bolt9 0 0 0 1 1 +} +} +// entity 1 +{ +"classname" "info_player_start" +"origin" "-240 80 56" +} +// entity 2 +{ +"classname" "func_wall" +// brush 0 +{ +( 64 64 48 ) ( 64 65 48 ) ( 64 64 49 ) clip 0 0 0 1 1 +( 64 64 48 ) ( 64 64 49 ) ( 65 64 48 ) clip 0 0 0 1 1 +( 64 64 48 ) ( 65 64 48 ) ( 64 65 48 ) clip 0 0 0 1 1 +( 128 128 80 ) ( 128 129 80 ) ( 129 128 80 ) clip 0 0 0 1 1 +( 128 128 64 ) ( 129 128 64 ) ( 128 128 65 ) clip 0 0 0 1 1 +( 128 128 64 ) ( 128 128 65 ) ( 128 129 64 ) clip 0 0 0 1 1 +} +}