mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- moved the shadow creation code out of animatesprites into a common subfunction.
Also removing several checks for non-enemy actors for which shadows are generally not being created.
This commit is contained in:
parent
6fb263d61b
commit
0d7288c543
6 changed files with 92 additions and 98 deletions
|
@ -1,4 +1,5 @@
|
|||
#include "src/actors.cpp"
|
||||
#include "src/animatesprites.cpp"
|
||||
#include "src/ccmds.cpp"
|
||||
#include "src/cheats.cpp"
|
||||
#include "src/d_menu.cpp"
|
||||
|
|
81
source/games/duke/src/animatesprites.cpp
Normal file
81
source/games/duke/src/animatesprites.cpp
Normal file
|
@ -0,0 +1,81 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
||||
Copyright (C) 2020 - Christoph Oelckers
|
||||
|
||||
This file is part of Raze
|
||||
|
||||
Duke Nukem 3D is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Original Source: 1996 - Todd Replogle
|
||||
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
||||
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#include "ns.h"
|
||||
#include "global.h"
|
||||
#include "dukeactor.h"
|
||||
#include "gamefuncs.h"
|
||||
#include "models/modeldata.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
void drawshadows(tspriteArray& tsprites, tspritetype* t, DDukeActor* h)
|
||||
{
|
||||
if (r_shadows && !(h->spr.cstat2 & CSTAT2_SPRITE_NOSHADOW))
|
||||
{
|
||||
auto sectp = t->sectp;
|
||||
double floorz;
|
||||
|
||||
if ((sectp->lotag & 0xff) > 2 || h->spr.statnum == STAT_PROJECTILE || h->spr.statnum == STAT_MISC || actorflag(h, SFLAG2_FLOATING))
|
||||
floorz = sectp->floorz;
|
||||
else
|
||||
floorz = h->floorz;
|
||||
|
||||
|
||||
if (h->spr.pos.Z - floorz < 8 && ps[screenpeek].GetActor()->getOffsetZ() < floorz)
|
||||
{
|
||||
auto shadowspr = tsprites.newTSprite();
|
||||
*shadowspr = *t;
|
||||
|
||||
shadowspr->statnum = STAT_TEMP;
|
||||
|
||||
shadowspr->scale.Y = (max(t->scale.Y * 0.125, 0.0625));
|
||||
shadowspr->shade = 127;
|
||||
shadowspr->cstat |= CSTAT_SPRITE_TRANSLUCENT;
|
||||
|
||||
shadowspr->pos.Z = floorz;
|
||||
shadowspr->pal = 4;
|
||||
|
||||
if (hw_models && modelManager.CheckModel(t->picnum, t->pal))
|
||||
{
|
||||
shadowspr->scale.Y = (0);
|
||||
// 512:trans reverse
|
||||
//1024:tell MD2SPRITE.C to use Z-buffer hacks to hide overdraw issues
|
||||
shadowspr->clipdist |= TSPR_FLAGS_MDHACK;
|
||||
shadowspr->cstat |= CSTAT_SPRITE_TRANS_FLIP;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Alter the shadow's position so that it appears behind the sprite itself.
|
||||
auto look = (shadowspr->pos.XY() - ps[screenpeek].GetActor()->spr.pos.XY()).Angle();
|
||||
shadowspr->pos.XY() += look.ToVector() * 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
END_DUKE_NS
|
|
@ -92,7 +92,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
break;
|
||||
}
|
||||
|
||||
if (t->statnum == 99) continue;
|
||||
if (t->statnum == STAT_TEMP) continue;
|
||||
auto pp = &ps[h->PlayerIndex()];
|
||||
if (h->spr.statnum != STAT_ACTOR && h->isPlayer() && pp->newOwner == nullptr && h->GetOwner())
|
||||
{
|
||||
|
@ -185,7 +185,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
auto newtspr = tsprites.newTSprite();
|
||||
*newtspr = *t;
|
||||
|
||||
newtspr->statnum = 99;
|
||||
newtspr->statnum = STAT_TEMP;
|
||||
|
||||
newtspr->scale.Y = (max(t->scale.Y * 0.125, 0.0625));
|
||||
|
||||
|
@ -375,57 +375,11 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
|
||||
if (h->spr.statnum == STAT_DUMMYPLAYER || badguy(h) || (h->isPlayer() && h->GetOwner()))
|
||||
{
|
||||
if (t->statnum != 99 && h->spr.picnum != EXPLOSION2 && h->spr.picnum != HANGLIGHT && h->spr.picnum != DOMELITE)
|
||||
drawshadows(tsprites, t, h);
|
||||
if (ps[screenpeek].heat_amount > 0 && ps[screenpeek].heat_on)
|
||||
{
|
||||
if (h->spr.picnum != HOTMEAT)
|
||||
{
|
||||
if (r_shadows && !(h->spr.cstat2 & CSTAT2_SPRITE_NOSHADOW))
|
||||
{
|
||||
double floorz;
|
||||
|
||||
if ((sectp->lotag & 0xff) > 2 || h->spr.statnum == 4 || h->spr.statnum == 5 || h->spr.picnum == DRONE || h->spr.picnum == COMMANDER)
|
||||
floorz = sectp->floorz;
|
||||
else
|
||||
floorz = h->floorz;
|
||||
|
||||
|
||||
if (h->spr.pos.Z - floorz < 8 && ps[screenpeek].GetActor()->getOffsetZ() < floorz)
|
||||
{
|
||||
auto shadowspr = tsprites.newTSprite();
|
||||
*shadowspr = *t;
|
||||
|
||||
shadowspr->statnum = 99;
|
||||
|
||||
shadowspr->scale.Y = (max(t->scale.Y * 0.125, 0.0625));
|
||||
shadowspr->shade = 127;
|
||||
shadowspr->cstat |= CSTAT_SPRITE_TRANSLUCENT;
|
||||
|
||||
shadowspr->pos.Z = floorz;
|
||||
shadowspr->pal = 4;
|
||||
|
||||
if (hw_models && modelManager.CheckModel(t->picnum, t->pal))
|
||||
{
|
||||
shadowspr->scale.Y = (0);
|
||||
// 512:trans reverse
|
||||
//1024:tell MD2SPRITE.C to use Z-buffer hacks to hide overdraw issues
|
||||
shadowspr->clipdist |= TSPR_FLAGS_MDHACK;
|
||||
shadowspr->cstat |= CSTAT_SPRITE_TRANS_FLIP;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Alter the shadow's position so that it appears behind the sprite itself.
|
||||
auto look = (shadowspr->pos.XY() - ps[screenpeek].GetActor()->spr.pos.XY()).Angle();
|
||||
shadowspr->pos.XY() += look.ToVector() * 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ps[screenpeek].heat_amount > 0 && ps[screenpeek].heat_on)
|
||||
{
|
||||
t->pal = 6;
|
||||
t->shade = 0;
|
||||
}
|
||||
}
|
||||
t->pal = 6;
|
||||
t->shade = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -446,52 +446,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
|
||||
if (h->spr.statnum == STAT_DUMMYPLAYER || badguy(h) || (h->isPlayer() && h->GetOwner()))
|
||||
{
|
||||
if ((h->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == 0 && t->statnum != 99)
|
||||
{
|
||||
if (h->spr.picnum != EXPLOSION2 && h->spr.picnum != DOMELITE && h->spr.picnum != TORNADO && h->spr.picnum != EXPLOSION3 && (h->spr.picnum != SBMOVE || isRRRA()))
|
||||
{
|
||||
if (r_shadows && !(h->spr.cstat2 & CSTAT2_SPRITE_NOSHADOW))
|
||||
{
|
||||
double floorz;
|
||||
|
||||
if (isRRRA() && sectp->lotag == ST_160_FLOOR_TELEPORT) continue;
|
||||
if ((sectp->lotag & 0xff) > 2 || h->spr.statnum == 4 || h->spr.statnum == 5 || h->spr.picnum == DRONE)
|
||||
floorz = sectp->floorz;
|
||||
else
|
||||
floorz = h->floorz;
|
||||
|
||||
if (h->spr.pos.Z - floorz < 8 && ps[screenpeek].GetActor()->getOffsetZ() < floorz)
|
||||
{
|
||||
auto shadowspr = tsprites.newTSprite();
|
||||
*shadowspr = *t;
|
||||
|
||||
shadowspr->statnum = 99;
|
||||
|
||||
shadowspr->scale.Y = (max(t->scale.Y * 0.125, 0.0625));
|
||||
shadowspr->shade = 127;
|
||||
shadowspr->cstat |= CSTAT_SPRITE_TRANSLUCENT;
|
||||
|
||||
shadowspr->pos.Z = floorz;
|
||||
shadowspr->pal = 4;
|
||||
|
||||
if (hw_models && modelManager.CheckModel(t->picnum, t->pal))
|
||||
{
|
||||
shadowspr->scale = DVector2(0, 0);
|
||||
// 512:trans reverse
|
||||
//1024:tell MD2SPRITE.C to use Z-buffer hacks to hide overdraw issues
|
||||
shadowspr->clipdist |= TSPR_FLAGS_MDHACK;
|
||||
shadowspr->cstat |= CSTAT_SPRITE_TRANS_FLIP;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Alter the shadow's position so that it appears behind the sprite itself.
|
||||
auto look = (shadowspr->pos.XY() - ps[screenpeek].GetActor()->spr.pos.XY()).Angle();
|
||||
shadowspr->pos.XY() += look.ToVector() * 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
drawshadows(tsprites, t, h);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -275,6 +275,7 @@ enum
|
|||
STAT_LIGHT = 14,
|
||||
STAT_RAROR = 15,
|
||||
|
||||
STAT_TEMP = 99,
|
||||
STAT_DESTRUCT = 100,
|
||||
STAT_BOWLING = 105,
|
||||
STAT_CHICKENPLANT = 106,
|
||||
|
|
|
@ -217,6 +217,8 @@ bool movementBlocked(player_struct *p);
|
|||
void loadcons();
|
||||
void DrawStatusBar();
|
||||
|
||||
void drawshadows(tspriteArray& tsprites, tspritetype* t, DDukeActor* h);
|
||||
|
||||
inline int32_t krand(void)
|
||||
{
|
||||
randomseed = (randomseed * 27584621) + 1;
|
||||
|
|
Loading…
Reference in a new issue