mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-08 16:52:10 +00:00
Use more short code in *EdgeSearch
This commit is contained in:
parent
466364589d
commit
e5ef665e09
3 changed files with 61 additions and 71 deletions
|
@ -223,17 +223,6 @@ typedef struct finalvert_s {
|
||||||
float xyz[3]; // eye space
|
float xyz[3]; // eye space
|
||||||
} finalvert_t;
|
} finalvert_t;
|
||||||
|
|
||||||
#define FINALVERT_V0 0
|
|
||||||
#define FINALVERT_V1 4
|
|
||||||
#define FINALVERT_V2 8
|
|
||||||
#define FINALVERT_V3 12
|
|
||||||
#define FINALVERT_V4 16
|
|
||||||
#define FINALVERT_V5 20
|
|
||||||
#define FINALVERT_FLAGS 24
|
|
||||||
#define FINALVERT_X 28
|
|
||||||
#define FINALVERT_Y 32
|
|
||||||
#define FINALVERT_Z 36
|
|
||||||
#define FINALVERT_SIZE 40
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
|
@ -302,41 +302,34 @@ R_LeadingEdgeBackwards (edge_t *edge)
|
||||||
|
|
||||||
surf2 = surfaces[1].next;
|
surf2 = surfaces[1].next;
|
||||||
|
|
||||||
if (surf->key > surf2->key)
|
|
||||||
goto newtop;
|
|
||||||
|
|
||||||
// if it's two surfaces on the same plane, the one that's already
|
// if it's two surfaces on the same plane, the one that's already
|
||||||
// active is in front, so keep going unless it's a bmodel
|
// active is in front, so keep going unless it's a bmodel
|
||||||
if (surf->insubmodel && (surf->key == surf2->key))
|
|
||||||
{
|
|
||||||
// must be two bmodels in the same leaf; don't care, because they'll
|
// must be two bmodels in the same leaf; don't care, because they'll
|
||||||
// never be farthest anyway
|
// never be farthest anyway
|
||||||
goto newtop;
|
if (surf->key > surf2->key || (surf->insubmodel && (surf->key == surf2->key))) {
|
||||||
|
// emit a span (obscures current top)
|
||||||
|
iu = edge->u >> shift_size;
|
||||||
|
|
||||||
|
if (iu > surf2->last_u)
|
||||||
|
{
|
||||||
|
espan_t *span;
|
||||||
|
|
||||||
|
span = span_p++;
|
||||||
|
span->u = surf2->last_u;
|
||||||
|
span->count = iu - span->u;
|
||||||
|
span->v = current_iv;
|
||||||
|
span->pnext = surf2->spans;
|
||||||
|
surf2->spans = span;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set last_u on the new span
|
||||||
|
surf->last_u = iu;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
surf2 = D_SurfSearchBackwards(surf, surf2);
|
|
||||||
|
|
||||||
goto gotposition;
|
|
||||||
newtop:
|
|
||||||
// emit a span (obscures current top)
|
|
||||||
iu = edge->u >> shift_size;
|
|
||||||
|
|
||||||
if (iu > surf2->last_u)
|
|
||||||
{
|
{
|
||||||
espan_t *span;
|
surf2 = D_SurfSearchBackwards(surf, surf2);
|
||||||
|
|
||||||
span = span_p++;
|
|
||||||
span->u = surf2->last_u;
|
|
||||||
span->count = iu - span->u;
|
|
||||||
span->v = current_iv;
|
|
||||||
span->pnext = surf2->spans;
|
|
||||||
surf2->spans = span;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set last_u on the new span
|
|
||||||
surf->last_u = iu;
|
|
||||||
|
|
||||||
gotposition:
|
|
||||||
// insert before surf2
|
// insert before surf2
|
||||||
surf->next = surf2;
|
surf->next = surf2;
|
||||||
surf->prev = surf2->prev;
|
surf->prev = surf2->prev;
|
||||||
|
@ -407,6 +400,42 @@ D_SurfSearchForward(surf_t *surf, surf_t *surf2)
|
||||||
return surf2;
|
return surf2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
==============
|
||||||
|
R_LeadingEdgeSearch
|
||||||
|
==============
|
||||||
|
*/
|
||||||
|
static surf_t*
|
||||||
|
R_LeadingEdgeSearch (edge_t *edge, surf_t *surf, surf_t *surf2)
|
||||||
|
{
|
||||||
|
float fu, newzi, testzi, newzitop, newzibottom;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
surf2 = D_SurfSearchForward(surf, surf2);
|
||||||
|
|
||||||
|
if (surf->key != surf2->key)
|
||||||
|
return surf2;
|
||||||
|
|
||||||
|
// must be two bmodels in the same leaf; sort on 1/z
|
||||||
|
fu = (float)(edge->u - (1<<shift_size) + 1) * (1.0 / (1<<shift_size));
|
||||||
|
newzi = surf->d_ziorigin + fv*surf->d_zistepv +
|
||||||
|
fu*surf->d_zistepu;
|
||||||
|
newzibottom = newzi * 0.99;
|
||||||
|
|
||||||
|
testzi = surf2->d_ziorigin + fv*surf2->d_zistepv +
|
||||||
|
fu*surf2->d_zistepu;
|
||||||
|
|
||||||
|
if (newzibottom < testzi)
|
||||||
|
return surf2;
|
||||||
|
|
||||||
|
newzitop = newzi * 1.01;
|
||||||
|
}
|
||||||
|
while(newzitop < testzi || surf->d_zistepu < surf2->d_zistepu);
|
||||||
|
|
||||||
|
return surf2;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==============
|
==============
|
||||||
R_LeadingEdge
|
R_LeadingEdge
|
||||||
|
@ -419,7 +448,6 @@ R_LeadingEdge (edge_t *edge)
|
||||||
{
|
{
|
||||||
surf_t *surf, *surf2;
|
surf_t *surf, *surf2;
|
||||||
shift20_t iu;
|
shift20_t iu;
|
||||||
float fu, newzi, testzi, newzitop, newzibottom;
|
|
||||||
|
|
||||||
// it's adding a new surface in, so find the correct place
|
// it's adding a new surface in, so find the correct place
|
||||||
surf = &surfaces[edge->surfs[1]];
|
surf = &surfaces[edge->surfs[1]];
|
||||||
|
@ -438,6 +466,8 @@ R_LeadingEdge (edge_t *edge)
|
||||||
// active is in front, so keep going unless it's a bmodel
|
// active is in front, so keep going unless it's a bmodel
|
||||||
if (surf->insubmodel && (surf->key == surf2->key))
|
if (surf->insubmodel && (surf->key == surf2->key))
|
||||||
{
|
{
|
||||||
|
float fu, newzi, testzi, newzitop, newzibottom;
|
||||||
|
|
||||||
// must be two bmodels in the same leaf; sort on 1/z
|
// must be two bmodels in the same leaf; sort on 1/z
|
||||||
fu = (float)(edge->u - (1<<shift_size) + 1) * (1.0 / (1<<shift_size));
|
fu = (float)(edge->u - (1<<shift_size) + 1) * (1.0 / (1<<shift_size));
|
||||||
newzi = surf->d_ziorigin + fv*surf->d_zistepv +
|
newzi = surf->d_ziorigin + fv*surf->d_zistepv +
|
||||||
|
@ -462,39 +492,8 @@ R_LeadingEdge (edge_t *edge)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
continue_search:
|
surf2 = R_LeadingEdgeSearch (edge, surf, surf2);
|
||||||
surf2 = D_SurfSearchForward(surf, surf2);
|
|
||||||
|
|
||||||
if (surf->key == surf2->key)
|
|
||||||
{
|
|
||||||
// must be two bmodels in the same leaf; sort on 1/z
|
|
||||||
fu = (float)(edge->u - (1<<shift_size) + 1) * (1.0 / (1<<shift_size));
|
|
||||||
newzi = surf->d_ziorigin + fv*surf->d_zistepv +
|
|
||||||
fu*surf->d_zistepu;
|
|
||||||
newzibottom = newzi * 0.99;
|
|
||||||
|
|
||||||
testzi = surf2->d_ziorigin + fv*surf2->d_zistepv +
|
|
||||||
fu*surf2->d_zistepu;
|
|
||||||
|
|
||||||
if (newzibottom >= testzi)
|
|
||||||
{
|
|
||||||
goto gotposition;
|
|
||||||
}
|
|
||||||
|
|
||||||
newzitop = newzi * 1.01;
|
|
||||||
if (newzitop >= testzi)
|
|
||||||
{
|
|
||||||
if (surf->d_zistepu >= surf2->d_zistepu)
|
|
||||||
{
|
|
||||||
goto gotposition;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
goto continue_search;
|
|
||||||
}
|
|
||||||
|
|
||||||
goto gotposition;
|
goto gotposition;
|
||||||
|
|
||||||
newtop:
|
newtop:
|
||||||
// emit a span (obscures current top)
|
// emit a span (obscures current top)
|
||||||
iu = edge->u >> shift_size;
|
iu = edge->u >> shift_size;
|
||||||
|
|
|
@ -339,6 +339,8 @@ void R_SetupFrame (void)
|
||||||
// current viewleaf
|
// current viewleaf
|
||||||
if ( !( r_newrefdef.rdflags & RDF_NOWORLDMODEL ) )
|
if ( !( r_newrefdef.rdflags & RDF_NOWORLDMODEL ) )
|
||||||
{
|
{
|
||||||
|
// Determine what is the current view cluster (walking the BSP tree)
|
||||||
|
// and store it in r_viewcluster
|
||||||
r_viewleaf = Mod_PointInLeaf (r_origin, r_worldmodel);
|
r_viewleaf = Mod_PointInLeaf (r_origin, r_worldmodel);
|
||||||
r_viewcluster = r_viewleaf->cluster;
|
r_viewcluster = r_viewleaf->cluster;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue