mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- Changed P_CheckPlayerSprites() so that it does not alter any actor data. It is now called by
R_ProjectSprite() to modify the appropriate data right before it is needed for rendering. SVN r4004 (trunk)
This commit is contained in:
parent
db01832519
commit
67eda6b1ad
5 changed files with 58 additions and 74 deletions
|
@ -775,7 +775,6 @@ void D_Display ()
|
|||
}
|
||||
screen->SetBlendingRect(viewwindowx, viewwindowy,
|
||||
viewwindowx + viewwidth, viewwindowy + viewheight);
|
||||
P_CheckPlayerSprites();
|
||||
P_PredictPlayer(&players[consoleplayer]);
|
||||
Renderer->RenderView(&players[consoleplayer]);
|
||||
P_UnPredictPlayer();
|
||||
|
|
|
@ -427,7 +427,7 @@ extern player_t players[MAXPLAYERS];
|
|||
|
||||
FArchive &operator<< (FArchive &arc, player_t *&p);
|
||||
|
||||
void P_CheckPlayerSprites();
|
||||
void P_CheckPlayerSprite(AActor *mo, unsigned &spritenum, fixed_t &scalex, fixed_t &scaley);
|
||||
|
||||
inline void AActor::SetFriendPlayer(player_t *player)
|
||||
{
|
||||
|
|
|
@ -2049,7 +2049,6 @@ static void PutSavePic (FILE *file, int width, int height)
|
|||
}
|
||||
else
|
||||
{
|
||||
P_CheckPlayerSprites();
|
||||
Renderer->WriteSavePic(&players[consoleplayer], file, width, height);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1483,77 +1483,55 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckPlayerDone)
|
|||
//
|
||||
// P_CheckPlayerSprites
|
||||
//
|
||||
// Here's the place where crouching sprites are handled
|
||||
// This must be called each frame before rendering
|
||||
// Here's the place where crouching sprites are handled.
|
||||
// R_ProjectSprite() calls this for any players.
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void P_CheckPlayerSprites()
|
||||
void P_CheckPlayerSprite(AActor *actor, unsigned &spritenum, fixed_t &scalex, fixed_t &scaley)
|
||||
{
|
||||
for(int i=0; i<MAXPLAYERS; i++)
|
||||
{
|
||||
player_t * player = &players[i];
|
||||
APlayerPawn * mo = player->mo;
|
||||
|
||||
if (playeringame[i] && mo != NULL)
|
||||
{
|
||||
player_t *player = actor->player;
|
||||
fixed_t defscaleY = actor->GetDefault()->scaleY;
|
||||
fixed_t defscaleX = actor->GetDefault()->scaleX;
|
||||
int crouchspriteno;
|
||||
fixed_t defscaleY = mo->GetDefault()->scaleY;
|
||||
fixed_t defscaleX = mo->GetDefault()->scaleX;
|
||||
|
||||
if (player->userinfo.skin != 0 && !(player->mo->flags4 & MF4_NOSKIN))
|
||||
if (player->userinfo.skin != 0 && !(actor->flags4 & MF4_NOSKIN))
|
||||
{
|
||||
defscaleY = skins[player->userinfo.skin].ScaleY;
|
||||
defscaleX = skins[player->userinfo.skin].ScaleX;
|
||||
}
|
||||
|
||||
// Set the crouch sprite
|
||||
// Set the crouch sprite?
|
||||
if (player->crouchfactor < FRACUNIT*3/4)
|
||||
{
|
||||
if (mo->sprite == mo->SpawnState->sprite || mo->sprite == mo->crouchsprite)
|
||||
if (spritenum == actor->SpawnState->sprite || spritenum == player->mo->crouchsprite)
|
||||
{
|
||||
crouchspriteno = mo->crouchsprite;
|
||||
crouchspriteno = player->mo->crouchsprite;
|
||||
}
|
||||
else if (!(player->mo->flags4 & MF4_NOSKIN) &&
|
||||
(mo->sprite == skins[player->userinfo.skin].sprite ||
|
||||
mo->sprite == skins[player->userinfo.skin].crouchsprite))
|
||||
else if (!(actor->flags4 & MF4_NOSKIN) &&
|
||||
(spritenum == skins[player->userinfo.skin].sprite ||
|
||||
spritenum == skins[player->userinfo.skin].crouchsprite))
|
||||
{
|
||||
crouchspriteno = skins[player->userinfo.skin].crouchsprite;
|
||||
}
|
||||
else
|
||||
{
|
||||
// no sprite -> squash the existing one
|
||||
{ // no sprite -> squash the existing one
|
||||
crouchspriteno = -1;
|
||||
}
|
||||
|
||||
if (crouchspriteno > 0)
|
||||
{
|
||||
mo->sprite = crouchspriteno;
|
||||
mo->scaleY = defscaleY;
|
||||
spritenum = crouchspriteno;
|
||||
}
|
||||
else if (player->playerstate != PST_DEAD)
|
||||
{
|
||||
mo->scaleY = player->crouchfactor < FRACUNIT*3/4 ? defscaleY/2 : defscaleY;
|
||||
}
|
||||
}
|
||||
else // Set the normal sprite
|
||||
{
|
||||
if (mo->sprite != 0)
|
||||
{
|
||||
if (mo->sprite == mo->crouchsprite)
|
||||
{
|
||||
mo->sprite = mo->SpawnState->sprite;
|
||||
}
|
||||
else if (mo->sprite != 0 && mo->sprite == skins[player->userinfo.skin].crouchsprite)
|
||||
{
|
||||
mo->sprite = skins[player->userinfo.skin].sprite;
|
||||
}
|
||||
}
|
||||
mo->scaleY = defscaleY;
|
||||
}
|
||||
mo->scaleX = defscaleX;
|
||||
if (player->crouchfactor < FRACUNIT*3/4)
|
||||
defscaleY /= 2;
|
||||
}
|
||||
}
|
||||
// Scale the sprite by the actor, skin, and crouch values
|
||||
scalex = FixedMul(scalex, defscaleX);
|
||||
scaley = FixedMul(scaley, defscaleY);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -523,6 +523,14 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
|
|||
tex = NULL;
|
||||
voxel = NULL;
|
||||
|
||||
unsigned spritenum = thing->sprite;
|
||||
fixed_t spritescaleX = thing->scaleX;
|
||||
fixed_t spritescaleY = thing->scaleY;
|
||||
if (thing->player != NULL)
|
||||
{
|
||||
P_CheckPlayerSprite(thing, spritenum, spritescaleX, spritescaleY);
|
||||
}
|
||||
|
||||
if (thing->picnum.isValid())
|
||||
{
|
||||
picnum = thing->picnum;
|
||||
|
@ -557,13 +565,13 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
|
|||
{
|
||||
// decide which texture to use for the sprite
|
||||
#ifdef RANGECHECK
|
||||
if ((unsigned)thing->sprite >= (unsigned)sprites.Size ())
|
||||
if (spritenum >= (unsigned)sprites.Size ())
|
||||
{
|
||||
DPrintf ("R_ProjectSprite: invalid sprite number %i\n", thing->sprite);
|
||||
DPrintf ("R_ProjectSprite: invalid sprite number %u\n", spritenum);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
spritedef_t *sprdef = &sprites[thing->sprite];
|
||||
spritedef_t *sprdef = &sprites[spritenum];
|
||||
if (thing->frame >= sprdef->numframes)
|
||||
{
|
||||
// If there are no frames at all for this sprite, don't draw it.
|
||||
|
@ -624,13 +632,13 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
|
|||
// [RH] Added scaling
|
||||
int scaled_to = tex->GetScaledTopOffset();
|
||||
int scaled_bo = scaled_to - tex->GetScaledHeight();
|
||||
gzt = fz + thing->scaleY * scaled_to;
|
||||
gzb = fz + thing->scaleY * scaled_bo;
|
||||
gzt = fz + spritescaleY * scaled_to;
|
||||
gzb = fz + spritescaleY * scaled_bo;
|
||||
}
|
||||
else
|
||||
{
|
||||
xscale = FixedMul(thing->scaleX, voxel->Scale);
|
||||
yscale = FixedMul(thing->scaleY, voxel->Scale);
|
||||
xscale = FixedMul(spritescaleX, voxel->Scale);
|
||||
yscale = FixedMul(spritescaleY, voxel->Scale);
|
||||
gzt = fz + MulScale8(yscale, voxel->Voxel->Mips[0].PivotZ) - thing->floorclip;
|
||||
gzb = fz + MulScale8(yscale, voxel->Voxel->Mips[0].PivotZ - (voxel->Voxel->Mips[0].SizeZ << 8));
|
||||
if (gzt <= gzb)
|
||||
|
@ -682,7 +690,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
|
|||
}
|
||||
|
||||
// calculate edges of the shape
|
||||
const fixed_t thingxscalemul = DivScale16(thing->scaleX, tex->xScale);
|
||||
const fixed_t thingxscalemul = DivScale16(spritescaleX, tex->xScale);
|
||||
|
||||
tx -= (flip ? (tex->GetWidth() - tex->LeftOffset - 1) : tex->LeftOffset) * thingxscalemul;
|
||||
x1 = centerx + MulScale32 (tx, xscale);
|
||||
|
@ -698,11 +706,11 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
|
|||
if ((x2 < WindowLeft || x2 <= x1))
|
||||
return;
|
||||
|
||||
xscale = FixedDiv(FixedMul(thing->scaleX, xscale), tex->xScale);
|
||||
xscale = FixedDiv(FixedMul(spritescaleX, xscale), tex->xScale);
|
||||
iscale = (tex->GetWidth() << FRACBITS) / (x2 - x1);
|
||||
x2--;
|
||||
|
||||
fixed_t yscale = SafeDivScale16(thing->scaleY, tex->yScale);
|
||||
fixed_t yscale = SafeDivScale16(spritescaleY, tex->yScale);
|
||||
|
||||
// store information in a vissprite
|
||||
vis = R_NewVisSprite();
|
||||
|
|
Loading…
Reference in a new issue