Skip to content

Commit e0c82fb

Browse files
committed
qbsp: handle func_detail_fence + func_illusionary_visblocker in q1
1 parent 9a257ee commit e0c82fb

6 files changed

Lines changed: 87 additions & 5 deletions

File tree

common/bspfile.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,19 @@ struct gamedef_q1_like_t : public gamedef_t
320320
*
321321
* Normally solid leafs are not written and just referenced as leaf 0.
322322
*/
323-
if (contents.is_detail_fence() || contents.is_detail_wall()) {
324-
return contentflags_t::make(EWT_VISCONTENTS_SOLID);
323+
if (contents.flags & EWT_VISCONTENTS_WINDOW) {
324+
// clear WINDOW and add SOLID
325+
contents = contentflags_t::make((contents.flags & ~EWT_VISCONTENTS_WINDOW) | EWT_VISCONTENTS_SOLID);
326+
}
327+
if (contents.flags & EWT_VISCONTENTS_DETAIL_WALL) {
328+
// clear DETAIL_WALL and add SOLID
329+
contents = contentflags_t::make((contents.flags & ~EWT_VISCONTENTS_DETAIL_WALL) | EWT_VISCONTENTS_SOLID);
325330
}
326331

327-
if (contents.flags & EWT_VISCONTENTS_MIST) {
328-
// clear mist. detail_illusionary on its own becomes CONTENTS_EMPTY,
332+
if (contents.flags & (EWT_VISCONTENTS_MIST | EWT_VISCONTENTS_AUX)) {
333+
// clear mist and aux. detail_illusionary on its own becomes CONTENTS_EMPTY,
329334
// detail_illusionary in water becomes CONTENTS_WATER, etc.
330-
contents = contentflags_t::make(contents.flags & ~EWT_VISCONTENTS_MIST);
335+
contents = contentflags_t::make(contents.flags & ~(EWT_VISCONTENTS_MIST | EWT_VISCONTENTS_AUX));
331336
}
332337
if (contents.flags & EWT_VISCONTENTS_ILLUSIONARY_VISBLOCKER) {
333338
// this exports as empty

common/bspfile_common.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,12 @@ std::ostream &operator<<(std::ostream &os, contents_t flags)
330330
return os;
331331
}
332332

333+
std::ostream &operator<<(std::ostream &os, contentflags_t flags)
334+
{
335+
os << get_contents_display(flags.flags);
336+
return os;
337+
}
338+
333339
// surfflags_t
334340

335341
bool surfflags_t::is_nodraw() const

include/common/bspfile_common.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ struct contentflags_t
288288

289289
// gtest support
290290
std::ostream &operator<<(std::ostream &os, contents_t flags);
291+
std::ostream &operator<<(std::ostream &os, contentflags_t flags);
291292

292293
enum q1_surf_flags_t : int32_t;
293294
enum q2_surf_flags_t : int32_t;

testmaps/q1_func_illusionary_visblocker_interactions.map

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,48 @@
231231
"classname" "info_null"
232232
"origin" "48 248 56"
233233
}
234+
// entity 17
235+
{
236+
"classname" "func_illusionary_visblocker"
237+
"_mirrorinside" "0"
238+
// brush 0
239+
{
240+
( 384 80 -32 ) ( 384 81 -32 ) ( 384 80 -31 ) *zwater1 0 -48 0 1 1
241+
( 320 -48 -32 ) ( 320 -48 -31 ) ( 321 -48 -32 ) *zwater1 0 -48 0 1 1
242+
( 320 80 16 ) ( 321 80 16 ) ( 320 81 16 ) *zwater1 0 0 0 1 1
243+
( 560 128 128 ) ( 560 129 128 ) ( 561 128 128 ) *zwater1 0 0 0 1 1
244+
( 560 16 -16 ) ( 561 16 -16 ) ( 560 16 -15 ) *zwater1 0 -48 0 1 1
245+
( 464 128 -16 ) ( 464 128 -15 ) ( 464 129 -16 ) *zwater1 0 -48 0 1 1
246+
}
247+
}
248+
// entity 18
249+
{
250+
"classname" "func_illusionary_visblocker"
251+
// brush 0
252+
{
253+
( 512 80 -32 ) ( 512 81 -32 ) ( 512 80 -31 ) *zwater1 0 -48 0 1 1
254+
( 448 -48 -32 ) ( 448 -48 -31 ) ( 449 -48 -32 ) *zwater1 0 -48 0 1 1
255+
( 448 80 16 ) ( 449 80 16 ) ( 448 81 16 ) *zwater1 0 0 0 1 1
256+
( 688 128 128 ) ( 688 129 128 ) ( 689 128 128 ) *zwater1 0 0 0 1 1
257+
( 688 16 -16 ) ( 689 16 -16 ) ( 688 16 -15 ) *zwater1 0 -48 0 1 1
258+
( 592 128 -16 ) ( 592 128 -15 ) ( 592 129 -16 ) *zwater1 0 -48 0 1 1
259+
}
260+
}
261+
// entity 19
262+
{
263+
"classname" "func_detail_fence"
264+
// brush 0
265+
{
266+
( 528 -24 16 ) ( 528 -23 16 ) ( 528 -24 17 ) {trigger 0 0 0 1 1
267+
( 528 -24 16 ) ( 528 -24 17 ) ( 529 -24 16 ) {trigger 0 0 0 1 1
268+
( 528 -24 16 ) ( 529 -24 16 ) ( 528 -23 16 ) {trigger 0 0 0 1 1
269+
( 576 8 40 ) ( 576 9 40 ) ( 577 8 40 ) {trigger 0 0 0 1 1
270+
( 576 8 24 ) ( 577 8 24 ) ( 576 8 25 ) {trigger 0 0 0 1 1
271+
( 576 8 24 ) ( 576 8 25 ) ( 576 9 24 ) {trigger 0 0 0 1 1
272+
}
273+
}
274+
// entity 20
275+
{
276+
"classname" "ambient_comp_hum"
277+
"origin" "552 -8 24"
278+
}

tests/test_common.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,22 @@ TEST(common, q2Contents)
356356
}
357357
}
358358

359+
TEST(common, q1ContentsRemap)
360+
{
361+
auto *game_q1 = bspver_q1.game;
362+
{
363+
SCOPED_TRACE("all content types combined (should make a combination of all q1 types)");
364+
auto all = contentflags_t::make(EWT_VISCONTENTS_SOLID | EWT_VISCONTENTS_SKY | EWT_VISCONTENTS_DETAIL_WALL |
365+
EWT_VISCONTENTS_WINDOW | EWT_VISCONTENTS_ILLUSIONARY_VISBLOCKER |
366+
EWT_VISCONTENTS_AUX | EWT_VISCONTENTS_LAVA | EWT_VISCONTENTS_SLIME |
367+
EWT_VISCONTENTS_WATER | EWT_VISCONTENTS_MIST);
368+
369+
EXPECT_EQ(contentflags_t::make(EWT_VISCONTENTS_SOLID | EWT_VISCONTENTS_SKY | EWT_VISCONTENTS_LAVA |
370+
EWT_VISCONTENTS_SLIME | EWT_VISCONTENTS_WATER),
371+
game_q1->contents_remap_for_export(all, gamedef_t::remap_type_t::leaf));
372+
}
373+
}
374+
359375
TEST(common, q1ContentsRoundtrip)
360376
{
361377
auto *game_q1 = bspver_q1.game;

tests/test_qbsp.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,15 @@ TEST(testmapsQ1, q1FuncIllusionaryVisblockerInteractions)
698698
EXPECT_THAT(BSP_FindFacesAtPoint(&bsp, &bsp.dmodels[0], {424, 16, 104}).size(),
699699
testing::AllOf(testing::Ge(1), testing::Le(2)));
700700
}
701+
702+
{
703+
SCOPED_TRACE("func_illusionary_visblocker with a func_detail_fence block inside");
704+
SCOPED_TRACE("the fence should compile out as CONTENTS_SOLID");
705+
706+
auto *fence_leaf = BSP_FindLeafAtPoint(&bsp, &bsp.dmodels[0], {552, -8, 24});
707+
708+
EXPECT_EQ(fence_leaf->contents, CONTENTS_SOLID);
709+
}
701710
}
702711

703712
TEST(testmapsQ1, simpleWorldspawnWorldspawn)

0 commit comments

Comments
 (0)