From 617c3ee7c7762a3328d75e9f4913c7b52756cb6c Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Tue, 26 Apr 2022 00:54:02 -0600 Subject: [PATCH] qbsp: make detail clip away faces --- qbsp/surfaces.cc | 5 +- qbsp/test_qbsp.cc | 15 ++++ testmaps/qbsp_simple_worldspawn_detail.map | 82 ++++++++++++++++++++++ 3 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 testmaps/qbsp_simple_worldspawn_detail.map diff --git a/qbsp/surfaces.cc b/qbsp/surfaces.cc index 546dee87..7ccc545b 100644 --- a/qbsp/surfaces.cc +++ b/qbsp/surfaces.cc @@ -526,12 +526,13 @@ void MakeMarkFaces(mapentity_t* entity, node_t* node) static std::list ClipFacesToTree_r(node_t *node, std::list faces) { if (node->planenum == PLANENUM_LEAF) { - if (node->contents.is_solid(options.target_game)) { + // fixme-brushbsp: move to contentflags_t? + if (node->contents.is_solid(options.target_game) + || node->contents.is_detail(CFLAGS_DETAIL)) { // solids eat any faces that reached this point return {}; } // other content types let the faces thorugh - // fixme-brushbsp: detail? return faces; } diff --git a/qbsp/test_qbsp.cc b/qbsp/test_qbsp.cc index b573413e..c19e5c0e 100644 --- a/qbsp/test_qbsp.cc +++ b/qbsp/test_qbsp.cc @@ -328,6 +328,21 @@ TEST(qsbsp, simple_worldspawn_detail_wall) ASSERT_EQ(bsp.dfaces.size(), 11); } +TEST(qsbsp, simple_worldspawn_detail) +{ + const mbsp_t bsp = LoadTestmap("qbsp_simple_worldspawn_detail.map"); + + ASSERT_FALSE(map.leakfile); + + // 6 for the room + // 1 for the button + ASSERT_EQ(map.brushes.size(), 7); + + // 5 faces for the "button" + // 9 faces for the room + ASSERT_EQ(bsp.dfaces.size(), 14); +} + TEST(qsbsp, noclipfaces) { const mbsp_t bsp = LoadTestmap("qbsp_noclipfaces.map"); diff --git a/testmaps/qbsp_simple_worldspawn_detail.map b/testmaps/qbsp_simple_worldspawn_detail.map new file mode 100644 index 00000000..fc34c9d6 --- /dev/null +++ b/testmaps/qbsp_simple_worldspawn_detail.map @@ -0,0 +1,82 @@ +// Game: Quake +// Format: Valve +// entity 0 +{ +"mapversion" "220" +"classname" "worldspawn" +"wad" "deprecated/free_wad.wad;deprecated/fence.wad;deprecated/origin.wad;deprecated/hintskip.wad" +"_wateralpha" "0.5" +"_tb_def" "builtin:Quake.fgd" +// brush 0 +{ +( -112 -112 96 ) ( -112 -111 96 ) ( -112 -112 97 ) orangestuff8 [ 0 1 0 -16 ] [ 0 0 -1 0 ] 0 2 2 +( -80 -96 80 ) ( -81 -96 80 ) ( -80 -96 81 ) orangestuff8 [ -1 0 0 16 ] [ 0 0 -1 0 ] 180 2 2 +( -80 -432 80 ) ( -80 -431 80 ) ( -81 -432 80 ) orangestuff8 [ 1 0 0 -16 ] [ 0 -1 0 16 ] 180 2 2 +( -160 -112 96 ) ( -161 -112 96 ) ( -160 -111 96 ) orangestuff8 [ -1 0 0 16 ] [ 0 -1 0 16 ] 180 2 2 +( -160 0 96 ) ( -160 0 97 ) ( -161 0 96 ) orangestuff8 [ 1 0 0 -16 ] [ 0 0 -1 0 ] 180 2 2 +( 64 -432 80 ) ( 64 -432 81 ) ( 64 -431 80 ) orangestuff8 [ 0 -1 0 16 ] [ 0 0 -1 0 ] 0 2 2 +} +// brush 1 +{ +( -112 -96 96 ) ( -112 -95 96 ) ( -112 -96 97 ) orangestuff8 [ 0 1 0 -16 ] [ 0 0 -1 0 ] 0 2 2 +( -80 0 80 ) ( -81 0 80 ) ( -80 0 81 ) orangestuff8 [ -1 0 0 16 ] [ 0 0 -1 0 ] 180 2 2 +( -80 -416 80 ) ( -80 -415 80 ) ( -81 -416 80 ) orangestuff8 [ 1 0 0 -16 ] [ 0 -1 0 16 ] 180 2 2 +( -160 -96 224 ) ( -161 -96 224 ) ( -160 -95 224 ) orangestuff8 [ -1 0 0 16 ] [ 0 -1 0 16 ] 180 2 2 +( -160 16 96 ) ( -160 16 97 ) ( -161 16 96 ) orangestuff8 [ 1 0 0 -16 ] [ 0 0 -1 0 ] 180 2 2 +( 64 -416 80 ) ( 64 -416 81 ) ( 64 -415 80 ) orangestuff8 [ 0 -1 0 16 ] [ 0 0 -1 0 ] 0 2 2 +} +// brush 2 +{ +( -112 -208 96 ) ( -112 -207 96 ) ( -112 -208 97 ) orangestuff8 [ 0 1 0 -16 ] [ 0 0 -1 0 ] 0 2 2 +( -80 -112 80 ) ( -81 -112 80 ) ( -80 -112 81 ) orangestuff8 [ -1 0 0 16 ] [ 0 0 -1 0 ] 180 2 2 +( -80 -528 80 ) ( -80 -527 80 ) ( -81 -528 80 ) orangestuff8 [ 1 0 0 -16 ] [ 0 -1 0 16 ] 180 2 2 +( -160 -208 224 ) ( -161 -208 224 ) ( -160 -207 224 ) orangestuff8 [ -1 0 0 16 ] [ 0 -1 0 16 ] 180 2 2 +( -160 -96 96 ) ( -160 -96 97 ) ( -161 -96 96 ) orangestuff8 [ 1 0 0 -16 ] [ 0 0 -1 0 ] 180 2 2 +( 64 -528 80 ) ( 64 -528 81 ) ( 64 -527 80 ) orangestuff8 [ 0 -1 0 16 ] [ 0 0 -1 0 ] 0 2 2 +} +// brush 3 +{ +( -128 -112 96 ) ( -128 -111 96 ) ( -128 -112 97 ) orangestuff8 [ 0 1 0 -16 ] [ 0 0 -1 0 ] 0 2 2 +( -256 -96 80 ) ( -257 -96 80 ) ( -256 -96 81 ) orangestuff8 [ -1 0 0 16 ] [ 0 0 -1 0 ] 180 2 2 +( -256 -432 80 ) ( -256 -431 80 ) ( -257 -432 80 ) orangestuff8 [ 1 0 0 -16 ] [ 0 -1 0 16 ] 180 2 2 +( -336 -112 224 ) ( -337 -112 224 ) ( -336 -111 224 ) orangestuff8 [ -1 0 0 16 ] [ 0 -1 0 16 ] 180 2 2 +( -336 0 96 ) ( -336 0 97 ) ( -337 0 96 ) orangestuff8 [ 1 0 0 -16 ] [ 0 0 -1 0 ] 180 2 2 +( -112 -432 80 ) ( -112 -432 81 ) ( -112 -431 80 ) orangestuff8 [ 0 -1 0 16 ] [ 0 0 -1 0 ] 0 2 2 +} +// brush 4 +{ +( 64 -112 96 ) ( 64 -111 96 ) ( 64 -112 97 ) orangestuff8 [ 0 1 0 -16 ] [ 0 0 -1 0 ] 0 2 2 +( -64 -96 80 ) ( -65 -96 80 ) ( -64 -96 81 ) orangestuff8 [ -1 0 0 16 ] [ 0 0 -1 0 ] 180 2 2 +( -64 -432 80 ) ( -64 -431 80 ) ( -65 -432 80 ) orangestuff8 [ 1 0 0 -16 ] [ 0 -1 0 16 ] 180 2 2 +( -144 -112 224 ) ( -145 -112 224 ) ( -144 -111 224 ) orangestuff8 [ -1 0 0 16 ] [ 0 -1 0 16 ] 180 2 2 +( -144 0 96 ) ( -144 0 97 ) ( -145 0 96 ) orangestuff8 [ 1 0 0 -16 ] [ 0 0 -1 0 ] 180 2 2 +( 80 -432 80 ) ( 80 -432 81 ) ( 80 -431 80 ) orangestuff8 [ 0 -1 0 16 ] [ 0 0 -1 0 ] 0 2 2 +} +// brush 5 +{ +( -112 -112 240 ) ( -112 -111 240 ) ( -112 -112 241 ) orangestuff8 [ 0 1 0 -16 ] [ 0 0 -1 0 ] 0 2 2 +( -80 -96 224 ) ( -81 -96 224 ) ( -80 -96 225 ) orangestuff8 [ -1 0 0 16 ] [ 0 0 -1 0 ] 180 2 2 +( -80 -432 224 ) ( -80 -431 224 ) ( -81 -432 224 ) orangestuff8 [ 1 0 0 -16 ] [ 0 -1 0 16 ] 180 2 2 +( -160 -112 240 ) ( -161 -112 240 ) ( -160 -111 240 ) orangestuff8 [ -1 0 0 16 ] [ 0 -1 0 16 ] 180 2 2 +( -160 0 240 ) ( -160 0 241 ) ( -161 0 240 ) orangestuff8 [ 1 0 0 -16 ] [ 0 0 -1 0 ] 180 2 2 +( 64 -432 224 ) ( 64 -432 225 ) ( 64 -431 224 ) orangestuff8 [ 0 -1 0 16 ] [ 0 0 -1 0 ] 0 2 2 +} +} +// entity 1 +{ +"classname" "info_player_start" +"origin" "-88 -64 120" +} +// entity 2 +{ +"classname" "func_detail" +// brush 0 +{ +( -16 -80 96 ) ( -16 -79 96 ) ( -16 -80 97 ) +0fan [ 0 -1 0 -16 ] [ 0 0 -1 0 ] 0 1 1 +( 16 -80 96 ) ( 16 -80 97 ) ( 17 -80 96 ) +0fan [ 1 0 0 16 ] [ 0 0 -1 0 ] 0 1 1 +( 16 -80 96 ) ( 17 -80 96 ) ( 16 -79 96 ) +0fan [ -1 0 0 -16 ] [ 0 -1 0 -16 ] 0 1 1 +( 80 -32 112 ) ( 80 -31 112 ) ( 81 -32 112 ) +0fan [ 1 0 0 16 ] [ 0 -1 0 -16 ] 0 1 1 +( 80 -16 112 ) ( 81 -16 112 ) ( 80 -16 113 ) +0fan [ -1 0 0 -16 ] [ 0 0 -1 0 ] 0 1 1 +( 48 -32 112 ) ( 48 -32 113 ) ( 48 -31 112 ) +0fan [ 0 1 0 16 ] [ 0 0 -1 0 ] 0 1 1 +} +}