mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
Sprite sorting changes:
-Sort by owner now occurs only when two sprites have matching x/y coordinates. -Cstat 1024 now activates a special drawing mode that indicates a sprite should be drawn without depth after all other sprites have been drawn. The previous cstat 1024 functionality, an internal hack for shadows cast by models in Polymost, has been moved to bit 1 of a new graphical effects bitfield stored in a tsprite's .extra member. git-svn-id: https://svn.eduke32.com/eduke32@5400 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
aaa6f57e62
commit
7eec6b36a5
6 changed files with 205 additions and 180 deletions
|
@ -551,7 +551,7 @@ typedef struct {
|
|||
#define SPREXT_TSPRACCESS 16
|
||||
#define SPREXT_TEMPINVISIBLE 32
|
||||
|
||||
#define CSTAT_SPRITE_MDHACK 1024
|
||||
#define TSPR_EXTRA_MDHACK 1
|
||||
|
||||
EXTERN int32_t guniqhudid;
|
||||
EXTERN int32_t spritesortcnt;
|
||||
|
|
|
@ -944,7 +944,7 @@ static void yax_copytsprites()
|
|||
|
||||
Bmemcpy(&tsprite[spritesortcnt], spr, sizeof(spritetype));
|
||||
tsprite[spritesortcnt].owner = spritenum;
|
||||
|
||||
tsprite[spritesortcnt].extra = 0;
|
||||
tsprite[spritesortcnt].sectnum = sectnum; // potentially tweak sectnum!
|
||||
spritesortcnt++;
|
||||
}
|
||||
|
@ -2475,6 +2475,7 @@ int32_t engine_addtsprite(int16_t z, int16_t sectnum)
|
|||
return 1;
|
||||
|
||||
Bmemcpy(&tsprite[spritesortcnt], spr, sizeof(spritetype));
|
||||
tsprite[spritesortcnt].extra = 0;
|
||||
tsprite[spritesortcnt++].owner = z;
|
||||
|
||||
#ifdef YAX_ENABLE
|
||||
|
@ -9764,7 +9765,6 @@ killsprite:
|
|||
spritesxyz[i].y = yp;
|
||||
}
|
||||
|
||||
{
|
||||
int32_t gap, ys;
|
||||
|
||||
gap = 1; while (gap < spritesortcnt) gap = (gap<<1)+1;
|
||||
|
@ -9822,7 +9822,9 @@ killsprite:
|
|||
|
||||
for (int32_t k=i+1; k<j; k++)
|
||||
for (int32_t l=i; l<k; l++)
|
||||
if (tspriteptr[k]->owner < tspriteptr[l]->owner)
|
||||
if (tspriteptr[k]->x == tspriteptr[l]->x &&
|
||||
tspriteptr[k]->y == tspriteptr[l]->y &&
|
||||
tspriteptr[k]->owner < tspriteptr[l]->owner)
|
||||
{
|
||||
swapptr(&tspriteptr[k], &tspriteptr[l]);
|
||||
vec3_t tv3 = spritesxyz[k];
|
||||
|
@ -9832,7 +9834,6 @@ killsprite:
|
|||
}
|
||||
i = j;
|
||||
}
|
||||
}
|
||||
|
||||
begindrawing(); //{{{
|
||||
#if 0
|
||||
|
@ -9856,7 +9857,7 @@ killsprite:
|
|||
}
|
||||
}
|
||||
#endif
|
||||
{
|
||||
|
||||
vec2f_t pos;
|
||||
|
||||
pos.x = fglobalposx;
|
||||
|
@ -9892,7 +9893,7 @@ killsprite:
|
|||
while (i)
|
||||
{
|
||||
i--;
|
||||
if (tspriteptr[i] != NULL)
|
||||
if (tspriteptr[i] != NULL && (tspriteptr[i]->cstat & 1024) != 1024)
|
||||
{
|
||||
vec2f_t spr;
|
||||
const tspritetype *tspr = tspriteptr[i];
|
||||
|
@ -9974,16 +9975,38 @@ killsprite:
|
|||
drawmaskwall(maskwallcnt);
|
||||
}
|
||||
|
||||
i = spritesortcnt;
|
||||
|
||||
while (i)
|
||||
{
|
||||
i--;
|
||||
if (tspriteptr[i] != NULL && (tspriteptr[i]->cstat & 1024) != 1024)
|
||||
{
|
||||
debugmask_add(i | 32768, tspriteptr[i]->owner);
|
||||
drawsprite(i);
|
||||
tspriteptr[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
if (getrendermode() >= REND_POLYMOST)
|
||||
bglDepthMask(GL_FALSE);
|
||||
#endif
|
||||
|
||||
while (spritesortcnt)
|
||||
{
|
||||
spritesortcnt--;
|
||||
if (tspriteptr[spritesortcnt] != NULL)
|
||||
if (tspriteptr[spritesortcnt] != NULL && (tspriteptr[spritesortcnt]->cstat & 1024))
|
||||
{
|
||||
debugmask_add(spritesortcnt | 32768, tspriteptr[spritesortcnt]->owner);
|
||||
drawsprite(spritesortcnt);
|
||||
tspriteptr[spritesortcnt] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
if (getrendermode() >= REND_POLYMOST)
|
||||
bglDepthMask(GL_TRUE);
|
||||
#endif
|
||||
|
||||
#ifdef POLYMER
|
||||
if (getrendermode() == REND_POLYMER)
|
||||
|
|
|
@ -2138,7 +2138,7 @@ static int32_t polymost_md3draw(md3model_t *m, const tspritetype *tspr)
|
|||
// flat-tsprite-on-floor shadows.
|
||||
// is this still needed?
|
||||
|
||||
if (tspr->cstat&CSTAT_SPRITE_MDHACK)
|
||||
if (tspr->extra&TSPR_EXTRA_MDHACK)
|
||||
{
|
||||
#ifdef __arm__ // GL ES has a glDepthRangef and the loss of precision is OK there
|
||||
float f = (float) (tspr->owner + 1) * (FLT_EPSILON * 8.0);
|
||||
|
@ -2209,7 +2209,7 @@ static int32_t polymost_md3draw(md3model_t *m, const tspritetype *tspr)
|
|||
if (sext->offset.y) // Compare with SCREEN_FACTORS above
|
||||
a0.y = (float) sext->offset.y * f;
|
||||
|
||||
if ((sext->offset.z) && !(tspr->cstat&CSTAT_SPRITE_MDHACK)) // Compare with SCREEN_FACTORS above
|
||||
if ((sext->offset.z) && !(tspr->extra&TSPR_EXTRA_MDHACK)) // Compare with SCREEN_FACTORS above
|
||||
a0.z = (float)sext->offset.z / (655360.f * (m0.z+m1.z) * (gxyaspect*fxdimen*(1.f/1280.f)));
|
||||
|
||||
k0 = (float)sintable[(sext->pitch+512)&2047] * (1.f/16384.f);
|
||||
|
@ -2303,7 +2303,7 @@ static int32_t polymost_md3draw(md3model_t *m, const tspritetype *tspr)
|
|||
//i = mdloadskin((md2model *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,surfi); //hack for testing multiple surfaces per MD3
|
||||
bglBindTexture(GL_TEXTURE_2D, i);
|
||||
|
||||
if (!(tspr->cstat&CSTAT_SPRITE_MDHACK))
|
||||
if (!(tspr->extra&TSPR_EXTRA_MDHACK))
|
||||
{
|
||||
#ifndef EDUKE32_GLES
|
||||
i = r_detailmapping ? mdloadskin((md2model_t *) m, tile2model[Ptile2tile(tspr->picnum, lpal)].skinnum, DETAILPAL, surfi) : 0;
|
||||
|
|
|
@ -4659,7 +4659,7 @@ static void polymer_drawmdsprite(tspritetype *tspr)
|
|||
if (!mdspritematerial.diffusemap)
|
||||
continue;
|
||||
|
||||
if (!(tspr->cstat&CSTAT_SPRITE_MDHACK))
|
||||
if (!(tspr->extra&TSPR_EXTRA_MDHACK))
|
||||
{
|
||||
mdspritematerial.detailmap =
|
||||
mdloadskin((md2model_t *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,DETAILPAL,surfi);
|
||||
|
@ -4671,13 +4671,13 @@ static void polymer_drawmdsprite(tspritetype *tspr)
|
|||
mdspritematerial.detailscale[0] = mdspritematerial.detailscale[1] = sk->param;
|
||||
}
|
||||
|
||||
if (!(tspr->cstat&CSTAT_SPRITE_MDHACK))
|
||||
if (!(tspr->extra&TSPR_EXTRA_MDHACK))
|
||||
{
|
||||
mdspritematerial.specmap =
|
||||
mdloadskin((md2model_t *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,SPECULARPAL,surfi);
|
||||
}
|
||||
|
||||
if (!(tspr->cstat&CSTAT_SPRITE_MDHACK))
|
||||
if (!(tspr->extra&TSPR_EXTRA_MDHACK))
|
||||
{
|
||||
mdspritematerial.normalmap =
|
||||
mdloadskin((md2model_t *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,NORMALPAL,surfi);
|
||||
|
@ -4691,7 +4691,7 @@ static void polymer_drawmdsprite(tspritetype *tspr)
|
|||
}
|
||||
}
|
||||
|
||||
if (!(tspr->cstat&CSTAT_SPRITE_MDHACK))
|
||||
if (!(tspr->extra&TSPR_EXTRA_MDHACK))
|
||||
{
|
||||
mdspritematerial.glowmap =
|
||||
mdloadskin((md2model_t *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,GLOWPAL,surfi);
|
||||
|
|
|
@ -951,7 +951,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, const tspritetype *tspr)
|
|||
mat[12] = -mat[12];
|
||||
}
|
||||
|
||||
if (tspr->cstat&CSTAT_SPRITE_MDHACK)
|
||||
if (tspr->extra&TSPR_EXTRA_MDHACK)
|
||||
{
|
||||
bglDepthFunc(GL_LESS); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS
|
||||
// bglDepthRange(0.0, 0.9999);
|
||||
|
@ -1055,7 +1055,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, const tspritetype *tspr)
|
|||
//------------
|
||||
bglDisable(GL_CULL_FACE);
|
||||
// bglPopAttrib();
|
||||
if (tspr->cstat&CSTAT_SPRITE_MDHACK)
|
||||
if (tspr->extra&TSPR_EXTRA_MDHACK)
|
||||
{
|
||||
bglDepthFunc(GL_LESS); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS
|
||||
// bglDepthRange(0.0, 0.99999);
|
||||
|
|
|
@ -4181,6 +4181,7 @@ static void G_OROR_DupeSprites(const spritetype *sp)
|
|||
tsprite[spritesortcnt].z = tsprite[spritesortcnt].z - sp->z + actor[sp->yvel].ceilingz;
|
||||
tsprite[spritesortcnt].sectnum = refsp->sectnum;
|
||||
tsprite[spritesortcnt].owner = k;
|
||||
tsprite[spritesortcnt].extra = 0;
|
||||
|
||||
// OSD_Printf("duped sprite of pic %d at %d %d %d\n",tsprite[spritesortcnt].picnum,tsprite[spritesortcnt].x,tsprite[spritesortcnt].y,tsprite[spritesortcnt].z);
|
||||
spritesortcnt++;
|
||||
|
@ -7967,7 +7968,8 @@ skip:
|
|||
newt->yrepeat = 0;
|
||||
// 512:trans reverse
|
||||
//1024:tell MD2SPRITE.C to use Z-buffer hacks to hide overdraw issues
|
||||
newt->cstat |= (512+CSTAT_SPRITE_MDHACK);
|
||||
newt->extra |= TSPR_EXTRA_MDHACK;
|
||||
newt->cstat |= 512;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -8010,7 +8012,7 @@ skip:
|
|||
//g_restorePalette = 1; // JBF 20040101: why?
|
||||
}
|
||||
t->shade = -127;
|
||||
t->cstat |= 8192;
|
||||
t->cstat |= 8192+1024;
|
||||
break;
|
||||
case FIRE__STATIC:
|
||||
case FIRE2__STATIC:
|
||||
|
@ -8021,11 +8023,11 @@ skip:
|
|||
t->z = actor[t->owner].floorz;
|
||||
t->shade = -127;
|
||||
case SMALLSMOKE__STATIC:
|
||||
t->cstat |= 8192;
|
||||
t->cstat |= 8192+1024;
|
||||
break;
|
||||
case COOLEXPLOSION1__STATIC:
|
||||
t->shade = -127;
|
||||
t->cstat |= 8192;
|
||||
t->cstat |= 8192+1024;
|
||||
t->picnum += (s->shade>>1);
|
||||
break;
|
||||
case PLAYERONWATER__STATIC:
|
||||
|
|
Loading…
Reference in a new issue