mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 00:41:55 +00:00
Implement rotate parameter for voxel definitions
# Conflicts: # source/build/include/build.h # source/build/include/mdsprite.h # source/build/src/defs.cpp
This commit is contained in:
parent
433fd62de5
commit
81f78c24b7
6 changed files with 33 additions and 15 deletions
|
@ -1449,6 +1449,9 @@ typedef struct
|
|||
|
||||
# define EXTRATILES (MAXTILES/8)
|
||||
|
||||
EXTERN intptr_t voxoff[MAXVOXELS][MAXVOXMIPS]; // used in KenBuild
|
||||
EXTERN int8_t voxreserve[(MAXVOXELS+7)>>3];
|
||||
EXTERN int8_t voxrotate[(MAXVOXELS+7)>>3];
|
||||
EXTERN int32_t mdinited;
|
||||
EXTERN tile2model_t tile2model[MAXTILES+EXTRATILES];
|
||||
|
||||
|
@ -1612,10 +1615,6 @@ extern int32_t(*saveboard_replace)(const char *filename, const vec3_t *dapos, in
|
|||
extern void(*PolymostProcessVoxels_Callback)(void);
|
||||
#endif
|
||||
|
||||
extern int32_t bloodhack;
|
||||
extern intptr_t voxoff[MAXVOXELS][MAXVOXMIPS]; // used in KenBuild
|
||||
extern int8_t voxreserve[(MAXVOXELS+7)>>3];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -203,6 +203,8 @@ typedef struct
|
|||
vec3_t siz;
|
||||
vec3f_t piv;
|
||||
int32_t is8bit;
|
||||
int8_t rotate;
|
||||
|
||||
} voxmodel_t;
|
||||
|
||||
EXTERN mdmodel_t **models;
|
||||
|
@ -213,7 +215,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]);
|
||||
EXTERN void md3_vox_calcmat_common(tspriteptr_t tspr, const vec3f_t *a0, float f, float mat[16], int32_t extraangoff = 0);
|
||||
|
||||
EXTERN int32_t mdpause;
|
||||
EXTERN int32_t nextmodelid;
|
||||
|
|
|
@ -121,10 +121,11 @@ enum scripttoken_t
|
|||
T_DST_COLOR, T_ONE_MINUS_DST_COLOR,
|
||||
T_SHADERED, T_SHADEGREEN, T_SHADEBLUE,
|
||||
T_SHADEFACTOR,
|
||||
T_RFFDEFINEID,
|
||||
T_IFCRC,
|
||||
T_EXTRA,
|
||||
T_NEWGAMECHOICES,
|
||||
T_RFFDEFINEID,
|
||||
T_EXTRA,
|
||||
T_ROTATE,
|
||||
};
|
||||
|
||||
static int32_t lastmodelid = -1, lastvoxid = -1, modelskin = -1, lastmodelskin = -1, seenframe = 0;
|
||||
|
@ -1854,6 +1855,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
{ "tile0", T_TILE0 },
|
||||
{ "tile1", T_TILE1 },
|
||||
{ "scale", T_SCALE },
|
||||
{ "rotate", T_ROTATE },
|
||||
};
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE(scriptfile_getstring(script,&fn)))
|
||||
|
@ -1916,6 +1918,14 @@ static int32_t defsparser(scriptfile *script)
|
|||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
case T_ROTATE:
|
||||
voxrotate[lastvoxid>>3] |= pow2char[lastvoxid&7];
|
||||
#ifdef USE_OPENGL
|
||||
if (voxmodels[lastvoxid])
|
||||
voxmodels[lastvoxid]->rotate = 1;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
lastvoxid = -1;
|
||||
|
|
|
@ -117,8 +117,6 @@ int32_t novoxmips = 1;
|
|||
#else
|
||||
# define DISTRECIPSIZ 131072
|
||||
#endif
|
||||
int8_t voxreserve[(MAXVOXELS+7)>>3];
|
||||
intptr_t voxoff[MAXVOXELS][MAXVOXMIPS]; // used in KenBuild
|
||||
static char voxlock[MAXVOXELS][MAXVOXMIPS];
|
||||
int32_t voxscale[MAXVOXELS];
|
||||
|
||||
|
@ -6210,6 +6208,9 @@ 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;
|
||||
|
||||
|
@ -8213,6 +8214,7 @@ int32_t engineInit(void)
|
|||
for (i=0; i<MAXTILES; i++)
|
||||
tiletovox[i] = -1;
|
||||
clearbuf(voxscale, sizeof(voxscale)>>2, 65536);
|
||||
clearbufbyte(voxrotate, sizeof(voxrotate), 0);
|
||||
|
||||
paletteloaded = 0;
|
||||
|
||||
|
@ -10435,6 +10437,7 @@ 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]);
|
||||
}
|
||||
}
|
||||
|
@ -10692,6 +10695,7 @@ void vox_undefine(int32_t const tile)
|
|||
voxoff[voxindex][j] = 0;
|
||||
}
|
||||
voxscale[voxindex] = 65536;
|
||||
voxrotate[voxindex>>3] &= ~pow2char[voxindex&7];
|
||||
tiletovox[tile] = -1;
|
||||
|
||||
// TODO: nextvoxid
|
||||
|
|
|
@ -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])
|
||||
void md3_vox_calcmat_common(tspriteptr_t tspr, const vec3f_t *a0, float f, float mat[16], int32_t extraangoff)
|
||||
{
|
||||
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+1024)&2047] * (1.f/16384.f);
|
||||
k5 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+ 512)&2047] * (1.f/16384.f);
|
||||
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);
|
||||
k2 = k0*(1-k4)+k1*k5;
|
||||
k3 = k1*(1-k4)-k0*k5;
|
||||
k6 = f*gstang - gsinang*gctang; k7 = g*gstang + gcosang*gctang;
|
||||
|
|
|
@ -881,6 +881,7 @@ 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*));
|
||||
}
|
||||
|
@ -1028,13 +1029,15 @@ 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+512)&2047]*(1.f/(64.f*16384.f));
|
||||
a0.x += tspr->xoffset*sintable[spriteext[tspr->owner].angoff&2047]*(1.f/(64.f*16384.f));
|
||||
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));
|
||||
}
|
||||
|
||||
if (globalorientation&8) { m0.z = -m0.z; a0.z = -a0.z; } //y-flipping
|
||||
|
@ -1068,7 +1071,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);
|
||||
md3_vox_calcmat_common(tspr, &a0, f, mat, rotateang);
|
||||
|
||||
//Mirrors
|
||||
if (grhalfxdown10x < 0)
|
||||
|
|
Loading…
Reference in a new issue