mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Engine memory reductions/optimizations:
-faketilesiz[MAXTILES] removed in favor of simple faketile[(MAXTILES+7)>>3] bitfield -h_xsize/h_ysize (tile size overrides from .def) are now uint16_t instead of int32_t -hudmem[2][MAXTILES] removed in favor of adding a hudmem ptr to mdmodel_t -tilefromtexture performance improvements -more tsectortype/twalltype usage in various engine functions that read but never write -continued Polymost cleanups and refactors. Please report any odd rendering errors. git-svn-id: https://svn.eduke32.com/eduke32@5079 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
d718d354c1
commit
9cb68410a0
7 changed files with 832 additions and 772 deletions
|
@ -817,7 +817,7 @@ EXTERN char gotsector[(MAXSECTORS+7)>>3];
|
|||
|
||||
EXTERN char editorcolors[256];
|
||||
|
||||
EXTERN int32_t faketilesiz[MAXTILES];
|
||||
EXTERN char faketile[(MAXTILES+7)>>3];
|
||||
EXTERN char *faketiledata[MAXTILES];
|
||||
|
||||
EXTERN char spritecol2d[MAXTILES][2];
|
||||
|
@ -849,7 +849,7 @@ extern int32_t usevoxels, voxscale[MAXVOXELS];
|
|||
extern int32_t usemodels, usehightile;
|
||||
extern int32_t rendmode;
|
||||
#endif
|
||||
EXTERN int32_t h_xsize[MAXTILES], h_ysize[MAXTILES];
|
||||
EXTERN uint16_t h_xsize[MAXTILES], h_ysize[MAXTILES];
|
||||
EXTERN int8_t h_xoffs[MAXTILES], h_yoffs[MAXTILES];
|
||||
|
||||
enum {
|
||||
|
@ -1313,14 +1313,19 @@ extern int32_t g_clipMapFilesNum;
|
|||
#endif
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
// TODO: dynamically allocate this
|
||||
|
||||
typedef struct { vec3f_t add; int16_t angadd, flags, fov; } hudtyp;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// maps build tiles to particular animation frames of a model
|
||||
int32_t modelid;
|
||||
int32_t skinnum;
|
||||
int32_t framenum; // calculate the number from the name when declaring
|
||||
float smoothduration;
|
||||
int32_t next;
|
||||
int16_t modelid;
|
||||
int16_t framenum; // calculate the number from the name when declaring
|
||||
int16_t nexttile;
|
||||
uint16_t smoothduration;
|
||||
hudtyp *hudmem[2];
|
||||
int8_t skinnum;
|
||||
char pal;
|
||||
} tile2model_t;
|
||||
|
||||
|
@ -1341,7 +1346,7 @@ int32_t md_defineanimation(int32_t modelid, const char *framestart, const char *
|
|||
int32_t fps, int32_t flags);
|
||||
int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32_t skinnum,
|
||||
int32_t surfnum, float param, float specpower, float specfactor);
|
||||
int32_t md_definehud (int32_t modelid, int32_t tilex, float xadd, float yadd, float zadd,
|
||||
int32_t md_definehud (int32_t modelid, int32_t tilex, vec3f_t add,
|
||||
int32_t angadd, int32_t flags, int32_t fov);
|
||||
int32_t md_undefinetile(int32_t tile);
|
||||
int32_t md_undefinemodel(int32_t modelid);
|
||||
|
|
|
@ -212,10 +212,6 @@ void clearskins(void);
|
|||
int32_t polymost_mddraw(const tspritetype *tspr);
|
||||
EXTERN void md3_vox_calcmat_common(const tspritetype *tspr, const vec3f_t *a0, float f, float mat[16]);
|
||||
|
||||
typedef struct { vec3f_t add; int16_t angadd, flags, fov; } hudtyp;
|
||||
|
||||
EXTERN hudtyp hudmem[2][MAXTILES];
|
||||
|
||||
EXTERN int32_t mdpause;
|
||||
EXTERN int32_t nextmodelid;
|
||||
EXTERN voxmodel_t *voxmodels[MAXVOXELS];
|
||||
|
|
|
@ -12,6 +12,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
typedef struct { uint8_t r, g, b, a; } coltype;
|
||||
typedef struct { float r, g, b, a; } coltypef;
|
||||
|
||||
extern int32_t rendmode;
|
||||
extern float gtang;
|
||||
|
|
|
@ -191,20 +191,24 @@ static void tile_from_truecolpic(int32_t tile, const palette_t *picptr, int32_t
|
|||
|
||||
faketiledata[tile] = (char *)Xmalloc(tsiz + 32);
|
||||
|
||||
for (i=siz.x-1; i>=0; i--)
|
||||
for (j = 0; j < siz.y; ++j)
|
||||
{
|
||||
uint32_t ofs = i * siz.y;
|
||||
|
||||
for (j=siz.y-1; j>=0; j--)
|
||||
int const ofs = j * siz.x;
|
||||
for (i = 0; i < siz.x; ++i)
|
||||
{
|
||||
const palette_t *col = &picptr[j*siz.x+i];
|
||||
if (col->f < alphacut) { faketilebuffer[ofs+j] = 255; continue; }
|
||||
faketilebuffer[ofs+j] = getclosestcol(col->b>>2, col->g>>2, col->r>>2);
|
||||
palette_t const *const col = &picptr[ofs + i];
|
||||
faketilebuffer[(i * siz.y) + j] =
|
||||
(col->f < alphacut) ? 255 : getclosestcol(col->b >> 2, col->g >> 2, col->r >> 2);
|
||||
}
|
||||
// initprintf(" %d %d %d %d\n",col->r,col->g,col->b,col->f);
|
||||
}
|
||||
|
||||
faketilesiz[tile] = LZ4_compress(faketilebuffer, faketiledata[tile], tsiz);
|
||||
if (LZ4_compress(faketilebuffer, faketiledata[tile], tsiz) != -1)
|
||||
faketile[tile>>3] |= pow2char[tile&7];
|
||||
else
|
||||
{
|
||||
DO_FREE_AND_NULL(faketiledata[tile]);
|
||||
faketile[tile>>3] &= ~pow2char[tile&7];
|
||||
}
|
||||
}
|
||||
|
||||
#undef USE_DEF_PROGRESS
|
||||
|
@ -397,7 +401,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
if (scriptfile_getdouble(script,&alpha)) break;
|
||||
#ifdef USE_OPENGL
|
||||
if ((uint32_t)tile < MAXTILES)
|
||||
alphahackarray[tile] = alpha * UINT8_MAX;
|
||||
alphahackarray[tile] = Blrintf(alpha * (float)UINT8_MAX);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
@ -418,7 +422,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
|
||||
#ifdef USE_OPENGL
|
||||
for (i=tilenume1; i<=tilenume2; i++)
|
||||
alphahackarray[i] = alpha * UINT8_MAX;
|
||||
alphahackarray[i] = Blrintf(alpha * (float)UINT8_MAX);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
@ -506,8 +510,10 @@ static int32_t defsparser(scriptfile *script)
|
|||
|
||||
if (scriptfile_getsymbol(script,&tile)) break;
|
||||
if ((unsigned)tile >= MAXUSERTILES) break;
|
||||
if (scriptfile_getsymbol(script,&h_xsize[tile])) break; // XXX
|
||||
if (scriptfile_getsymbol(script,&h_ysize[tile])) break;
|
||||
if (scriptfile_getsymbol(script,&tmp)) break; // XXX
|
||||
h_xsize[tile] = tmp;
|
||||
if (scriptfile_getsymbol(script,&tmp)) break;
|
||||
h_ysize[tile] = tmp;
|
||||
if (scriptfile_getsymbol(script,&tmp)) break;
|
||||
h_xoffs[tile]=tmp;
|
||||
if (scriptfile_getsymbol(script,&tmp)) break;
|
||||
|
@ -717,7 +723,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
{
|
||||
set_tilesiz(tile, xsiz, ysiz);
|
||||
Bmemset(&picanm[tile], 0, sizeof(picanm_t));
|
||||
faketilesiz[tile] = -1;
|
||||
faketile[tile>>3] |= pow2char[tile&7];
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -741,7 +747,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
{
|
||||
set_tilesiz(i, xsiz, ysiz);
|
||||
Bmemset(&picanm[i], 0, sizeof(picanm_t));
|
||||
faketilesiz[i] = -1;
|
||||
faketile[i>>3] |= pow2char[i&7];
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1074,6 +1080,12 @@ static int32_t defsparser(scriptfile *script)
|
|||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
if (smoothduration > 1.0)
|
||||
{
|
||||
initprintf("Warning: smoothduration out of range.\n");
|
||||
smoothduration = 1.0;
|
||||
}
|
||||
#ifdef USE_OPENGL
|
||||
for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++)
|
||||
{
|
||||
|
@ -1344,7 +1356,8 @@ static int32_t defsparser(scriptfile *script)
|
|||
#ifdef USE_OPENGL
|
||||
for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++)
|
||||
{
|
||||
switch (md_definehud(lastmodelid, tilex, xadd, yadd, zadd, angadd, flags, fov))
|
||||
vec3f_t const add = { (float)xadd, (float)yadd, (float)zadd };
|
||||
switch (md_definehud(lastmodelid, tilex, add, angadd, flags, fov))
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
|
@ -1903,7 +1916,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
{
|
||||
set_tilesiz(tile, xsiz, ysiz);
|
||||
Bmemset(&picanm[tile], 0, sizeof(picanm_t));
|
||||
faketilesiz[tile] = -1;
|
||||
faketile[tile>>3] |= pow2char[tile&7];
|
||||
}
|
||||
#ifdef USE_OPENGL
|
||||
xscale = 1.0f / xscale;
|
||||
|
|
|
@ -3041,32 +3041,31 @@ do_mvlineasm1:
|
|||
//
|
||||
int32_t wallfront(int32_t l1, int32_t l2)
|
||||
{
|
||||
vec2_t l1vect = *(vec2_t *)&wall[thewall[l1]];
|
||||
vec2_t l1p2vect = *(vec2_t *)&wall[wall[thewall[l1]].point2];
|
||||
vec2_t l2vect = *(vec2_t *)&wall[thewall[l2]];
|
||||
vec2_t l2p2vect = *(vec2_t *)&wall[wall[thewall[l2]].point2];
|
||||
int32_t dx = l1p2vect.x-l1vect.x;
|
||||
int32_t dy = l1p2vect.y-l1vect.y;
|
||||
int32_t t1 = dmulscale2(l2vect.x-l1vect.x, dy, -dx, l2vect.y-l1vect.y); //p1(l2) vs. l1
|
||||
int32_t t2 = dmulscale2(l2p2vect.x-l1vect.x, dy, -dx, l2p2vect.y-l1vect.y); //p2(l2) vs. l1
|
||||
vec2_t const l1vect = *(vec2_t *)&wall[thewall[l1]];
|
||||
vec2_t const l1p2vect = *(vec2_t *)&wall[wall[thewall[l1]].point2];
|
||||
vec2_t const l2vect = *(vec2_t *)&wall[thewall[l2]];
|
||||
vec2_t const l2p2vect = *(vec2_t *)&wall[wall[thewall[l2]].point2];
|
||||
vec2_t d = { l1p2vect.x - l1vect.x, l1p2vect.y - l1vect.y };
|
||||
int32_t t1 = dmulscale2(l2vect.x-l1vect.x, d.y, -d.x, l2vect.y-l1vect.y); //p1(l2) vs. l1
|
||||
int32_t t2 = dmulscale2(l2p2vect.x-l1vect.x, d.y, -d.x, l2p2vect.y-l1vect.y); //p2(l2) vs. l1
|
||||
|
||||
if (t1 == 0) { if (t2 == 0) return -1; t1 = t2; }
|
||||
if (t2 == 0) t2 = t1;
|
||||
|
||||
if ((t1^t2) >= 0) //pos vs. l1
|
||||
return (dmulscale2(globalposx-l1vect.x, dy, -dx, globalposy-l1vect.y) ^ t1) >= 0;
|
||||
return (dmulscale2(globalposx-l1vect.x, d.y, -d.x, globalposy-l1vect.y) ^ t1) >= 0;
|
||||
|
||||
dx = l2p2vect.x-l2vect.x;
|
||||
dy = l2p2vect.y-l2vect.y;
|
||||
d.x = l2p2vect.x-l2vect.x;
|
||||
d.y = l2p2vect.y-l2vect.y;
|
||||
|
||||
t1 = dmulscale2(l1vect.x-l2vect.x, dy, -dx, l1vect.y-l2vect.y); //p1(l1) vs. l2
|
||||
t2 = dmulscale2(l1p2vect.x-l2vect.x, dy, -dx, l1p2vect.y-l2vect.y); //p2(l1) vs. l2
|
||||
t1 = dmulscale2(l1vect.x-l2vect.x, d.y, -d.x, l1vect.y-l2vect.y); //p1(l1) vs. l2
|
||||
t2 = dmulscale2(l1p2vect.x-l2vect.x, d.y, -d.x, l1p2vect.y-l2vect.y); //p2(l1) vs. l2
|
||||
|
||||
if (t1 == 0) { if (t2 == 0) return -1; t1 = t2; }
|
||||
if (t2 == 0) t2 = t1;
|
||||
|
||||
if ((t1^t2) >= 0) //pos vs. l2
|
||||
return (dmulscale2(globalposx-l2vect.x,dy,-dx,globalposy-l2vect.y) ^ t1) < 0;
|
||||
return (dmulscale2(globalposx-l2vect.x,d.y,-d.x,globalposy-l2vect.y) ^ t1) < 0;
|
||||
|
||||
return -2;
|
||||
}
|
||||
|
@ -3076,11 +3075,11 @@ int32_t wallfront(int32_t l1, int32_t l2)
|
|||
//
|
||||
static inline int32_t spritewallfront(const tspritetype *s, int32_t w)
|
||||
{
|
||||
const walltype *const wal = &wall[w];
|
||||
const walltype *wal2 = &wall[wal->point2];
|
||||
const int32_t x1 = wal->x, y1 = wal->y;
|
||||
const twalltype *const wal = (twalltype *)&wall[w];
|
||||
const twalltype *wal2 = (twalltype *)&wall[wal->point2];
|
||||
const vec2_t v = { wal->x, wal->y };
|
||||
|
||||
return (dmulscale32(wal2->x-x1, s->y-y1, -(s->x-x1), wal2->y-y1) >= 0);
|
||||
return dmulscale32(wal2->x - v.x, s->y - v.y, -(s->x - v.x), wal2->y - v.y) >= 0;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -3140,20 +3139,28 @@ static int32_t spriteobstructswall(spritetype *s, int32_t w)
|
|||
//
|
||||
static inline int32_t bunchfront(int32_t b1, int32_t b2)
|
||||
{
|
||||
int32_t x1b1, x2b1, x1b2, x2b2, b1f, b2f, i;
|
||||
int b1f = bunchfirst[b1];
|
||||
int const x1b1 = xb1[b1f];
|
||||
int const x2b2 = xb2[bunchlast[b2]] + 1;
|
||||
|
||||
b1f = bunchfirst[b1]; x1b1 = xb1[b1f]; x2b2 = xb2[bunchlast[b2]]+1;
|
||||
if (x1b1 >= x2b2) return(-1);
|
||||
b2f = bunchfirst[b2]; x1b2 = xb1[b2f]; x2b1 = xb2[bunchlast[b1]]+1;
|
||||
if (x1b2 >= x2b1) return(-1);
|
||||
if (x1b1 >= x2b2)
|
||||
return (-1);
|
||||
|
||||
int b2f = bunchfirst[b2];
|
||||
int const x1b2 = xb1[b2f];
|
||||
int const x2b1 = xb2[bunchlast[b1]] + 1;
|
||||
|
||||
if (x1b2 >= x2b1)
|
||||
return (-1);
|
||||
|
||||
if (x1b1 >= x1b2)
|
||||
{
|
||||
for (i=b2f; xb2[i]<x1b1; i=bunchp2[i]);
|
||||
return(wallfront(b1f,i));
|
||||
for (; xb2[b2f] < x1b1; b2f = bunchp2[b2f]);
|
||||
return wallfront(b1f, b2f);
|
||||
}
|
||||
for (i=b1f; xb2[i]<x1b2; i=bunchp2[i]);
|
||||
return(wallfront(i,b2f));
|
||||
|
||||
for (; xb2[b1f] < x1b2; b1f = bunchp2[b1f]);
|
||||
return wallfront(b1f, b2f);
|
||||
}
|
||||
|
||||
|
||||
|
@ -8555,30 +8562,30 @@ void getclosestcol_flush(void)
|
|||
// <lastokcol> must be in [0 .. 255].
|
||||
int32_t getclosestcol_lim(int32_t r, int32_t g, int32_t b, int32_t lastokcol)
|
||||
{
|
||||
int32_t i, k, retcol = -1;
|
||||
int32_t mindist = -1;
|
||||
|
||||
const int32_t j = (r>>3)*FASTPALGRIDSIZ*FASTPALGRIDSIZ
|
||||
const int j = (r>>3)*FASTPALGRIDSIZ*FASTPALGRIDSIZ
|
||||
+ (g>>3)*FASTPALGRIDSIZ + (b>>3)
|
||||
+ FASTPALGRIDSIZ*FASTPALGRIDSIZ
|
||||
+ FASTPALGRIDSIZ+1;
|
||||
|
||||
uint32_t col;
|
||||
|
||||
#ifdef DEBUGGINGAIDS
|
||||
Bassert(lastokcol >= 0 && lastokcol <= 255);
|
||||
#endif
|
||||
|
||||
r = 64-r, g = 64-g, b = 64-b;
|
||||
|
||||
col = (r + (g<<8) + (b<<16));
|
||||
uint32_t col = (r + (g<<8) + (b<<16));
|
||||
int mindist = -1;
|
||||
|
||||
int const k = (numclosestcolresults > COLRESULTSIZ) ? (COLRESULTSIZ-4) : (numclosestcolresults-4);
|
||||
|
||||
if (!numclosestcolresults) goto skip;
|
||||
|
||||
if (col == (getclosestcol_results[(numclosestcolresults-1) & (COLRESULTSIZ-1)] & 0x00ffffff))
|
||||
return getclosestcol_results[(numclosestcolresults-1) & (COLRESULTSIZ-1)]>>24;
|
||||
|
||||
k = (numclosestcolresults > COLRESULTSIZ) ? (COLRESULTSIZ-4) : (numclosestcolresults-4);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < k; i+=4)
|
||||
for (i = 0; i < k+4; i+=4)
|
||||
{
|
||||
if (col == (getclosestcol_results[i] & 0x00ffffff)) { mindist = i; break; }
|
||||
if (col == (getclosestcol_results[i+1] & 0x00ffffff)) { mindist = i+1; break; }
|
||||
|
@ -8587,7 +8594,7 @@ int32_t getclosestcol_lim(int32_t r, int32_t g, int32_t b, int32_t lastokcol)
|
|||
}
|
||||
|
||||
if (mindist == -1)
|
||||
for (; i < k+4; i++)
|
||||
for (; i < k; i++)
|
||||
if (col == (getclosestcol_results[i] & 0x00ffffff)) { mindist = i; break; }
|
||||
|
||||
if (mindist != -1 && getclosestcol_results[mindist]>>24 < (unsigned)lastokcol)
|
||||
|
@ -8597,12 +8604,14 @@ skip:
|
|||
getclosestcol_results[numclosestcolresults & (COLRESULTSIZ-1)] = col;
|
||||
|
||||
mindist = min(rdist[coldist[r&7]+64+8], gdist[coldist[g&7]+64+8]);
|
||||
mindist = min(mindist, bdist[coldist[b&7]+64+8]);
|
||||
mindist++;
|
||||
mindist = min(mindist, bdist[coldist[b&7]+64+8]) + 1;
|
||||
|
||||
for (k=26; k>=0; k--)
|
||||
int retcol = -1;
|
||||
|
||||
for (int k=26; k>=0; k--)
|
||||
{
|
||||
i = colscan[k]+j;
|
||||
|
||||
if ((colhere[i>>3]&pow2char[i&7]) == 0)
|
||||
continue;
|
||||
|
||||
|
@ -8610,28 +8619,22 @@ skip:
|
|||
|
||||
do
|
||||
{
|
||||
const char *pal1 = (char *)&palette[i*3];
|
||||
int32_t dist = gdist[pal1[1]+g];
|
||||
char const * const pal1 = (char *)&palette[i*3];
|
||||
int dist = gdist[pal1[1]+g];
|
||||
|
||||
if (dist >= mindist || i > lastokcol) continue;
|
||||
if ((dist += rdist[pal1[0]+r]) >= mindist) continue;
|
||||
if ((dist += bdist[pal1[2]+b]) >= mindist) continue;
|
||||
|
||||
if (dist < mindist && i <= lastokcol)
|
||||
{
|
||||
dist += rdist[pal1[0]+r];
|
||||
if (dist >= mindist)
|
||||
continue;
|
||||
dist += bdist[pal1[2]+b];
|
||||
if (dist >= mindist)
|
||||
continue;
|
||||
mindist = dist;
|
||||
retcol = i;
|
||||
}
|
||||
}
|
||||
while ((i = colnext[i]) >= 0);
|
||||
}
|
||||
|
||||
if (retcol >= 0)
|
||||
{
|
||||
getclosestcol_results[numclosestcolresults & (COLRESULTSIZ-1)] |= retcol<<24;
|
||||
numclosestcolresults++;
|
||||
getclosestcol_results[numclosestcolresults++ & (COLRESULTSIZ-1)] |= retcol<<24;
|
||||
return retcol;
|
||||
}
|
||||
|
||||
|
@ -8639,17 +8642,18 @@ skip:
|
|||
|
||||
for (i=lastokcol; i>=0; i--)
|
||||
{
|
||||
const char *pal1 = (char *)&palette[i*3];
|
||||
char const * const pal1 = (char *)&palette[i*3];
|
||||
int dist = gdist[pal1[1]+g];
|
||||
|
||||
int32_t dist = gdist[pal1[1]+g]; if (dist >= mindist) continue;
|
||||
dist += rdist[pal1[0]+r]; if (dist >= mindist) continue;
|
||||
dist += bdist[pal1[2]+b]; if (dist >= mindist) continue;
|
||||
if (dist >= mindist) continue;
|
||||
if ((dist += rdist[pal1[0]+r]) >= mindist) continue;
|
||||
if ((dist += bdist[pal1[2]+b]) >= mindist) continue;
|
||||
|
||||
mindist = dist; retcol = i;
|
||||
mindist = dist;
|
||||
retcol = i;
|
||||
}
|
||||
|
||||
getclosestcol_results[numclosestcolresults & (COLRESULTSIZ-1)] |= retcol<<24;
|
||||
numclosestcolresults++;
|
||||
getclosestcol_results[numclosestcolresults++ & (COLRESULTSIZ-1)] |= retcol<<24;
|
||||
return retcol;
|
||||
}
|
||||
|
||||
|
@ -11956,7 +11960,7 @@ static int32_t E_ReadArtFile(int32_t tilefilei)
|
|||
{
|
||||
// Tiles having dummytile replacements or those that are
|
||||
// cache1d-locked can't be replaced.
|
||||
if (faketilesiz[i] || walock[i] >= 200)
|
||||
if (faketile[i>>3] & pow2char[i&7] || walock[i] >= 200)
|
||||
{
|
||||
initprintf("loadpics: per-map ART file \"%s\": "
|
||||
"tile %d has dummytile or is locked\n", fn, i);
|
||||
|
@ -12102,9 +12106,10 @@ void loadtile(int16_t tilenume)
|
|||
}
|
||||
|
||||
// dummy tiles for highres replacements and tilefromtexture definitions
|
||||
if (faketilesiz[tilenume])
|
||||
|
||||
if (faketile[tilenume>>3] & pow2char[tilenume&7])
|
||||
{
|
||||
if (faketilesiz[tilenume] != -1 && faketiledata[tilenume] != NULL)
|
||||
if (faketiledata[tilenume] != NULL)
|
||||
LZ4_decompress_fast(faketiledata[tilenume], (char *) waloff[tilenume], dasiz);
|
||||
|
||||
faketimerhandler();
|
||||
|
|
|
@ -52,25 +52,28 @@ static int32_t addtileP(int32_t model,int32_t tile,int32_t pallet)
|
|||
if (tile2model[tile].pal==pallet)
|
||||
return tile;
|
||||
|
||||
while (tile2model[tile].next!=-1)
|
||||
while (tile2model[tile].nexttile!=-1)
|
||||
{
|
||||
tile=tile2model[tile].next;
|
||||
tile=tile2model[tile].nexttile;
|
||||
if (tile2model[tile].pal==pallet)
|
||||
return tile;
|
||||
}
|
||||
|
||||
tile2model[tile].next=curextra;
|
||||
tile2model[tile].nexttile=curextra;
|
||||
tile2model[curextra].pal=pallet;
|
||||
|
||||
return curextra++;
|
||||
}
|
||||
int32_t Ptile2tile(int32_t tile,int32_t pallet)
|
||||
|
||||
int32_t Ptile2tile(int32_t tile,int32_t palette)
|
||||
{
|
||||
int32_t t=tile;
|
||||
// if(tile>=1550&&tile<=1589){initprintf("(%d, %d)\n",tile,pallet);pallet=0;}
|
||||
while ((tile=tile2model[tile].next)!=-1)
|
||||
if (tile2model[tile].pal==pallet)
|
||||
return tile;
|
||||
int t = tile;
|
||||
while ((tile = tile2model[tile].nexttile) != -1)
|
||||
if (tile2model[tile].pal == palette)
|
||||
{
|
||||
t = tile;
|
||||
break;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
|
@ -133,7 +136,10 @@ void freeallmodels()
|
|||
nextmodelid = 0;
|
||||
}
|
||||
|
||||
memset(tile2model,-1,sizeof(tile2model));
|
||||
Bmemset(tile2model,-1,sizeof(tile2model));
|
||||
for (i=0; i<MAXTILES; i++)
|
||||
Bmemset(tile2model[i].hudmem, 0, sizeof(tile2model[i].hudmem));
|
||||
|
||||
curextra=MAXTILES;
|
||||
|
||||
if (vertlist)
|
||||
|
@ -242,7 +248,6 @@ void clearskins()
|
|||
|
||||
void mdinit()
|
||||
{
|
||||
memset(hudmem,0,sizeof(hudmem));
|
||||
freeallmodels();
|
||||
mdinited = 1;
|
||||
}
|
||||
|
@ -335,7 +340,7 @@ int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume,
|
|||
tile2model[tilenume].modelid = modelid;
|
||||
tile2model[tilenume].framenum = i;
|
||||
tile2model[tilenume].skinnum = skinnum;
|
||||
tile2model[tilenume].smoothduration = smoothduration;
|
||||
tile2model[tilenume].smoothduration = Blrintf((float)UINT16_MAX * smoothduration);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
@ -520,19 +525,21 @@ int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t md_definehud(int32_t modelid, int32_t tilex, float xadd, float yadd, float zadd, int32_t angadd, int32_t flags, int32_t fov)
|
||||
int32_t md_definehud(int32_t modelid, int32_t tilex, vec3f_t add, int32_t angadd, int32_t flags, int32_t fov)
|
||||
{
|
||||
if (!mdinited) mdinit();
|
||||
|
||||
if ((uint32_t)modelid >= (uint32_t)nextmodelid) return -1;
|
||||
if ((uint32_t)tilex >= (uint32_t)MAXTILES) return -2;
|
||||
|
||||
hudmem[(flags>>2)&1][tilex].add.x = xadd;
|
||||
hudmem[(flags>>2)&1][tilex].add.y = yadd;
|
||||
hudmem[(flags>>2)&1][tilex].add.z = zadd;
|
||||
hudmem[(flags>>2)&1][tilex].angadd = ((int16_t)angadd)|2048;
|
||||
hudmem[(flags>>2)&1][tilex].flags = (int16_t)flags;
|
||||
hudmem[(flags>>2)&1][tilex].fov = (int16_t)fov;
|
||||
tile2model[tilex].hudmem[(flags>>2)&1] = (hudtyp *)Xmalloc(sizeof(hudtyp));
|
||||
|
||||
hudtyp * const hud = tile2model[tilex].hudmem[(flags>>2)&1];
|
||||
|
||||
hud->add = add;
|
||||
hud->angadd = ((int16_t)angadd)|2048;
|
||||
hud->flags = (int16_t)flags;
|
||||
hud->fov = (int16_t)fov;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -543,10 +550,7 @@ int32_t md_undefinetile(int32_t tile)
|
|||
if ((unsigned)tile >= (unsigned)MAXTILES) return -1;
|
||||
|
||||
tile2model[tile].modelid = -1;
|
||||
tile2model[tile].next=-1;
|
||||
hudmem[0][tile].angadd = 0;
|
||||
hudmem[1][tile].angadd = 0;
|
||||
|
||||
tile2model[tile].nexttile = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -560,7 +564,11 @@ int32_t md_undefinemodel(int32_t modelid)
|
|||
|
||||
for (i=MAXTILES+EXTRATILES-1; i>=0; i--)
|
||||
if (tile2model[i].modelid == modelid)
|
||||
{
|
||||
tile2model[i].modelid = -1;
|
||||
DO_FREE_AND_NULL(tile2model[i].hudmem[0]);
|
||||
DO_FREE_AND_NULL(tile2model[i].hudmem[1]);
|
||||
}
|
||||
|
||||
if (models)
|
||||
{
|
||||
|
@ -1013,7 +1021,9 @@ void updateanimation(md2model_t *m, const tspritetype *tspr, uint8_t lpal)
|
|||
return;
|
||||
}
|
||||
|
||||
fps = smooth->mdsmooth ? Blrintf((1.0f / (float) (tile2model[tile].smoothduration)) * 66.f) : anim->fpssc;
|
||||
fps = smooth->mdsmooth ?
|
||||
Blrintf((1.0f / ((float)tile2model[tile].smoothduration * (1.f / (float)UINT16_MAX))) * 66.f) :
|
||||
anim->fpssc;
|
||||
|
||||
i = (mdtims - sprext->mdanimtims)*((fps*timerticspersec)/120);
|
||||
|
||||
|
@ -2537,8 +2547,6 @@ void md_allocvbos(void)
|
|||
|
||||
int32_t polymost_mddraw(const tspritetype *tspr)
|
||||
{
|
||||
mdmodel_t *vm;
|
||||
|
||||
if (r_vbos && (r_vbocount > allocvbos))
|
||||
md_allocvbos();
|
||||
|
||||
|
@ -2548,7 +2556,8 @@ int32_t polymost_mddraw(const tspritetype *tspr)
|
|||
allocmodelverts = maxmodelverts;
|
||||
}
|
||||
|
||||
vm = models[tile2model[Ptile2tile(tspr->picnum,(tspr->owner >= MAXSPRITES) ? tspr->pal : sprite[tspr->owner].pal)].modelid];
|
||||
mdmodel_t const *const vm = models[tile2model[Ptile2tile(tspr->picnum,
|
||||
(tspr->owner >= MAXSPRITES) ? tspr->pal : sprite[tspr->owner].pal)].modelid];
|
||||
if (vm->mdnum == 1) { return polymost_voxdraw((voxmodel_t *)vm,tspr); }
|
||||
if (vm->mdnum == 3) { return polymost_md3draw((md3model_t *)vm,tspr); }
|
||||
return 0;
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue