mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +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,
|
screen->SetBlendingRect(viewwindowx, viewwindowy,
|
||||||
viewwindowx + viewwidth, viewwindowy + viewheight);
|
viewwindowx + viewwidth, viewwindowy + viewheight);
|
||||||
P_CheckPlayerSprites();
|
|
||||||
P_PredictPlayer(&players[consoleplayer]);
|
P_PredictPlayer(&players[consoleplayer]);
|
||||||
Renderer->RenderView(&players[consoleplayer]);
|
Renderer->RenderView(&players[consoleplayer]);
|
||||||
P_UnPredictPlayer();
|
P_UnPredictPlayer();
|
||||||
|
|
|
@ -427,7 +427,7 @@ extern player_t players[MAXPLAYERS];
|
||||||
|
|
||||||
FArchive &operator<< (FArchive &arc, player_t *&p);
|
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)
|
inline void AActor::SetFriendPlayer(player_t *player)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2049,7 +2049,6 @@ static void PutSavePic (FILE *file, int width, int height)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
P_CheckPlayerSprites();
|
|
||||||
Renderer->WriteSavePic(&players[consoleplayer], file, width, height);
|
Renderer->WriteSavePic(&players[consoleplayer], file, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1483,77 +1483,55 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckPlayerDone)
|
||||||
//
|
//
|
||||||
// P_CheckPlayerSprites
|
// P_CheckPlayerSprites
|
||||||
//
|
//
|
||||||
// Here's the place where crouching sprites are handled
|
// Here's the place where crouching sprites are handled.
|
||||||
// This must be called each frame before rendering
|
// 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 = actor->player;
|
||||||
|
fixed_t defscaleY = actor->GetDefault()->scaleY;
|
||||||
|
fixed_t defscaleX = actor->GetDefault()->scaleX;
|
||||||
|
int crouchspriteno;
|
||||||
|
|
||||||
|
if (player->userinfo.skin != 0 && !(actor->flags4 & MF4_NOSKIN))
|
||||||
{
|
{
|
||||||
player_t * player = &players[i];
|
defscaleY = skins[player->userinfo.skin].ScaleY;
|
||||||
APlayerPawn * mo = player->mo;
|
defscaleX = skins[player->userinfo.skin].ScaleX;
|
||||||
|
}
|
||||||
|
|
||||||
if (playeringame[i] && mo != NULL)
|
// Set the crouch sprite?
|
||||||
|
if (player->crouchfactor < FRACUNIT*3/4)
|
||||||
|
{
|
||||||
|
if (spritenum == actor->SpawnState->sprite || spritenum == player->mo->crouchsprite)
|
||||||
{
|
{
|
||||||
int crouchspriteno;
|
crouchspriteno = player->mo->crouchsprite;
|
||||||
fixed_t defscaleY = mo->GetDefault()->scaleY;
|
}
|
||||||
fixed_t defscaleX = mo->GetDefault()->scaleX;
|
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
|
||||||
|
crouchspriteno = -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (player->userinfo.skin != 0 && !(player->mo->flags4 & MF4_NOSKIN))
|
if (crouchspriteno > 0)
|
||||||
{
|
{
|
||||||
defscaleY = skins[player->userinfo.skin].ScaleY;
|
spritenum = crouchspriteno;
|
||||||
defscaleX = skins[player->userinfo.skin].ScaleX;
|
}
|
||||||
}
|
else if (player->playerstate != PST_DEAD)
|
||||||
|
{
|
||||||
// Set the crouch sprite
|
|
||||||
if (player->crouchfactor < FRACUNIT*3/4)
|
if (player->crouchfactor < FRACUNIT*3/4)
|
||||||
{
|
defscaleY /= 2;
|
||||||
if (mo->sprite == mo->SpawnState->sprite || mo->sprite == mo->crouchsprite)
|
|
||||||
{
|
|
||||||
crouchspriteno = mo->crouchsprite;
|
|
||||||
}
|
|
||||||
else if (!(player->mo->flags4 & MF4_NOSKIN) &&
|
|
||||||
(mo->sprite == skins[player->userinfo.skin].sprite ||
|
|
||||||
mo->sprite == skins[player->userinfo.skin].crouchsprite))
|
|
||||||
{
|
|
||||||
crouchspriteno = skins[player->userinfo.skin].crouchsprite;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// no sprite -> squash the existing one
|
|
||||||
crouchspriteno = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (crouchspriteno > 0)
|
|
||||||
{
|
|
||||||
mo->sprite = crouchspriteno;
|
|
||||||
mo->scaleY = defscaleY;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 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;
|
tex = NULL;
|
||||||
voxel = 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())
|
if (thing->picnum.isValid())
|
||||||
{
|
{
|
||||||
picnum = thing->picnum;
|
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
|
// decide which texture to use for the sprite
|
||||||
#ifdef RANGECHECK
|
#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;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
spritedef_t *sprdef = &sprites[thing->sprite];
|
spritedef_t *sprdef = &sprites[spritenum];
|
||||||
if (thing->frame >= sprdef->numframes)
|
if (thing->frame >= sprdef->numframes)
|
||||||
{
|
{
|
||||||
// If there are no frames at all for this sprite, don't draw it.
|
// 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
|
// [RH] Added scaling
|
||||||
int scaled_to = tex->GetScaledTopOffset();
|
int scaled_to = tex->GetScaledTopOffset();
|
||||||
int scaled_bo = scaled_to - tex->GetScaledHeight();
|
int scaled_bo = scaled_to - tex->GetScaledHeight();
|
||||||
gzt = fz + thing->scaleY * scaled_to;
|
gzt = fz + spritescaleY * scaled_to;
|
||||||
gzb = fz + thing->scaleY * scaled_bo;
|
gzb = fz + spritescaleY * scaled_bo;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xscale = FixedMul(thing->scaleX, voxel->Scale);
|
xscale = FixedMul(spritescaleX, voxel->Scale);
|
||||||
yscale = FixedMul(thing->scaleY, voxel->Scale);
|
yscale = FixedMul(spritescaleY, voxel->Scale);
|
||||||
gzt = fz + MulScale8(yscale, voxel->Voxel->Mips[0].PivotZ) - thing->floorclip;
|
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));
|
gzb = fz + MulScale8(yscale, voxel->Voxel->Mips[0].PivotZ - (voxel->Voxel->Mips[0].SizeZ << 8));
|
||||||
if (gzt <= gzb)
|
if (gzt <= gzb)
|
||||||
|
@ -682,7 +690,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate edges of the shape
|
// 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;
|
tx -= (flip ? (tex->GetWidth() - tex->LeftOffset - 1) : tex->LeftOffset) * thingxscalemul;
|
||||||
x1 = centerx + MulScale32 (tx, xscale);
|
x1 = centerx + MulScale32 (tx, xscale);
|
||||||
|
@ -698,11 +706,11 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
|
||||||
if ((x2 < WindowLeft || x2 <= x1))
|
if ((x2 < WindowLeft || x2 <= x1))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xscale = FixedDiv(FixedMul(thing->scaleX, xscale), tex->xScale);
|
xscale = FixedDiv(FixedMul(spritescaleX, xscale), tex->xScale);
|
||||||
iscale = (tex->GetWidth() << FRACBITS) / (x2 - x1);
|
iscale = (tex->GetWidth() << FRACBITS) / (x2 - x1);
|
||||||
x2--;
|
x2--;
|
||||||
|
|
||||||
fixed_t yscale = SafeDivScale16(thing->scaleY, tex->yScale);
|
fixed_t yscale = SafeDivScale16(spritescaleY, tex->yScale);
|
||||||
|
|
||||||
// store information in a vissprite
|
// store information in a vissprite
|
||||||
vis = R_NewVisSprite();
|
vis = R_NewVisSprite();
|
||||||
|
|
Loading…
Reference in a new issue