Add sprite shadows for the software renderer

This commit is contained in:
nashmuhandes 2021-04-21 22:15:05 +08:00 committed by Rachael Alexanderson
commit 5446a1a355
7 changed files with 77 additions and 3 deletions

View file

@ -105,6 +105,21 @@ CUSTOM_CVAR(Float, r_quakeintensity, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
else if (self > 1.f) self = 1.f;
}
CUSTOM_CVARD(Int, r_actorspriteshadow, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "render actor sprite shadows. 0 = off, 1 = default, 2 = always on")
{
if (self < 0)
self = 0;
else if (self > 2)
self = 2;
}
CUSTOM_CVARD(Float, r_actorspriteshadowdist, 1500.0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "how far sprite shadows should be rendered")
{
if (self < 0.f)
self = 0.f;
else if (self > 8192.f)
self = 8192.f;
}
int viewwindowx;
int viewwindowy;
int viewwidth;
@ -1051,3 +1066,29 @@ CUSTOM_CVAR(Float, maxviewpitch, 90.f, CVAR_ARCHIVE | CVAR_SERVERINFO)
players[consoleplayer].SendPitchLimits();
}
}
//==========================================================================
//
// R_ShouldDrawSpriteShadow
//
//==========================================================================
bool R_ShouldDrawSpriteShadow(AActor *thing)
{
switch (r_actorspriteshadow)
{
case 1:
return (thing->renderflags & RF_CASTSPRITESHADOW);
case 2:
if (thing->renderflags & RF_CASTSPRITESHADOW)
{
return true;
}
return (thing->renderflags & RF_CASTSPRITESHADOW) || (!(thing->renderflags & RF_NOSPRITESHADOW) && ((thing->flags3 & MF3_ISMONSTER) || thing->player != nullptr));
default:
case 0:
return false;
}
}