From 5585351c0f92215c871f3184da919e687080292b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 Apr 2021 20:00:54 +0200 Subject: [PATCH] - added a hack to help the new renderer with Lunatic Fringe. This is by no means a permanent solution but having it buys some time to find something more universal that won't affect performance too badly and investigate the need for a more robust solution. The idea here is to define pairs of walls where when the first element of the pair is seen, it will treat the second one as view blocking. This is used as the two offending windows (sectors 151 and 152) to cope with the lack of a height sensitive clipper. --- source/core/gamecontrol.h | 5 ++++ source/core/maploader.cpp | 3 +++ .../core/rendering/scene/hw_bunchdrawer.cpp | 27 +++++++++++++++++++ source/core/rendering/scene/hw_bunchdrawer.h | 1 + 4 files changed, 36 insertions(+) diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index f2917b396..0872d7868 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -181,6 +181,11 @@ inline bool isWW2GI() return g_gameType & (GAMEFLAG_WW2GI); } +inline bool isDuke() +{ + return g_gameType & (GAMEFLAG_DUKE); +} + inline bool isRR() { return g_gameType & (GAMEFLAG_RRALL); diff --git a/source/core/maploader.cpp b/source/core/maploader.cpp index 3a7108ac7..2eed4b474 100644 --- a/source/core/maploader.cpp +++ b/source/core/maploader.cpp @@ -371,6 +371,7 @@ static void insertAllSprites(const char* filename, const vec3_t* pos, int16_t* c assert(realnumsprites == Numsprites); } +void addBlockingPairs(); void engineLoadBoard(const char* filename, int flags, vec3_t* pos, int16_t* ang, int16_t* cursectnum) { @@ -454,6 +455,8 @@ void engineLoadBoard(const char* filename, int flags, vec3_t* pos, int16_t* ang, memcpy(wallbackup, wall, sizeof(wallbackup)); memcpy(sectorbackup, sector, sizeof(sectorbackup)); + + addBlockingPairs(); } diff --git a/source/core/rendering/scene/hw_bunchdrawer.cpp b/source/core/rendering/scene/hw_bunchdrawer.cpp index 5c3b5a434..0be90bfae 100644 --- a/source/core/rendering/scene/hw_bunchdrawer.cpp +++ b/source/core/rendering/scene/hw_bunchdrawer.cpp @@ -41,7 +41,30 @@ #include "hw_portal.h" #include "gamestruct.h" #include "hw_voxels.h" +#include "mapinfo.h" +#include "gamecontrol.h" +TArray blockingpairs[MAXWALLS]; + +// temporary hack job to make Lunatic Fringe work while searching for a proper solution. +void addBlockingPairs() +{ + for (auto& p : blockingpairs) p.Clear(); + if (!isDuke()) return; + if (wall[682].sector == 151 && wall[683].sector == 151 && wall[684].sector == 151 && + wall[694].sector == 152 && wall[695].sector == 152 && wall[695].sector == 152 && + wall[755].sector == 158 && wall[756].sector == 158 && wall[757].sector == 158 && + wall[739].sector == 158 && wall[740].sector == 158 && wall[741].sector == 158) + { + for (int i = 755; i<=757; i++) blockingpairs[682].Push(i); + blockingpairs[683] = blockingpairs[682]; + blockingpairs[684] = blockingpairs[682]; + + for (int i = 739; i <= 741; i++) blockingpairs[694].Push(i); + blockingpairs[695] = blockingpairs[694]; + blockingpairs[696] = blockingpairs[694]; + } +} //========================================================================== // @@ -92,6 +115,7 @@ void BunchDrawer::StartScene() gotsector.Zero(); gotsector2.Zero(); gotwall.Zero(); + blockwall.Zero(); } //========================================================================== @@ -196,6 +220,8 @@ bool BunchDrawer::CheckClip(walltype* wal) int BunchDrawer::ClipLine(int line, bool portal) { + if (blockwall[line]) return CL_Draw; + auto wal = &wall[line]; auto startAngleBam = wal->clipangle; @@ -277,6 +303,7 @@ void BunchDrawer::ProcessBunch(int bnch) if (clipped & CL_Draw) { + for (auto p : blockingpairs[i]) blockwall.Set(p); show2dwall.Set(i); if (!gotwall[i]) diff --git a/source/core/rendering/scene/hw_bunchdrawer.h b/source/core/rendering/scene/hw_bunchdrawer.h index 805b60a93..f230fb570 100644 --- a/source/core/rendering/scene/hw_bunchdrawer.h +++ b/source/core/rendering/scene/hw_bunchdrawer.h @@ -30,6 +30,7 @@ class BunchDrawer FixedBitArray gotsector; FixedBitArray gotsector2; FixedBitArray gotwall; + FixedBitArray blockwall; binangle ang1, ang2; int sectstartang[MAXSECTORS], sectendang[MAXSECTORS];