Skip to content

Commit

Permalink
qbsp: fix func_illusionary_visblocker
Browse files Browse the repository at this point in the history
Fixes #440
  • Loading branch information
ericwa committed Nov 19, 2024
1 parent 27c40b6 commit 8038b73
Show file tree
Hide file tree
Showing 8 changed files with 322 additions and 19 deletions.
1 change: 0 additions & 1 deletion common/bspfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,6 @@ struct gamedef_q2_t : public gamedef_t
if (contents.flags & EWT_INVISCONTENTS_MONSTERCLIP) result |= Q2_CONTENTS_MONSTERCLIP;
if (contents.flags & EWT_INVISCONTENTS_PROJECTILECLIP) result |= Q2_CONTENTS_PROJECTILECLIP;
if (contents.flags & EWT_INVISCONTENTS_AREAPORTAL) result |= Q2_CONTENTS_AREAPORTAL;
if (contents.flags & EWT_INVISCONTENTS_ILLUSIONARY_VISBLOCKER) throw std::invalid_argument("illusionary visblocker not a contents in Q2");
if (contents.flags & EWT_CFLAG_DETAIL) result |= Q2_CONTENTS_DETAIL;

// cflags
Expand Down
3 changes: 1 addition & 2 deletions include/common/bspfile_common.hh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ enum contents_t : contents_int_t {
EWT_CFLAG_MONSTER = nth_bit<uint64_t>(26), // disallowed in maps, only for gamecode use
EWT_CFLAG_DEADMONSTER = nth_bit<uint64_t>(27), // disallowed in maps, only for gamecode use

EWT_INVISCONTENTS_ILLUSIONARY_VISBLOCKER = nth_bit<uint64_t>(28),
// 28 unused
EWT_CFLAG_DETAIL = nth_bit<uint64_t>(29), // brushes to be added after vis leafs

// unused Q2 contents bits - just present here so we can roundtrip all 32-bit Q2 contents
Expand Down Expand Up @@ -128,7 +128,6 @@ enum contents_t : contents_int_t {
EWT_INVISCONTENTS_PLAYERCLIP |
EWT_INVISCONTENTS_MONSTERCLIP |
EWT_INVISCONTENTS_AREAPORTAL |
EWT_INVISCONTENTS_ILLUSIONARY_VISBLOCKER |
EWT_INVISCONTENTS_PROJECTILECLIP,
};

Expand Down
5 changes: 4 additions & 1 deletion qbsp/map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,10 @@ static contentflags_t Brush_GetContents(const mapentity_t &entity, const mapbrus
}

if (string_iequals(entity.epairs.get("classname"), "func_illusionary_visblocker")) {
base_contents = contentflags_t::make(base_contents.flags | EWT_INVISCONTENTS_ILLUSIONARY_VISBLOCKER);
// unset solid + detail, set mist
// note this overrides the logic in face_get_contents() that normally forces mist to be detail
base_contents = contentflags_t::make((base_contents.flags & ~(EWT_VISCONTENTS_SOLID | EWT_CFLAG_DETAIL))
| EWT_VISCONTENTS_MIST);
}

// non-Q2: -transwater implies liquids are detail
Expand Down
5 changes: 0 additions & 5 deletions qbsp/portals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ bool Portal_VisFlood(const portal_t *p)
contentflags_t contents0 = ClusterContents(p->nodes[0]);
contentflags_t contents1 = ClusterContents(p->nodes[1]);

/* Can't see through func_illusionary_visblocker */
if ((contents0.flags & EWT_INVISCONTENTS_ILLUSIONARY_VISBLOCKER)
|| (contents1.flags & EWT_INVISCONTENTS_ILLUSIONARY_VISBLOCKER))
return false;

// Check per-game visibility
return qbsp_options.target_game->portal_can_see_through(
contents0, contents1, qbsp_options.transwater.value());
Expand Down
105 changes: 105 additions & 0 deletions testmaps/q1_func_illusionary_visblocker.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Game: Quake
// Format: Standard
// entity 0
{
"classname" "worldspawn"
"_tb_textures" "textures/e1u1"
"wad" "deprecated/free_wad.wad;deprecated/fence.wad"
// brush 0
{
( -80 -64 208 ) ( -80 -63 208 ) ( -80 -64 209 ) bolt8 0 -32 0 1 1
( -80 -1136 208 ) ( -80 -1136 209 ) ( -79 -1136 208 ) bolt8 16 -32 0 1 1
( -80 -64 16 ) ( -79 -64 16 ) ( -80 -63 16 ) bolt8 16 0 0 1 1
( 48 64 240 ) ( 48 65 240 ) ( 49 64 240 ) bolt8 16 0 0 1 1
( 48 1376 240 ) ( 49 1376 240 ) ( 48 1376 241 ) bolt8 16 -32 0 1 1
( -64 64 240 ) ( -64 64 241 ) ( -64 65 240 ) bolt8 0 -32 0 1 1
}
// brush 1
{
( 176 -64 208 ) ( 176 -63 208 ) ( 176 -64 209 ) bolt8 0 -32 0 1 1
( 176 -1136 208 ) ( 176 -1136 209 ) ( 177 -1136 208 ) bolt8 -48 -32 0 1 1
( 176 -64 16 ) ( 177 -64 16 ) ( 176 -63 16 ) bolt8 -48 0 0 1 1
( 304 64 240 ) ( 304 65 240 ) ( 305 64 240 ) bolt8 -48 0 0 1 1
( 304 1376 240 ) ( 305 1376 240 ) ( 304 1376 241 ) bolt8 -48 -32 0 1 1
( 192 64 240 ) ( 192 64 241 ) ( 192 65 240 ) bolt8 0 -32 0 1 1
}
// brush 2
{
( -64 544 -16 ) ( -64 545 -16 ) ( -64 544 -15 ) bolt8 -32 0 0 1 1
( -64 -1136 -16 ) ( -64 -1136 -15 ) ( -63 -1136 -16 ) bolt8 0 0 0 1 1
( -64 544 -16 ) ( -63 544 -16 ) ( -64 545 -16 ) bolt8 0 32 0 1 1
( 64 672 16 ) ( 64 673 16 ) ( 65 672 16 ) bolt8 0 32 0 1 1
( 64 1376 16 ) ( 65 1376 16 ) ( 64 1376 17 ) bolt8 0 0 0 1 1
( 176 672 16 ) ( 176 672 17 ) ( 176 673 16 ) bolt8 -32 0 0 1 1
}
// brush 3
{
( -64 544 240 ) ( -64 545 240 ) ( -64 544 241 ) bolt8 -32 0 0 1 1
( -64 -1136 240 ) ( -64 -1136 241 ) ( -63 -1136 240 ) bolt8 0 0 0 1 1
( -64 544 240 ) ( -63 544 240 ) ( -64 545 240 ) bolt8 0 32 0 1 1
( 64 672 272 ) ( 64 673 272 ) ( 65 672 272 ) bolt8 0 32 0 1 1
( 64 1376 272 ) ( 65 1376 272 ) ( 64 1376 273 ) bolt8 0 0 0 1 1
( 176 672 272 ) ( 176 672 273 ) ( 176 673 272 ) bolt8 -32 0 0 1 1
}
// brush 4
{
( -64 -1136 80 ) ( -64 -1136 64 ) ( -64 -1008 64 ) bolt8 -16 -32 0 1 1
( 160 -1136 208 ) ( 160 -1136 209 ) ( 161 -1136 208 ) bolt8 32 -32 0 1 1
( 16 -1136 16 ) ( 16 -1152 16 ) ( 32 -1136 16 ) bolt8 32 16 0 1 1
( 288 -816 240 ) ( 288 -815 240 ) ( 289 -816 240 ) bolt8 32 16 0 1 1
( 288 -1120 240 ) ( 289 -1120 240 ) ( 288 -1120 241 ) bolt8 32 -32 0 1 1
( 176 -816 240 ) ( 176 -816 241 ) ( 176 -815 240 ) bolt8 -16 -32 0 1 1
}
// brush 5
{
( -64 1392 32 ) ( -64 1408 32 ) ( -64 1392 48 ) bolt8 32 -32 0 1 1
( 160 1376 208 ) ( 160 1376 209 ) ( 161 1376 208 ) bolt8 32 -32 0 1 1
( 160 1568 16 ) ( 161 1568 16 ) ( 160 1569 16 ) bolt8 32 -32 0 1 1
( 288 1696 240 ) ( 288 1697 240 ) ( 289 1696 240 ) bolt8 32 -32 0 1 1
( 288 1392 240 ) ( 289 1392 240 ) ( 288 1392 241 ) bolt8 32 -32 0 1 1
( 176 1696 240 ) ( 176 1696 241 ) ( 176 1697 240 ) bolt8 32 -32 0 1 1
}
// brush 6
{
( -96 -16 32 ) ( -96 -48 16 ) ( -96 -48 0 ) bolt8 12.8 7.1554174 26.565052 1.118034 1
( -96 -48 16 ) ( 240 -48 16 ) ( 240 -48 0 ) bolt8 16 -16 0 1 1
( -96 -16 32 ) ( 240 -16 32 ) ( 240 -48 16 ) bolt8 16 -16 0 1 1
( 240 -48 0 ) ( 240 -16 16 ) ( -96 -16 16 ) bolt8 16 -16 0 1 1
( 240 -16 16 ) ( 240 -16 32 ) ( -96 -16 32 ) bolt8 16 0 0 1 1
( 240 -48 16 ) ( 240 -16 32 ) ( 240 -16 16 ) bolt8 12.8 7.1554174 26.565052 1.118034 1
}
// brush 7
{
( -96 48 16 ) ( -96 16 32 ) ( -96 16 16 ) bolt8 -44.8 7.155417 333.43494 1.118034 1
( -96 16 32 ) ( 240 16 32 ) ( 240 16 16 ) bolt8 16 0 0 1 1
( 240 16 16 ) ( 240 48 0 ) ( -96 48 0 ) bolt8 16 48 0 1 1
( -96 48 16 ) ( 240 48 16 ) ( 240 16 32 ) bolt8 16 48 0 1 1
( 240 48 0 ) ( 240 48 16 ) ( -96 48 16 ) bolt8 16 -16 0 1 1
( 240 16 32 ) ( 240 48 16 ) ( 240 48 0 ) bolt8 -44.8 7.155417 333.43494 1.118034 1
}
}
// entity 1
{
"classname" "weapon_nailgun"
"origin" "48 464 32"
}
// entity 2
{
"classname" "info_player_start"
"origin" "64 -176 40"
"angle" "90"
}
// entity 3
{
"classname" "func_illusionary_visblocker"
"_mirrorinside" "1"
// brush 0
{
( -64 80 16 ) ( -64 81 16 ) ( -64 80 17 ) {trigger 0 0 0 1 1
( -64 -16 16 ) ( -64 -16 17 ) ( -63 -16 16 ) {trigger 0 0 0 1 1
( -64 80 16 ) ( -63 80 16 ) ( -64 81 16 ) {trigger 0 0 0 1 1
( 176 128 240 ) ( 176 129 240 ) ( 177 128 240 ) {trigger 0 0 0 1 1
( 176 16 32 ) ( 177 16 32 ) ( 176 16 33 ) {trigger 0 0 0 1 1
( 176 128 32 ) ( 176 128 33 ) ( 176 129 32 ) {trigger 0 0 0 1 1
}
}
103 changes: 103 additions & 0 deletions testmaps/q2_func_illusionary_visblocker.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Game: Quake 2
// Format: Quake2
// entity 0
{
"classname" "worldspawn"
"_tb_textures" "textures/e1u1"
// brush 0
{
( -80 -64 208 ) ( -80 -63 208 ) ( -80 -64 209 ) e1u1/color1_3 0 -32 0 1 1
( -80 -1136 208 ) ( -80 -1136 209 ) ( -79 -1136 208 ) e1u1/color1_3 16 -32 0 1 1
( -80 -64 16 ) ( -79 -64 16 ) ( -80 -63 16 ) e1u1/color1_3 16 0 0 1 1
( 48 64 240 ) ( 48 65 240 ) ( 49 64 240 ) e1u1/color1_3 16 0 0 1 1
( 48 1376 240 ) ( 49 1376 240 ) ( 48 1376 241 ) e1u1/color1_3 16 -32 0 1 1
( -64 64 240 ) ( -64 64 241 ) ( -64 65 240 ) e1u1/color1_3 0 -32 0 1 1
}
// brush 1
{
( 176 -64 208 ) ( 176 -63 208 ) ( 176 -64 209 ) e1u1/color1_3 0 -32 0 1 1
( 176 -1136 208 ) ( 176 -1136 209 ) ( 177 -1136 208 ) e1u1/color1_3 -48 -32 0 1 1
( 176 -64 16 ) ( 177 -64 16 ) ( 176 -63 16 ) e1u1/color1_3 -48 0 0 1 1
( 304 64 240 ) ( 304 65 240 ) ( 305 64 240 ) e1u1/color1_3 -48 0 0 1 1
( 304 1376 240 ) ( 305 1376 240 ) ( 304 1376 241 ) e1u1/color1_3 -48 -32 0 1 1
( 192 64 240 ) ( 192 64 241 ) ( 192 65 240 ) e1u1/color1_3 0 -32 0 1 1
}
// brush 2
{
( -64 544 -16 ) ( -64 545 -16 ) ( -64 544 -15 ) e1u1/color1_6 -32 0 0 1 1
( -64 -1136 -16 ) ( -64 -1136 -15 ) ( -63 -1136 -16 ) e1u1/color1_6 0 0 0 1 1
( -64 544 -16 ) ( -63 544 -16 ) ( -64 545 -16 ) e1u1/color1_6 0 32 0 1 1
( 64 672 16 ) ( 64 673 16 ) ( 65 672 16 ) e1u1/color1_6 0 32 0 1 1
( 64 1376 16 ) ( 65 1376 16 ) ( 64 1376 17 ) e1u1/color1_6 0 0 0 1 1
( 176 672 16 ) ( 176 672 17 ) ( 176 673 16 ) e1u1/color1_6 -32 0 0 1 1
}
// brush 3
{
( -64 544 240 ) ( -64 545 240 ) ( -64 544 241 ) e1u1/color1_6 -32 0 0 1 1
( -64 -1136 240 ) ( -64 -1136 241 ) ( -63 -1136 240 ) e1u1/color1_6 0 0 0 1 1
( -64 544 240 ) ( -63 544 240 ) ( -64 545 240 ) e1u1/color1_6 0 32 0 1 1
( 64 672 272 ) ( 64 673 272 ) ( 65 672 272 ) e1u1/color1_6 0 32 0 1 1
( 64 1376 272 ) ( 65 1376 272 ) ( 64 1376 273 ) e1u1/color1_6 0 0 0 1 1
( 176 672 272 ) ( 176 672 273 ) ( 176 673 272 ) e1u1/color1_6 -32 0 0 1 1
}
// brush 4
{
( -64 -1136 80 ) ( -64 -1136 64 ) ( -64 -1008 64 ) e1u1/color1_3 -16 -32 0 1 1
( 160 -1136 208 ) ( 160 -1136 209 ) ( 161 -1136 208 ) e1u1/color1_3 32 -32 0 1 1
( 16 -1136 16 ) ( 16 -1152 16 ) ( 32 -1136 16 ) e1u1/color1_3 32 16 0 1 1
( 288 -816 240 ) ( 288 -815 240 ) ( 289 -816 240 ) e1u1/color1_3 32 16 0 1 1
( 288 -1120 240 ) ( 289 -1120 240 ) ( 288 -1120 241 ) e1u1/color1_3 32 -32 0 1 1
( 176 -816 240 ) ( 176 -816 241 ) ( 176 -815 240 ) e1u1/color1_3 -16 -32 0 1 1
}
// brush 5
{
( -64 1392 32 ) ( -64 1408 32 ) ( -64 1392 48 ) e1u1/color1_3 32 -32 0 1 1
( 160 1376 208 ) ( 160 1376 209 ) ( 161 1376 208 ) e1u1/color1_3 32 -32 0 1 1
( 160 1568 16 ) ( 161 1568 16 ) ( 160 1569 16 ) e1u1/color1_3 32 -32 0 1 1
( 288 1696 240 ) ( 288 1697 240 ) ( 289 1696 240 ) e1u1/color1_3 32 -32 0 1 1
( 288 1392 240 ) ( 289 1392 240 ) ( 288 1392 241 ) e1u1/color1_3 32 -32 0 1 1
( 176 1696 240 ) ( 176 1696 241 ) ( 176 1697 240 ) e1u1/color1_3 32 -32 0 1 1
}
// brush 6
{
( -96 -16 32 ) ( -96 -48 16 ) ( -96 -48 0 ) e1u1/box3_6 12.8 7.1554174 26.565052 1.118034 1
( -96 -48 16 ) ( 240 -48 16 ) ( 240 -48 0 ) e1u1/box3_6 16 -16 0 1 1
( -96 -16 32 ) ( 240 -16 32 ) ( 240 -48 16 ) e1u1/box3_6 16 -16 0 1 1
( 240 -48 0 ) ( 240 -16 16 ) ( -96 -16 16 ) e1u1/box3_6 16 -16 0 1 1
( 240 -16 16 ) ( 240 -16 32 ) ( -96 -16 32 ) e1u1/box3_6 16 0 0 1 1
( 240 -48 16 ) ( 240 -16 32 ) ( 240 -16 16 ) e1u1/box3_6 12.8 7.1554174 26.565052 1.118034 1
}
// brush 7
{
( -96 48 16 ) ( -96 16 32 ) ( -96 16 16 ) e1u1/box3_6 -44.8 7.155417 333.43494 1.118034 1
( -96 16 32 ) ( 240 16 32 ) ( 240 16 16 ) e1u1/box3_6 16 0 0 1 1
( 240 16 16 ) ( 240 48 0 ) ( -96 48 0 ) e1u1/box3_6 16 48 0 1 1
( -96 48 16 ) ( 240 48 16 ) ( 240 16 32 ) e1u1/box3_6 16 48 0 1 1
( 240 48 0 ) ( 240 48 16 ) ( -96 48 16 ) e1u1/box3_6 16 -16 0 1 1
( 240 16 32 ) ( 240 48 16 ) ( 240 48 0 ) e1u1/box3_6 -44.8 7.155417 333.43494 1.118034 1
}
}
// entity 1
{
"classname" "item_enviro"
"origin" "48 464 32"
}
// entity 2
{
"classname" "info_player_start"
"origin" "64 -176 40"
"angle" "90"
}
// entity 3
{
"classname" "func_illusionary_visblocker"
// brush 0
{
( -64 80 16 ) ( -64 81 16 ) ( -64 80 17 ) e1u1/p_lit_03 0 0 0 1 1 0 0 0
( -64 -16 16 ) ( -64 -16 17 ) ( -63 -16 16 ) e1u1/p_lit_03 0 0 0 1 1 0 0 0
( -64 80 16 ) ( -63 80 16 ) ( -64 81 16 ) e1u1/p_lit_03 0 0 0 1 1 0 0 0
( 176 128 240 ) ( 176 129 240 ) ( 177 128 240 ) e1u1/p_lit_03 0 0 0 1 1 0 0 0
( 176 16 32 ) ( 177 16 32 ) ( 176 16 33 ) e1u1/p_lit_03 0 0 0 1 1 0 0 0
( 176 128 32 ) ( 176 128 33 ) ( 176 129 32 ) e1u1/p_lit_03 0 0 0 1 1 0 0 0
}
}
8 changes: 8 additions & 0 deletions tests/test_qbsp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,14 @@ TEST(testmapsQ1, simpleSealed2)
std::vector<const mface_t *>{other_floor, other_ceil, other_minus_x, other_plus_x, other_plus_y});
}

TEST(testmapsQ1, q1FuncIllusionaryVisblocker)
{
const auto [bsp, bspx, prt] = LoadTestmapQ1("q1_func_illusionary_visblocker.map", {});

EXPECT_EQ(prt->portalleafs, 3);
EXPECT_EQ(prt->portals.size(), 0);
}

TEST(testmapsQ1, simpleWorldspawnWorldspawn)
{
const auto [bsp, bspx, prt] = LoadTestmapQ1("qbsp_simple_worldspawn_worldspawn.map", {"-tjunc", "rotate"});
Expand Down
Loading

0 comments on commit 8038b73

Please sign in to comment.