mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Merge branch 'sw-findplane-opt' into 'next'
R_FindPlane optimization See merge request STJr/SRB2!1199
This commit is contained in:
commit
0583eca009
2 changed files with 36 additions and 23 deletions
|
@ -60,7 +60,7 @@ INT32 numffloors;
|
|||
|
||||
//SoM: 3/23/2000: Boom visplane hashing routine.
|
||||
#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
|
||||
size_t maxopenings;
|
||||
|
@ -380,28 +380,30 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
|
|||
lightlevel = 0;
|
||||
}
|
||||
|
||||
// New visplane algorithm uses hash table
|
||||
hash = visplane_hash(picnum, lightlevel, height);
|
||||
|
||||
for (check = visplanes[hash]; check; check = check->next)
|
||||
if (!pfloor)
|
||||
{
|
||||
if (check->polyobj && pfloor)
|
||||
continue;
|
||||
if (polyobj != check->polyobj)
|
||||
continue;
|
||||
if (height == check->height && picnum == check->picnum
|
||||
&& lightlevel == check->lightlevel
|
||||
&& xoff == check->xoffs && yoff == check->yoffs
|
||||
&& planecolormap == check->extra_colormap
|
||||
&& !pfloor && !check->ffloor
|
||||
&& check->viewx == viewx && check->viewy == viewy && check->viewz == viewz
|
||||
&& check->viewangle == viewangle
|
||||
&& check->plangle == plangle
|
||||
&& check->slope == slope)
|
||||
hash = visplane_hash(picnum, lightlevel, height);
|
||||
for (check = visplanes[hash]; check; check = check->next)
|
||||
{
|
||||
return check;
|
||||
if (polyobj != check->polyobj)
|
||||
continue;
|
||||
if (height == check->height && picnum == check->picnum
|
||||
&& lightlevel == check->lightlevel
|
||||
&& xoff == check->xoffs && yoff == check->yoffs
|
||||
&& planecolormap == check->extra_colormap
|
||||
&& check->viewx == viewx && check->viewy == viewy && check->viewz == viewz
|
||||
&& check->viewangle == viewangle
|
||||
&& check->plangle == plangle
|
||||
&& check->slope == slope)
|
||||
{
|
||||
return check;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hash = MAXVISPLANES - 1;
|
||||
}
|
||||
|
||||
check = new_visplane(hash);
|
||||
|
||||
|
@ -471,9 +473,17 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop)
|
|||
}
|
||||
else /* Cannot use existing plane; create a new one */
|
||||
{
|
||||
unsigned hash =
|
||||
visplane_hash(pl->picnum, pl->lightlevel, pl->height);
|
||||
visplane_t *new_pl = new_visplane(hash);
|
||||
visplane_t *new_pl;
|
||||
if (pl->ffloor)
|
||||
{
|
||||
new_pl = new_visplane(MAXVISPLANES - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned hash =
|
||||
visplane_hash(pl->picnum, pl->lightlevel, pl->height);
|
||||
new_pl = new_visplane(hash);
|
||||
}
|
||||
|
||||
new_pl->height = pl->height;
|
||||
new_pl->picnum = pl->picnum;
|
||||
|
|
|
@ -19,7 +19,10 @@
|
|||
#include "r_textures.h"
|
||||
#include "p_polyobj.h"
|
||||
|
||||
#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)
|
||||
|
||||
//
|
||||
// Now what is a visplane, anyway?
|
||||
|
|
Loading…
Reference in a new issue