From 61b4fae6e0b292bc4374c034c8e4b018f43d4435 Mon Sep 17 00:00:00 2001 From: nukeykt Date: Mon, 30 Sep 2019 15:35:33 +0900 Subject: [PATCH] Simplify voxel rotation handling # Conflicts: # source/build/include/mdsprite.h --- source/blood/src/view.cpp | 9 +++++++-- source/build/include/mdsprite.h | 3 +-- source/build/src/defs.cpp | 4 ---- source/build/src/engine.cpp | 4 ---- source/build/src/mdsprite.cpp | 6 +++--- source/build/src/voxmodel.cpp | 9 +++------ 6 files changed, 14 insertions(+), 21 deletions(-) diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 16c72253e..22a06a242 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -2290,15 +2290,20 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t 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); - if (usevoxels && videoGetRenderMode() != REND_POLYMER && tiletovox[nAnimTile] != -1) + if (tiletovox[nAnimTile] != -1) { pTSprite->yoffset += picanm[nAnimTile].yofs; 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]; diff --git a/source/build/include/mdsprite.h b/source/build/include/mdsprite.h index 44bf5ceac..00d86560b 100644 --- a/source/build/include/mdsprite.h +++ b/source/build/include/mdsprite.h @@ -199,7 +199,6 @@ typedef struct vec3_t siz; vec3f_t piv; int32_t is8bit; - int8_t rotate; } voxmodel_t; @@ -211,7 +210,7 @@ void mdinit(void); void freeallmodels(void); void clearskins(int32_t type); 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 nextmodelid; diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index 648db8da8..0d7d58526 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -1921,10 +1921,6 @@ static int32_t defsparser(scriptfile *script) case T_ROTATE: voxrotate[lastvoxid>>3] |= pow2char[lastvoxid&7]; -#ifdef USE_OPENGL - if (voxmodels[lastvoxid]) - voxmodels[lastvoxid]->rotate = 1; -#endif break; } } diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 7d7a7d9fc..0df02c01f 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -6195,9 +6195,6 @@ draw_as_face_sprite: i = (int32_t)tspr->ang+1536; 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 floorz = (sec->floorstat&3) == 0 ? sec->floorz : INT32_MAX; @@ -10535,7 +10532,6 @@ static void PolymostProcessVoxels(void) { voxmodels[i] = voxload(voxfilenames[i]); voxmodels[i]->scale = voxscale[i]*(1.f/65536.f); - voxmodels[i]->rotate = (voxrotate[i>>3]>>(i&7))&1; DO_FREE_AND_NULL(voxfilenames[i]); } } diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index 94120e94b..22743fd9e 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -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 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); f = gcosang2*gshang/gvrcorrection; g = gsinang2*gshang/gvrcorrection; - k4 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+extraangoff+1024)&2047] * (1.f/16384.f); - k5 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+extraangoff+ 512)&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+ 512)&2047] * (1.f/16384.f); k2 = k0*(1-k4)+k1*k5; k3 = k1*(1-k4)-k0*k5; k6 = f*gstang - gsinang*gctang; k7 = g*gstang + gcosang*gctang; diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index 5b92b1751..cd64ae0a9 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -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->piv.x = voxpiv.x; vm->piv.y = voxpiv.y; vm->piv.z = voxpiv.z; vm->is8bit = is8bit; - vm->rotate = 0; 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 a0 = { 0, 0, m->zadd*m->scale }; - int32_t const rotateang = m->rotate ? (int32_t)totalclocklock<<3 : 0; - k0 = m->bscale / 64.f; f = (float) tspr->xrepeat * (256.f/320.f) * k0; if ((sprite[tspr->owner].cstat&48)==16) { f *= 1.25f; - a0.y -= tspr->xoffset*sintable[(spriteext[tspr->owner].angoff+rotateang+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.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 @@ -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; float mat[16]; - md3_vox_calcmat_common(tspr, &a0, f, mat, rotateang); + md3_vox_calcmat_common(tspr, &a0, f, mat); //Mirrors if (grhalfxdown10x < 0)