mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Simplify voxel rotation handling
# Conflicts: # source/build/include/mdsprite.h
This commit is contained in:
parent
c00ff59579
commit
61b4fae6e0
6 changed files with 14 additions and 21 deletions
|
@ -2290,15 +2290,20 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
|
||||||
nAnim--;
|
nAnim--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pTSprite->cstat&48) != 48)
|
if ((pTSprite->cstat&48) != 48 && usevoxels && videoGetRenderMode() != REND_POLYMER)
|
||||||
{
|
{
|
||||||
int nAnimTile = pTSprite->picnum + animateoffs_replace(pTSprite->picnum, 32768+pTSprite->owner);
|
int nAnimTile = pTSprite->picnum + animateoffs_replace(pTSprite->picnum, 32768+pTSprite->owner);
|
||||||
|
|
||||||
if (usevoxels && videoGetRenderMode() != REND_POLYMER && tiletovox[nAnimTile] != -1)
|
if (tiletovox[nAnimTile] != -1)
|
||||||
{
|
{
|
||||||
pTSprite->yoffset += picanm[nAnimTile].yofs;
|
pTSprite->yoffset += picanm[nAnimTile].yofs;
|
||||||
pTSprite->xoffset += picanm[nAnimTile].xofs;
|
pTSprite->xoffset += picanm[nAnimTile].xofs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int const nVoxel = tiletovox[pTSprite->picnum];
|
||||||
|
|
||||||
|
if (nVoxel != -1 && (voxrotate[nVoxel>>3]&pow2char[nVoxel&7]) != 0)
|
||||||
|
pTSprite->ang = (pTSprite->ang+((int)totalclock<<3))&2047;
|
||||||
}
|
}
|
||||||
|
|
||||||
sectortype *pSector = §or[pTSprite->sectnum];
|
sectortype *pSector = §or[pTSprite->sectnum];
|
||||||
|
|
|
@ -199,7 +199,6 @@ typedef struct
|
||||||
vec3_t siz;
|
vec3_t siz;
|
||||||
vec3f_t piv;
|
vec3f_t piv;
|
||||||
int32_t is8bit;
|
int32_t is8bit;
|
||||||
int8_t rotate;
|
|
||||||
|
|
||||||
} voxmodel_t;
|
} voxmodel_t;
|
||||||
|
|
||||||
|
@ -211,7 +210,7 @@ void mdinit(void);
|
||||||
void freeallmodels(void);
|
void freeallmodels(void);
|
||||||
void clearskins(int32_t type);
|
void clearskins(int32_t type);
|
||||||
int32_t polymost_mddraw(tspriteptr_t tspr);
|
int32_t polymost_mddraw(tspriteptr_t tspr);
|
||||||
EXTERN void md3_vox_calcmat_common(tspriteptr_t tspr, const vec3f_t *a0, float f, float mat[16], int32_t extraangoff = 0);
|
EXTERN void md3_vox_calcmat_common(tspriteptr_t tspr, const vec3f_t *a0, float f, float mat[16]);
|
||||||
|
|
||||||
EXTERN int32_t mdpause;
|
EXTERN int32_t mdpause;
|
||||||
EXTERN int32_t nextmodelid;
|
EXTERN int32_t nextmodelid;
|
||||||
|
|
|
@ -1921,10 +1921,6 @@ static int32_t defsparser(scriptfile *script)
|
||||||
|
|
||||||
case T_ROTATE:
|
case T_ROTATE:
|
||||||
voxrotate[lastvoxid>>3] |= pow2char[lastvoxid&7];
|
voxrotate[lastvoxid>>3] |= pow2char[lastvoxid&7];
|
||||||
#ifdef USE_OPENGL
|
|
||||||
if (voxmodels[lastvoxid])
|
|
||||||
voxmodels[lastvoxid]->rotate = 1;
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6195,9 +6195,6 @@ draw_as_face_sprite:
|
||||||
i = (int32_t)tspr->ang+1536;
|
i = (int32_t)tspr->ang+1536;
|
||||||
i += spriteext[spritenum].angoff;
|
i += spriteext[spritenum].angoff;
|
||||||
|
|
||||||
if (voxrotate[vtilenum>>3]&pow2char[vtilenum&7])
|
|
||||||
i += (int)totalclocklock<<3;
|
|
||||||
|
|
||||||
const int32_t ceilingz = (sec->ceilingstat&3) == 0 ? sec->ceilingz : INT32_MIN;
|
const int32_t ceilingz = (sec->ceilingstat&3) == 0 ? sec->ceilingz : INT32_MIN;
|
||||||
const int32_t floorz = (sec->floorstat&3) == 0 ? sec->floorz : INT32_MAX;
|
const int32_t floorz = (sec->floorstat&3) == 0 ? sec->floorz : INT32_MAX;
|
||||||
|
|
||||||
|
@ -10535,7 +10532,6 @@ static void PolymostProcessVoxels(void)
|
||||||
{
|
{
|
||||||
voxmodels[i] = voxload(voxfilenames[i]);
|
voxmodels[i] = voxload(voxfilenames[i]);
|
||||||
voxmodels[i]->scale = voxscale[i]*(1.f/65536.f);
|
voxmodels[i]->scale = voxscale[i]*(1.f/65536.f);
|
||||||
voxmodels[i]->rotate = (voxrotate[i>>3]>>(i&7))&1;
|
|
||||||
DO_FREE_AND_NULL(voxfilenames[i]);
|
DO_FREE_AND_NULL(voxfilenames[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1843,7 +1843,7 @@ int md3postload_polymer(md3model_t *m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void md3_vox_calcmat_common(tspriteptr_t tspr, const vec3f_t *a0, float f, float mat[16], int32_t extraangoff)
|
void md3_vox_calcmat_common(tspriteptr_t tspr, const vec3f_t *a0, float f, float mat[16])
|
||||||
{
|
{
|
||||||
float g;
|
float g;
|
||||||
float k0, k1, k2, k3, k4, k5, k6, k7;
|
float k0, k1, k2, k3, k4, k5, k6, k7;
|
||||||
|
@ -1852,8 +1852,8 @@ void md3_vox_calcmat_common(tspriteptr_t tspr, const vec3f_t *a0, float f, float
|
||||||
k1 = ((float)(tspr->y-globalposy))*f*(1.f/1024.f);
|
k1 = ((float)(tspr->y-globalposy))*f*(1.f/1024.f);
|
||||||
f = gcosang2*gshang/gvrcorrection;
|
f = gcosang2*gshang/gvrcorrection;
|
||||||
g = gsinang2*gshang/gvrcorrection;
|
g = gsinang2*gshang/gvrcorrection;
|
||||||
k4 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+extraangoff+1024)&2047] * (1.f/16384.f);
|
k4 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+1024)&2047] * (1.f/16384.f);
|
||||||
k5 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+extraangoff+ 512)&2047] * (1.f/16384.f);
|
k5 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+ 512)&2047] * (1.f/16384.f);
|
||||||
k2 = k0*(1-k4)+k1*k5;
|
k2 = k0*(1-k4)+k1*k5;
|
||||||
k3 = k1*(1-k4)-k0*k5;
|
k3 = k1*(1-k4)-k0*k5;
|
||||||
k6 = f*gstang - gsinang*gctang; k7 = g*gstang + gcosang*gctang;
|
k6 = f*gstang - gsinang*gctang; k7 = g*gstang + gcosang*gctang;
|
||||||
|
|
|
@ -881,7 +881,6 @@ voxmodel_t *voxload(const char *filnam)
|
||||||
vm->siz.x = voxsiz.x; vm->siz.y = voxsiz.y; vm->siz.z = voxsiz.z;
|
vm->siz.x = voxsiz.x; vm->siz.y = voxsiz.y; vm->siz.z = voxsiz.z;
|
||||||
vm->piv.x = voxpiv.x; vm->piv.y = voxpiv.y; vm->piv.z = voxpiv.z;
|
vm->piv.x = voxpiv.x; vm->piv.y = voxpiv.y; vm->piv.z = voxpiv.z;
|
||||||
vm->is8bit = is8bit;
|
vm->is8bit = is8bit;
|
||||||
vm->rotate = 0;
|
|
||||||
|
|
||||||
vm->texid = (FHardwareTexture * *)Xcalloc(MAXPALOOKUPS, sizeof(FHardwareTexture*));
|
vm->texid = (FHardwareTexture * *)Xcalloc(MAXPALOOKUPS, sizeof(FHardwareTexture*));
|
||||||
}
|
}
|
||||||
|
@ -1029,15 +1028,13 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
|
||||||
vec3f_t m0 = { m->scale, m->scale, m->scale };
|
vec3f_t m0 = { m->scale, m->scale, m->scale };
|
||||||
vec3f_t a0 = { 0, 0, m->zadd*m->scale };
|
vec3f_t a0 = { 0, 0, m->zadd*m->scale };
|
||||||
|
|
||||||
int32_t const rotateang = m->rotate ? (int32_t)totalclocklock<<3 : 0;
|
|
||||||
|
|
||||||
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+rotateang+512)&2047]*(1.f/(64.f*16384.f));
|
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+rotateang)&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&8) { m0.z = -m0.z; a0.z = -a0.z; } //y-flipping
|
||||||
|
@ -1071,7 +1068,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
|
||||||
m0.z *= g; a0.z = (((float)(k0 -globalposz - shadowHack)) * -(1.f/16384.f) + a0.z) * g;
|
m0.z *= g; a0.z = (((float)(k0 -globalposz - shadowHack)) * -(1.f/16384.f) + a0.z) * g;
|
||||||
|
|
||||||
float mat[16];
|
float mat[16];
|
||||||
md3_vox_calcmat_common(tspr, &a0, f, mat, rotateang);
|
md3_vox_calcmat_common(tspr, &a0, f, mat);
|
||||||
|
|
||||||
//Mirrors
|
//Mirrors
|
||||||
if (grhalfxdown10x < 0)
|
if (grhalfxdown10x < 0)
|
||||||
|
|
Loading…
Reference in a new issue