mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-10 14:52:08 +00:00
R_RecursiveWorldNode from DP, speed improvement..
This commit is contained in:
parent
8e64d0d3cc
commit
016f682389
1 changed files with 28 additions and 47 deletions
|
@ -914,29 +914,18 @@ R_RecursiveWorldNode
|
||||||
void R_RecursiveWorldNode (mnode_t *node)
|
void R_RecursiveWorldNode (mnode_t *node)
|
||||||
{
|
{
|
||||||
int c, side;
|
int c, side;
|
||||||
mplane_t *plane;
|
|
||||||
msurface_t *surf, **mark;
|
msurface_t *surf, **mark;
|
||||||
mleaf_t *pleaf;
|
mleaf_t *pleaf;
|
||||||
double dot;
|
double dot;
|
||||||
|
|
||||||
if (node->contents == CONTENTS_SOLID)
|
// if a leaf node, draw stuff
|
||||||
return; // solid
|
|
||||||
|
|
||||||
if (node->visframe != r_visframecount)
|
|
||||||
return;
|
|
||||||
if (R_CullBox (node->minmaxs, node->minmaxs+3))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// if a leaf node, draw stuff
|
|
||||||
if (node->contents < 0)
|
if (node->contents < 0)
|
||||||
{
|
{
|
||||||
pleaf = (mleaf_t *)node;
|
pleaf = (mleaf_t *)node;
|
||||||
|
|
||||||
mark = pleaf->firstmarksurface;
|
if ((c = pleaf->nummarksurfaces))
|
||||||
c = pleaf->nummarksurfaces;
|
|
||||||
|
|
||||||
if (c)
|
|
||||||
{
|
{
|
||||||
|
mark = pleaf->firstmarksurface;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
(*mark)->visframe = r_framecount;
|
(*mark)->visframe = r_framecount;
|
||||||
|
@ -951,74 +940,66 @@ void R_RecursiveWorldNode (mnode_t *node)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// node is just a decision point, so go down the apropriate sides
|
// node is just a decision point, so go down the apropriate sides
|
||||||
|
|
||||||
// find which side of the node we are on
|
// find which side of the node we are on
|
||||||
plane = node->plane;
|
switch (node->plane->type)
|
||||||
|
|
||||||
switch (plane->type)
|
|
||||||
{
|
{
|
||||||
case PLANE_X:
|
case PLANE_X:
|
||||||
dot = modelorg[0] - plane->dist;
|
dot = modelorg[0] - node->plane->dist;
|
||||||
break;
|
break;
|
||||||
case PLANE_Y:
|
case PLANE_Y:
|
||||||
dot = modelorg[1] - plane->dist;
|
dot = modelorg[1] - node->plane->dist;
|
||||||
break;
|
break;
|
||||||
case PLANE_Z:
|
case PLANE_Z:
|
||||||
dot = modelorg[2] - plane->dist;
|
dot = modelorg[2] - node->plane->dist;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dot = DotProduct (modelorg, plane->normal) - plane->dist;
|
dot = DotProduct (modelorg, node->plane->normal) - node->plane->dist;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
side = dot < 0;
|
side = dot < 0;
|
||||||
|
|
||||||
// recurse down the children, front side first
|
// recurse down the children, front side first
|
||||||
R_RecursiveWorldNode (node->children[side]);
|
// LordHavoc: save a stack frame by avoiding a call
|
||||||
|
if (node->children[side]->contents != CONTENTS_SOLID && node->children[side]->visframe == r_visframecount && !R_CullBox (node->children[side]->minmaxs, node->children[side]->minmaxs+3))
|
||||||
|
R_RecursiveWorldNode (node->children[side]);
|
||||||
|
|
||||||
// draw stuff
|
// draw stuff
|
||||||
c = node->numsurfaces;
|
if ((c = node->numsurfaces))
|
||||||
|
|
||||||
if (c)
|
|
||||||
{
|
{
|
||||||
surf = cl.worldmodel->surfaces + node->firstsurface;
|
surf = cl.worldmodel->surfaces + node->firstsurface;
|
||||||
|
|
||||||
if (dot < 0 -BACKFACE_EPSILON)
|
if (dot < -BACKFACE_EPSILON)
|
||||||
side = SURF_PLANEBACK;
|
side = SURF_PLANEBACK;
|
||||||
else if (dot > BACKFACE_EPSILON)
|
else if (dot > BACKFACE_EPSILON)
|
||||||
side = 0;
|
side = 0;
|
||||||
|
|
||||||
for ( ; c ; c--, surf++)
|
for ( ; c ; c--, surf++)
|
||||||
{
|
{
|
||||||
if (surf->visframe != r_framecount)
|
if (surf->visframe != r_framecount)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// don't backface underwater surfaces, because they warp
|
|
||||||
if ((dot < 0) ^ !!(surf->flags & SURF_PLANEBACK))
|
if ((dot < 0) ^ !!(surf->flags & SURF_PLANEBACK))
|
||||||
continue; // wrong side
|
continue; // wrong side
|
||||||
|
|
||||||
// if sorting by texture, just store it out
|
// if sorting by texture, just store it out
|
||||||
if (gl_texsort->value)
|
if (gl_texsort->value)
|
||||||
{
|
{
|
||||||
if (!mirror
|
surf->texturechain = surf->texinfo->texture->texturechain;
|
||||||
|| surf->texinfo->texture != cl.worldmodel->textures[mirrortexturenum])
|
surf->texinfo->texture->texturechain = surf;
|
||||||
{
|
|
||||||
surf->texturechain = surf->texinfo->texture->texturechain;
|
|
||||||
surf->texinfo->texture->texturechain = surf;
|
|
||||||
}
|
|
||||||
} else if (surf->flags & SURF_DRAWSKY) {
|
|
||||||
surf->texturechain = skychain;
|
|
||||||
skychain = surf;
|
|
||||||
} else if (surf->flags & SURF_DRAWTURB) {
|
|
||||||
surf->texturechain = waterchain;
|
|
||||||
waterchain = surf;
|
|
||||||
} else
|
|
||||||
R_DrawSequentialPoly (surf);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
R_DrawSequentialPoly (surf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// recurse down the back side
|
// recurse down the back side
|
||||||
R_RecursiveWorldNode (node->children[!side]);
|
// LordHavoc: save a stack frame by avoiding a call
|
||||||
|
side = !side;
|
||||||
|
if (node->children[side]->contents != CONTENTS_SOLID && node->children[side]->visframe == r_visframecount && !R_CullBox (node->children[side]->minmaxs, node->children[side]->minmaxs+3))
|
||||||
|
R_RecursiveWorldNode (node->children[side]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue