mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-26 03:30:46 +00:00
Patch from Nuke.YKT to add support for the cstat flip bits to voxels in both software and Polymost
git-svn-id: https://svn.eduke32.com/eduke32@7723 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
1c3487444c
commit
2ce96f67be
3 changed files with 65 additions and 26 deletions
|
@ -42,6 +42,8 @@ enum rendmode_t {
|
||||||
#define PI 3.14159265358979323846
|
#define PI 3.14159265358979323846
|
||||||
#define fPI 3.14159265358979323846f
|
#define fPI 3.14159265358979323846f
|
||||||
|
|
||||||
|
#define BANG2RAD (fPI * (1.f/1024.f))
|
||||||
|
|
||||||
#define MAXSECTORSV8 4096
|
#define MAXSECTORSV8 4096
|
||||||
#define MAXWALLSV8 16384
|
#define MAXWALLSV8 16384
|
||||||
#define MAXSPRITESV8 16384
|
#define MAXSPRITESV8 16384
|
||||||
|
|
|
@ -4420,7 +4420,8 @@ typedef zint_t voxint_t;
|
||||||
//
|
//
|
||||||
static void classicDrawVoxel(int32_t dasprx, int32_t daspry, int32_t dasprz, int32_t dasprang,
|
static void classicDrawVoxel(int32_t dasprx, int32_t daspry, int32_t dasprz, int32_t dasprang,
|
||||||
int32_t daxscale, int32_t dayscale, int32_t daindex,
|
int32_t daxscale, int32_t dayscale, int32_t daindex,
|
||||||
int8_t dashade, char dapal, const int32_t *daumost, const int32_t *dadmost)
|
int8_t dashade, char dapal, const int32_t *daumost, const int32_t *dadmost,
|
||||||
|
const int8_t cstat)
|
||||||
{
|
{
|
||||||
int32_t i, j, k, x, y;
|
int32_t i, j, k, x, y;
|
||||||
|
|
||||||
|
@ -4469,7 +4470,8 @@ static void classicDrawVoxel(int32_t dasprx, int32_t daspry, int32_t dasprz, int
|
||||||
|
|
||||||
int32_t *longptr = (int32_t *)davoxptr;
|
int32_t *longptr = (int32_t *)davoxptr;
|
||||||
const int32_t daxsiz = B_LITTLE32(longptr[0]), daysiz = B_LITTLE32(longptr[1]), dazsiz = B_LITTLE32(longptr[2]);
|
const int32_t daxsiz = B_LITTLE32(longptr[0]), daysiz = B_LITTLE32(longptr[1]), dazsiz = B_LITTLE32(longptr[2]);
|
||||||
const int32_t daxpivot = B_LITTLE32(longptr[3]), daypivot = B_LITTLE32(longptr[4]);// dazpivot = B_LITTLE32(longptr[5]);
|
int32_t daxpivot = B_LITTLE32(longptr[3]), daypivot = B_LITTLE32(longptr[4]);// dazpivot = B_LITTLE32(longptr[5]);
|
||||||
|
if (cstat & 4) daxpivot = (daxsiz<<8)-daxpivot;
|
||||||
davoxptr += (6<<2);
|
davoxptr += (6<<2);
|
||||||
|
|
||||||
x = mulscale16(globalposx-dasprx, daxscalerecip);
|
x = mulscale16(globalposx-dasprx, daxscalerecip);
|
||||||
|
@ -4586,9 +4588,19 @@ static void classicDrawVoxel(int32_t dasprx, int32_t daspry, int32_t dasprz, int
|
||||||
x2 = gxinc+gyinc; y2 = gyinc-gxinc; break;
|
x2 = gxinc+gyinc; y2 = gyinc-gxinc; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char oand = pow2char[(xs<backx)+0] + pow2char[(ys<backy)+2];
|
char oand = pow2char[(xs<backx)+0] + pow2char[(ys<backy)+2];
|
||||||
const char oand16 = oand+16;
|
|
||||||
const char oand32 = oand+32;
|
if (cstat&4)
|
||||||
|
oand ^= 3;
|
||||||
|
|
||||||
|
char oand16 = oand+16;
|
||||||
|
char oand32 = oand+32;
|
||||||
|
|
||||||
|
if (cstat&8)
|
||||||
|
{
|
||||||
|
oand16 = oand+32;
|
||||||
|
oand32 = oand+16;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t dagxinc, dagyinc;
|
int32_t dagxinc, dagyinc;
|
||||||
|
|
||||||
|
@ -4604,8 +4616,9 @@ static void classicDrawVoxel(int32_t dasprx, int32_t daspry, int32_t dasprz, int
|
||||||
|
|
||||||
for (x=xs; x!=xe; x+=xi)
|
for (x=xs; x!=xe; x+=xi)
|
||||||
{
|
{
|
||||||
const intptr_t slabxoffs = (intptr_t)&davoxptr[B_LITTLE32(longptr[x])];
|
const int32_t xf = (cstat & 4) ? daxsiz-1-x : x;
|
||||||
int16_t *const shortptr = (int16_t *)&davoxptr[((x*(daysiz+1))<<1) + xyvoxoffs];
|
const intptr_t slabxoffs = (intptr_t)&davoxptr[B_LITTLE32(longptr[xf])];
|
||||||
|
int16_t *const shortptr = (int16_t *)&davoxptr[((xf*(daysiz+1))<<1) + xyvoxoffs];
|
||||||
|
|
||||||
voxint_t nx = mulscale16z(ggxstart+ggxinc[x], viewingrangerecip) + x1;
|
voxint_t nx = mulscale16z(ggxstart+ggxinc[x], viewingrangerecip) + x1;
|
||||||
voxint_t ny = ggystart + ggyinc[x];
|
voxint_t ny = ggystart + ggyinc[x];
|
||||||
|
@ -4646,7 +4659,11 @@ static void classicDrawVoxel(int32_t dasprx, int32_t daspry, int32_t dasprz, int
|
||||||
|
|
||||||
for (; voxptr<voxend; voxptr+=voxptr[1]+3)
|
for (; voxptr<voxend; voxptr+=voxptr[1]+3)
|
||||||
{
|
{
|
||||||
j = (voxptr[0]<<15)-syoff;
|
if (cstat&8)
|
||||||
|
j = dazsiz-voxptr[0]-voxptr[1];
|
||||||
|
else
|
||||||
|
j = voxptr[0];
|
||||||
|
j = (j<<15)-syoff;
|
||||||
|
|
||||||
if (j < 0)
|
if (j < 0)
|
||||||
{
|
{
|
||||||
|
@ -4687,6 +4704,11 @@ static void classicDrawVoxel(int32_t dasprx, int32_t daspry, int32_t dasprz, int
|
||||||
|
|
||||||
if (z1 < daumost[lx]) { yplc = yinc*(daumost[lx]-z1); z1 = daumost[lx]; }
|
if (z1 < daumost[lx]) { yplc = yinc*(daumost[lx]-z1); z1 = daumost[lx]; }
|
||||||
else yplc = 0;
|
else yplc = 0;
|
||||||
|
|
||||||
|
if (cstat & 8)
|
||||||
|
yinc = -yinc;
|
||||||
|
if (cstat & 8)
|
||||||
|
yplc = ((voxptr[1])<<16) - yplc + yinc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (z2 > dadmost[lx])
|
if (z2 > dadmost[lx])
|
||||||
|
@ -5785,9 +5807,27 @@ draw_as_face_sprite:
|
||||||
nyrepeat = ((int32_t)tspr->yrepeat)*voxscale[vtilenum];
|
nyrepeat = ((int32_t)tspr->yrepeat)*voxscale[vtilenum];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cstat&128)) tspr->z -= mulscale22(B_LITTLE32(longptr[5]),nyrepeat);
|
if (!(cstat&128))
|
||||||
|
{
|
||||||
|
if (cstat&8)
|
||||||
|
tspr->z += mulscale22(B_LITTLE32(longptr[5]),nyrepeat);
|
||||||
|
else
|
||||||
|
tspr->z -= mulscale22(B_LITTLE32(longptr[5]),nyrepeat);
|
||||||
|
}
|
||||||
|
off.x = tspr->xoffset;
|
||||||
off.y = /*picanm[sprite[tspr->owner].picnum].yofs +*/ tspr->yoffset;
|
off.y = /*picanm[sprite[tspr->owner].picnum].yofs +*/ tspr->yoffset;
|
||||||
tspr->z -= mulscale14(off.y,nyrepeat);
|
if (cstat & 4) off.x = -off.x;
|
||||||
|
if (cstat & 8) off.y = -off.y;
|
||||||
|
tspr->z -= off.y * tspr->yrepeat << 2;
|
||||||
|
|
||||||
|
if ((sprite[spritenum].cstat&CSTAT_SPRITE_ALIGNMENT) == CSTAT_SPRITE_ALIGNMENT_WALL)
|
||||||
|
{
|
||||||
|
const int32_t xv = tspr->xrepeat*sintable[(tspr->ang+2560+1536)&2047];
|
||||||
|
const int32_t yv = tspr->xrepeat*sintable[(tspr->ang+2048+1536)&2047];
|
||||||
|
|
||||||
|
tspr->x -= mulscale16(xv, off.x);
|
||||||
|
tspr->y -= mulscale16(yv, off.x);
|
||||||
|
}
|
||||||
|
|
||||||
globvis = globalvisibility;
|
globvis = globalvisibility;
|
||||||
if (sec->visibility != 0) globvis = mulscale4(globvis, (uint8_t)(sec->visibility+16));
|
if (sec->visibility != 0) globvis = mulscale4(globvis, (uint8_t)(sec->visibility+16));
|
||||||
|
@ -5847,7 +5887,7 @@ draw_as_face_sprite:
|
||||||
|
|
||||||
i = (int32_t)tspr->ang+1536;
|
i = (int32_t)tspr->ang+1536;
|
||||||
i += spriteext[spritenum].angoff;
|
i += spriteext[spritenum].angoff;
|
||||||
classicDrawVoxel(tspr->x,tspr->y,tspr->z,i,daxrepeat,(int32_t)tspr->yrepeat,vtilenum,tspr->shade,tspr->pal,lwall,swall);
|
classicDrawVoxel(tspr->x,tspr->y,tspr->z,i,daxrepeat,(int32_t)tspr->yrepeat,vtilenum,tspr->shade,tspr->pal,lwall,swall,cstat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7214,8 +7254,6 @@ static inline void calcbritable(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BANG2RAD (fPI * (1.f/1024.f))
|
|
||||||
|
|
||||||
static int32_t engineLoadTables(void)
|
static int32_t engineLoadTables(void)
|
||||||
{
|
{
|
||||||
static char tablesloaded = 0;
|
static char tablesloaded = 0;
|
||||||
|
|
|
@ -1026,20 +1026,19 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
|
||||||
//updateanimation((md2model *)m,tspr);
|
//updateanimation((md2model *)m,tspr);
|
||||||
|
|
||||||
vec3f_t m0 = { m->scale, m->scale, m->scale };
|
vec3f_t m0 = { m->scale, m->scale, m->scale };
|
||||||
vec3f_t a0 = { 0, 0, ((globalorientation&8) ? -m->zadd : m->zadd)*m->scale };
|
vec3f_t a0 = { 0, 0, m->zadd*m->scale };
|
||||||
|
|
||||||
//if (globalorientation&8) //y-flipping
|
|
||||||
//{
|
|
||||||
// m0.z = -m0.z; a0.z = -a0.z;
|
|
||||||
// //Add height of 1st frame (use same frame to prevent animation bounce)
|
|
||||||
// a0.z += m->zsiz*m->scale;
|
|
||||||
//}
|
|
||||||
//if (globalorientation&4) { m0.y = -m0.y; a0.y = -a0.y; } //x-flipping
|
|
||||||
|
|
||||||
k0 = m->bscale / 64.f;
|
k0 = m->bscale / 64.f;
|
||||||
f = (float) tspr->xrepeat * (256.f/320.f) * k0;
|
f = (float) tspr->xrepeat * (256.f/320.f) * k0;
|
||||||
if ((sprite[tspr->owner].cstat&48)==16)
|
if ((sprite[tspr->owner].cstat&48)==16)
|
||||||
|
{
|
||||||
f *= 1.25f;
|
f *= 1.25f;
|
||||||
|
a0.y -= tspr->xoffset*sintable[(spriteext[tspr->owner].angoff+512)&2047]*(1.f/(64.f*16384.f));
|
||||||
|
a0.x += tspr->xoffset*sintable[spriteext[tspr->owner].angoff&2047]*(1.f/(64.f*16384.f));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (globalorientation&8) { m0.z = -m0.z; a0.z = -a0.z; } //y-flipping
|
||||||
|
if (globalorientation&4) { m0.x = -m0.x; a0.x = -a0.x; a0.y = -a0.y; } //x-flipping
|
||||||
|
|
||||||
m0.x *= f; a0.x *= f; f = -f;
|
m0.x *= f; a0.x *= f; f = -f;
|
||||||
m0.y *= f; a0.y *= f;
|
m0.y *= f; a0.y *= f;
|
||||||
|
@ -1047,9 +1046,9 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
|
||||||
m0.z *= f; a0.z *= f;
|
m0.z *= f; a0.z *= f;
|
||||||
|
|
||||||
k0 = (float) tspr->z;
|
k0 = (float) tspr->z;
|
||||||
k0 -= ((tspr->yoffset * tspr->yrepeat) << 2) * m->bscale;
|
f = (globalorientation&8) ? -4.f : 4.f;
|
||||||
if (!(tspr->cstat & 128))
|
k0 -= (tspr->yoffset*tspr->yrepeat)*f*m->bscale;
|
||||||
k0 -= (tspr->yrepeat << 2) * m->piv.z * m->bscale;
|
if (!(tspr->cstat&128)) k0 -= (m->piv.z*tspr->yrepeat)*f*m->scale;
|
||||||
|
|
||||||
f = (65536.f*512.f) / ((float)xdimen*viewingrange);
|
f = (65536.f*512.f) / ((float)xdimen*viewingrange);
|
||||||
g = 32.f / ((float)xdimen*gxyaspect);
|
g = 32.f / ((float)xdimen*gxyaspect);
|
||||||
|
@ -1078,7 +1077,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
|
||||||
|
|
||||||
// glPushAttrib(GL_POLYGON_BIT);
|
// glPushAttrib(GL_POLYGON_BIT);
|
||||||
|
|
||||||
if ((grhalfxdown10x >= 0) /*^ ((globalorientation&8) != 0) ^ ((globalorientation&4) != 0)*/)
|
if ((grhalfxdown10x >= 0) ^ ((globalorientation&8) != 0) ^ ((globalorientation&4) != 0))
|
||||||
glFrontFace(GL_CW);
|
glFrontFace(GL_CW);
|
||||||
else
|
else
|
||||||
glFrontFace(GL_CCW);
|
glFrontFace(GL_CCW);
|
||||||
|
|
Loading…
Reference in a new issue