mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-14 11:50:49 +00:00
- added sprite collection loop to ProcessSector and did a bit of cleanup on the TSprite code.
This commit is contained in:
parent
f6568fee0c
commit
0b1e81023f
8 changed files with 57 additions and 64 deletions
|
@ -161,25 +161,33 @@ extern sectortype sectorbackup[MAXSECTORS];
|
||||||
extern walltype wallbackup[MAXWALLS];
|
extern walltype wallbackup[MAXWALLS];
|
||||||
|
|
||||||
|
|
||||||
static inline tspriteptr_t renderMakeTSpriteFromSprite(tspriteptr_t const tspr, uint16_t const spritenum)
|
inline tspriteptr_t renderAddNewTSprite()
|
||||||
{
|
{
|
||||||
auto const spr = &sprite[spritenum];
|
auto tspr = &tsprite[spritesortcnt++];
|
||||||
|
*tspr = {};
|
||||||
*tspr = *spr;
|
|
||||||
|
|
||||||
tspr->clipdist = 0;
|
|
||||||
tspr->owner = spritenum;
|
|
||||||
|
|
||||||
return tspr;
|
return tspr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline tspriteptr_t renderAddTSpriteFromSprite(uint16_t const spritenum)
|
inline tspriteptr_t renderAddTSpriteFromSprite(uint16_t const spritenum)
|
||||||
{
|
{
|
||||||
return renderMakeTSpriteFromSprite(&tsprite[spritesortcnt++], spritenum);
|
auto tspr = &tsprite[spritesortcnt++];
|
||||||
|
auto const spr = &sprite[spritenum];
|
||||||
|
*tspr = *spr;
|
||||||
|
tspr->clipdist = 0;
|
||||||
|
tspr->owner = spritenum;
|
||||||
|
return tspr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns: 0=continue sprite collecting;
|
||||||
|
// 1=break out of sprite collecting;
|
||||||
|
inline int32_t renderAddTsprite(int16_t z, int16_t sectnum)
|
||||||
|
{
|
||||||
|
if (spritesortcnt >= MAXSPRITESONSCREEN) return 1;
|
||||||
|
renderAddTSpriteFromSprite(z);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EXTERN tspriteptr_t tspriteptr[MAXSPRITESONSCREEN + 1];
|
|
||||||
|
|
||||||
EXTERN int32_t xdim, ydim;
|
EXTERN int32_t xdim, ydim;
|
||||||
EXTERN int32_t yxaspect, viewingrange;
|
EXTERN int32_t yxaspect, viewingrange;
|
||||||
|
@ -192,8 +200,6 @@ EXTERN int32_t randomseed;
|
||||||
|
|
||||||
EXTERN uint8_t paletteloaded;
|
EXTERN uint8_t paletteloaded;
|
||||||
|
|
||||||
EXTERN int32_t maxspritesonscreen;
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PALETTE_MAIN = 1<<0,
|
PALETTE_MAIN = 1<<0,
|
||||||
PALETTE_SHADE = 1<<1,
|
PALETTE_SHADE = 1<<1,
|
||||||
|
|
|
@ -172,20 +172,6 @@ char inpreparemirror = 0;
|
||||||
// Internal Engine Functions
|
// Internal Engine Functions
|
||||||
//
|
//
|
||||||
|
|
||||||
// returns: 0=continue sprite collecting;
|
|
||||||
// 1=break out of sprite collecting;
|
|
||||||
int32_t renderAddTsprite(int16_t z, int16_t sectnum)
|
|
||||||
{
|
|
||||||
auto const spr = (uspriteptr_t)&sprite[z];
|
|
||||||
if (spritesortcnt >= maxspritesonscreen)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
renderAddTSpriteFromSprite(z);
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// animateoffs (internal)
|
// animateoffs (internal)
|
||||||
|
@ -703,8 +689,6 @@ int32_t engineInit(void)
|
||||||
g_visibility = 512;
|
g_visibility = 512;
|
||||||
parallaxvisibility = 512;
|
parallaxvisibility = 512;
|
||||||
|
|
||||||
maxspritesonscreen = MAXSPRITESONSCREEN;
|
|
||||||
|
|
||||||
GPalette.Init(MAXPALOOKUPS + 1); // one slot for each translation, plus a separate one for the base palettes.
|
GPalette.Init(MAXPALOOKUPS + 1); // one slot for each translation, plus a separate one for the base palettes.
|
||||||
gi->loadPalette();
|
gi->loadPalette();
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#define ENGINE_PRIV_H
|
#define ENGINE_PRIV_H
|
||||||
|
|
||||||
extern int32_t globalpal, globalfloorpal;
|
extern int32_t globalpal, globalfloorpal;
|
||||||
extern tspriteptr_t tspriteptr[MAXSPRITESONSCREEN + 1];
|
|
||||||
extern int32_t xdimen, xdimenscale, xdimscale, ydimen;
|
extern int32_t xdimen, xdimenscale, xdimscale, ydimen;
|
||||||
extern float fxdimen;
|
extern float fxdimen;
|
||||||
extern int32_t globalposx, globalposy, globalposz;
|
extern int32_t globalposx, globalposy, globalposz;
|
||||||
|
|
|
@ -61,6 +61,7 @@ static int16_t bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB];
|
||||||
static int16_t numscans, numbunches;
|
static int16_t numscans, numbunches;
|
||||||
static int16_t maskwall[MAXWALLSB], maskwallcnt;
|
static int16_t maskwall[MAXWALLSB], maskwallcnt;
|
||||||
static int16_t sectorborder[256];
|
static int16_t sectorborder[256];
|
||||||
|
static tspriteptr_t tspriteptr[MAXSPRITESONSCREEN + 1];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,13 @@ void BunchDrawer::Init(HWDrawInfo *_di, Clipper* c, vec2_t& view)
|
||||||
clipper = c;
|
clipper = c;
|
||||||
viewx = view.x * (1/ 16.f);
|
viewx = view.x * (1/ 16.f);
|
||||||
viewy = view.y * -(1/ 16.f);
|
viewy = view.y * -(1/ 16.f);
|
||||||
|
iview = view;
|
||||||
StartScene();
|
StartScene();
|
||||||
clipper->SetViewpoint(view);
|
clipper->SetViewpoint(view);
|
||||||
|
|
||||||
|
gcosang = bamang(di->Viewpoint.RotAngle).fcos();
|
||||||
|
gsinang = bamang(di->Viewpoint.RotAngle).fsin();
|
||||||
|
|
||||||
for (int i = 0; i < numwalls; i++)
|
for (int i = 0; i < numwalls; i++)
|
||||||
{
|
{
|
||||||
// Precalculate the clip angles to avoid doing this repeatedly during level traversal.
|
// Precalculate the clip angles to avoid doing this repeatedly during level traversal.
|
||||||
|
@ -419,16 +424,40 @@ void BunchDrawer::ProcessSector(int sectnum)
|
||||||
if (gotsector[sectnum]) return;
|
if (gotsector[sectnum]) return;
|
||||||
gotsector.Set(sectnum);
|
gotsector.Set(sectnum);
|
||||||
|
|
||||||
Bsp.Clock();
|
|
||||||
|
|
||||||
auto sect = §or[sectnum];
|
auto sect = §or[sectnum];
|
||||||
bool inbunch;
|
bool inbunch;
|
||||||
binangle startangle;
|
binangle startangle;
|
||||||
|
|
||||||
|
SetupSprite.Clock();
|
||||||
|
|
||||||
|
int z;
|
||||||
|
SectIterator it(sectnum);
|
||||||
|
while ((z = it.NextIndex()) >= 0)
|
||||||
|
{
|
||||||
|
auto const spr = (uspriteptr_t)&sprite[z];
|
||||||
|
|
||||||
|
if ((spr->cstat & CSTAT_SPRITE_INVISIBLE) || spr->xrepeat == 0 || spr->yrepeat == 0) // skip invisible sprites
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int sx = spr->x - iview.x, sy = spr->y - int(iview.y);
|
||||||
|
|
||||||
|
if ((spr->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) || (hw_models && tile2model[spr->picnum].modelid >= 0) || ((sx * gcosang) + (sy * gsinang) > 0)) // is it behind the camera? (fixme!)
|
||||||
|
{
|
||||||
|
if ((spr->cstat & (CSTAT_SPRITE_ONE_SIDED | CSTAT_SPRITE_ALIGNMENT_MASK)) != (CSTAT_SPRITE_ONE_SIDED | CSTAT_SPRITE_ALIGNMENT_WALL + 16) ||
|
||||||
|
(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))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SetupSprite.Unclock();
|
||||||
|
|
||||||
|
|
||||||
SetupFlat.Clock();
|
SetupFlat.Clock();
|
||||||
HWFlat flat;
|
HWFlat flat;
|
||||||
flat.ProcessSector(di, §or[sectnum]);
|
flat.ProcessSector(di, §or[sectnum]);
|
||||||
SetupFlat.Unclock();
|
SetupFlat.Unclock();
|
||||||
|
Bsp.Clock();
|
||||||
|
|
||||||
//Todo: process subsectors
|
//Todo: process subsectors
|
||||||
inbunch = false;
|
inbunch = false;
|
||||||
|
|
|
@ -24,6 +24,8 @@ class BunchDrawer
|
||||||
TArray<FBunch> Bunches;
|
TArray<FBunch> Bunches;
|
||||||
TArray<int> CompareData;
|
TArray<int> CompareData;
|
||||||
double viewx, viewy;
|
double viewx, viewy;
|
||||||
|
vec2_t iview;
|
||||||
|
float gcosang, gsinang;
|
||||||
FixedBitArray<MAXSECTORS> gotsector;
|
FixedBitArray<MAXSECTORS> gotsector;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -126,7 +126,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
|
||||||
{
|
{
|
||||||
assert(nViewEffect >= 0 && nViewEffect < kViewEffectMax);
|
assert(nViewEffect >= 0 && nViewEffect < kViewEffectMax);
|
||||||
auto pTSprite = &tsprite[nTSprite];
|
auto pTSprite = &tsprite[nTSprite];
|
||||||
if (gDetail < effectDetail[nViewEffect] || nTSprite >= maxspritesonscreen) return NULL;
|
if (gDetail < effectDetail[nViewEffect] || nTSprite >= MAXSPRITESONSCREEN) return NULL;
|
||||||
switch (nViewEffect)
|
switch (nViewEffect)
|
||||||
{
|
{
|
||||||
case VIEW_EFFECT_18:
|
case VIEW_EFFECT_18:
|
||||||
|
@ -220,7 +220,7 @@ static tspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect)
|
||||||
{
|
{
|
||||||
nAng = (nAng+1024)&2047;
|
nAng = (nAng+1024)&2047;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 5 && spritesortcnt < maxspritesonscreen; i++)
|
for (int i = 0; i < 5 && spritesortcnt < MAXSPRITESONSCREEN; i++)
|
||||||
{
|
{
|
||||||
int nSector = pTSprite->sectnum;
|
int nSector = pTSprite->sectnum;
|
||||||
auto pNSprite = viewInsertTSprite<tspritetype>(nSector, 32767, NULL);
|
auto pNSprite = viewInsertTSprite<tspritetype>(nSector, 32767, NULL);
|
||||||
|
@ -433,7 +433,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
|
||||||
{
|
{
|
||||||
// shift before interpolating to increase precision.
|
// shift before interpolating to increase precision.
|
||||||
int myclock = (PlayClock<<3) + MulScale(4<<3, smoothratio, 16);
|
int myclock = (PlayClock<<3) + MulScale(4<<3, smoothratio, 16);
|
||||||
assert(spritesortcnt <= maxspritesonscreen);
|
assert(spritesortcnt <= MAXSPRITESONSCREEN);
|
||||||
gCameraAng = cA;
|
gCameraAng = cA;
|
||||||
int nViewSprites = spritesortcnt;
|
int nViewSprites = spritesortcnt;
|
||||||
for (int nTSprite = spritesortcnt-1; nTSprite >= 0; nTSprite--)
|
for (int nTSprite = spritesortcnt-1; nTSprite >= 0; nTSprite--)
|
||||||
|
@ -633,7 +633,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
|
||||||
pTSprite->xrepeat = pTSprite->yrepeat = 0;
|
pTSprite->xrepeat = pTSprite->yrepeat = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (spritesortcnt >= maxspritesonscreen) continue;
|
if (spritesortcnt >= MAXSPRITESONSCREEN) continue;
|
||||||
if (pTXSprite && pTXSprite->burnTime > 0)
|
if (pTXSprite && pTXSprite->burnTime > 0)
|
||||||
{
|
{
|
||||||
pTSprite->shade = ClipRange(pTSprite->shade-16-QRandom(8), -128, 127);
|
pTSprite->shade = ClipRange(pTSprite->shade-16-QRandom(8), -128, 127);
|
||||||
|
|
|
@ -1094,34 +1094,6 @@ void PrintSpriteInfo(PLAYERp pp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SpriteSortList2D(int tx, int ty)
|
|
||||||
{
|
|
||||||
SPRITEp sp;
|
|
||||||
int i;
|
|
||||||
int dist,a,b,c;
|
|
||||||
|
|
||||||
spritesortcnt = 0;
|
|
||||||
for (i = 0; i < MAXSPRITES; i++)
|
|
||||||
{
|
|
||||||
if (sprite[i].statnum < MAXSTATUS)
|
|
||||||
{
|
|
||||||
sp = &sprite[i];
|
|
||||||
|
|
||||||
if (!TEST(sp->cstat, CSTAT_SPRITE_INVISIBLE) &&
|
|
||||||
(sp->xrepeat > 0) && (sp->yrepeat > 0) &&
|
|
||||||
(spritesortcnt < MAXSPRITESONSCREEN))
|
|
||||||
{
|
|
||||||
DISTANCE(tx,ty,sp->x,sp->y,dist,a,b,c);
|
|
||||||
|
|
||||||
if (dist < 22000)
|
|
||||||
{
|
|
||||||
renderAddTSpriteFromSprite(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawCrosshair(PLAYERp pp)
|
void DrawCrosshair(PLAYERp pp)
|
||||||
{
|
{
|
||||||
extern bool CameraTestMode;
|
extern bool CameraTestMode;
|
||||||
|
|
Loading…
Reference in a new issue