From 10e4c3e121bb65c0ff898f21ab365e442f6a67b1 Mon Sep 17 00:00:00 2001 From: NY00123 Date: Sun, 19 Apr 2020 21:15:57 +0300 Subject: [PATCH] sw/src/draw.cpp: Import from Duke3D the Polymost shadow drawing hacks --- source/sw/src/draw.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index b362d74c5..9d8fff331 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -368,7 +368,7 @@ DoVoxelShadow(SPRITEp tspr) #endif void -DoShadows(tspriteptr_t tsp, int viewz) +DoShadows(tspriteptr_t tsp, int viewz, SWBOOL mirror) { tspriteptr_t New = &tsprite[spritesortcnt]; USERp tu = User[tsp->owner]; @@ -456,6 +456,28 @@ DoShadows(tspriteptr_t tsp, int viewz) New->xrepeat = xrepeat; New->yrepeat = yrepeat; +#ifdef USE_OPENGL + if (videoGetRenderMode() >= REND_POLYMOST) + { + if (tilehasmodelorvoxel(tsp->picnum,tsp->pal)) + { + New->yrepeat = 0; + // cstat: trans reverse + // clipdist: tell mdsprite.cpp to use Z-buffer hacks to hide overdraw issues + New->clipdist |= TSPR_FLAGS_MDHACK; + New->cstat |= 512; + } + else + { + int const camang = mirror ? NORM_ANGLE(2048 - Player[screenpeek].siang) : Player[screenpeek].siang; + vec2_t const ofs = { sintable[NORM_ANGLE(camang+512)]>>11, sintable[NORM_ANGLE(camang)]>>11}; + + New->x += ofs.x; + New->y += ofs.y; + } + } +#endif + // Check for voxel items and use a round generic pic if so //DoVoxelShadow(New); @@ -758,7 +780,7 @@ analyzesprites(int viewx, int viewy, int viewz, SWBOOL mirror) if (r_shadows && TEST(tu->Flags, SPR_SHADOW)) { - DoShadows(tsp, viewz); + DoShadows(tsp, viewz, mirror); } //#define UK_VERSION 1