From cdf79f0041d69342ab485d2923271d4fbb7daf1e Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Wed, 9 Aug 2017 00:11:43 -0400 Subject: [PATCH 01/21] - added Hellser's teleporter fix for doom2.wad map29 - https://forum.zdoom.org/viewtopic.php?t=57525 --- wadsrc/static/compatibility.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/wadsrc/static/compatibility.txt b/wadsrc/static/compatibility.txt index 485991a07..ee676b051 100644 --- a/wadsrc/static/compatibility.txt +++ b/wadsrc/static/compatibility.txt @@ -689,6 +689,30 @@ EBDAC00E9D25D884B2C8F4B1F0390539 // doom2.wad map21 setsectorspecial 93 0 setwalltexture 582 back top ZIMMER3 } +20251EDA21B2F2ECF6FF5B8BBC00B26C // Doom II, MAP29 +{ + // Missing textures on teleporters + setwalltexture 405 back bot SUPPORT3 + setwalltexture 406 back bot SUPPORT3 + setwalltexture 407 back bot SUPPORT3 + setwalltexture 408 back bot SUPPORT3 + setwalltexture 516 back bot SUPPORT3 + setwalltexture 517 back bot SUPPORT3 + setwalltexture 518 back bot SUPPORT3 + setwalltexture 519 back bot SUPPORT3 + setwalltexture 524 back bot SUPPORT3 + setwalltexture 525 back bot SUPPORT3 + setwalltexture 526 back bot SUPPORT3 + setwalltexture 527 back bot SUPPORT3 + setwalltexture 1146 back bot SUPPORT3 + setwalltexture 1147 back bot SUPPORT3 + setwalltexture 1148 back bot SUPPORT3 + setwalltexture 1149 back bot SUPPORT3 + setwalltexture 1138 back bot SUPPORT3 + setwalltexture 1139 back bot SUPPORT3 + setwalltexture 1140 back bot SUPPORT3 + setwalltexture 1141 back bot SUPPORT3 +} ABC4EB5A1535ECCD0061AD14F3547908 // Plutonia Experiment, map26 { setsectorspecial 156 0 From ef9c3b4f54b9f260d3bd43b2542db84ed48e12b5 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 9 Aug 2017 16:16:33 +0300 Subject: [PATCH 02/21] Fixed unset inflictor in WorldThingDamaged event https://forum.zdoom.org/viewtopic.php?t=57527 --- src/events.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/events.cpp b/src/events.cpp index 2649bf162..cca0a9398 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -762,6 +762,7 @@ void DStaticEventHandler::WorldThingDamaged(AActor* actor, AActor* inflictor, AA return; FWorldEvent e = E_SetupWorldEvent(); e.Thing = actor; + e.Inflictor = inflictor; e.Damage = damage; e.DamageSource = source; e.DamageType = mod; From 0db79f8dec6e2cca9b300ce8c4bbca426b15d7fa Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Aug 2017 09:15:59 +0200 Subject: [PATCH 03/21] - removed tag 0 check for 3D floors because as seems to be par for course in Doom modding, some people actually exploited this bug. --- src/p_3dfloors.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index 66ab0d7c8..2ad374166 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -876,8 +876,7 @@ void P_Spawn3DFloors (void) line.args[4]=0; } } - if (line.args[0] != 0) - P_Set3DFloor(&line, line.args[1]&~8, line.args[2], line.args[3]); + P_Set3DFloor(&line, line.args[1]&~8, line.args[2], line.args[3]); break; default: From b4fa95ab15158dd4e1eea2922d877e4074d2057d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Aug 2017 10:04:06 +0200 Subject: [PATCH 04/21] - handle state label resolution in a non-actor cpntext more gracefully. Note that this is merely a hotfix. Properly handling this to allow universal use of state scopes will require more work in cases where a scoped state is being accessed through a non-self pointer. --- src/scripting/backend/codegen.cpp | 8 ++++---- src/scripting/backend/codegen.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index 4a1cc7d77..4ce0d4ec0 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -11101,7 +11101,7 @@ ExpEmit FxRuntimeStateIndex::Emit(VMFunctionBuilder *build) // //========================================================================== -FxMultiNameState::FxMultiNameState(const char *_statestring, const FScriptPosition &pos) +FxMultiNameState::FxMultiNameState(const char *_statestring, const FScriptPosition &pos, PClassActor *checkclass) :FxExpression(EFX_MultiNameState, pos) { FName scopename; @@ -11119,7 +11119,7 @@ FxMultiNameState::FxMultiNameState(const char *_statestring, const FScriptPositi } names = MakeStateNameList(statestring); names.Insert(0, scopename); - scope = nullptr; + scope = checkclass; } //========================================================================== @@ -11135,8 +11135,8 @@ FxExpression *FxMultiNameState::Resolve(FCompileContext &ctx) int symlabel; auto vclass = PType::toClass(ctx.Class); - assert(vclass != nullptr); - auto clstype = ValidateActor(vclass->Descriptor); + //assert(vclass != nullptr); + auto clstype = vclass == nullptr? nullptr : ValidateActor(vclass->Descriptor); if (names[0] == NAME_None) { diff --git a/src/scripting/backend/codegen.h b/src/scripting/backend/codegen.h index 2121eff7a..58ac84d85 100644 --- a/src/scripting/backend/codegen.h +++ b/src/scripting/backend/codegen.h @@ -2089,7 +2089,7 @@ class FxMultiNameState : public FxExpression TArray names; public: - FxMultiNameState(const char *statestring, const FScriptPosition &pos); + FxMultiNameState(const char *statestring, const FScriptPosition &pos, PClassActor *checkclass = nullptr); FxExpression *Resolve(FCompileContext&); }; From c1de32896c5f06b7e0751bed8fd6f58a145de003 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Aug 2017 10:20:34 +0200 Subject: [PATCH 05/21] - addressed incorrect ACS printbold implementation: For native Hexen maps it will now be correct, but all others will have to set a flag in MAPINFO's 'gameinfo' section to avoid problems with numerous ZDoom maps depending on the incorrect implementation. --- src/gi.cpp | 1 + src/gi.h | 1 + src/p_acs.cpp | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gi.cpp b/src/gi.cpp index a6efab358..202122b32 100644 --- a/src/gi.cpp +++ b/src/gi.cpp @@ -376,6 +376,7 @@ void FMapInfoParser::ParseGameInfo() GAMEINFOKEY_BOOL(drawreadthis, "drawreadthis") GAMEINFOKEY_BOOL(swapmenu, "swapmenu") GAMEINFOKEY_BOOL(dontcrunchcorpses, "dontcrunchcorpses") + GAMEINFOKEY_BOOL(correctprintbold, "correctprintbold") GAMEINFOKEY_BOOL(intermissioncounter, "intermissioncounter") GAMEINFOKEY_BOOL(nightmarefast, "nightmarefast") GAMEINFOKEY_COLOR(dimcolor, "dimcolor") diff --git a/src/gi.h b/src/gi.h index be46aabfa..97ce7f99c 100644 --- a/src/gi.h +++ b/src/gi.h @@ -114,6 +114,7 @@ struct gameinfo_t bool nightmarefast; bool swapmenu; bool dontcrunchcorpses; + bool correctprintbold; TArray creditPages; TArray finalePages; TArray infoPages; diff --git a/src/p_acs.cpp b/src/p_acs.cpp index fa62ac2c1..37aef6fad 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -8765,7 +8765,10 @@ scriptwait: if (pcd == PCD_ENDPRINTBOLD || screen == NULL || screen->CheckLocalView (consoleplayer)) { - C_MidPrint (activefont, work); + if (pcd == PCD_ENDPRINTBOLD && (gameinfo.correctprintbold || (level.flags2 & LEVEL2_HEXENHACK))) + C_MidPrintBold(activefont, work); + else + C_MidPrint (activefont, work); } STRINGBUILDER_FINISH(work); } From 163b10286f2e04d945e5fda9f6910b42b7442b71 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Aug 2017 11:48:36 +0200 Subject: [PATCH 06/21] - Reset interpolation coordinates for all actors before the current thinking turn instead of at the start of each actor's own Tick function so that indirect actor movement gets properly interpolated. --- src/p_mobj.cpp | 4 ---- src/p_tick.cpp | 9 +++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index c02490420..b49be43d8 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4069,10 +4069,6 @@ void AActor::Tick () return; } - // This is necessary to properly interpolate movement outside this function - // like from an ActorMover - ClearInterpolation(); - if (flags5 & MF5_NOINTERACTION) { // only do the minimally necessary things here to save time: diff --git a/src/p_tick.cpp b/src/p_tick.cpp index 78dfa9abb..820a4ff68 100644 --- a/src/p_tick.cpp +++ b/src/p_tick.cpp @@ -119,6 +119,15 @@ void P_Ticker (void) P_ResetSightCounters (false); R_ClearInterpolationPath(); + // Reset all actor interpolations for all actors before the current thinking turn so that indirect actor movement gets properly interpolated. + TThinkerIterator it; + AActor *ac; + + while ((ac = it.Next())) + { + ac->ClearInterpolation(); + } + // Since things will be moving, it's okay to interpolate them in the renderer. r_NoInterpolate = false; From aa8424982c4e64a9e700cfb4181efa5a75ea3b5b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Aug 2017 12:04:40 +0200 Subject: [PATCH 07/21] - fixed: The color for untranslated font was missing its alpha channel. --- src/v_font.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/v_font.cpp b/src/v_font.cpp index 1f5c12c9c..30a3f45f6 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -766,6 +766,7 @@ FRemapTable *FFont::GetColorTranslation (EColorRange range, PalEntry *color) con if (range >= 0 && range < NumTextColors && range != CR_UNTRANSLATED) { retcolor = TranslationColors[range]; + retcolor.a = 255; } if (color != nullptr) *color = retcolor; } From 4261a0c592aeef4745fdb83bdd5079f4d4dd1887 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Aug 2017 12:30:42 +0200 Subject: [PATCH 08/21] - print a warning if a decal definition cannot find an animator. This is important because DECALDEF cannot tentatively find animators declared after the decal. --- src/decallib.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/decallib.cpp b/src/decallib.cpp index aa6fa38b4..c4af2cbe6 100644 --- a/src/decallib.cpp +++ b/src/decallib.cpp @@ -562,6 +562,10 @@ void FDecalLib::ParseDecal (FScanner &sc) case DECAL_ANIMATOR: sc.MustGetString (); newdecal.Animator = FindAnimator (sc.String); + if (newdecal.Animator == nullptr) + { + sc.ScriptMessage("Unable to find animator %s", sc.String); + } break; case DECAL_LOWERDECAL: From 7cbf45d76d44f3f2cc4274897d2d8c5550bbd6a9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Aug 2017 12:35:01 +0200 Subject: [PATCH 09/21] - let PlayerPawn.ForwardThrust use its angle parameter. --- wadsrc/static/zscript/shared/player.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/zscript/shared/player.txt b/wadsrc/static/zscript/shared/player.txt index 98b504985..8b8710416 100644 --- a/wadsrc/static/zscript/shared/player.txt +++ b/wadsrc/static/zscript/shared/player.txt @@ -753,7 +753,7 @@ class PlayerPawn : Actor native Vel.Z -= zpush; move *= cos(Pitch); } - Thrust(move); + Thrust(move, angle); } //---------------------------------------------------------------------------- From f52e767b516a7c45ffad356e7b70c4a9faa2a1ca Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Aug 2017 12:51:45 +0200 Subject: [PATCH 10/21] - fixed: a destination-less line portal should be ignored by the sight checking code. --- src/p_sight.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_sight.cpp b/src/p_sight.cpp index f86ae4c22..62f973528 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -236,7 +236,7 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in) FLinePortal *lport = li->getPortal(); - if (open.range == 0 && open.portalflags == 0 && (lport == NULL || lport->mType != PORTT_LINKED)) // quick test for totally closed doors (must be delayed if portal checks are needed, though) + if (open.range == 0 && open.portalflags == 0 && (lport == nullptr || lport->mType != PORTT_LINKED)) // quick test for totally closed doors (must be delayed if portal checks are needed, though) return false; // stop if (in->frac == 0) @@ -284,7 +284,7 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in) portals.Push({ in->frac, topslope, bottomslope, sector_t::floor, backsec->GetOppositePortalGroup(sector_t::floor) }); } } - if (lport) + if (lport != nullptr && lport->mDestination != nullptr) { portals.Push({ in->frac, topslope, bottomslope, portaldir, lport->mDestination->frontsector->PortalGroup }); return false; From ba9cf023855175d883e30cacbb3c6418a4e0357b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Aug 2017 13:08:11 +0200 Subject: [PATCH 11/21] - added a user reserved range of statnums from 70-90 --- src/statnums.h | 3 +++ wadsrc/static/zscript/base.txt | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/statnums.h b/src/statnums.h index 682366142..7450ccbdd 100644 --- a/src/statnums.h +++ b/src/statnums.h @@ -61,6 +61,9 @@ enum STAT_MAPMARKER, // Map marker actors STAT_DLIGHT, + STAT_USER = 70, + STAT_USER_MAX = 90, + STAT_DEFAULT = 100, // Thinkers go here unless specified otherwise. STAT_SECTOREFFECT, // All sector effects that cause floor and ceiling movement STAT_ACTORMOVER, // actor movers diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index b7607d555..4be135118 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -385,6 +385,9 @@ class Thinker : Object native play STAT_MAPMARKER, // Map marker actors STAT_DLIGHT, // Dynamic lights + STAT_USER = 70, + STAT_USER_MAX = 90, + STAT_DEFAULT = 100, // Thinkers go here unless specified otherwise. STAT_SECTOREFFECT, // All sector effects that cause floor and ceiling movement STAT_ACTORMOVER, // actor movers From 89980d9e774973c82d07299b563b34211dbf9267 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 12 Aug 2017 14:41:23 +0300 Subject: [PATCH 12/21] Fixed linking with GCC and Clang toolchains --- src/p_tick.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_tick.cpp b/src/p_tick.cpp index 820a4ff68..67bcc592d 100644 --- a/src/p_tick.cpp +++ b/src/p_tick.cpp @@ -40,6 +40,7 @@ #include "p_spec.h" #include "g_levellocals.h" #include "events.h" +#include "actorinlines.h" extern gamestate_t wipegamestate; From 4483d665d42689b10d9888b837a17b7335fc2b61 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Aug 2017 13:55:33 +0200 Subject: [PATCH 13/21] - fixed: FastProjectile's movement code was missong a portal check. --- src/p_mobj.cpp | 8 ++++++++ wadsrc/static/zscript/actor.txt | 1 + wadsrc/static/zscript/shared/fastprojectile.txt | 1 + 3 files changed, 10 insertions(+) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index b49be43d8..daa8b5aa4 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4036,6 +4036,14 @@ void AActor::CheckPortalTransition(bool islinked) if (islinked && moved) LinkToWorld(&ctx); } +DEFINE_ACTION_FUNCTION(AActor, CheckPortalTransition) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_BOOL_DEF(linked); + self->CheckPortalTransition(linked); + return 0; +} + // // P_MobjThinker // diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 048ba0759..27ce423a8 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -518,6 +518,7 @@ class Actor : Thinker native native clearscope int GetRenderStyle() const; native clearscope bool CheckKeys(int locknum, bool remote, bool quiet = false); native clearscope Inventory FirstInv() const; + protected native void CheckPortalTransition(bool linked = true); native clearscope string GetTag(string defstr = "") const; native void SetTag(string defstr = ""); diff --git a/wadsrc/static/zscript/shared/fastprojectile.txt b/wadsrc/static/zscript/shared/fastprojectile.txt index a0fa1a91c..1bed8cba2 100644 --- a/wadsrc/static/zscript/shared/fastprojectile.txt +++ b/wadsrc/static/zscript/shared/fastprojectile.txt @@ -156,6 +156,7 @@ class FastProjectile : Actor ExplodeMissile (NULL, NULL); return; } + CheckPortalTransition(); if (changexy && ripcount <= 0) { ripcount = count >> 3; From bf38fd57b055c999d707cd0abb546443baa5dfd8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 12 Aug 2017 15:16:31 +0200 Subject: [PATCH 14/21] - Replace subsector gbuffer in softpoly with a zbuffer --- src/polyrenderer/drawers/poly_buffer.cpp | 6 +- src/polyrenderer/drawers/poly_buffer.h | 8 +- src/polyrenderer/drawers/poly_draw_args.h | 15 +- src/polyrenderer/drawers/poly_triangle.cpp | 2 +- src/polyrenderer/drawers/screen_triangle.cpp | 252 ++++++++++++------- src/polyrenderer/drawers/screen_triangle.h | 2 +- src/polyrenderer/poly_renderer.cpp | 2 +- src/polyrenderer/scene/poly_decal.cpp | 15 +- src/polyrenderer/scene/poly_decal.h | 4 +- src/polyrenderer/scene/poly_particle.cpp | 7 +- src/polyrenderer/scene/poly_particle.h | 2 +- src/polyrenderer/scene/poly_plane.cpp | 23 +- src/polyrenderer/scene/poly_plane.h | 6 +- src/polyrenderer/scene/poly_portal.h | 3 +- src/polyrenderer/scene/poly_scene.cpp | 12 +- src/polyrenderer/scene/poly_sky.cpp | 1 - src/polyrenderer/scene/poly_sprite.cpp | 7 +- src/polyrenderer/scene/poly_sprite.h | 2 +- src/polyrenderer/scene/poly_wall.cpp | 11 +- src/polyrenderer/scene/poly_wallsprite.cpp | 6 +- src/polyrenderer/scene/poly_wallsprite.h | 2 +- 21 files changed, 222 insertions(+), 166 deletions(-) diff --git a/src/polyrenderer/drawers/poly_buffer.cpp b/src/polyrenderer/drawers/poly_buffer.cpp index 143d16bbd..43e873145 100644 --- a/src/polyrenderer/drawers/poly_buffer.cpp +++ b/src/polyrenderer/drawers/poly_buffer.cpp @@ -38,13 +38,13 @@ ///////////////////////////////////////////////////////////////////////////// -PolySubsectorGBuffer *PolySubsectorGBuffer::Instance() +PolyZBuffer *PolyZBuffer::Instance() { - static PolySubsectorGBuffer buffer; + static PolyZBuffer buffer; return &buffer; } -void PolySubsectorGBuffer::Resize(int newwidth, int newheight) +void PolyZBuffer::Resize(int newwidth, int newheight) { width = newwidth; height = newheight; diff --git a/src/polyrenderer/drawers/poly_buffer.h b/src/polyrenderer/drawers/poly_buffer.h index a376cec46..a7c44c9c0 100644 --- a/src/polyrenderer/drawers/poly_buffer.h +++ b/src/polyrenderer/drawers/poly_buffer.h @@ -26,21 +26,21 @@ struct TriVertex; -class PolySubsectorGBuffer +class PolyZBuffer { public: - static PolySubsectorGBuffer *Instance(); + static PolyZBuffer *Instance(); void Resize(int newwidth, int newheight); int Width() const { return width; } int Height() const { return height; } int BlockWidth() const { return (width + 7) / 8; } int BlockHeight() const { return (height + 7) / 8; } - uint32_t *Values() { return values.data(); } + float *Values() { return values.data(); } private: int width; int height; - std::vector values; + std::vector values; }; class PolyStencilBuffer diff --git a/src/polyrenderer/drawers/poly_draw_args.h b/src/polyrenderer/drawers/poly_draw_args.h index c90aaadd0..0d84d24df 100644 --- a/src/polyrenderer/drawers/poly_draw_args.h +++ b/src/polyrenderer/drawers/poly_draw_args.h @@ -53,12 +53,11 @@ public: void SetTexture(FTexture *texture); void SetTexture(FTexture *texture, uint32_t translationID, bool forcePal = false); void SetLight(FSWColormap *basecolormap, uint32_t lightlevel, double globVis, bool fixed); - void SetSubsectorDepth(uint32_t subsectorDepth) { mSubsectorDepth = subsectorDepth; } - void SetSubsectorDepthTest(bool enable) { mSubsectorTest = enable; } + void SetDepthTest(bool enable) { mDepthTest = enable; } void SetStencilTestValue(uint8_t stencilTestValue) { mStencilTestValue = stencilTestValue; } void SetWriteColor(bool enable) { mWriteColor = enable; } void SetWriteStencil(bool enable, uint8_t stencilWriteValue = 0) { mWriteStencil = enable; mStencilWriteValue = stencilWriteValue; } - void SetWriteSubsectorDepth(bool enable) { mWriteSubsector = enable; } + void SetWriteDepth(bool enable) { mWriteDepth = enable; } void SetFaceCullCCW(bool counterclockwise) { mFaceCullCCW = counterclockwise; } void SetStyle(TriBlendMode blendmode, double srcalpha = 1.0, double destalpha = 1.0) { mBlendMode = blendmode; mSrcAlpha = (uint32_t)(srcalpha * 256.0 + 0.5); mDestAlpha = (uint32_t)(destalpha * 256.0 + 0.5); } void SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FTexture *texture, bool fullbright); @@ -85,9 +84,8 @@ public: uint8_t StencilTestValue() const { return mStencilTestValue; } uint8_t StencilWriteValue() const { return mStencilWriteValue; } - bool SubsectorTest() const { return mSubsectorTest; } - bool WriteSubsector() const { return mWriteSubsector; } - uint32_t SubsectorDepth() const { return mSubsectorDepth; } + bool DepthTest() const { return mDepthTest; } + bool WriteDepth() const { return mWriteDepth; } TriBlendMode BlendMode() const { return mBlendMode; } uint32_t Color() const { return mColor; } @@ -117,10 +115,10 @@ private: int mVertexCount = 0; PolyDrawMode mDrawMode = PolyDrawMode::Triangles; bool mFaceCullCCW = false; - bool mSubsectorTest = false; + bool mDepthTest = false; bool mWriteStencil = true; bool mWriteColor = true; - bool mWriteSubsector = true; + bool mWriteDepth = true; const uint8_t *mTexturePixels = nullptr; int mTextureWidth = 0; int mTextureHeight = 0; @@ -131,7 +129,6 @@ private: float mClipPlane[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; TriBlendMode mBlendMode = TriBlendMode::FillOpaque; uint32_t mLight = 0; - uint32_t mSubsectorDepth = 0; uint32_t mColor = 0; uint32_t mSrcAlpha = 0; uint32_t mDestAlpha = 0; diff --git a/src/polyrenderer/drawers/poly_triangle.cpp b/src/polyrenderer/drawers/poly_triangle.cpp index 1cf9609cc..c411dff27 100644 --- a/src/polyrenderer/drawers/poly_triangle.cpp +++ b/src/polyrenderer/drawers/poly_triangle.cpp @@ -99,7 +99,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, WorkerThreadD args.stencilPitch = PolyStencilBuffer::Instance()->BlockWidth(); args.stencilValues = PolyStencilBuffer::Instance()->Values(); args.stencilMasks = PolyStencilBuffer::Instance()->Masks(); - args.subsectorGBuffer = PolySubsectorGBuffer::Instance()->Values(); + args.zbuffer = PolyZBuffer::Instance()->Values(); bool ccw = drawargs.FaceCullCCW(); const TriVertex *vinput = drawargs.Vertices(); diff --git a/src/polyrenderer/drawers/screen_triangle.cpp b/src/polyrenderer/drawers/screen_triangle.cpp index 01dd16766..f44c983e7 100644 --- a/src/polyrenderer/drawers/screen_triangle.cpp +++ b/src/polyrenderer/drawers/screen_triangle.cpp @@ -76,10 +76,9 @@ private: int clipright; int clipbottom; - // Subsector buffer - uint32_t * RESTRICT subsectorGBuffer; - uint32_t subsectorDepth; - int32_t subsectorPitch; + // Depth buffer + float * RESTRICT zbuffer; + int32_t zbufferPitch; // Triangle bounding block int minx, miny; @@ -113,10 +112,10 @@ private: void CoverageTest(); void StencilEqualTest(); void StencilGreaterEqualTest(); - void SubsectorTest(); + void DepthTest(const TriDrawTriangleArgs *args); void ClipTest(); void StencilWrite(); - void SubsectorWrite(); + void DepthWrite(const TriDrawTriangleArgs *args); }; TriangleBlock::TriangleBlock(const TriDrawTriangleArgs *args) @@ -134,9 +133,8 @@ TriangleBlock::TriangleBlock(const TriDrawTriangleArgs *args) stencilTestValue = args->uniforms->StencilTestValue(); stencilWriteValue = args->uniforms->StencilWriteValue(); - subsectorGBuffer = args->subsectorGBuffer; - subsectorDepth = args->uniforms->SubsectorDepth(); - subsectorPitch = args->stencilPitch; + zbuffer = args->zbuffer; + zbufferPitch = args->stencilPitch; // 28.4 fixed-point coordinates #ifdef NO_SSE @@ -235,10 +233,10 @@ void TriangleBlock::Loop(const TriDrawTriangleArgs *args, WorkerThreadData *thre int core_skip = (num_cores - ((miny / q) - core) % num_cores) % num_cores; int start_miny = miny + core_skip * q; - bool subsectorTest = args->uniforms->SubsectorTest(); + bool depthTest = args->uniforms->DepthTest(); bool writeColor = args->uniforms->WriteColor(); bool writeStencil = args->uniforms->WriteStencil(); - bool writeSubsector = args->uniforms->WriteSubsector(); + bool writeDepth = args->uniforms->WriteDepth(); int bmode = (int)args->uniforms->BlendMode(); auto drawFunc = args->destBgra ? ScreenTriangle::TriDrawers32[bmode] : ScreenTriangle::TriDrawers8[bmode]; @@ -259,8 +257,8 @@ void TriangleBlock::Loop(const TriDrawTriangleArgs *args, WorkerThreadData *thre if (Mask0 == 0 && Mask1 == 0) continue; - // To do: make the stencil test use its own flag for comparison mode instead of abusing the subsector test.. - if (!subsectorTest) + // To do: make the stencil test use its own flag for comparison mode instead of abusing the depth test.. + if (!depthTest) { StencilEqualTest(); if (Mask0 == 0 && Mask1 == 0) @@ -272,7 +270,7 @@ void TriangleBlock::Loop(const TriDrawTriangleArgs *args, WorkerThreadData *thre if (Mask0 == 0 && Mask1 == 0) continue; - SubsectorTest(); + DepthTest(args); if (Mask0 == 0 && Mask1 == 0) continue; } @@ -281,34 +279,54 @@ void TriangleBlock::Loop(const TriDrawTriangleArgs *args, WorkerThreadData *thre drawFunc(X, Y, Mask0, Mask1, args); if (writeStencil) StencilWrite(); - if (writeSubsector) - SubsectorWrite(); + if (writeDepth) + DepthWrite(args); } } } #ifdef NO_SSE -void TriangleBlock::SubsectorTest() +void TriangleBlock::DepthTest(const TriDrawTriangleArgs *args) { - int block = (X >> 3) + (Y >> 3) * subsectorPitch; - uint32_t *subsector = subsectorGBuffer + block * 64; + int block = (X >> 3) + (Y >> 3) * zbufferPitch; + float *depth = zbuffer + block * 64; + + const TriVertex &v1 = *args->v1; + + float stepXW = args->gradientX.W; + float stepYW = args->gradientY.W; + float posYW = v1.w + stepXW * (X - v1.x) + stepYW * (Y - v1.y); + uint32_t mask0 = 0; uint32_t mask1 = 0; - for (int i = 0; i < 32; i++) + for (int iy = 0; iy < 4; iy++) { - bool covered = *subsector >= subsectorDepth; - mask0 <<= 1; - mask0 |= (uint32_t)covered; - subsector++; + float posXW = posYW; + for (int ix = 0; ix < 8; ix++) + { + bool covered = *depth <= posXW; + mask0 <<= 1; + mask0 |= (uint32_t)covered; + depth++; + posXW += stepXW; + } + posYW += stepYW; } - for (int i = 0; i < 32; i++) + + for (int iy = 0; iy < 4; iy++) { - bool covered = *subsector >= subsectorDepth; - mask1 <<= 1; - mask1 |= (uint32_t)covered; - subsector++; + float posXW = posYW; + for (int ix = 0; ix < 8; ix++) + { + bool covered = *depth <= posXW; + mask1 <<= 1; + mask1 |= (uint32_t)covered; + depth++; + posXW += stepXW; + } + posYW += stepYW; } Mask0 = Mask0 & mask0; @@ -317,26 +335,50 @@ void TriangleBlock::SubsectorTest() #else -void TriangleBlock::SubsectorTest() +void TriangleBlock::DepthTest(const TriDrawTriangleArgs *args) { - int block = (X >> 3) + (Y >> 3) * subsectorPitch; - uint32_t *subsector = subsectorGBuffer + block * 64; + int block = (X >> 3) + (Y >> 3) * zbufferPitch; + float *depth = zbuffer + block * 64; + + const TriVertex &v1 = *args->v1; + + float stepXW = args->gradientX.W; + float stepYW = args->gradientY.W; + float posYW = v1.w + stepXW * (X - v1.x) + stepYW * (Y - v1.y); + + __m128 mposYW = _mm_setr_ps(posYW, posYW + stepXW, posYW + stepXW + stepXW, posYW + stepXW + stepXW + stepXW); + __m128 mstepXW = _mm_set1_ps(stepXW * 4.0f); + __m128 mstepYW = _mm_set1_ps(stepYW); + uint32_t mask0 = 0; uint32_t mask1 = 0; - __m128i msubsectorDepth = _mm_set1_epi32(subsectorDepth); - __m128i mnotxor = _mm_set1_epi32(0xffffffff); - for (int iy = 0; iy < 8; iy++) + for (int iy = 0; iy < 4; iy++) { - mask0 <<= 4; - mask0 |= _mm_movemask_ps(_mm_castsi128_ps(_mm_shuffle_epi32(_mm_xor_si128(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)subsector), msubsectorDepth), mnotxor), _MM_SHUFFLE(0, 1, 2, 3)))); - subsector += 4; + __m128 mposXW = mposYW; + for (int ix = 0; ix < 2; ix++) + { + __m128 covered = _mm_cmplt_ps(_mm_loadu_ps(depth), mposXW); + mask0 <<= 4; + mask0 |= _mm_movemask_ps(_mm_shuffle_ps(covered, covered, _MM_SHUFFLE(0, 1, 2, 3))); + depth += 4; + mposXW = _mm_add_ps(mposXW, mstepXW); + } + mposYW = _mm_add_ps(mposYW, mstepYW); } - for (int iy = 0; iy < 8; iy++) + + for (int iy = 0; iy < 4; iy++) { - mask1 <<= 4; - mask1 |= _mm_movemask_ps(_mm_castsi128_ps(_mm_shuffle_epi32(_mm_xor_si128(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)subsector), msubsectorDepth), mnotxor), _MM_SHUFFLE(0, 1, 2, 3)))); - subsector += 4; + __m128 mposXW = mposYW; + for (int ix = 0; ix < 2; ix++) + { + __m128 covered = _mm_cmplt_ps(_mm_loadu_ps(depth), mposXW); + mask1 <<= 4; + mask1 |= _mm_movemask_ps(_mm_shuffle_ps(covered, covered, _MM_SHUFFLE(0, 1, 2, 3))); + depth += 4; + mposXW = _mm_add_ps(mposXW, mstepXW); + } + mposYW = _mm_add_ps(mposYW, mstepYW); } Mask0 = Mask0 & mask0; @@ -798,65 +840,91 @@ void TriangleBlock::StencilWrite() #ifdef NO_SSE -void TriangleBlock::SubsectorWrite() +void TriangleBlock::DepthWrite(const TriDrawTriangleArgs *args) { - int block = (X >> 3) + (Y >> 3) * subsectorPitch; - uint32_t *subsector = subsectorGBuffer + block * 64; + int block = (X >> 3) + (Y >> 3) * zbufferPitch; + float *depth = zbuffer + block * 64; + + const TriVertex &v1 = *args->v1; + + float stepXW = args->gradientX.W; + float stepYW = args->gradientY.W; + float posYW = v1.w + stepXW * (X - v1.x) + stepYW * (Y - v1.y); if (Mask0 == 0xffffffff && Mask1 == 0xffffffff) { - for (int i = 0; i < 64; i++) + for (int iy = 0; iy < 8; iy++) { - *(subsector++) = subsectorDepth; + float posXW = posYW; + for (int ix = 0; ix < 8; ix++) + { + *(depth++) = posXW; + posXW += stepXW; + } + posYW += stepYW; } } else { uint32_t mask0 = Mask0; uint32_t mask1 = Mask1; - for (int i = 0; i < 32; i++) + + for (int iy = 0; iy < 4; iy++) { - if (mask0 & (1 << 31)) - *subsector = subsectorDepth; - mask0 <<= 1; - subsector++; + float posXW = posYW; + for (int ix = 0; ix < 8; ix++) + { + if (mask0 & (1 << 31)) + *depth = posXW; + posXW += stepXW; + mask0 <<= 1; + depth++; + } + posYW += stepYW; } - for (int i = 0; i < 32; i++) + + for (int iy = 0; iy < 4; iy++) { - if (mask1 & (1 << 31)) - *subsector = subsectorDepth; - mask1 <<= 1; - subsector++; + float posXW = posYW; + for (int ix = 0; ix < 8; ix++) + { + if (mask1 & (1 << 31)) + *depth = posXW; + posXW += stepXW; + mask1 <<= 1; + depth++; + } + posYW += stepYW; } } } #else -void TriangleBlock::SubsectorWrite() +void TriangleBlock::DepthWrite(const TriDrawTriangleArgs *args) { - int block = (X >> 3) + (Y >> 3) * subsectorPitch; - uint32_t *subsector = subsectorGBuffer + block * 64; - __m128i msubsectorDepth = _mm_set1_epi32(subsectorDepth); + int block = (X >> 3) + (Y >> 3) * zbufferPitch; + float *depth = zbuffer + block * 64; + + const TriVertex &v1 = *args->v1; + + float stepXW = args->gradientX.W; + float stepYW = args->gradientY.W; + float posYW = v1.w + stepXW * (X - v1.x) + stepYW * (Y - v1.y); + + __m128 mposYW = _mm_setr_ps(posYW, posYW + stepXW, posYW + stepXW + stepXW, posYW + stepXW + stepXW + stepXW); + __m128 mstepXW = _mm_set1_ps(stepXW * 4.0f); + __m128 mstepYW = _mm_set1_ps(stepYW); if (Mask0 == 0xffffffff && Mask1 == 0xffffffff) { - _mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4; - _mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4; - _mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4; - _mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4; - _mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4; - _mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4; - _mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4; - _mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4; - _mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4; - _mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4; - _mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4; - _mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4; - _mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4; - _mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4; - _mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4; - _mm_storeu_si128((__m128i*)subsector, msubsectorDepth); + for (int iy = 0; iy < 8; iy++) + { + __m128 mposXW = mposYW; + _mm_storeu_ps(depth, mposXW); depth += 4; mposXW = _mm_add_ps(mposXW, mstepXW); + _mm_storeu_ps(depth, mposXW); depth += 4; + mposYW = _mm_add_ps(mposYW, mstepYW); + } } else { @@ -866,23 +934,21 @@ void TriangleBlock::SubsectorWrite() __m128i mmask0 = _mm_set1_epi32(Mask0); __m128i mmask1 = _mm_set1_epi32(Mask1); - _mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask0 = _mm_slli_epi32(mmask0, 4); subsector += 4; - _mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask0 = _mm_slli_epi32(mmask0, 4); subsector += 4; - _mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask0 = _mm_slli_epi32(mmask0, 4); subsector += 4; - _mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask0 = _mm_slli_epi32(mmask0, 4); subsector += 4; - _mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask0 = _mm_slli_epi32(mmask0, 4); subsector += 4; - _mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask0 = _mm_slli_epi32(mmask0, 4); subsector += 4; - _mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask0 = _mm_slli_epi32(mmask0, 4); subsector += 4; - _mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); subsector += 4; + for (int iy = 0; iy < 4; iy++) + { + __m128 mposXW = mposYW; + _mm_maskmoveu_si128(_mm_castps_si128(mposXW), _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)depth); mmask0 = _mm_slli_epi32(mmask0, 4); depth += 4; mposXW = _mm_add_ps(mposXW, mstepXW); + _mm_maskmoveu_si128(_mm_castps_si128(mposXW), _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)depth); mmask0 = _mm_slli_epi32(mmask0, 4); depth += 4; + mposYW = _mm_add_ps(mposYW, mstepYW); + } - _mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask1 = _mm_slli_epi32(mmask1, 4); subsector += 4; - _mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask1 = _mm_slli_epi32(mmask1, 4); subsector += 4; - _mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask1 = _mm_slli_epi32(mmask1, 4); subsector += 4; - _mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask1 = _mm_slli_epi32(mmask1, 4); subsector += 4; - _mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask1 = _mm_slli_epi32(mmask1, 4); subsector += 4; - _mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask1 = _mm_slli_epi32(mmask1, 4); subsector += 4; - _mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask1 = _mm_slli_epi32(mmask1, 4); subsector += 4; - _mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); subsector += 4; + for (int iy = 0; iy < 4; iy++) + { + __m128 mposXW = mposYW; + _mm_maskmoveu_si128(_mm_castps_si128(mposXW), _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)depth); mmask1 = _mm_slli_epi32(mmask1, 4); depth += 4; mposXW = _mm_add_ps(mposXW, mstepXW); + _mm_maskmoveu_si128(_mm_castps_si128(mposXW), _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)depth); mmask1 = _mm_slli_epi32(mmask1, 4); depth += 4; + mposYW = _mm_add_ps(mposYW, mstepYW); + } } } diff --git a/src/polyrenderer/drawers/screen_triangle.h b/src/polyrenderer/drawers/screen_triangle.h index 4339edaf4..98ea1146c 100644 --- a/src/polyrenderer/drawers/screen_triangle.h +++ b/src/polyrenderer/drawers/screen_triangle.h @@ -60,7 +60,7 @@ struct TriDrawTriangleArgs uint8_t *stencilValues; uint32_t *stencilMasks; int32_t stencilPitch; - uint32_t *subsectorGBuffer; + float *zbuffer; const PolyDrawArgs *uniforms; bool destBgra; ScreenTriangleStepVariables gradientX; diff --git a/src/polyrenderer/poly_renderer.cpp b/src/polyrenderer/poly_renderer.cpp index fc119e65e..53f051b1f 100644 --- a/src/polyrenderer/poly_renderer.cpp +++ b/src/polyrenderer/poly_renderer.cpp @@ -159,7 +159,7 @@ void PolyRenderer::ClearBuffers() { FrameMemory.Clear(); PolyStencilBuffer::Instance()->Clear(RenderTarget->GetWidth(), RenderTarget->GetHeight(), 0); - PolySubsectorGBuffer::Instance()->Resize(RenderTarget->GetPitch(), RenderTarget->GetHeight()); + PolyZBuffer::Instance()->Resize(RenderTarget->GetPitch(), RenderTarget->GetHeight()); NextStencilValue = 0; } diff --git a/src/polyrenderer/scene/poly_decal.cpp b/src/polyrenderer/scene/poly_decal.cpp index 1c7538415..d619c13f5 100644 --- a/src/polyrenderer/scene/poly_decal.cpp +++ b/src/polyrenderer/scene/poly_decal.cpp @@ -31,7 +31,7 @@ #include "a_sharedglobal.h" #include "swrenderer/scene/r_scene.h" -void RenderPolyDecal::RenderWallDecals(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue) +void RenderPolyDecal::RenderWallDecals(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, const seg_t *line, uint32_t stencilValue) { if (line->linedef == nullptr && line->sidedef == nullptr) return; @@ -39,11 +39,11 @@ void RenderPolyDecal::RenderWallDecals(const TriMatrix &worldToClip, const PolyC for (DBaseDecal *decal = line->sidedef->AttachedDecals; decal != nullptr; decal = decal->WallNext) { RenderPolyDecal render; - render.Render(worldToClip, clipPlane, decal, line, subsectorDepth, stencilValue); + render.Render(worldToClip, clipPlane, decal, line, stencilValue); } } -void RenderPolyDecal::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue) +void RenderPolyDecal::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, DBaseDecal *decal, const seg_t *line, uint32_t stencilValue) { if (decal->RenderFlags & RF_INVISIBLE || !viewactive || !decal->PicNum.isValid()) return; @@ -62,6 +62,10 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const PolyClipPlane & DVector2 decal_pos = { dcx, dcy }; DVector2 angvec = (line->v2->fPos() - line->v1->fPos()).Unit(); + DVector2 normal = { angvec.Y, -angvec.X }; + + decal_pos += normal; + DVector2 decal_left = decal_pos - edge_left * angvec; DVector2 decal_right = decal_pos + edge_right * angvec; @@ -139,7 +143,6 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const PolyClipPlane & PolyDrawArgs args; args.SetLight(GetColorTable(front->Colormap), lightlevel, PolyRenderer::Instance()->Light.WallGlobVis(foggy), fullbrightSprite); - args.SetSubsectorDepth(subsectorDepth); args.SetColor(0xff000000 | decal->AlphaColor, decal->AlphaColor >> 24); args.SetStyle(decal->RenderStyle, decal->Alpha, decal->AlphaColor, decal->Translation, tex, false); args.SetTransform(&worldToClip); @@ -147,8 +150,8 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const PolyClipPlane & args.SetStencilTestValue(stencilValue); args.SetWriteStencil(true, stencilValue); args.SetClipPlane(clipPlane); - args.SetSubsectorDepthTest(true); + args.SetDepthTest(true); args.SetWriteStencil(false); - args.SetWriteSubsectorDepth(false); + args.SetWriteDepth(false); args.DrawArray(vertices, 4, PolyDrawMode::TriangleFan); } diff --git a/src/polyrenderer/scene/poly_decal.h b/src/polyrenderer/scene/poly_decal.h index a0d676951..0cab330ca 100644 --- a/src/polyrenderer/scene/poly_decal.h +++ b/src/polyrenderer/scene/poly_decal.h @@ -27,8 +27,8 @@ class RenderPolyDecal { public: - static void RenderWallDecals(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue); + static void RenderWallDecals(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, const seg_t *line, uint32_t stencilValue); private: - void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue); + void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, DBaseDecal *decal, const seg_t *line, uint32_t stencilValue); }; diff --git a/src/polyrenderer/scene/poly_particle.cpp b/src/polyrenderer/scene/poly_particle.cpp index ab80400dd..1a67de786 100644 --- a/src/polyrenderer/scene/poly_particle.cpp +++ b/src/polyrenderer/scene/poly_particle.cpp @@ -31,7 +31,7 @@ EXTERN_CVAR(Int, gl_particles_style) -void RenderPolyParticle::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) +void RenderPolyParticle::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, particle_t *particle, subsector_t *sub, uint32_t stencilValue) { DVector3 pos = particle->Pos; double psize = particle->size / 8.0; @@ -75,15 +75,14 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, const PolyClipPlan PolyDrawArgs args; args.SetLight(GetColorTable(sub->sector->Colormap), lightlevel, PolyRenderer::Instance()->Light.ParticleGlobVis(foggy), fullbrightSprite); - args.SetSubsectorDepth(subsectorDepth); - args.SetSubsectorDepthTest(true); + args.SetDepthTest(true); args.SetColor(particle->color | 0xff000000, particle->color >> 24); args.SetStyle(TriBlendMode::Shaded, particle->alpha, 1.0 - particle->alpha); args.SetTransform(&worldToClip); args.SetFaceCullCCW(true); args.SetStencilTestValue(stencilValue); args.SetWriteStencil(false); - args.SetWriteSubsectorDepth(false); + args.SetWriteDepth(false); args.SetClipPlane(clipPlane); args.SetTexture(GetParticleTexture(), ParticleTextureSize, ParticleTextureSize); args.DrawArray(vertices, 4, PolyDrawMode::TriangleFan); diff --git a/src/polyrenderer/scene/poly_particle.h b/src/polyrenderer/scene/poly_particle.h index a5cc3d0d0..af4b4ebfc 100644 --- a/src/polyrenderer/scene/poly_particle.h +++ b/src/polyrenderer/scene/poly_particle.h @@ -28,7 +28,7 @@ class RenderPolyParticle { public: - void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue); + void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, particle_t *particle, subsector_t *sub, uint32_t stencilValue); private: static uint8_t *GetParticleTexture(); diff --git a/src/polyrenderer/scene/poly_plane.cpp b/src/polyrenderer/scene/poly_plane.cpp index ad471b4f0..d76a1756f 100644 --- a/src/polyrenderer/scene/poly_plane.cpp +++ b/src/polyrenderer/scene/poly_plane.cpp @@ -33,7 +33,7 @@ EXTERN_CVAR(Int, r_3dfloors) -void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t ceilingSubsectorDepth, uint32_t floorSubsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals) +void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals) { RenderPolyPlane plane; @@ -61,7 +61,7 @@ void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, const PolyClipP double fakeHeight = fakeFloor->top.plane->ZatPoint(frontsector->centerspot); if (fakeHeight < viewpoint.Pos.Z && fakeHeight > frontsector->floorplane.ZatPoint(frontsector->centerspot)) { - plane.Render3DFloor(worldToClip, clipPlane, sub, floorSubsectorDepth, stencilValue, false, fakeFloor); + plane.Render3DFloor(worldToClip, clipPlane, sub, stencilValue, false, fakeFloor); } } @@ -82,16 +82,16 @@ void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, const PolyClipP double fakeHeight = fakeFloor->bottom.plane->ZatPoint(frontsector->centerspot); if (fakeHeight > viewpoint.Pos.Z && fakeHeight < frontsector->ceilingplane.ZatPoint(frontsector->centerspot)) { - plane.Render3DFloor(worldToClip, clipPlane, sub, ceilingSubsectorDepth, stencilValue, true, fakeFloor); + plane.Render3DFloor(worldToClip, clipPlane, sub, stencilValue, true, fakeFloor); } } } - plane.Render(worldToClip, clipPlane, cull, sub, ceilingSubsectorDepth, stencilValue, true, skyCeilingHeight, sectorPortals); - plane.Render(worldToClip, clipPlane, cull, sub, floorSubsectorDepth, stencilValue, false, skyFloorHeight, sectorPortals); + plane.Render(worldToClip, clipPlane, cull, sub, stencilValue, true, skyCeilingHeight, sectorPortals); + plane.Render(worldToClip, clipPlane, cull, sub, stencilValue, false, skyFloorHeight, sectorPortals); } -void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakeFloor) +void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, subsector_t *sub, uint32_t stencilValue, bool ceiling, F3DFloor *fakeFloor) { FTextureID picnum = ceiling ? *fakeFloor->bottom.texture : *fakeFloor->top.texture; FTexture *tex = TexMan(picnum); @@ -131,7 +131,6 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const PolyClip PolyDrawArgs args; args.SetLight(GetColorTable(sub->sector->Colormap), lightlevel, PolyRenderer::Instance()->Light.WallGlobVis(foggy), false); - args.SetSubsectorDepth(subsectorDepth); args.SetTransform(&worldToClip); args.SetStyle(TriBlendMode::TextureOpaque); args.SetFaceCullCCW(true); @@ -142,7 +141,7 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const PolyClip args.DrawArray(vertices, sub->numlines, PolyDrawMode::TriangleFan); } -void RenderPolyPlane::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals) +void RenderPolyPlane::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals) { const auto &viewpoint = PolyRenderer::Instance()->Viewpoint; bool foggy = false; @@ -302,7 +301,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const PolyClipPlane & PolyDrawArgs args; args.SetLight(GetColorTable(frontsector->Colormap, frontsector->SpecialColors[ceiling]), frontsector->lightlevel, PolyRenderer::Instance()->Light.WallGlobVis(foggy), false); - args.SetSubsectorDepth(isSky ? RenderPolyScene::SkySubsectorDepth : subsectorDepth); + //args.SetSubsectorDepth(isSky ? RenderPolyScene::SkySubsectorDepth : subsectorDepth); args.SetTransform(&worldToClip); args.SetFaceCullCCW(ccw); args.SetStencilTestValue(stencilValue); @@ -320,7 +319,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const PolyClipPlane & if (portal) { args.SetWriteStencil(true, polyportal->StencilValue); - polyportal->Shape.push_back({ vertices, (int)sub->numlines, ccw, subsectorDepth }); + polyportal->Shape.push_back({ vertices, (int)sub->numlines, ccw }); } else { @@ -328,7 +327,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const PolyClipPlane & } args.SetWriteColor(false); - args.SetWriteSubsectorDepth(false); + args.SetWriteDepth(false); args.DrawArray(vertices, sub->numlines, PolyDrawMode::TriangleFan); for (uint32_t i = 0; i < sub->numlines; i++) @@ -397,7 +396,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const PolyClipPlane & if (portal) { - polyportal->Shape.push_back({ wallvert, 4, ccw, subsectorDepth }); + polyportal->Shape.push_back({ wallvert, 4, ccw }); } } } diff --git a/src/polyrenderer/scene/poly_plane.h b/src/polyrenderer/scene/poly_plane.h index bb022aea9..3da2e4709 100644 --- a/src/polyrenderer/scene/poly_plane.h +++ b/src/polyrenderer/scene/poly_plane.h @@ -30,7 +30,7 @@ class PolyCull; class RenderPolyPlane { public: - static void RenderPlanes(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t ceilingSubsectorDepth, uint32_t floorSubsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals); + static void RenderPlanes(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals); private: struct UVTransform @@ -47,7 +47,7 @@ private: float xOffs, yOffs; }; - void Render3DFloor(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakefloor); - void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals); + void Render3DFloor(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, subsector_t *sub, uint32_t stencilValue, bool ceiling, F3DFloor *fakefloor); + void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals); TriVertex PlaneVertex(vertex_t *v1, double height, const UVTransform &transform); }; diff --git a/src/polyrenderer/scene/poly_portal.h b/src/polyrenderer/scene/poly_portal.h index 266313e40..b62922f56 100644 --- a/src/polyrenderer/scene/poly_portal.h +++ b/src/polyrenderer/scene/poly_portal.h @@ -26,11 +26,10 @@ struct PolyPortalVertexRange { - PolyPortalVertexRange(const TriVertex *vertices, int count, bool ccw, uint32_t subsectorDepth) : Vertices(vertices), Count(count), Ccw(ccw), SubsectorDepth(subsectorDepth) { } + PolyPortalVertexRange(const TriVertex *vertices, int count, bool ccw) : Vertices(vertices), Count(count), Ccw(ccw) { } const TriVertex *Vertices; int Count; bool Ccw; - uint32_t SubsectorDepth; }; class PolyPortalSegment diff --git a/src/polyrenderer/scene/poly_scene.cpp b/src/polyrenderer/scene/poly_scene.cpp index 2e5b04840..036d30ffe 100644 --- a/src/polyrenderer/scene/poly_scene.cpp +++ b/src/polyrenderer/scene/poly_scene.cpp @@ -179,7 +179,7 @@ void RenderPolyScene::RenderSubsector(subsector_t *sub, uint32_t ceilingSubsecto if (sub->sector->CenterFloor() != sub->sector->CenterCeiling()) { - RenderPolyPlane::RenderPlanes(WorldToClip, PortalPlane, Cull, sub, ceilingSubsectorDepth, floorSubsectorDepth, StencilValue, Cull.MaxCeilingHeight, Cull.MinFloorHeight, SectorPortals); + RenderPolyPlane::RenderPlanes(WorldToClip, PortalPlane, Cull, sub, StencilValue, Cull.MaxCeilingHeight, Cull.MinFloorHeight, SectorPortals); } if (mainBSP) @@ -384,7 +384,6 @@ void RenderPolyScene::RenderPortals(int portalDepth) for (const auto &verts : portal->Shape) { args.SetFaceCullCCW(verts.Ccw); - args.SetSubsectorDepth(verts.SubsectorDepth); args.DrawArray(verts.Vertices, verts.Count, PolyDrawMode::TriangleFan); } } @@ -396,7 +395,6 @@ void RenderPolyScene::RenderPortals(int portalDepth) for (const auto &verts : portal->Shape) { args.SetFaceCullCCW(verts.Ccw); - args.SetSubsectorDepth(verts.SubsectorDepth); args.DrawArray(verts.Vertices, verts.Count, PolyDrawMode::TriangleFan); } } @@ -420,7 +418,6 @@ void RenderPolyScene::RenderTranslucent(int portalDepth) for (const auto &verts : portal->Shape) { args.SetFaceCullCCW(verts.Ccw); - args.SetSubsectorDepth(verts.SubsectorDepth); args.SetWriteColor(false); args.DrawArray(verts.Vertices, verts.Count, PolyDrawMode::TriangleFan); } @@ -439,7 +436,6 @@ void RenderPolyScene::RenderTranslucent(int portalDepth) for (const auto &verts : portal->Shape) { args.SetFaceCullCCW(verts.Ccw); - args.SetSubsectorDepth(verts.SubsectorDepth); args.SetWriteColor(false); args.DrawArray(verts.Vertices, verts.Count, PolyDrawMode::TriangleFan); } @@ -467,7 +463,7 @@ void RenderPolyScene::RenderTranslucent(int portalDepth) if (obj->particle) { RenderPolyParticle spr; - spr.Render(WorldToClip, PortalPlane, obj->particle, obj->sub, obj->subsectorDepth, StencilValue + 1); + spr.Render(WorldToClip, PortalPlane, obj->particle, obj->sub, StencilValue + 1); } else if (!obj->thing) { @@ -476,12 +472,12 @@ void RenderPolyScene::RenderTranslucent(int portalDepth) else if ((obj->thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) { RenderPolyWallSprite wallspr; - wallspr.Render(WorldToClip, PortalPlane, obj->thing, obj->sub, obj->subsectorDepth, StencilValue + 1); + wallspr.Render(WorldToClip, PortalPlane, obj->thing, obj->sub, StencilValue + 1); } else { RenderPolySprite spr; - spr.Render(WorldToClip, PortalPlane, obj->thing, obj->sub, obj->subsectorDepth, StencilValue + 1, obj->SpriteLeft, obj->SpriteRight); + spr.Render(WorldToClip, PortalPlane, obj->thing, obj->sub, StencilValue + 1, obj->SpriteLeft, obj->SpriteRight); } } } diff --git a/src/polyrenderer/scene/poly_sky.cpp b/src/polyrenderer/scene/poly_sky.cpp index 4fa4e7889..531fb6be5 100644 --- a/src/polyrenderer/scene/poly_sky.cpp +++ b/src/polyrenderer/scene/poly_sky.cpp @@ -83,7 +83,6 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) PolyDrawArgs args; args.SetLight(&NormalLight, 255, PolyRenderer::Instance()->Light.WallGlobVis(false), true); - args.SetSubsectorDepth(RenderPolyScene::SkySubsectorDepth); args.SetTransform(&objectToClip); args.SetStencilTestValue(255); args.SetWriteStencil(true, 1); diff --git a/src/polyrenderer/scene/poly_sprite.cpp b/src/polyrenderer/scene/poly_sprite.cpp index 3ff88514d..e0782ebd5 100644 --- a/src/polyrenderer/scene/poly_sprite.cpp +++ b/src/polyrenderer/scene/poly_sprite.cpp @@ -67,7 +67,7 @@ bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right) return true; } -void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, float t1, float t2) +void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t stencilValue, float t1, float t2) { DVector2 line[2]; if (!GetLine(thing, line[0], line[1])) @@ -142,7 +142,6 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane PolyDrawArgs args; args.SetLight(GetColorTable(sub->sector->Colormap, sub->sector->SpecialColors[sector_t::sprites], true), lightlevel, PolyRenderer::Instance()->Light.SpriteGlobVis(foggy), fullbrightSprite); - args.SetSubsectorDepth(subsectorDepth); args.SetTransform(&worldToClip); args.SetFaceCullCCW(true); args.SetStencilTestValue(stencilValue); @@ -152,8 +151,8 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane args.SetStyle(LegacyRenderStyles[STYLE_Normal], 1.0f, thing->fillcolor, thing->Translation, tex, fullbrightSprite); else args.SetStyle(thing->RenderStyle, thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite); - args.SetSubsectorDepthTest(true); - args.SetWriteSubsectorDepth(false); + args.SetDepthTest(true); + args.SetWriteDepth(false); args.SetWriteStencil(false); args.DrawArray(vertices, 4, PolyDrawMode::TriangleFan); } diff --git a/src/polyrenderer/scene/poly_sprite.h b/src/polyrenderer/scene/poly_sprite.h index e190d9ee6..bb31fab0a 100644 --- a/src/polyrenderer/scene/poly_sprite.h +++ b/src/polyrenderer/scene/poly_sprite.h @@ -27,7 +27,7 @@ class RenderPolySprite { public: - void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, float t1, float t2); + void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t stencilValue, float t1, float t2); static bool GetLine(AActor *thing, DVector2 &left, DVector2 &right); static bool IsThingCulled(AActor *thing); diff --git a/src/polyrenderer/scene/poly_wall.cpp b/src/polyrenderer/scene/poly_wall.cpp index db95ec94a..4a4494781 100644 --- a/src/polyrenderer/scene/poly_wall.cpp +++ b/src/polyrenderer/scene/poly_wall.cpp @@ -270,7 +270,6 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const PolyClipPlane &c PolyDrawArgs args; args.SetLight(GetColorTable(Line->frontsector->Colormap, Line->frontsector->SpecialColors[sector_t::walltop]), GetLightLevel(), PolyRenderer::Instance()->Light.WallGlobVis(foggy), false); - args.SetSubsectorDepth(SubsectorDepth); args.SetTransform(&worldToClip); args.SetFaceCullCCW(true); args.SetStencilTestValue(StencilValue); @@ -283,9 +282,9 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const PolyClipPlane &c { args.SetWriteStencil(true, Polyportal->StencilValue); args.SetWriteColor(false); - args.SetWriteSubsectorDepth(false); + args.SetWriteDepth(false); args.DrawArray(vertices, 4, PolyDrawMode::TriangleFan); - Polyportal->Shape.push_back({ vertices, 4, true, SubsectorDepth }); + Polyportal->Shape.push_back({ vertices, 4, true }); } else if (!Masked) { @@ -298,13 +297,13 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const PolyClipPlane &c double srcalpha = MIN(Line->alpha, 1.0); double destalpha = addtrans ? 1.0 : 1.0 - srcalpha; args.SetStyle(TriBlendMode::TextureAdd, srcalpha, destalpha); - args.SetSubsectorDepthTest(true); - args.SetWriteSubsectorDepth(true); + args.SetDepthTest(true); + args.SetWriteDepth(true); args.SetWriteStencil(false); args.DrawArray(vertices, 4, PolyDrawMode::TriangleFan); } - RenderPolyDecal::RenderWallDecals(worldToClip, clipPlane, LineSeg, SubsectorDepth, StencilValue); + RenderPolyDecal::RenderWallDecals(worldToClip, clipPlane, LineSeg, StencilValue); } void RenderPolyWall::ClampHeight(TriVertex &v1, TriVertex &v2) diff --git a/src/polyrenderer/scene/poly_wallsprite.cpp b/src/polyrenderer/scene/poly_wallsprite.cpp index d00e6d2bd..36e02fbb4 100644 --- a/src/polyrenderer/scene/poly_wallsprite.cpp +++ b/src/polyrenderer/scene/poly_wallsprite.cpp @@ -29,7 +29,7 @@ #include "polyrenderer/poly_renderer.h" #include "polyrenderer/scene/poly_light.h" -void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) +void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t stencilValue) { if (RenderPolySprite::IsThingCulled(thing)) return; @@ -106,8 +106,8 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const PolyClipPl args.SetStencilTestValue(stencilValue); args.SetTexture(tex); args.SetClipPlane(clipPlane); - args.SetSubsectorDepthTest(true); - args.SetWriteSubsectorDepth(false); + args.SetDepthTest(true); + args.SetWriteDepth(false); args.SetWriteStencil(false); args.SetStyle(TriBlendMode::TextureMasked); args.DrawArray(vertices, 4, PolyDrawMode::TriangleFan); diff --git a/src/polyrenderer/scene/poly_wallsprite.h b/src/polyrenderer/scene/poly_wallsprite.h index c0c0005b8..5e1a992b1 100644 --- a/src/polyrenderer/scene/poly_wallsprite.h +++ b/src/polyrenderer/scene/poly_wallsprite.h @@ -27,5 +27,5 @@ class RenderPolyWallSprite { public: - void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue); + void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t stencilValue); }; From 6d6c25bb26952b9c428e0496cf6e524ecb1d7ef9 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 13 Aug 2017 01:10:33 +0200 Subject: [PATCH 15/21] - Add sprite adjustment to softpoly --- src/polyrenderer/scene/poly_sprite.cpp | 131 +++++++++++++++++++++++-- src/polyrenderer/scene/poly_sprite.h | 4 +- 2 files changed, 126 insertions(+), 9 deletions(-) diff --git a/src/polyrenderer/scene/poly_sprite.cpp b/src/polyrenderer/scene/poly_sprite.cpp index e0782ebd5..185f009a9 100644 --- a/src/polyrenderer/scene/poly_sprite.cpp +++ b/src/polyrenderer/scene/poly_sprite.cpp @@ -29,10 +29,14 @@ #include "polyrenderer/poly_renderer.h" #include "polyrenderer/scene/poly_light.h" #include "r_data/r_vanillatrans.h" +#include "actorinlines.h" EXTERN_CVAR(Float, transsouls) EXTERN_CVAR(Int, r_drawfuzz) EXTERN_CVAR (Bool, r_debug_disable_vis_filter) +EXTERN_CVAR(Int, gl_spriteclip) +EXTERN_CVAR(Float, gl_sclipthreshold) +EXTERN_CVAR(Float, gl_sclipfactor) extern uint32_t r_renderercaps; bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right) @@ -74,8 +78,17 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane return; const auto &viewpoint = PolyRenderer::Instance()->Viewpoint; - DVector3 pos = thing->InterpolatedPosition(viewpoint.TicFrac); - pos.Z += thing->GetBobOffset(viewpoint.TicFrac); + DVector3 thingpos = thing->InterpolatedPosition(viewpoint.TicFrac); + + DVector3 pos = thingpos; + + uint32_t spritetype = (thing->renderflags & RF_SPRITETYPEMASK); + + if (spritetype == RF_FACESPRITE) + pos.Z -= thing->Floorclip; + + if (thing->flags2 & MF2_FLOATBOB) + pos.Z += thing->GetBobOffset(viewpoint.TicFrac); bool flipTextureX = false; FTexture *tex = GetSpriteTexture(thing, flipTextureX); @@ -85,20 +98,19 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane DVector2 spriteScale = thing->Scale; double thingxscalemul = spriteScale.X / tex->Scale.X; double thingyscalemul = spriteScale.Y / tex->Scale.Y; + double spriteHalfWidth = thingxscalemul * tex->GetWidth() * 0.5; + double spriteHeight = thingyscalemul * tex->GetHeight(); if (flipTextureX) pos.X -= (tex->GetWidth() - tex->LeftOffset) * thingxscalemul; else pos.X -= tex->LeftOffset * thingxscalemul; - //pos.Z -= tex->TopOffset * thingyscalemul; - pos.Z -= (tex->GetHeight() - tex->TopOffset) * thingyscalemul + thing->Floorclip; - - double spriteHalfWidth = thingxscalemul * tex->GetWidth() * 0.5; - double spriteHeight = thingyscalemul * tex->GetHeight(); - pos.X += spriteHalfWidth; + pos.Z -= (tex->GetHeight() - tex->TopOffset) * thingyscalemul; + pos.Z = PerformSpriteClipAdjustment(thing, thingpos, spriteHeight, pos.Z); + //double depth = 1.0; //visstyle_t visstyle = GetSpriteVisStyle(thing, depth); // Rumor has it that AlterWeaponSprite needs to be called with visstyle passed in somewhere around here.. @@ -157,6 +169,109 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane args.DrawArray(vertices, 4, PolyDrawMode::TriangleFan); } +double RenderPolySprite::GetSpriteFloorZ(AActor *thing, const DVector2 &thingpos) +{ + extsector_t::xfloor &x = thing->Sector->e->XFloor; + for (unsigned int i = 0; i < x.ffloors.Size(); i++) + { + F3DFloor *ff = x.ffloors[i]; + double floorh = ff->top.plane->ZatPoint(thingpos); + if (floorh == thing->floorz) + return floorh; + } + + if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) + { + if (thing->flags2&MF2_ONMOBJ && thing->floorz == thing->Sector->heightsec->floorplane.ZatPoint(thingpos)) + { + return thing->floorz; + } + } + + return thing->Sector->floorplane.ZatPoint(thing) - thing->Floorclip; +} + +double RenderPolySprite::GetSpriteCeilingZ(AActor *thing, const DVector2 &thingpos) +{ + extsector_t::xfloor &x = thing->Sector->e->XFloor; + for (unsigned int i = 0; i < x.ffloors.Size(); i++) + { + F3DFloor *ff = x.ffloors[i]; + double ceilingh = ff->bottom.plane->ZatPoint(thingpos); + if (ceilingh == thing->ceilingz) + return ceilingh; + } + + if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) + { + if (thing->flags2&MF2_ONMOBJ && thing->ceilingz == thing->Sector->heightsec->ceilingplane.ZatPoint(thingpos)) + { + return thing->ceilingz; + } + } + + return thing->Sector->ceilingplane.ZatPoint(thingpos); +} + +double RenderPolySprite::PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, double spriteheight, double z2) +{ + int spriteclip = 2; // gl_spriteclip, but use 'always' mode for now + + double z1 = z2 + spriteheight; + + // Tests show that this doesn't look good for many decorations and corpses + uint32_t spritetype = (thing->renderflags & RF_SPRITETYPEMASK); + if (!(spriteheight > 0 && spriteclip > 0 && spritetype == RF_FACESPRITE)) + return z2; + + bool clipthing = (thing->player || thing->flags3&MF3_ISMONSTER || thing->IsKindOf(RUNTIME_CLASS(AInventory))) && (thing->flags&MF_ICECORPSE || !(thing->flags&MF_CORPSE)); + bool smarterclip = !clipthing && spriteclip == 3; + if (clipthing || spriteclip > 1) + { + double diffb = MIN(z2 - GetSpriteFloorZ(thing, thingpos), 0.0); + + // Adjust sprites clipping into ceiling and adjust clipping adjustment for tall graphics + if (smarterclip) + { + // Reduce slightly clipping adjustment of corpses + if (thing->flags & MF_CORPSE || spriteheight > fabs(diffb)) + { + double ratio = clamp((fabs(diffb) * (double)gl_sclipfactor / (spriteheight + 1)), 0.5, 1.0); + diffb *= ratio; + } + if (!diffb) + { + double difft = MAX(z1 - GetSpriteCeilingZ(thing, thingpos), 0.0); + if (difft >= (double)gl_sclipthreshold) + { + // dumb copy of the above. + if (!(thing->flags3&MF3_ISMONSTER) || (thing->flags&MF_NOGRAVITY) || (thing->flags&MF_CORPSE) || difft > (double)gl_sclipthreshold) + { + difft = 0; + } + } + if (spriteheight > fabs(difft)) + { + double ratio = clamp((fabs(difft) * (double)gl_sclipfactor / (spriteheight + 1)), 0.5, 1.0); + difft *= ratio; + } + z2 -= difft; + } + } + if (diffb <= (0 - (double)gl_sclipthreshold)) // such a large displacement can't be correct! + { + // for living monsters standing on the floor allow a little more. + if (!(thing->flags3&MF3_ISMONSTER) || (thing->flags&MF_NOGRAVITY) || (thing->flags&MF_CORPSE) || diffb < (-1.8*(double)gl_sclipthreshold)) + { + diffb = 0; + } + } + + z2 -= diffb; + } + return z2; +} + bool RenderPolySprite::IsThingCulled(AActor *thing) { FIntCVar *cvar = thing->GetInfo()->distancecheck; diff --git a/src/polyrenderer/scene/poly_sprite.h b/src/polyrenderer/scene/poly_sprite.h index bb31fab0a..ecd61c235 100644 --- a/src/polyrenderer/scene/poly_sprite.h +++ b/src/polyrenderer/scene/poly_sprite.h @@ -34,5 +34,7 @@ public: static FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX); private: - //visstyle_t GetSpriteVisStyle(AActor *thing, double z); + static double PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, double spriteheight, double z); + static double GetSpriteFloorZ(AActor *thing, const DVector2 &thingpos); + static double GetSpriteCeilingZ(AActor *thing, const DVector2 &thingpos); }; From 4afface97c76eb0476c002f35a07a1b806fd138c Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 13 Aug 2017 12:22:48 +0300 Subject: [PATCH 16/21] Fixed camera rotation from FraggleScript https://forum.zdoom.org/viewtopic.php?t=57559 --- src/fragglescript/t_func.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 90c8fbe5a..127a5ba9d 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -2910,11 +2910,14 @@ void FParser::SF_MoveCamera(void) DAngle targetangle = floatvalue(t_argv[4]); DAngle anglespeed = floatvalue(t_argv[5]); - DAngle diffangle = deltaangle(cam->Angles.Yaw, targetangle); if (movespeed > 0 && anglespeed == 0.) { - if (!finished) targetangle = diffangle * movespeed / movelen; + if (!finished) + { + const DAngle diffangle = targetangle - cam->Angles.Yaw; + targetangle = cam->Angles.Yaw + diffangle * movespeed / movelen; + } } else { @@ -2924,6 +2927,7 @@ void FParser::SF_MoveCamera(void) cam->radius = 1 / 8192.; cam->Height = 1 / 8192.; cam->SetOrigin(movepos, true); + cam->SetAngle(targetangle, false); t_return.value.i = 1; } else From a6d4bfc748706cfbcfa6cc6468c4bd2579f13a8c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 13 Aug 2017 13:49:02 +0200 Subject: [PATCH 17/21] - Added linear and nearest shadowmap filters (enabled with defines) --- wadsrc/static/shaders/glsl/main.fp | 55 ++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index cab4f5d9b..83cabbd0d 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -138,27 +138,57 @@ float R_DoomLightingEquation(float light) #ifdef SUPPORTS_SHADOWMAPS -float sampleShadowmap(vec2 dir, float v) +float shadowDirToU(vec2 dir) { - float u; if (abs(dir.x) > abs(dir.y)) { if (dir.x >= 0.0) - u = dir.y / dir.x * 0.125 + (0.25 + 0.125); + return dir.y / dir.x * 0.125 + (0.25 + 0.125); else - u = dir.y / dir.x * 0.125 + (0.75 + 0.125); + return dir.y / dir.x * 0.125 + (0.75 + 0.125); } else { if (dir.y >= 0.0) - u = dir.x / dir.y * 0.125 + 0.125; + return dir.x / dir.y * 0.125 + 0.125; else - u = dir.x / dir.y * 0.125 + (0.50 + 0.125); + return dir.x / dir.y * 0.125 + (0.50 + 0.125); } +} + +float sampleShadowmap(vec2 dir, float v) +{ + float u = shadowDirToU(dir); float dist2 = dot(dir, dir); return texture(ShadowMap, vec2(u, v)).x > dist2 ? 1.0 : 0.0; } +float sampleShadowmapLinear(vec2 dir, float v) +{ + float u = shadowDirToU(dir); + float dist2 = dot(dir, dir); + + vec2 isize = textureSize(ShadowMap, 0); + vec2 size = vec2(isize); + + vec2 fetchPos = vec2(u, v) * size - vec2(0.5, 0.0); + if (fetchPos.x < 0.0) + fetchPos.x += size.x; + + ivec2 ifetchPos = ivec2(fetchPos); + int y = ifetchPos.y; + + float t = fract(fetchPos.x); + int x0 = ifetchPos.x; + int x1 = ifetchPos.x + 1; + if (x1 == isize.x) + x1 = 0; + + float depth0 = texelFetch(ShadowMap, ivec2(x0, y), 0).x; + float depth1 = texelFetch(ShadowMap, ivec2(x1, y), 0).x; + return mix(step(dist2, depth0), step(dist2, depth1), t); +} + //=========================================================================== // // Check if light is in shadow using Percentage Closer Filtering (PCF) @@ -168,6 +198,9 @@ float sampleShadowmap(vec2 dir, float v) #define PCF_FILTER_STEP_COUNT 3 #define PCF_COUNT (PCF_FILTER_STEP_COUNT * 2 + 1) +// #define USE_LINEAR_SHADOW_FILTER +#define USE_PCF_SHADOW_FILTER 1 + float shadowmapAttenuation(vec4 lightpos, float shadowIndex) { if (shadowIndex >= 1024.0) @@ -182,7 +215,11 @@ float shadowmapAttenuation(vec4 lightpos, float shadowIndex) vec2 dir = ray / length; - ray -= dir * 2.0; // margin +#if defined(USE_LINEAR_SHADOW_FILTER) + ray -= dir * 6.0; // Shadow acne margin + return sampleShadowmapLinear(ray, v); +#elif defined(USE_PCF_SHADOW_FILTER) + ray -= dir * 2.0; // Shadow acne margin dir = dir * min(length / 50.0, 1.0); // avoid sampling behind light vec2 normal = vec2(-dir.y, dir.x); @@ -194,6 +231,10 @@ float shadowmapAttenuation(vec4 lightpos, float shadowIndex) sum += sampleShadowmap(ray + normal * x - bias * abs(x), v); } return sum / PCF_COUNT; +#else // nearest shadow filter + ray -= dir * 6.0; // Shadow acne margin + return sampleShadowmap(ray, v); +#endif } #endif From b077518c89804cf317429132cdadece783a5c2d7 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 13 Aug 2017 16:15:31 +0300 Subject: [PATCH 18/21] Fixed crash when morph item is used from ACS https://forum.zdoom.org/viewtopic.php?t=57571 --- src/p_acs.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 37aef6fad..5b146f2d1 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -1843,7 +1843,9 @@ static bool DoUseInv (AActor *actor, PClassActor *info) AInventory *item = actor->FindInventory (info); if (item != NULL) { - if (actor->player == NULL) + player_t* const player = actor->player; + + if (nullptr == player) { return actor->UseInventory(item); } @@ -1853,10 +1855,10 @@ static bool DoUseInv (AActor *actor, PClassActor *info) bool res; // Bypass CF_TOTALLYFROZEN - cheats = actor->player->cheats; - actor->player->cheats &= ~CF_TOTALLYFROZEN; + cheats = player->cheats; + player->cheats &= ~CF_TOTALLYFROZEN; res = actor->UseInventory(item); - actor->player->cheats |= (cheats & CF_TOTALLYFROZEN); + player->cheats |= (cheats & CF_TOTALLYFROZEN); return res; } } From eb5208848701b7cc1b59febcee2551462450a4f0 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 13 Aug 2017 16:42:08 +0300 Subject: [PATCH 19/21] Fixed compilation warnings reported by Clang src/gl/scene/gl_sprite.cpp:685:34: warning: '&&' within '||' [-Wlogical-op-parentheses] src/polyrenderer/scene/poly_sprite.cpp:297:34: warning: '&&' within '||' [-Wlogical-op-parentheses] src/swrenderer/scene/r_opaque_pass.cpp:975:35: warning: '&&' within '||' [-Wlogical-op-parentheses] src/sound/mididevices/music_timiditypp_mididevice.cpp:548:30: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare] --- src/gl/scene/gl_sprite.cpp | 4 ++-- src/polyrenderer/scene/poly_sprite.cpp | 2 +- src/sound/mididevices/music_timiditypp_mididevice.cpp | 2 +- src/swrenderer/scene/r_opaque_pass.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index acd1d6d5d..f3b698360 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -682,7 +682,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) // check renderrequired vs ~r_rendercaps, if anything matches we don't support that feature, // check renderhidden vs r_rendercaps, if anything matches we do support that feature and should hide it. - if (!r_debug_disable_vis_filter && (!!(thing->RenderRequired & ~r_renderercaps)) || + if ((!r_debug_disable_vis_filter && !!(thing->RenderRequired & ~r_renderercaps)) || (!!(thing->RenderHidden & r_renderercaps))) return; @@ -1298,4 +1298,4 @@ void GLSceneDrawer::RenderActorsInPortal(FGLLinePortal *glport) } } } -} \ No newline at end of file +} diff --git a/src/polyrenderer/scene/poly_sprite.cpp b/src/polyrenderer/scene/poly_sprite.cpp index 185f009a9..02667b19b 100644 --- a/src/polyrenderer/scene/poly_sprite.cpp +++ b/src/polyrenderer/scene/poly_sprite.cpp @@ -294,7 +294,7 @@ bool RenderPolySprite::IsThingCulled(AActor *thing) // check renderrequired vs ~r_rendercaps, if anything matches we don't support that feature, // check renderhidden vs r_rendercaps, if anything matches we do support that feature and should hide it. - if (!r_debug_disable_vis_filter && (!!(thing->RenderRequired & ~r_renderercaps)) || + if ((!r_debug_disable_vis_filter && !!(thing->RenderRequired & ~r_renderercaps)) || (!!(thing->RenderHidden & r_renderercaps))) return true; diff --git a/src/sound/mididevices/music_timiditypp_mididevice.cpp b/src/sound/mididevices/music_timiditypp_mididevice.cpp index 254b840a0..934ceacbb 100644 --- a/src/sound/mididevices/music_timiditypp_mididevice.cpp +++ b/src/sound/mididevices/music_timiditypp_mididevice.cpp @@ -545,7 +545,7 @@ bool TimidityPPMIDIDevice::LaunchTimidity () globfree(&glb); int strCount = 1; - for (spaceIdx = 0; spaceIdx < CommandLine.Len(); spaceIdx++) + for (spaceIdx = 0; spaceIdx < static_cast(CommandLine.Len()); spaceIdx++) { if (CommandLine[spaceIdx] == ' ') { diff --git a/src/swrenderer/scene/r_opaque_pass.cpp b/src/swrenderer/scene/r_opaque_pass.cpp index 5935b1ff4..03467ce72 100644 --- a/src/swrenderer/scene/r_opaque_pass.cpp +++ b/src/swrenderer/scene/r_opaque_pass.cpp @@ -972,7 +972,7 @@ namespace swrenderer // check renderrequired vs ~r_rendercaps, if anything matches we don't support that feature, // check renderhidden vs r_rendercaps, if anything matches we do support that feature and should hide it. - if (!r_debug_disable_vis_filter && (!!(thing->RenderRequired & ~r_renderercaps)) || + if ((!r_debug_disable_vis_filter && !!(thing->RenderRequired & ~r_renderercaps)) || (!!(thing->RenderHidden & r_renderercaps))) return false; From d645e55545cce517a5e97feca01f43f84dec4a26 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 13 Aug 2017 17:06:53 +0300 Subject: [PATCH 20/21] Unified suppression of format warnings for GCC and Clang This disables the following compilation warning reported by Clang: src/p_3dfloors.cpp:1002:24: warning: format specifies type 'char *' but the argument has type 'int' [-Wformat] --- src/zstring.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/zstring.h b/src/zstring.h index 4de4a2ba0..cdb4dc521 100644 --- a/src/zstring.h +++ b/src/zstring.h @@ -46,16 +46,10 @@ #define PRINTFISH(x) #endif -#ifdef __clang__ +#ifdef __GNUC__ #define IGNORE_FORMAT_PRE \ _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wformat-invalid-specifier\"") \ - _Pragma("GCC diagnostic ignored \"-Wformat-extra-args\"") -#define IGNORE_FORMAT_POST _Pragma("GCC diagnostic pop") -#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 6))) -#define IGNORE_FORMAT_PRE \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wformat=\"") \ + _Pragma("GCC diagnostic ignored \"-Wformat\"") \ _Pragma("GCC diagnostic ignored \"-Wformat-extra-args\"") #define IGNORE_FORMAT_POST _Pragma("GCC diagnostic pop") #else From c7d28b0a244fc7f0f4232413c1a5e63e8413ba29 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 13 Aug 2017 17:48:49 +0300 Subject: [PATCH 21/21] Fixed incorrect damage flags' checks for A_Kill...() functions Only GCC 7 reported this as a warning but only for one occurrence: src/p_actionfunctions.cpp:5909:22: warning: enum constant in boolean context [-Wint-in-bool-context] --- src/p_actionfunctions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 51c37f23d..a62ce0210 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -5904,9 +5904,9 @@ static void DoKill(AActor *killtarget, AActor *inflictor, AActor *source, FName { int dmgFlags = DMG_NO_ARMOR | DMG_NO_FACTOR; - if (KILS_FOILINVUL) + if (flags & KILS_FOILINVUL) dmgFlags |= DMG_FOILINVUL; - if (KILS_FOILBUDDHA) + if (flags & KILS_FOILBUDDHA) dmgFlags |= DMG_FOILBUDDHA; if ((killtarget->flags & MF_MISSILE) && (flags & KILS_KILLMISSILES))