- re-enabled all model specific code in Duke's animatesprites function and removed some remaining software renderer-only code in the engine.

This commit is contained in:
Christoph Oelckers 2020-12-01 23:57:39 +01:00
parent 9a507e5d0a
commit 25ef58f897
12 changed files with 142 additions and 201 deletions

View file

@ -94,11 +94,8 @@ template<typename T> tspritetype* viewInsertTSprite(int nSector, int nStatnum, T
pTSprite->owner = pSprite->owner;
pTSprite->ang = pSprite->ang;
}
if (videoGetRenderMode() >= REND_POLYMOST)
{
pTSprite->x += Cos(gCameraAng)>>25;
pTSprite->y += Sin(gCameraAng)>>25;
}
pTSprite->x += Cos(gCameraAng)>>25;
pTSprite->y += Sin(gCameraAng)>>25;
return pTSprite;
}
@ -573,7 +570,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
nAnim--;
}
if ((pTSprite->cstat&48) != 48 && r_voxels && videoGetRenderMode() != REND_POLYMER && !(spriteext[nSprite].flags&SPREXT_NOTMD))
if ((pTSprite->cstat&48) != 48 && r_voxels && !(spriteext[nSprite].flags&SPREXT_NOTMD))
{
int const nRootTile = pTSprite->picnum;
int nAnimTile = pTSprite->picnum + animateoffs_replace(pTSprite->picnum, 32768+pTSprite->owner);

View file

@ -298,8 +298,6 @@ void sub_557C4(int x, int y, int interpolation)
void DrawMirrors(int x, int y, int z, fixed_t a, fixed_t horiz, int smooth, int viewPlayer)
{
if (videoGetRenderMode() == REND_POLYMER)
return;
for (int i = mirrorcnt - 1; i >= 0; i--)
{
int nTile = 4080+i;

View file

@ -841,7 +841,7 @@ void viewDrawScreen(bool sceneonly)
if ((v78 || bDelirium) && !sceneonly)
{
if (videoGetRenderMode() == REND_POLYMOST && gDeliriumBlur)
if (gDeliriumBlur)
{
// todo: Implement using modern techniques instead of relying on deprecated old stuff that isn't well supported anymore.
/* names broken up so that searching for GL keywords won't find them anymore

View file

@ -41,12 +41,6 @@ EXTERN int16_t sintable[2048];
typedef int64_t coord_t;
enum rendmode_t {
REND_CLASSIC,
REND_POLYMOST = 3,
REND_POLYMER
};
enum
{
MAXSECTORS = 4096,
@ -350,9 +344,6 @@ extern int16_t tiletovox[MAXTILES];
extern int32_t voxscale[MAXVOXELS];
extern char g_haveVoxels;
#ifdef USE_OPENGL
extern int32_t rendmode;
#endif
extern uint8_t globalr, globalg, globalb;
enum {
@ -367,15 +358,6 @@ extern const char *engineerrstr;
EXTERN int32_t editorzrange[2];
static FORCE_INLINE int32_t videoGetRenderMode(void)
{
#ifndef USE_OPENGL
return REND_CLASSIC;
#else
return rendmode;
#endif
}
enum {
ENGINECOMPATIBILITY_NONE = 0,
ENGINECOMPATIBILITY_19950829, // Powerslave/Exhumed
@ -744,7 +726,6 @@ EXTERN_CVAR(Bool, r_voxels)
extern int32_t r_downsize;
extern int32_t mdtims, omdtims;
extern int32_t glrendmode;
extern int32_t r_rortexture;
extern int32_t r_rortexturerange;

View file

@ -4,12 +4,9 @@
#include "mdsprite.h"
void Polymost_CacheHitList(uint8_t* hash);
typedef struct { uint8_t r, g, b, a; } coltype;
typedef struct { float r, g, b, a; } coltypef;
extern int32_t rendmode;
extern float gtang;
extern double gxyaspect;
extern float grhalfxdown10x;
@ -23,7 +20,6 @@ void polymost_outputGLDebugMessage(uint8_t severity, const char* format, ...);
void polymost_drawsprite(int32_t snum);
void polymost_drawmaskwall(int32_t damaskwallcnt);
void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, int8_t dashade, uint8_t dapalnum, int32_t dastat, uint8_t daalpha, uint8_t dablend, int32_t uniqid);
void polymost_fillpolygon(int32_t npoints);
void polymost_initosdfuncs(void);
void polymost_drawrooms(void);
void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang, fixed_t dahoriz, int16_t mirrorWall);

View file

@ -40,8 +40,6 @@
#endif
int32_t rendmode=0;
int32_t glrendmode = REND_POLYMOST;
int32_t r_rortexture = 0;
int32_t r_rortexturerange = 0;
int32_t r_rorphase = 0;
@ -327,10 +325,7 @@ static void renderDrawSprite(int32_t snum)
//
static void renderDrawMaskedWall(int16_t damaskwallcnt)
{
if (videoGetRenderMode() == REND_POLYMOST)
{
polymost_drawmaskwall(damaskwallcnt); return;
}
polymost_drawmaskwall(damaskwallcnt); return;
}
@ -1130,16 +1125,12 @@ static inline int32_t sameside(const _equation *eq, const vec2f_t *p1, c
static inline int comparetsprites(int const k, int const l)
{
#ifdef USE_OPENGL
if (videoGetRenderMode() == REND_POLYMOST)
{
if ((tspriteptr[k]->cstat & 48) != (tspriteptr[l]->cstat & 48))
return (tspriteptr[k]->cstat & 48) - (tspriteptr[l]->cstat & 48);
if ((tspriteptr[k]->cstat & 48) != (tspriteptr[l]->cstat & 48))
return (tspriteptr[k]->cstat & 48) - (tspriteptr[l]->cstat & 48);
if ((tspriteptr[k]->cstat & 48) == 16 && tspriteptr[k]->ang != tspriteptr[l]->ang)
return tspriteptr[k]->ang - tspriteptr[l]->ang;
if ((tspriteptr[k]->cstat & 48) == 16 && tspriteptr[k]->ang != tspriteptr[l]->ang)
return tspriteptr[k]->ang - tspriteptr[l]->ang;
}
#endif
if (tspriteptr[k]->statnum != tspriteptr[l]->statnum)
return tspriteptr[k]->statnum - tspriteptr[l]->statnum;
@ -1230,29 +1221,18 @@ void renderDrawMasks(void)
int32_t i = spritesortcnt-1;
int32_t numSprites = spritesortcnt;
#ifdef USE_OPENGL
if (videoGetRenderMode() == REND_POLYMOST)
spritesortcnt = 0;
int32_t back = i;
for (; i >= 0; --i)
{
spritesortcnt = 0;
int32_t back = i;
for (; i >= 0; --i)
if (polymost_spriteHasTranslucency(&tsprite[i]))
{
if (polymost_spriteHasTranslucency(&tsprite[i]))
{
tspriteptr[spritesortcnt] = &tsprite[i];
++spritesortcnt;
} else
{
tspriteptr[back] = &tsprite[i];
--back;
}
}
} else
#endif
{
for (; i >= 0; --i)
tspriteptr[spritesortcnt] = &tsprite[i];
++spritesortcnt;
} else
{
tspriteptr[i] = &tsprite[i];
tspriteptr[back] = &tsprite[i];
--back;
}
}
@ -1260,9 +1240,7 @@ void renderDrawMasks(void)
{
const int32_t xs = tspriteptr[i]->x-globalposx, ys = tspriteptr[i]->y-globalposy;
const int32_t yp = dmulscale6(xs,cosviewingrangeglobalang,ys,sinviewingrangeglobalang);
#ifdef USE_OPENGL
const int32_t modelp = polymost_spriteIsModelOrVoxel(tspriteptr[i]);
#endif
if (yp > (4<<8))
{
@ -1276,9 +1254,7 @@ void renderDrawMasks(void)
else if ((tspriteptr[i]->cstat&48) == 0)
{
killsprite:
#ifdef USE_OPENGL
if (!modelp)
#endif
{
//Delete face sprite if on wrong side!
if (i >= spritesortcnt)
@ -1315,81 +1291,76 @@ killsprite:
sortsprites(spritesortcnt, numSprites);
renderBeginScene();
#ifdef USE_OPENGL
if (videoGetRenderMode() == REND_POLYMOST)
GLInterface.EnableBlend(false);
GLInterface.EnableAlphaTest(true);
GLInterface.SetDepthBias(-2, -256);
if (spritesortcnt < numSprites)
{
GLInterface.EnableBlend(false);
GLInterface.EnableAlphaTest(true);
GLInterface.SetDepthBias(-2, -256);
if (spritesortcnt < numSprites)
i = spritesortcnt;
for (bssize_t i = spritesortcnt; i < numSprites;)
{
i = spritesortcnt;
for (bssize_t i = spritesortcnt; i < numSprites;)
int32_t py = spritesxyz[i].y;
int32_t pcstat = tspriteptr[i]->cstat & 48;
int32_t pangle = tspriteptr[i]->ang;
int j = i + 1;
if (!polymost_spriteIsModelOrVoxel(tspriteptr[i]))
{
int32_t py = spritesxyz[i].y;
int32_t pcstat = tspriteptr[i]->cstat & 48;
int32_t pangle = tspriteptr[i]->ang;
int j = i + 1;
if (!polymost_spriteIsModelOrVoxel(tspriteptr[i]))
while (j < numSprites && py == spritesxyz[j].y && pcstat == (tspriteptr[j]->cstat & 48) && (pcstat != 16 || pangle == tspriteptr[j]->ang)
&& !polymost_spriteIsModelOrVoxel(tspriteptr[j]))
{
while (j < numSprites && py == spritesxyz[j].y && pcstat == (tspriteptr[j]->cstat & 48) && (pcstat != 16 || pangle == tspriteptr[j]->ang)
&& !polymost_spriteIsModelOrVoxel(tspriteptr[j]))
{
j++;
}
j++;
}
if (j - i == 1)
{
debugmask_add(i | 32768, tspriteptr[i]->owner);
renderDrawSprite(i);
tspriteptr[i] = NULL;
}
else
{
GLInterface.SetDepthMask(false);
for (bssize_t k = j-1; k >= i; k--)
{
debugmask_add(k | 32768, tspriteptr[k]->owner);
renderDrawSprite(k);
}
GLInterface.SetDepthMask(true);
GLInterface.SetColorMask(false);
for (bssize_t k = j-1; k >= i; k--)
{
renderDrawSprite(k);
tspriteptr[k] = NULL;
}
GLInterface.SetColorMask(true);
}
i = j;
}
}
int32_t numMaskWalls = maskwallcnt;
maskwallcnt = 0;
for (i = 0; i < numMaskWalls; i++)
{
if (polymost_maskWallHasTranslucency((uwalltype *) &wall[thewall[maskwall[i]]]))
if (j - i == 1)
{
maskwall[maskwallcnt] = maskwall[i];
maskwallcnt++;
debugmask_add(i | 32768, tspriteptr[i]->owner);
renderDrawSprite(i);
tspriteptr[i] = NULL;
}
else
renderDrawMaskedWall(i);
}
{
GLInterface.SetDepthMask(false);
GLInterface.EnableBlend(true);
GLInterface.EnableAlphaTest(true);
GLInterface.SetDepthMask(false);
for (bssize_t k = j-1; k >= i; k--)
{
debugmask_add(k | 32768, tspriteptr[k]->owner);
renderDrawSprite(k);
}
GLInterface.SetDepthMask(true);
GLInterface.SetColorMask(false);
for (bssize_t k = j-1; k >= i; k--)
{
renderDrawSprite(k);
tspriteptr[k] = NULL;
}
GLInterface.SetColorMask(true);
}
i = j;
}
}
#endif
int32_t numMaskWalls = maskwallcnt;
maskwallcnt = 0;
for (i = 0; i < numMaskWalls; i++)
{
if (polymost_maskWallHasTranslucency((uwalltype *) &wall[thewall[maskwall[i]]]))
{
maskwall[maskwallcnt] = maskwall[i];
maskwallcnt++;
}
else
renderDrawMaskedWall(i);
}
GLInterface.EnableBlend(true);
GLInterface.EnableAlphaTest(true);
GLInterface.SetDepthMask(false);
vec2f_t pos;
@ -1401,8 +1372,7 @@ killsprite:
while (maskwallcnt)
{
// PLAG: sorting stuff
const int32_t w = (videoGetRenderMode()==REND_POLYMER) ?
maskwall[maskwallcnt-1] : thewall[maskwall[maskwallcnt-1]];
const int32_t w = thewall[maskwall[maskwallcnt-1]];
maskwallcnt--;
@ -1878,8 +1848,6 @@ int32_t videoSetGameMode(char davidoption, int32_t daupscaledxdim, int32_t daups
strcpy(kensmessage,"!!!! BUILD engine&tools programmed by Ken Silverman of E.G. RI."
" (c) Copyright 1995 Ken Silverman. Summary: BUILD = Ken. !!!!");
rendmode = REND_POLYMOST;
upscalefactor = 1;
xdim = daupscaledxdim;
ydim = daupscaledydim;

View file

@ -2452,8 +2452,6 @@ static void polymost_initmosts(const float * px, const float * py, int const n)
void polymost_drawrooms()
{
if (videoGetRenderMode() == REND_CLASSIC) return;
polymost_outputGLDebugMessage(3, "polymost_drawrooms()");
GLInterface.ClearDepth();
@ -3596,7 +3594,6 @@ void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype)
// basically this just means walls are repeating
// while sprites are clamped
if (videoGetRenderMode() < REND_POLYMOST) return;
if ((dapalnum < (MAXPALOOKUPS - RESERVEDPALS)) && (!lookups.checkTable(dapalnum))) return;//dapalnum = 0;
//Printf("precached %d %d type %d\n", dapicnum, dapalnum, datype);

View file

@ -624,7 +624,7 @@ int seq_PlotSequence(short nSprite, short edx, short nFrame, short ecx)
}
pTSprite->cstat = 0x22; // transluscence, floor sprite
pTSprite->z = videoGetRenderMode() >= REND_POLYMOST ? nFloorZ : nFloorZ + 1;
pTSprite->z = nFloorZ;
pTSprite->yrepeat = (uint8_t)edx;
pTSprite->xrepeat = (uint8_t)edx;
pTSprite->statnum = -3;

View file

@ -81,12 +81,11 @@ void animatesprites_d(int x, int y, int a, int smoothratio)
t->xrepeat = t->yrepeat = 0;
continue;
case CHAIR3:
/*
if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum) >= 0) {
if (hw_models && md_tilehasmodel(t->picnum, t->pal) >= 0)
{
t->cstat &= ~4;
break;
}
*/
k = (((t->ang + 3072 + 128 - a) & 2047) >> 8) & 7;
if (k > 4)
@ -279,10 +278,11 @@ void animatesprites_d(int x, int y, int a, int smoothratio)
t->picnum = GROWSPARK + ((ud.levelclock >> 4) & 3);
break;
case RPG:
/*if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) {
if (hw_models && md_tilehasmodel(s->picnum, s->pal) >= 0)
{
t->cstat &= ~4;
break;
}*/
}
k = getangle(s->x - x, s->y - y);
k = (((s->ang + 3072 + 128 - k) & 2047) / 170);
@ -296,10 +296,11 @@ void animatesprites_d(int x, int y, int a, int smoothratio)
break;
case RECON:
/*if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) {
if (hw_models && md_tilehasmodel(s->picnum, s->pal) >= 0)
{
t->cstat &= ~4;
break;
}*/
}
k = getangle(s->x - x, s->y - y);
if (h->temp_data[0] < 4)
@ -387,10 +388,13 @@ void animatesprites_d(int x, int y, int a, int smoothratio)
if (!h->GetOwner())
{
/*if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) {
if (hw_models && md_tilehasmodel(s->picnum, s->pal) >= 0)
{
k = 0;
t->cstat &= ~4;
} else*/ {
}
else
{
k = (((s->ang + 3072 + 128 - a) & 2047) >> 8) & 7;
if (k > 4)
{
@ -504,10 +508,13 @@ void animatesprites_d(int x, int y, int a, int smoothratio)
{
l = ScriptCode[t4 + 2];
/*if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) {
if (hw_models && md_tilehasmodel(s->picnum, s->pal) >= 0)
{
k = 0;
t->cstat &= ~4;
} else*/ switch (l) {
}
else switch (l)
{
case 2:
k = (((s->ang + 3072 + 128 - a) & 2047) >> 8) & 1;
break;
@ -599,25 +606,20 @@ void animatesprites_d(int x, int y, int a, int smoothratio)
shadowspr->z = daz;
shadowspr->pal = 4;
if (videoGetRenderMode() >= REND_POLYMOST)
if (hw_models && md_tilehasmodel(t->picnum, t->pal) >= 0)
{
/*
if (hw_models && md_tilehasmodel(t->picnum, t->pal) >= 0)
{
shadowspr->yrepeat = 0;
// 512:trans reverse
//1024:tell MD2SPRITE.C to use Z-buffer hacks to hide overdraw issues
shadowspr->clipdist |= TSPR_FLAGS_MDHACK;
shadowspr->cstat |= 512;
}
else
*/
{
// Alter the shadow's position so that it appears behind the sprite itself.
int look = getangle(shadowspr->x - ps[screenpeek].posx, shadowspr->y - ps[screenpeek].posy);
shadowspr->x += bcos(look, -9);
shadowspr->y += bsin(look, -9);
}
shadowspr->yrepeat = 0;
// 512:trans reverse
//1024:tell MD2SPRITE.C to use Z-buffer hacks to hide overdraw issues
shadowspr->clipdist |= TSPR_FLAGS_MDHACK;
shadowspr->cstat |= 512;
}
else
{
// Alter the shadow's position so that it appears behind the sprite itself.
int look = getangle(shadowspr->x - ps[screenpeek].posx, shadowspr->y - ps[screenpeek].posy);
shadowspr->x += bcos(look, -9);
shadowspr->y += bsin(look, -9);
}
spritesortcnt++;
}
@ -672,10 +674,13 @@ void animatesprites_d(int x, int y, int a, int smoothratio)
t->picnum += (s->shade >> 1);
break;
case PLAYERONWATER:
/*if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) {
if (hw_models && md_tilehasmodel(s->picnum, s->pal) >= 0)
{
k = 0;
t->cstat &= ~4;
} else*/ {
}
else
{
k = (((t->ang + 3072 + 128 - a) & 2047) >> 8) & 7;
if (k > 4)
{
@ -726,10 +731,11 @@ void animatesprites_d(int x, int y, int a, int smoothratio)
case CAMERA1:
case RAT:
/*if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) {
if (hw_models && md_tilehasmodel(s->picnum, s->pal) >= 0)
{
t->cstat &= ~4;
break;
}*/
}
k = (((t->ang + 3072 + 128 - a) & 2047) >> 8) & 7;
if (k > 4)

View file

@ -438,10 +438,12 @@ void animatesprites_r(int x, int y, int a, int smoothratio)
if (!h->GetOwner())
{
/*if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) {
if (hw_models && md_tilehasmodel(s->picnum, s->pal) >= 0)
{
k = 0;
t->cstat &= ~4;
} else*/ {
} else
{
k = (((s->ang + 3072 + 128 - a) & 2047) >> 8) & 7;
if (k > 4)
{
@ -642,10 +644,13 @@ void animatesprites_r(int x, int y, int a, int smoothratio)
{
l = ScriptCode[t4 + 2];
/*if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) {
if (hw_models && md_tilehasmodel(s->picnum, s->pal) >= 0)
{
k = 0;
t->cstat &= ~4;
} else*/ switch (l) {
}
else switch (l)
{
case 2:
k = (((s->ang + 3072 + 128 - a) & 2047) >> 8) & 1;
break;
@ -760,25 +765,20 @@ void animatesprites_r(int x, int y, int a, int smoothratio)
shadowspr->z = daz;
shadowspr->pal = 4;
if (videoGetRenderMode() >= REND_POLYMOST)
if (hw_models && md_tilehasmodel(t->picnum, t->pal) >= 0)
{
/*
if (hw_models && md_tilehasmodel(t->picnum, t->pal) >= 0)
{
shadowspr->yrepeat = 0;
// 512:trans reverse
//1024:tell MD2SPRITE.C to use Z-buffer hacks to hide overdraw issues
shadowspr->clipdist |= TSPR_FLAGS_MDHACK;
shadowspr->cstat |= 512;
}
else
*/
{
// Alter the shadow's position so that it appears behind the sprite itself.
int look = getangle(shadowspr->x - ps[screenpeek].posx, shadowspr->y - ps[screenpeek].posy);
shadowspr->x += bcos(look, -9);
shadowspr->y += bsin(look, -9);
}
shadowspr->yrepeat = 0;
// 512:trans reverse
//1024:tell MD2SPRITE.C to use Z-buffer hacks to hide overdraw issues
shadowspr->clipdist |= TSPR_FLAGS_MDHACK;
shadowspr->cstat |= 512;
}
else
{
// Alter the shadow's position so that it appears behind the sprite itself.
int look = getangle(shadowspr->x - ps[screenpeek].posx, shadowspr->y - ps[screenpeek].posy);
shadowspr->x += bcos(look, -9);
shadowspr->y += bsin(look, -9);
}
spritesortcnt++;
}

View file

@ -366,7 +366,6 @@ void renderSetVisibility(float vis)
void renderBeginScene()
{
if (videoGetRenderMode() < REND_POLYMOST) return;
assert(BufferLock == 0);
vp.mPalLightLevels = numshades | (static_cast<int>(gl_fogmode) << 8) | ((int)5 << 16);
@ -380,7 +379,6 @@ void renderBeginScene()
void renderFinishScene()
{
if (videoGetRenderMode() < REND_POLYMOST) return;
assert(BufferLock == 1);
if (--BufferLock == 0)
{

View file

@ -1045,7 +1045,7 @@ JAnalyzeSprites(tspriteptr_t tspr)
// Take care of autosizing
DoAutoSize(tspr);
if (videoGetRenderMode() >= REND_POLYMOST && md_tilehasmodel(tspr->picnum, 0) >= 0 && hw_models) return;
if (md_tilehasmodel(tspr->picnum, 0) >= 0 && hw_models) return;
// Check for voxels
//if (bVoxelsOn)