mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 04:41:23 +00:00
R_FindPlane optimization from SRB2
This commit is contained in:
parent
a5ff1bd99d
commit
8ee560f216
1 changed files with 37 additions and 24 deletions
|
@ -46,7 +46,10 @@
|
||||||
//#define SHITPLANESPARENCY
|
//#define SHITPLANESPARENCY
|
||||||
|
|
||||||
//SoM: 3/23/2000: Use Boom visplane hashing.
|
//SoM: 3/23/2000: Use Boom visplane hashing.
|
||||||
#define MAXVISPLANES 512
|
#define VISPLANEHASHBITS 9
|
||||||
|
#define VISPLANEHASHMASK ((1<<VISPLANEHASHBITS)-1)
|
||||||
|
// the last visplane list is outside of the hash table and is used for fof planes
|
||||||
|
#define MAXVISPLANES ((1<<VISPLANEHASHBITS)+1)
|
||||||
|
|
||||||
static visplane_t *visplanes[MAXVISPLANES];
|
static visplane_t *visplanes[MAXVISPLANES];
|
||||||
static visplane_t *freetail;
|
static visplane_t *freetail;
|
||||||
|
@ -61,7 +64,7 @@ INT32 numffloors;
|
||||||
|
|
||||||
//SoM: 3/23/2000: Boom visplane hashing routine.
|
//SoM: 3/23/2000: Boom visplane hashing routine.
|
||||||
#define visplane_hash(picnum,lightlevel,height) \
|
#define visplane_hash(picnum,lightlevel,height) \
|
||||||
((unsigned)((picnum)*3+(lightlevel)+(height)*7) & (MAXVISPLANES-1))
|
((unsigned)((picnum)*3+(lightlevel)+(height)*7) & VISPLANEHASHMASK)
|
||||||
|
|
||||||
//SoM: 3/23/2000: Use boom opening limit removal
|
//SoM: 3/23/2000: Use boom opening limit removal
|
||||||
size_t maxopenings;
|
size_t maxopenings;
|
||||||
|
@ -466,20 +469,17 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
|
||||||
lightlevel = 0;
|
lightlevel = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// New visplane algorithm uses hash table
|
if (!pfloor)
|
||||||
|
{
|
||||||
hash = visplane_hash(picnum, lightlevel, height);
|
hash = visplane_hash(picnum, lightlevel, height);
|
||||||
|
|
||||||
for (check = visplanes[hash]; check; check = check->next)
|
for (check = visplanes[hash]; check; check = check->next)
|
||||||
{
|
{
|
||||||
if (check->polyobj && pfloor)
|
|
||||||
continue;
|
|
||||||
if (polyobj != check->polyobj)
|
if (polyobj != check->polyobj)
|
||||||
continue;
|
continue;
|
||||||
if (height == check->height && picnum == check->picnum
|
if (height == check->height && picnum == check->picnum
|
||||||
&& lightlevel == check->lightlevel
|
&& lightlevel == check->lightlevel
|
||||||
&& xoff == check->xoffs && yoff == check->yoffs
|
&& xoff == check->xoffs && yoff == check->yoffs
|
||||||
&& planecolormap == check->extra_colormap
|
&& planecolormap == check->extra_colormap
|
||||||
&& !pfloor && !check->ffloor
|
|
||||||
&& check->viewx == viewx && check->viewy == viewy && check->viewz == viewz
|
&& check->viewx == viewx && check->viewy == viewy && check->viewz == viewz
|
||||||
&& check->viewangle == viewangle
|
&& check->viewangle == viewangle
|
||||||
&& check->plangle == plangle
|
&& check->plangle == plangle
|
||||||
|
@ -489,6 +489,11 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
|
||||||
return check;
|
return check;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hash = MAXVISPLANES - 1;
|
||||||
|
}
|
||||||
|
|
||||||
check = new_visplane(hash);
|
check = new_visplane(hash);
|
||||||
|
|
||||||
|
@ -558,10 +563,18 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop)
|
||||||
pl->maxx = unionh;
|
pl->maxx = unionh;
|
||||||
}
|
}
|
||||||
else /* Cannot use existing plane; create a new one */
|
else /* Cannot use existing plane; create a new one */
|
||||||
|
{
|
||||||
|
visplane_t *new_pl;
|
||||||
|
if (pl->ffloor)
|
||||||
|
{
|
||||||
|
new_pl = new_visplane(MAXVISPLANES - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
unsigned hash =
|
unsigned hash =
|
||||||
visplane_hash(pl->picnum, pl->lightlevel, pl->height);
|
visplane_hash(pl->picnum, pl->lightlevel, pl->height);
|
||||||
visplane_t *new_pl = new_visplane(hash);
|
new_pl = new_visplane(hash);
|
||||||
|
}
|
||||||
|
|
||||||
new_pl->height = pl->height;
|
new_pl->height = pl->height;
|
||||||
new_pl->picnum = pl->picnum;
|
new_pl->picnum = pl->picnum;
|
||||||
|
|
Loading…
Reference in a new issue