mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-03 23:10:48 +00:00
160 lines
5.1 KiB
C++
160 lines
5.1 KiB
C++
|
|
#if 0
|
|
void polymost_drawsprite(int32_t snum)
|
|
{
|
|
|
|
vec2_t off = { 0, 0 };
|
|
|
|
if ((globalorientation & 48) != 48) // only non-voxel sprites should do this
|
|
{
|
|
int const flag = hw_hightile && TileFiles.tiledata[globalpicnum].h_xsize;
|
|
off = { (int32_t)tspr->xoffset + (flag ? TileFiles.tiledata[globalpicnum].h_xoffs : tileLeftOffset(globalpicnum)),
|
|
(int32_t)tspr->yoffset + (flag ? TileFiles.tiledata[globalpicnum].h_yoffs : tileTopOffset(globalpicnum)) };
|
|
}
|
|
|
|
int32_t method = DAMETH_MASK | DAMETH_CLAMPED;
|
|
|
|
if (tspr->cstat & 2)
|
|
method = DAMETH_CLAMPED | ((tspr->cstat & 512) ? DAMETH_TRANS2 : DAMETH_TRANS1);
|
|
|
|
SetRenderStyleFromBlend(!!(tspr->cstat & 2), tspr->blend, !!(tspr->cstat & 512));
|
|
|
|
drawpoly_alpha = spriteext[spritenum].alpha;
|
|
drawpoly_blend = tspr->blend;
|
|
|
|
sec = (usectorptr_t)§or[tspr->sectnum];
|
|
|
|
|
|
vec3_t pos = tspr->pos;
|
|
|
|
|
|
vec2_t tsiz;
|
|
|
|
if (hw_hightile && TileFiles.tiledata[globalpicnum].h_xsize)
|
|
tsiz = { TileFiles.tiledata[globalpicnum].h_xsize, TileFiles.tiledata[globalpicnum].h_ysize };
|
|
else
|
|
tsiz = { tileWidth(globalpicnum), tileHeight(globalpicnum) };
|
|
|
|
if (tsiz.x <= 0 || tsiz.y <= 0)
|
|
return;
|
|
|
|
vec2f_t const ftsiz = { (float) tsiz.x, (float) tsiz.y };
|
|
|
|
switch ((globalorientation >> 4) & 3)
|
|
{
|
|
case 0: // Face sprite
|
|
{
|
|
// Project 3D to 2D
|
|
if (globalorientation & 4)
|
|
off.x = -off.x;
|
|
// NOTE: yoff not negated not for y flipping, unlike wall and floor
|
|
// aligned sprites.
|
|
|
|
int const ang = (getangle(tspr->x - globalposx, tspr->y - globalposy) + 1024) & 2047;
|
|
|
|
float foffs = TSPR_OFFSET(tspr);
|
|
float foffs2 = TSPR_OFFSET(tspr);
|
|
if (fabs(foffs2) < fabs(foffs)) foffs = foffs2;
|
|
|
|
vec2f_t const offs = { float(bcosf(ang, -6) * foffs), float(bsinf(ang, -6) * foffs) };
|
|
|
|
vec2f_t s0 = { (float)(tspr->x - globalposx) + offs.x,
|
|
(float)(tspr->y - globalposy) + offs.y};
|
|
|
|
vec2f_t p0 = { s0.y * gcosang - s0.x * gsinang, s0.x * gcosang2 + s0.y * gsinang2 };
|
|
|
|
if (p0.y <= SCISDIST)
|
|
goto _drawsprite_return;
|
|
|
|
float const ryp0 = 1.f / p0.y;
|
|
s0 = { ghalfx * p0.x * ryp0 + ghalfx, ((float)(pos.z - globalposz)) * gyxscale * ryp0 + ghoriz };
|
|
|
|
float const f = ryp0 * fxdimen * (1.0f / 160.f);
|
|
|
|
vec2f_t ff = { ((float)tspr->xrepeat) * f,
|
|
((float)tspr->yrepeat) * f * ((float)yxaspect * (1.0f / 65536.f)) };
|
|
|
|
if (tsiz.x & 1)
|
|
s0.x += ff.x * 0.5f;
|
|
if (globalorientation & 128 && tsiz.y & 1)
|
|
s0.y += ff.y * 0.5f;
|
|
|
|
s0.x -= ff.x * (float) off.x;
|
|
s0.y -= ff.y * (float) off.y;
|
|
|
|
ff.x *= ftsiz.x;
|
|
ff.y *= ftsiz.y;
|
|
|
|
vec2f_t pxy[4];
|
|
|
|
pxy[0].x = pxy[3].x = s0.x - ff.x * 0.5f;
|
|
pxy[1].x = pxy[2].x = s0.x + ff.x * 0.5f;
|
|
if (!(globalorientation & 128))
|
|
{
|
|
pxy[0].y = pxy[1].y = s0.y - ff.y;
|
|
pxy[2].y = pxy[3].y = s0.y;
|
|
}
|
|
else
|
|
{
|
|
pxy[0].y = pxy[1].y = s0.y - ff.y * 0.5f;
|
|
pxy[2].y = pxy[3].y = s0.y + ff.y * 0.5f;
|
|
}
|
|
|
|
xtex.d = ytex.d = ytex.u = xtex.v = 0;
|
|
otex.d = ryp0 * gviewxrange;
|
|
|
|
if (!(globalorientation & 4))
|
|
{
|
|
xtex.u = ftsiz.x * otex.d / (pxy[1].x - pxy[0].x + .002f);
|
|
otex.u = -xtex.u * (pxy[0].x - .001f);
|
|
}
|
|
else
|
|
{
|
|
xtex.u = ftsiz.x * otex.d / (pxy[0].x - pxy[1].x - .002f);
|
|
otex.u = -xtex.u * (pxy[1].x + .001f);
|
|
}
|
|
|
|
if (!(globalorientation & 8))
|
|
{
|
|
ytex.v = ftsiz.y * otex.d / (pxy[3].y - pxy[0].y + .002f);
|
|
otex.v = -ytex.v * (pxy[0].y - .001f);
|
|
}
|
|
else
|
|
{
|
|
ytex.v = ftsiz.y * otex.d / (pxy[0].y - pxy[3].y - .002f);
|
|
otex.v = -ytex.v * (pxy[3].y + .001f);
|
|
}
|
|
|
|
// Clip sprites to ceilings/floors when no parallaxing and not sloped
|
|
if (!(sector[tspr->sectnum].ceilingstat & 3))
|
|
{
|
|
s0.y = ((float) (sector[tspr->sectnum].ceilingz - globalposz)) * gyxscale * ryp0 + ghoriz;
|
|
if (pxy[0].y < s0.y)
|
|
pxy[0].y = pxy[1].y = s0.y;
|
|
}
|
|
|
|
if (!(sector[tspr->sectnum].floorstat & 3))
|
|
{
|
|
s0.y = ((float) (sector[tspr->sectnum].floorz - globalposz)) * gyxscale * ryp0 + ghoriz;
|
|
if (pxy[2].y > s0.y)
|
|
pxy[2].y = pxy[3].y = s0.y;
|
|
}
|
|
|
|
vec2_16_t tempsiz = { (int16_t)tsiz.x, (int16_t)tsiz.y };
|
|
pow2xsplit = 0;
|
|
polymost_drawpoly(pxy, 4, method, tempsiz);
|
|
|
|
drawpoly_srepeat = 0;
|
|
drawpoly_trepeat = 0;
|
|
}
|
|
break;
|
|
|
|
}
|
|
|
|
if (automapping == 1 && (unsigned)spritenum < MAXSPRITES)
|
|
show2dsprite.Set(spritenum);
|
|
|
|
_drawsprite_return:
|
|
;
|
|
}
|
|
#endif
|