- give each DrawInfo its own list of tsprites.

Since these do not fully get processed sequentially the contents need to be preserved until needed.
This required getting rid of the global tsprite array. Polymost still uses a static vatiable, though, but this is only accessed in polymost-exclusive code.
This commit is contained in:
Christoph Oelckers 2021-04-02 10:28:40 +02:00
parent 6afbb82e66
commit c8a75a8664
33 changed files with 174 additions and 167 deletions

View file

@ -140,7 +140,6 @@ enum
};
EXTERN int32_t guniqhudid;
EXTERN int32_t spritesortcnt;
struct usermaphack_t
{
@ -155,21 +154,13 @@ EXTERN spritesmooth_t *spritesmooth;
EXTERN sectortype *sector;
EXTERN walltype *wall;
EXTERN spritetype *sprite;
EXTERN tspriteptr_t tsprite;
EXTERN int leveltimer;
extern sectortype sectorbackup[MAXSECTORS];
extern walltype wallbackup[MAXWALLS];
inline tspriteptr_t renderAddNewTSprite()
{
auto tspr = &tsprite[spritesortcnt++];
*tspr = {};
return tspr;
}
inline tspriteptr_t renderAddTSpriteFromSprite(uint16_t const spritenum)
inline tspriteptr_t renderAddTSpriteFromSprite(spritetype* tsprite, int& spritesortcnt, uint16_t const spritenum)
{
auto tspr = &tsprite[spritesortcnt++];
auto const spr = &sprite[spritenum];
@ -181,10 +172,10 @@ inline tspriteptr_t renderAddTSpriteFromSprite(uint16_t const spritenum)
// returns: 0=continue sprite collecting;
// 1=break out of sprite collecting;
inline int32_t renderAddTsprite(int16_t z, int16_t sectnum)
inline int32_t renderAddTsprite(spritetype* tsprite, int& spritesortcnt, int16_t z, int16_t sectnum)
{
if (spritesortcnt >= MAXSPRITESONSCREEN) return 1;
renderAddTSpriteFromSprite(z);
renderAddTSpriteFromSprite(tsprite, spritesortcnt, z);
return 0;
}
@ -768,8 +759,6 @@ enum EHitBits
void updateModelInterpolation();
int32_t renderAddTsprite(int16_t z, int16_t sectnum);
inline void tileUpdatePicnum(int* const tileptr, int const obj, int stat)
{
auto& tile = *tileptr;

View file

@ -4,6 +4,10 @@
#include "mdsprite.h"
extern tspritetype pm_tsprite[MAXSPRITESONSCREEN];
extern int pm_spritesortcnt;
namespace Polymost
{
extern float gtang;

View file

@ -654,14 +654,12 @@ static spritesmooth_t spritesmooth_s[MAXSPRITES+MAXUNIQHUDID];
static sectortype sector_s[MAXSECTORS];
static walltype wall_s[MAXWALLS];
spritetype sprite_s[MAXSPRITES];
static tspritetype tsprite_s[MAXSPRITESONSCREEN];
int32_t enginePreInit(void)
{
sector = sector_s;
wall = wall_s;
sprite = sprite_s;
tsprite = tsprite_s;
spriteext = spriteext_s;
spritesmooth = spritesmooth_s;
return 0;

View file

@ -62,6 +62,8 @@ static int16_t numscans, numbunches;
static int16_t maskwall[MAXWALLSB], maskwallcnt;
static int16_t sectorborder[256];
static tspriteptr_t tspriteptr[MAXSPRITESONSCREEN + 1];
tspritetype pm_tsprite[MAXSPRITESONSCREEN];
int pm_spritesortcnt;
@ -1914,7 +1916,7 @@ void polymost_scansector(int32_t sectnum)
if ((spr->cstat&(64+48))!=(64+16) ||
(r_voxels && tiletovox[spr->picnum] >= 0 && voxmodels[tiletovox[spr->picnum]]) ||
DMulScale(bcos(spr->ang), -s.x, bsin(spr->ang), -s.y, 6) > 0)
if (renderAddTsprite(z, sectnum))
if (renderAddTsprite(pm_tsprite, pm_spritesortcnt, z, sectnum))
break;
}
}
@ -3329,7 +3331,7 @@ EXTERN_CVAR(Int, gl_fogmode)
int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz,
fixed_t daang, fixed_t dahoriz, int16_t dacursectnum)
{
spritesortcnt = 0;
pm_spritesortcnt = 0;
checkRotatedWalls();
if (gl_fogmode == 1) gl_fogmode = 2; // only radial fog works with Build's screwed up coordinate system.
@ -3492,21 +3494,21 @@ static void sortsprites(int const start, int const end)
void renderDrawMasks(void)
{
# define debugmask_add(dispidx, idx) do {} while (0)
int32_t i = spritesortcnt - 1;
int32_t numSprites = spritesortcnt;
int32_t i = pm_spritesortcnt - 1;
int32_t numSprites = pm_spritesortcnt;
spritesortcnt = 0;
pm_spritesortcnt = 0;
int32_t back = i;
for (; i >= 0; --i)
{
if (Polymost::polymost_spriteHasTranslucency(&tsprite[i]))
if (Polymost::polymost_spriteHasTranslucency(&pm_tsprite[i]))
{
tspriteptr[spritesortcnt] = &tsprite[i];
++spritesortcnt;
tspriteptr[pm_spritesortcnt] = &pm_tsprite[i];
++pm_spritesortcnt;
}
else
{
tspriteptr[back] = &tsprite[i];
tspriteptr[back] = &pm_tsprite[i];
--back;
}
}
@ -3532,7 +3534,7 @@ void renderDrawMasks(void)
if (!modelp)
{
//Delete face sprite if on wrong side!
if (i >= spritesortcnt)
if (i >= pm_spritesortcnt)
{
--numSprites;
if (i != numSprites)
@ -3545,15 +3547,15 @@ void renderDrawMasks(void)
else
{
--numSprites;
--spritesortcnt;
--pm_spritesortcnt;
if (i != numSprites)
{
tspriteptr[i] = tspriteptr[spritesortcnt];
spritesxyz[i].x = spritesxyz[spritesortcnt].x;
spritesxyz[i].y = spritesxyz[spritesortcnt].y;
tspriteptr[spritesortcnt] = tspriteptr[numSprites];
spritesxyz[spritesortcnt].x = spritesxyz[numSprites].x;
spritesxyz[spritesortcnt].y = spritesxyz[numSprites].y;
tspriteptr[i] = tspriteptr[pm_spritesortcnt];
spritesxyz[i].x = spritesxyz[pm_spritesortcnt].x;
spritesxyz[i].y = spritesxyz[pm_spritesortcnt].y;
tspriteptr[pm_spritesortcnt] = tspriteptr[numSprites];
spritesxyz[pm_spritesortcnt].x = spritesxyz[numSprites].x;
spritesxyz[pm_spritesortcnt].y = spritesxyz[numSprites].y;
}
}
continue;
@ -3562,18 +3564,18 @@ void renderDrawMasks(void)
spritesxyz[i].y = yp;
}
sortsprites(0, spritesortcnt);
sortsprites(spritesortcnt, numSprites);
sortsprites(0, pm_spritesortcnt);
sortsprites(pm_spritesortcnt, numSprites);
renderBeginScene();
GLInterface.EnableBlend(false);
GLInterface.EnableAlphaTest(true);
GLInterface.SetDepthBias(-2, -256);
if (spritesortcnt < numSprites)
if (pm_spritesortcnt < numSprites)
{
i = spritesortcnt;
for (bssize_t i = spritesortcnt; i < numSprites;)
i = pm_spritesortcnt;
for (bssize_t i = pm_spritesortcnt; i < numSprites;)
{
int32_t py = spritesxyz[i].y;
int32_t pcstat = tspriteptr[i]->cstat & 48;
@ -3659,7 +3661,7 @@ void renderDrawMasks(void)
_equation p1eq = equation(pos.x, pos.y, dot.x, dot.y);
_equation p2eq = equation(pos.x, pos.y, dot2.x, dot2.y);
i = spritesortcnt;
i = pm_spritesortcnt;
while (i)
{
i--;
@ -3743,14 +3745,14 @@ void renderDrawMasks(void)
Polymost::polymost_drawmaskwall(maskwallcnt);
}
while (spritesortcnt)
while (pm_spritesortcnt)
{
--spritesortcnt;
if (tspriteptr[spritesortcnt] != NULL)
--pm_spritesortcnt;
if (tspriteptr[pm_spritesortcnt] != NULL)
{
debugmask_add(i | 32768, tspriteptr[i]->owner);
Polymost::polymost_drawsprite(spritesortcnt);
tspriteptr[spritesortcnt] = NULL;
Polymost::polymost_drawsprite(pm_spritesortcnt);
tspriteptr[pm_spritesortcnt] = NULL;
}
}
renderFinishScene();

View file

@ -103,7 +103,7 @@ struct GameInterface
virtual int chaseCamX(binangle ang) { return 0; }
virtual int chaseCamY(binangle ang) { return 0; }
virtual int chaseCamZ(fixedhoriz horiz) { return 0; }
virtual void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) = 0;
virtual void processSprites(spritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) = 0;
virtual void UpdateCameras(double smoothratio) {}
virtual void EnterPortal(spritetype* viewer, int type) {}
virtual void LeavePortal(spritetype* viewer, int type) {}

View file

@ -447,7 +447,7 @@ void BunchDrawer::ProcessSector(int sectnum)
if ((spr->cstat & (CSTAT_SPRITE_ONE_SIDED | CSTAT_SPRITE_ALIGNMENT_MASK)) != (CSTAT_SPRITE_ONE_SIDED | CSTAT_SPRITE_ALIGNMENT_WALL) ||
(r_voxels && tiletovox[spr->picnum] >= 0 && voxmodels[tiletovox[spr->picnum]]) ||
DMulScale(bcos(spr->ang), -sx, bsin(spr->ang), -sy, 6) > 0)
if (renderAddTsprite(z, sectnum))
if (renderAddTsprite(di->tsprite, di->spritesortcnt, z, sectnum))
break;
}
}

View file

@ -393,7 +393,7 @@ void HWDrawInfo::CreateScene()
mDrawer.RenderScene(&vp.SectCount, 1);
SetupSprite.Clock();
gi->processSprites(view.x, view.y, vp.Pos.Z * -256, bamang(vp.RotAngle), vp.TicFrac * 65536);
gi->processSprites(tsprite, spritesortcnt, view.x, view.y, vp.Pos.Z * -256, bamang(vp.RotAngle), vp.TicFrac * 65536);
DispatchSprites();
SetupSprite.Unclock();

View file

@ -108,6 +108,8 @@ struct HWDrawInfo
FRenderViewpoint Viewpoint;
HWViewpointUniforms VPUniforms; // per-viewpoint uniform state
TArray<HWPortal *> Portals;
spritetype tsprite[MAXSPRITESONSCREEN];
int spritesortcnt = 0;
// This is needed by the BSP traverser.
bool multithread;

View file

@ -1,3 +1,4 @@
#include "polymost.h"
BEGIN_BLD_NS
@ -30,7 +31,7 @@ void collectTSpritesForPortal(int x, int y, int i, int interpolation)
int dx = mirror[j].dx;
int dy = mirror[j].dy;
int dz = mirror[j].dz;
tspritetype* pTSprite = &tsprite[spritesortcnt++];
tspritetype* pTSprite = &pm_tsprite[pm_spritesortcnt++];
*pTSprite = {};
pTSprite->type = pSprite->type;
pTSprite->index = pSprite->index;
@ -91,7 +92,7 @@ void collectTSpritesForPortal(int x, int y, int i, int interpolation)
nAnim--;
}
spritesortcnt++;
pm_spritesortcnt++;
}
}
@ -99,11 +100,11 @@ void collectTSpritesForPortal(int x, int y, int i, int interpolation)
void processSpritesOnOtherSideOfPortal(int x, int y, int interpolation)
{
if (spritesortcnt == 0) return;
int nViewSprites = spritesortcnt-1;
if (pm_spritesortcnt == 0) return;
int nViewSprites = pm_spritesortcnt-1;
for (int nTSprite = nViewSprites; nTSprite >= 0; nTSprite--)
{
tspritetype *pTSprite = &tsprite[nTSprite];
tspritetype *pTSprite = &pm_tsprite[nTSprite];
pTSprite->xrepeat = pTSprite->yrepeat = 0;
}
for (int i = mirrorcnt-1; i >= 0; i--)
@ -159,7 +160,7 @@ RORHACK:
}
renderDrawRoomsQ16(cX, cY, cZ, cA.asq16(), cH.asq16() + deliriumPitchI, nSectnum);
viewProcessSprites(cX, cY, cZ, cA.asbuild(), gInterpolate);
viewProcessSprites(pm_tsprite, pm_spritesortcnt, cX, cY, cZ, cA.asbuild(), gInterpolate);
bool do_ror_hack = false;
for (int i = 0; i < 16; i++)
if (ror_status[i] != TestBitString(gotpic, 4080 + i))
@ -167,13 +168,13 @@ RORHACK:
if (do_ror_hack)
{
gView->pSprite->cstat = bakCstat;
spritesortcnt = 0;
pm_spritesortcnt = 0;
goto RORHACK;
}
setPortalFlags(1);
int nSpriteSortCnt = spritesortcnt;
int nSpriteSortCnt = pm_spritesortcnt;
renderDrawMasks();
spritesortcnt = nSpriteSortCnt;
pm_spritesortcnt = nSpriteSortCnt;
setPortalFlags(0);
processSpritesOnOtherSideOfPortal(cX, cY, gInterpolate);
renderDrawMasks();
@ -252,7 +253,7 @@ void DrawMirrors(int x, int y, int z, fixed_t a, fixed_t horiz, int smooth, int
renderPrepareMirror(x, y, z, a, horiz, nWall, &cx, &cy, &ca);
}
int32_t didmirror = renderDrawRoomsQ16(cx, cy, z, ca, horiz, mirrorsector | MAXSECTORS);
viewProcessSprites(cx, cy, z, FixedToInt(ca), smooth);
viewProcessSprites(pm_tsprite, pm_spritesortcnt, cx, cy, z, FixedToInt(ca), smooth);
renderDrawMasks();
if (GetWallType(nWall) != kWallStack)
renderCompleteMirror();
@ -280,7 +281,7 @@ void DrawMirrors(int x, int y, int z, fixed_t a, fixed_t horiz, int smooth, int
}
}
renderDrawRoomsQ16(x + mirror[i].dx, y + mirror[i].dy, z + mirror[i].dz, a, horiz, nSector | MAXSECTORS);
viewProcessSprites(x + mirror[i].dx, y + mirror[i].dy, z + mirror[i].dz, FixedToInt(a), smooth);
viewProcessSprites(pm_tsprite, pm_spritesortcnt, x + mirror[i].dx, y + mirror[i].dy, z + mirror[i].dz, FixedToInt(a), smooth);
short fstat = sector[nSector].floorstat;
sector[nSector].floorstat |= 1;
renderDrawMasks();
@ -312,7 +313,7 @@ void DrawMirrors(int x, int y, int z, fixed_t a, fixed_t horiz, int smooth, int
}
}
renderDrawRoomsQ16(x + mirror[i].dx, y + mirror[i].dy, z + mirror[i].dz, a, horiz, nSector | MAXSECTORS);
viewProcessSprites(x + mirror[i].dx, y + mirror[i].dy, z + mirror[i].dz, FixedToInt(a), smooth);
viewProcessSprites(pm_tsprite, pm_spritesortcnt, x + mirror[i].dx, y + mirror[i].dy, z + mirror[i].dz, FixedToInt(a), smooth);
short cstat = sector[nSector].ceilingstat;
sector[nSector].ceilingstat |= 1;
renderDrawMasks();

View file

@ -67,7 +67,7 @@ static void RotateXZ(int *pX, int *, int *pZ, int ang)
*pZ = dmulscale30r(oX,angSin,oZ,angCos);
}
template<typename T> tspritetype* viewInsertTSprite(int nSector, int nStatnum, T const * const pSprite)
template<typename T> tspritetype* viewInsertTSprite(spritetype* tsprite, int& spritesortcnt, int nSector, int nStatnum, T const * const pSprite)
{
int nTSprite = spritesortcnt;
tspritetype *pTSprite = &tsprite[nTSprite];
@ -122,7 +122,7 @@ static const WEAPONICON gWeaponIcon[] = {
};
static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int nTSprite, VIEW_EFFECT nViewEffect)
{
assert(nViewEffect >= 0 && nViewEffect < kViewEffectMax);
auto pTSprite = &tsprite[nTSprite];
@ -132,7 +132,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
case VIEW_EFFECT_18:
for (int i = 0; i < 16; i++)
{
auto pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
int ang = (PlayClock*2048)/120;
int nRand1 = dword_172CE0[i][0];
int nRand2 = dword_172CE0[i][1];
@ -155,7 +155,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
{
int top, bottom;
GetSpriteExtents(pTSprite, &top, &bottom);
auto pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
pNSprite->shade = -128;
pNSprite->pal = 0;
pNSprite->z = top;
@ -168,7 +168,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
}
case VIEW_EFFECT_15:
{
auto pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
pNSprite->z = pTSprite->z;
pNSprite->cstat |= 2;
pNSprite->shade = -128;
@ -179,7 +179,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
}
case VIEW_EFFECT_14:
{
auto pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
pNSprite->shade = -128;
pNSprite->pal = 0;
pNSprite->xrepeat = pNSprite->yrepeat = 64;
@ -188,7 +188,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
}
case VIEW_EFFECT_13:
{
auto pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
pNSprite->shade = 26;
pNSprite->pal = 0;
pNSprite->cstat |= 2;
@ -198,7 +198,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
}
case VIEW_EFFECT_11:
{
auto pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
int top, bottom;
GetSpriteExtents(pTSprite, &top, &bottom);
pNSprite->shade = 26;
@ -223,7 +223,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
for (int i = 0; i < 5 && spritesortcnt < MAXSPRITESONSCREEN; i++)
{
int nSector = pTSprite->sectnum;
auto pNSprite = viewInsertTSprite<tspritetype>(nSector, 32767, NULL);
auto pNSprite = viewInsertTSprite<tspritetype>(tsprite, spritesortcnt, nSector, 32767, NULL);
int nLen = 128+(i<<7);
int x = MulScale(nLen, Cos(nAng), 30);
pNSprite->x = pTSprite->x + x;
@ -247,7 +247,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
}
case VIEW_EFFECT_8:
{
auto pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
pNSprite->shade = -128;
pNSprite->z = pTSprite->z;
pNSprite->picnum = 908;
@ -257,7 +257,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
}
case VIEW_EFFECT_6:
{
auto pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
int top, bottom;
GetSpriteExtents(pTSprite, &top, &bottom);
pNSprite->z = top;
@ -273,7 +273,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
}
case VIEW_EFFECT_7:
{
auto pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
int top, bottom;
GetSpriteExtents(pTSprite, &top, &bottom);
pNSprite->z = bottom;
@ -289,7 +289,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
}
case VIEW_EFFECT_4:
{
auto pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
int top, bottom;
GetSpriteExtents(pTSprite, &top, &bottom);
pNSprite->z = top;
@ -300,7 +300,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
}
case VIEW_EFFECT_5:
{
auto pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
int top, bottom;
GetSpriteExtents(pTSprite, &top, &bottom);
pNSprite->z = bottom;
@ -313,7 +313,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
{
if (r_shadows)
{
auto pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
pNSprite->z = getflorzofslope(pTSprite->sectnum, pNSprite->x, pNSprite->y);
pNSprite->shade = 127;
pNSprite->cstat |= 2;
@ -329,7 +329,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
}
case VIEW_EFFECT_1:
{
auto pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
pNSprite->shade = -128;
pNSprite->pal = 2;
pNSprite->cstat |= 2;
@ -341,7 +341,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
}
case VIEW_EFFECT_2:
{
auto pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
sectortype *pSector = &sector[pTSprite->sectnum];
pNSprite->x = pTSprite->x;
pNSprite->y = pTSprite->y;
@ -357,7 +357,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
}
case VIEW_EFFECT_3:
{
auto pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
sectortype *pSector = &sector[pTSprite->sectnum];
pNSprite->x = pTSprite->x;
pNSprite->y = pTSprite->y;
@ -374,7 +374,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
}
case VIEW_EFFECT_9:
{
auto pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
pNSprite->z = pTSprite->z;
if (gDetail > 1)
pNSprite->cstat |= 514;
@ -391,7 +391,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
WEAPONICON weaponIcon = gWeaponIcon[pPlayer->curWeapon];
const int nTile = weaponIcon.nTile;
if (nTile < 0) break;
auto pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectnum, 32767, pTSprite);
pNSprite->x = pTSprite->x;
pNSprite->y = pTSprite->y;
pNSprite->z = pTSprite->z-(32<<8);
@ -429,7 +429,7 @@ static void viewApplyDefaultPal(tspritetype *pTSprite, sectortype const *pSector
}
}
void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t smoothratio)
void viewProcessSprites(spritetype* tsprite, int& spritesortcnt, int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t smoothratio)
{
// shift before interpolating to increase precision.
int myclock = (PlayClock<<3) + MulScale(4<<3, smoothratio, 16);
@ -640,7 +640,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
}
if (pTSprite->flags&256)
{
viewAddEffect(nTSprite, VIEW_EFFECT_6);
viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_6);
}
if (pTSprite->flags&1024)
{
@ -656,7 +656,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
case kDecorationCandle:
if (!pTXSprite || pTXSprite->state == 1) {
pTSprite->shade = -128;
viewAddEffect(nTSprite, VIEW_EFFECT_11);
viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_11);
} else {
pTSprite->shade = -8;
}
@ -664,9 +664,9 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
case kDecorationTorch:
if (!pTXSprite || pTXSprite->state == 1) {
pTSprite->picnum++;
viewAddEffect(nTSprite, VIEW_EFFECT_4);
viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_4);
} else {
viewAddEffect(nTSprite, VIEW_EFFECT_6);
viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_6);
}
break;
default:
@ -679,13 +679,13 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
switch (pTSprite->type) {
case kItemFlagABase:
if (pTXSprite && pTXSprite->state > 0 && gGameOptions.nGameType == 3) {
auto pNTSprite = viewAddEffect(nTSprite, VIEW_EFFECT_17);
auto pNTSprite = viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_17);
if (pNTSprite) pNTSprite->pal = 10;
}
break;
case kItemFlagBBase:
if (pTXSprite && pTXSprite->state > 0 && gGameOptions.nGameType == 3) {
auto pNTSprite = viewAddEffect(nTSprite, VIEW_EFFECT_17);
auto pNTSprite = viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_17);
if (pNTSprite) pNTSprite->pal = 7;
}
break;
@ -713,10 +713,10 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
pTSprite->cstat |= 32;
break;
case kMissileTeslaRegular:
viewAddEffect(nTSprite, VIEW_EFFECT_15);
viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_15);
break;
case kMissileButcherKnife:
viewAddEffect(nTSprite, VIEW_EFFECT_10);
viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_10);
break;
case kMissileFlareRegular:
case kMissileFlareAlt:
@ -728,18 +728,18 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
}
}
viewAddEffect(nTSprite, VIEW_EFFECT_1);
viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_1);
if (pTSprite->type != kMissileFlareRegular) break;
sectortype *pSector = &sector[pTSprite->sectnum];
int zDiff = (pTSprite->z - pSector->ceilingz) >> 8;
if ((pSector->ceilingstat&1) == 0 && zDiff < 64) {
viewAddEffect(nTSprite, VIEW_EFFECT_2);
viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_2);
}
zDiff = (pSector->floorz - pTSprite->z) >> 8;
if ((pSector->floorstat&1) == 0 && zDiff < 64) {
viewAddEffect(nTSprite, VIEW_EFFECT_3);
viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_3);
}
break;
}
@ -774,15 +774,15 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
}
if (powerupCheck(pPlayer, kPwUpReflectShots)) {
viewAddEffect(nTSprite, VIEW_EFFECT_13);
viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_13);
}
if (cl_showweapon && gGameOptions.nGameType > 0 && gView) {
viewAddEffect(nTSprite, VIEW_EFFECT_12);
viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_12);
}
if (pPlayer->flashEffect && (gView != pPlayer || gViewPos != VIEWPOS_0)) {
auto pNTSprite = viewAddEffect(nTSprite, VIEW_EFFECT_14);
auto pNTSprite = viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_14);
if (pNTSprite) {
POSTURE *pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture];
pNTSprite->x += MulScale(pPosture->zOffset, Cos(pTSprite->ang), 28);
@ -793,7 +793,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
if (pPlayer->hasFlag > 0 && gGameOptions.nGameType == 3) {
if (pPlayer->hasFlag&1) {
auto pNTSprite = viewAddEffect(nTSprite, VIEW_EFFECT_16);
auto pNTSprite = viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_16);
if (pNTSprite)
{
pNTSprite->pal = 10;
@ -801,7 +801,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
}
}
if (pPlayer->hasFlag&2) {
auto pNTSprite = viewAddEffect(nTSprite, VIEW_EFFECT_16);
auto pNTSprite = viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_16);
if (pNTSprite)
{
pNTSprite->pal = 7;
@ -814,7 +814,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
if (pTSprite->owner != gView->pSprite->index || gViewPos != VIEWPOS_0) {
if (getflorzofslope(pTSprite->sectnum, pTSprite->x, pTSprite->y) >= cZ)
{
viewAddEffect(nTSprite, VIEW_EFFECT_0);
viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_0);
}
}
break;
@ -825,7 +825,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
if (pTXSprite->data1) {
pTSprite->picnum = 772;
if (pTXSprite->data2)
viewAddEffect(nTSprite, VIEW_EFFECT_9);
viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_9);
}
}
else if (pTXSprite->data1) pTSprite->picnum = 773;
@ -839,7 +839,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
if (pTSprite->type < kThingBase || pTSprite->type >= kThingMax || !gSpriteHit[nXSprite].florhit) {
if ((pTSprite->flags & kPhysMove) && getflorzofslope(pTSprite->sectnum, pTSprite->x, pTSprite->y) >= cZ)
viewAddEffect(nTSprite, VIEW_EFFECT_0);
viewAddEffect(tsprite, spritesortcnt, nTSprite, VIEW_EFFECT_0);
}
}
break;
@ -887,9 +887,9 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
}
void GameInterface::processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio)
void GameInterface::processSprites(spritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio)
{
viewProcessSprites(viewx, viewy, viewz, viewang.asbuild(), int(smoothRatio));
viewProcessSprites(tsprite, spritesortcnt, viewx, viewy, viewz, viewang.asbuild(), int(smoothRatio));
}
int display_mirror;

View file

@ -147,7 +147,7 @@ struct GameInterface : ::GameInterface
int chaseCamX(binangle ang) override { return MulScale(-Cos(ang.asbuild()), 1280, 30); }
int chaseCamY(binangle ang) override { return MulScale(-Sin(ang.asbuild()), 1280, 30); }
int chaseCamZ(fixedhoriz horiz) override { return FixedToInt(MulScale(horiz.asq16(), 1280, 3)) - (16 << 8); }
void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
void processSprites(spritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
void EnterPortal(spritetype* viewer, int type) override;
void LeavePortal(spritetype* viewer, int type) override;

View file

@ -144,7 +144,7 @@ void viewDrawText(int nFont, const char *pString, int x, int y, int nShade, int
void InitStatusBar(void);
void UpdateStatusBar();
void viewInit(void);
void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t smooth);
void viewProcessSprites(spritetype* tsprite, int& spritesortcnt, int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t smooth);
void viewSetMessage(const char *pMessage, const int pal = 0, const MESSAGE_PRIORITY priority = MESSAGE_PRIORITY_NORMAL);

View file

@ -95,7 +95,7 @@ void SE40_Draw(int tag, spritetype *spr, int x, int y, int z, binangle a, fixedh
offy = y - floor1->y;
renderDrawRoomsQ16(floor2->x + offx, floor2->y + offy, z, a.asq16(), h.asq16(), floor2->sectnum);
fi.animatesprites(offx + floor2->x, offy + floor2->y, a.asbuild(), smoothratio);
fi.animatesprites(pm_tsprite, pm_spritesortcnt, offx + floor2->x, offy + floor2->y, a.asbuild(), smoothratio);
renderDrawMasks();
it.Reset(STAT_RAROR);
@ -187,7 +187,7 @@ void renderMirror(int cposx, int cposy, int cposz, binangle cang, fixedhoriz cho
renderDrawRoomsQ16(tposx, tposy, cposz, tang, choriz.asq16(), mirrorsector[i] + MAXSECTORS);
display_mirror = 1;
fi.animatesprites(tposx, tposy, tang, smoothratio);
fi.animatesprites(pm_tsprite, pm_spritesortcnt, tposx, tposy, tang, smoothratio);
display_mirror = 0;
renderDrawMasks();
@ -208,7 +208,7 @@ static void geometryEffect(int cposx, int cposy, int cposz, binangle cang, fixed
{
short gs, tgsect, geosect, geoid = 0;
renderDrawRoomsQ16(cposx, cposy, cposz, cang.asq16(), choriz.asq16(), sect);
fi.animatesprites(cposx, cposy, cang.asbuild(), smoothratio);
fi.animatesprites(pm_tsprite, pm_spritesortcnt, cposx, cposy, cang.asbuild(), smoothratio);
renderDrawMasks();
for (gs = 0; gs < geocnt; gs++)
{
@ -241,7 +241,7 @@ static void geometryEffect(int cposx, int cposy, int cposz, binangle cang, fixed
setsprite(act, act->s.x += geox[gs], act->s.y += geoy[gs], act->s.z);
}
}
fi.animatesprites(cposx, cposy, cang.asbuild(), smoothratio);
fi.animatesprites(pm_tsprite, pm_spritesortcnt, cposx, cposy, cang.asbuild(), smoothratio);
renderDrawMasks();
for (gs = 0; gs < geocnt; gs++)
{
@ -273,7 +273,7 @@ static void geometryEffect(int cposx, int cposy, int cposz, binangle cang, fixed
setsprite(act, act->s.x += geox2[gs], act->s.y += geoy2[gs], act->s.z);
}
}
fi.animatesprites(cposx, cposy, cang.asbuild(), smoothratio);
fi.animatesprites(pm_tsprite, pm_spritesortcnt, cposx, cposy, cang.asbuild(), smoothratio);
renderDrawMasks();
}
END_DUKE_NS

View file

@ -43,7 +43,7 @@ EXTERN_CVAR(Bool, wt_commentary)
BEGIN_DUKE_NS
void animatesprites_d(int x, int y, int a, int smoothratio)
void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int a, int smoothratio)
{
int i, j, k, p;
short sect;

View file

@ -36,7 +36,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
BEGIN_DUKE_NS
void animatesprites_r(int x, int y, int a, int smoothratio)
void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int a, int smoothratio)
{
int i, j, k, p;
short sect;

View file

@ -102,8 +102,8 @@ void displaymasks_d(int snum, double smoothratio);
void displaymasks_r(int snum, double smoothratio);
void think_d();
void think_r();
void animatesprites_d(int x, int y, int a, int smoothratio);
void animatesprites_r(int x, int y, int a, int smoothratio);
void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int a, int smoothratio);
void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int a, int smoothratio);
void Logo_d(const CompletionFunc&);
void Logo_r(const CompletionFunc&);

View file

@ -65,7 +65,7 @@ struct GameInterface : public ::GameInterface
int chaseCamX(binangle ang) { return -ang.bcos(-4); }
int chaseCamY(binangle ang) { return -ang.bsin(-4); }
int chaseCamZ(fixedhoriz horiz) { return horiz.asq16() >> 9; }
void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
void processSprites(spritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
void UpdateCameras(double smoothratio) override;
void EnterPortal(spritetype* viewer, int type) override;
void LeavePortal(spritetype* viewer, int type) override;
@ -119,7 +119,7 @@ struct Dispatcher
void (*displayweapon)(int snum, double smoothratio);
void (*displaymasks)(int snum, double smoothratio);
void (*animatesprites)(int x, int y, int a, int smoothratio);
void (*animatesprites)(spritetype* tsprite, int& spritesortcnt, int x, int y, int a, int smoothratio);
};

View file

@ -77,7 +77,7 @@ void renderView(spritetype* playersprite, int sectnum, int x, int y, int z, bina
se40code(x, y, z, a, h, smoothratio);
renderMirror(x, y, z, a, h, smoothratio);
renderDrawRoomsQ16(x, y, z, a.asq16(), h.asq16(), sectnum);
fi.animatesprites(x, y, a.asbuild(), smoothratio);
fi.animatesprites(pm_tsprite, pm_spritesortcnt, x, y, a.asbuild(), smoothratio);
renderDrawMasks();
}
else
@ -121,7 +121,7 @@ void GameInterface::UpdateCameras(double smoothratio)
{
// Note: no ROR or camera here - Polymost has no means to detect these things before rendering the scene itself.
renderDrawRoomsQ16(camera->x, camera->y, camera->z, ang.asq16(), IntToFixed(camera->shade), camera->sectnum); // why 'shade'...?
fi.animatesprites(camera->x, camera->y, ang.asbuild(), smoothratio);
fi.animatesprites(pm_tsprite, pm_spritesortcnt, camera->x, camera->y, ang.asbuild(), smoothratio);
renderDrawMasks();
}
else
@ -424,9 +424,9 @@ bool GameInterface::GenerateSavePic()
return true;
}
void GameInterface::processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio)
void GameInterface::processSprites(spritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio)
{
fi.animatesprites(viewx, viewy, viewz, int(smoothRatio));
fi.animatesprites(tsprite, spritesortcnt, viewx, viewy, viewz, int(smoothRatio));
}

View file

@ -270,7 +270,7 @@ void FuncAnim(int a, int, int nRun)
case 0x90000:
{
seq_PlotSequence(a & 0xFFFF, nSeq, AnimList[nAnim].field_2, 0x101);
tsprite[a & 0xFFFF].owner = -1;
mytsprite[a & 0xFFFF].owner = -1;
return;
}

View file

@ -203,7 +203,7 @@ void FuncBubble(int a, int, int nRun)
case 0x90000:
{
seq_PlotSequence(a & 0xFFFF, nSeq, BubbleList[nBubble].nFrame, 1);
tsprite[a & 0xFFFF].owner = -1;
mytsprite[a & 0xFFFF].owner = -1;
return;
}

View file

@ -854,7 +854,7 @@ void FuncBullet(int a, int, int nRun)
case 0x90000:
{
short nSprite2 = a & 0xFFFF;
tsprite[nSprite2].statnum = 1000;
mytsprite[nSprite2].statnum = 1000;
if (BulletList[nBullet].nType == 15)
{
@ -863,7 +863,7 @@ void FuncBullet(int a, int, int nRun)
else
{
seq_PlotSequence(nSprite2, nSeq, BulletList[nBullet].nFrame, 0);
tsprite[nSprite2].owner = -1;
mytsprite[nSprite2].owner = -1;
}
break;
}

View file

@ -255,7 +255,7 @@ struct GameInterface : ::GameInterface
int chaseCamX(binangle ang) { return -ang.bcos() / 12; }
int chaseCamY(binangle ang) { return -ang.bsin() / 12; }
int chaseCamZ(fixedhoriz horiz) { return horiz.asq16() / 384; }
void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
void processSprites(spritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
::GameStats getStats() override;
};

View file

@ -330,7 +330,7 @@ void FuncFish(int a, int nDamage, int nRun)
case 0x90000:
{
seq_PlotSequence(a & 0xFFFF, SeqOffsets[kSeqFish] + FishSeq[nAction].a, FishList[nFish].nFrame, FishSeq[nAction].b);
tsprite[a & 0xFFFF].owner = -1;
mytsprite[a & 0xFFFF].owner = -1;
return;
}

View file

@ -232,7 +232,7 @@ void FuncLava(int a, int nDamage, int nRun)
case 0x90000:
{
seq_PlotSequence(a & 0xFFFF, nSeq, LavaList[nLava].nFrame, LavadudeSeq[nAction].b);
tsprite[a & 0xFFFF].owner = -1;
mytsprite[a & 0xFFFF].owner = -1;
return;
}

View file

@ -306,7 +306,7 @@ void FuncRa(int a, int, int nRun)
{
short nSprite2 = a & 0xFFFF;
seq_PlotSequence(nSprite2, nSeq, Ra[nPlayer].nFrame, 1);
tsprite[nSprite2].owner = -1;
mytsprite[nSprite2].owner = -1;
return;
}
}

View file

@ -471,7 +471,7 @@ int seq_GetSeqPicnum(short nSeq, short edx, short ebx)
int seq_PlotArrowSequence(short nSprite, short nSeq, int nVal)
{
tspriteptr_t pTSprite = &tsprite[nSprite];
tspriteptr_t pTSprite = &mytsprite[nSprite];
int nAngle = GetMyAngle(nCamerax - pTSprite->x, nCameray - pTSprite->y);
int nSeqOffset = ((((pTSprite->ang + 512) - nAngle) + 128) & kAngleMask) >> 8;
@ -519,7 +519,7 @@ int seq_PlotArrowSequence(short nSprite, short nSeq, int nVal)
int seq_PlotSequence(short nSprite, short edx, short nFrame, short ecx)
{
tspriteptr_t pTSprite = &tsprite[nSprite];
tspriteptr_t pTSprite = &mytsprite[nSprite];
int nAngle = GetMyAngle(nCamerax - pTSprite->x, nCameray - pTSprite->y);
int val;
@ -572,7 +572,7 @@ int seq_PlotSequence(short nSprite, short edx, short nFrame, short ecx)
break;
}
tspriteptr_t tsp = &tsprite[spritesortcnt++];
tspriteptr_t tsp = &mytsprite[(*myspritesortcnt)++];
tsp->x = pTSprite->x;
tsp->y = pTSprite->y;
tsp->z = pTSprite->z;

View file

@ -417,7 +417,7 @@ SEARCH_ENEMY:
seq_PlotSequence(nSprite, SeqOffsets[kSeqSnakBody], 0, 0);
}
tsprite[nSprite].owner = -1;
mytsprite[nSprite].owner = -1;
break;
}

View file

@ -65,11 +65,18 @@ short enemy;
short nEnemyPal = 0;
// We cannot drag these through the entire event system... :(
spritetype* mytsprite;
int* myspritesortcnt;
// NOTE - not to be confused with Ken's analyzesprites()
static void analyzesprites(int x, int y, int z, double const smoothratio)
static void analyzesprites(spritetype* tsprite, int& spritesortcnt, int x, int y, int z, double const smoothratio)
{
tspritetype *pTSprite;
mytsprite = tsprite;
myspritesortcnt = &spritesortcnt;
for (int i = 0; i < spritesortcnt; i++) {
pTSprite = &tsprite[i];
@ -173,6 +180,10 @@ static void analyzesprites(int x, int y, int z, double const smoothratio)
besttarget = -1;
}
}
mytsprite = nullptr;
myspritesortcnt = nullptr;
}
void ResetView()
@ -357,7 +368,7 @@ void DrawView(double smoothRatio, bool sceneonly)
{
renderSetRollAngle(rotscrnang.asbuildf());
renderDrawRoomsQ16(nCamerax, nCameray, viewz, nCameraa.asq16(), nCamerapan.asq16(), nSector);
analyzesprites(nCamerax, nCameray, viewz, smoothRatio);
analyzesprites(pm_tsprite, pm_spritesortcnt, nCamerax, nCameray, viewz, smoothRatio);
renderDrawMasks();
}
else
@ -462,9 +473,9 @@ bool GameInterface::GenerateSavePic()
return true;
}
void GameInterface::processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio)
void GameInterface::processSprites(spritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio)
{
analyzesprites(viewx, viewy, viewz, smoothRatio);
analyzesprites(tsprite, spritesortcnt, viewx, viewy, viewz, smoothRatio);
}

View file

@ -40,6 +40,9 @@ extern short bTouchFloor;
extern short nChunkTotal;
extern int gFov;
extern spritetype* mytsprite;
extern int* myspritesortcnt;
static inline int angle_interpolate16(int a, int b, int smooth)
{
return a + MulScale(((b+1024-a)&2047)-1024, smooth, 16);

View file

@ -68,8 +68,8 @@ DrawOverlapRoom(int tx, int ty, int tz, fixed_t tq16ang, fixed_t tq16horiz, shor
sector[save.sectnum[i]].floorheinum = save.slope[i];
}
analyzesprites(tx, ty, tz, false);
post_analyzesprites();
analyzesprites(pm_tsprite, pm_spritesortcnt, tx, ty, tz, false);
post_analyzesprites(pm_tsprite, pm_spritesortcnt);
renderDrawMasks();
}
@ -93,8 +93,8 @@ DrawOverlapRoom(int tx, int ty, int tz, fixed_t tq16ang, fixed_t tq16horiz, shor
sector[save.sectnum[i]].ceilingheinum = save.slope[i];
}
analyzesprites(tx, ty, tz, false);
post_analyzesprites();
analyzesprites(pm_tsprite, pm_spritesortcnt, tx, ty, tz, false);
post_analyzesprites(pm_tsprite, pm_spritesortcnt);
renderDrawMasks();
}
@ -177,8 +177,8 @@ void polymost_drawscreen(PLAYERp pp, int tx, int ty, int tz, binangle tang, fixe
if (!FAF_DebugView)
FAF_DrawRooms(tx, ty, tz, tang.asq16(), thoriz.asq16(), tsectnum);
analyzesprites(tx, ty, tz, tang.asbuild());
post_analyzesprites();
analyzesprites(pm_tsprite, pm_spritesortcnt, tx, ty, tz, tang.asbuild());
post_analyzesprites(pm_tsprite, pm_spritesortcnt);
renderDrawMasks();
}
@ -305,7 +305,7 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed
if (mirror[cnt].campic != -1)
tileDelete(mirror[cnt].campic);
renderDrawRoomsQ16(dx, dy, dz, tpq16ang, tpq16horiz, sp->sectnum + MAXSECTORS);
analyzesprites(dx, dy, dz, false);
analyzesprites(pm_tsprite, pm_spritesortcnt, dx, dy, dz, false);
renderDrawMasks();
}
}
@ -323,7 +323,7 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed
renderDrawRoomsQ16(tposx, tposy, tz, (tang), tpq16horiz, mirror[cnt].mirrorsector + MAXSECTORS);
analyzesprites(tposx, tposy, tz, tang >> 16);
analyzesprites(pm_tsprite, pm_spritesortcnt, tposx, tposy, tz, tang >> 16);
renderDrawMasks();
renderCompleteMirror(); // Reverse screen x-wise in this

View file

@ -102,7 +102,7 @@ ShadeSprite(tspriteptr_t tsp)
short
GetRotation(short tSpriteNum, int viewx, int viewy)
GetRotation(spritetype* tsprite, int& spritesortcnt, short tSpriteNum, int viewx, int viewy)
{
static short RotTable8[] = {0, 7, 6, 5, 4, 3, 2, 1};
static short RotTable5[] = {0, 1, 2, 3, 4, 3, 2, 1};
@ -173,7 +173,7 @@ directions was not standardized.
*/
int
SetActorRotation(short tSpriteNum, int viewx, int viewy)
SetActorRotation(spritetype* tsprite, int& spritesortcnt, short tSpriteNum, int viewx, int viewy)
{
tspriteptr_t tsp = &tsprite[tSpriteNum];
USERp tu = User[tsp->owner];
@ -190,7 +190,7 @@ SetActorRotation(short tSpriteNum, int viewx, int viewy)
StateOffset = State - StateStart;
// Get the rotation angle
Rotation = GetRotation(tSpriteNum, viewx, viewy);
Rotation = GetRotation(tsprite, spritesortcnt, tSpriteNum, viewx, viewy);
ASSERT(Rotation < 5);
@ -266,7 +266,7 @@ DoShadowFindGroundPoint(tspriteptr_t sp)
}
void
DoShadows(tspriteptr_t tsp, int viewz, int camang)
DoShadows(spritetype* tsprite, int& spritesortcnt, tspriteptr_t tsp, int viewz, int camang)
{
tspriteptr_t New = &tsprite[spritesortcnt];
USERp tu = User[tsp->owner];
@ -367,7 +367,7 @@ DoShadows(tspriteptr_t tsp, int viewz, int camang)
}
void
DoMotionBlur(tspritetype const * const tsp)
DoMotionBlur(spritetype* tsprite, int& spritesortcnt, tspritetype const * const tsp)
{
USERp tu = User[tsp->owner];
int nx,ny,nz = 0,dx,dy,dz;
@ -454,7 +454,7 @@ void SetVoxelSprite(SPRITEp sp, short pic)
sp->picnum = pic;
}
void WarpCopySprite(void)
void WarpCopySprite(spritetype* tsprite, int& spritesortcnt)
{
SPRITEp sp1, sp2, sp;
int sn, sn2;
@ -491,7 +491,7 @@ void WarpCopySprite(void)
if (sprite[spnum].picnum == ST1)
continue;
tspriteptr_t New = renderAddTSpriteFromSprite(spnum);
tspriteptr_t New = renderAddTSpriteFromSprite(tsprite, spritesortcnt, spnum);
New->statnum = 0;
xoff = sp1->x - New->x;
@ -513,7 +513,7 @@ void WarpCopySprite(void)
if (sprite[spnum].picnum == ST1)
continue;
tspriteptr_t New = renderAddTSpriteFromSprite(spnum);
tspriteptr_t New = renderAddTSpriteFromSprite(tsprite, spritesortcnt, spnum);
New->statnum = 0;
xoff = sp2->x - New->x;
@ -553,8 +553,7 @@ void DoStarView(tspriteptr_t tsp, USERp tu, int viewz)
}
}
void
analyzesprites(int viewx, int viewy, int viewz, int camang)
void analyzesprites(spritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, int camang)
{
int tSpriteNum;
short SpriteNum;
@ -646,7 +645,7 @@ analyzesprites(int viewx, int viewy, int viewz, int camang)
if (r_shadows && TEST(tu->Flags, SPR_SHADOW))
{
DoShadows(tsp, viewz, camang);
DoShadows(tsprite, spritesortcnt, tsp, viewz, camang);
}
//#define UK_VERSION 1
@ -677,11 +676,11 @@ analyzesprites(int viewx, int viewy, int viewz, int camang)
// rotation
if (tu->RotNum > 0)
SetActorRotation(tSpriteNum, viewx, viewy);
SetActorRotation(tsprite, spritesortcnt, tSpriteNum, viewx, viewy);
if (tu->motion_blur_num)
{
DoMotionBlur(tsp);
DoMotionBlur(tsprite, spritesortcnt, tsp);
}
// set palette lookup correctly
@ -866,13 +865,13 @@ analyzesprites(int viewx, int viewy, int viewz, int camang)
}
}
WarpCopySprite();
WarpCopySprite(tsprite, spritesortcnt);
}
#if 1
tspriteptr_t get_tsprite(short SpriteNum)
tspriteptr_t get_tsprite(spritetype* tsprite, int& spritesortcnt, int SpriteNum)
{
int tSpriteNum;
@ -886,7 +885,7 @@ tspriteptr_t get_tsprite(short SpriteNum)
}
void
post_analyzesprites(void)
post_analyzesprites(spritetype* tsprite, int& spritesortcnt)
{
int tSpriteNum;
short SpriteNum;
@ -903,7 +902,7 @@ post_analyzesprites(void)
{
if (tu->ID == FIREBALL_FLAMES && tu->Attach >= 0)
{
tspriteptr_t const atsp = get_tsprite(tu->Attach);
tspriteptr_t const atsp = get_tsprite(tsprite, spritesortcnt, tu->Attach);
if (!atsp)
{
@ -1922,10 +1921,10 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang,
return true;
}
void GameInterface::processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio)
void GameInterface::processSprites(spritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio)
{
analyzesprites(viewx, viewy, viewz, viewang.asbuild());
post_analyzesprites();
analyzesprites(tsprite, spritesortcnt, viewx, viewy, viewz, viewang.asbuild());
post_analyzesprites(tsprite, spritesortcnt);
}

View file

@ -1881,7 +1881,6 @@ ANIMATOR NullAnimator;
int Distance(int x1, int y1, int x2, int y2);
int SetActorRotation(short SpriteNum,int,int);
int NewStateGroup(short SpriteNum, STATEp SpriteGroup[]);
void SectorMidPoint(short sectnum, int *xmid, int *ymid, int *zmid);
USERp SpawnUser(short SpriteNum, short id, STATEp state);
@ -1963,7 +1962,7 @@ int DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, int skip_targets);
void change_sprite_stat(short, short);
void SetOwner(short, short);
void SetAttach(short, short);
void analyzesprites(int,int,int,int);
void analyzesprites(spritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, int camang);
void ChangeState(short SpriteNum, STATEp statep);
void CollectPortals();
@ -2114,7 +2113,6 @@ void getsyncstat(void); // sync.c
void SyncStatMessage(void); // sync.c
void drawscreen(PLAYERp pp, double smoothratio); // draw.c
void post_analyzesprites(void); // draw.c
int COVERsetgamemode(int mode, int xdim, int ydim, int bpp); // draw.c
void ScreenCaptureKeys(void); // draw.c
@ -2244,7 +2242,7 @@ struct GameInterface : ::GameInterface
int chaseCamX(binangle ang) { return -ang.bcos(-3); }
int chaseCamY(binangle ang) { return -ang.bsin(-3); }
int chaseCamZ(fixedhoriz horiz) { return horiz.asq16() >> 8; }
void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
void processSprites(spritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
void UpdateCameras(double smoothratio) override;
void EnterPortal(spritetype* viewer, int type) override;
void LeavePortal(spritetype* viewer, int type) override;

View file

@ -476,7 +476,7 @@ void drawroomstotile(int daposx, int daposy, int daposz,
if (!testnewrenderer)
{
renderDrawRoomsQ16(daposx, daposy, daposz, ang.asq16(), horiz.asq16(), dacursectnum);
analyzesprites(daposx, daposy, daposz, ang.asbuild());
analyzesprites(pm_tsprite, pm_spritesortcnt, daposx, daposy, daposz, ang.asbuild());
renderDrawMasks();
}
else