mirror of
https://github.com/nzp-team/dquakeplus.git
synced 2024-11-22 20:02:37 +00:00
ADQuake's improved R_CullBox
This commit is contained in:
parent
72288cf9ee
commit
4857dab378
4 changed files with 26 additions and 109 deletions
|
@ -253,7 +253,6 @@ Returns 1, 2, or 1 + 2
|
|||
// crow_bar's enhanced boxonplaneside
|
||||
int BoxOnPlaneSide(vec3_t emins, vec3_t emaxs, mplane_t *p)
|
||||
{
|
||||
#ifdef PSP_VFPU
|
||||
int sides;
|
||||
__asm__ (
|
||||
".set push\n" // save assembler option
|
||||
|
@ -428,58 +427,6 @@ int BoxOnPlaneSide(vec3_t emins, vec3_t emaxs, mplane_t *p)
|
|||
: "$8"
|
||||
);
|
||||
return sides;
|
||||
#else
|
||||
int sides = 0;
|
||||
float dist1, dist2;
|
||||
|
||||
// general case
|
||||
switch( p->signbits )
|
||||
{
|
||||
case 0:
|
||||
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
|
||||
dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
|
||||
break;
|
||||
case 1:
|
||||
dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
|
||||
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
|
||||
break;
|
||||
case 2:
|
||||
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
|
||||
dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
|
||||
break;
|
||||
case 3:
|
||||
dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
|
||||
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
|
||||
break;
|
||||
case 4:
|
||||
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
|
||||
dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
|
||||
break;
|
||||
case 5:
|
||||
dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
|
||||
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
|
||||
break;
|
||||
case 6:
|
||||
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
|
||||
dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
|
||||
break;
|
||||
case 7:
|
||||
dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
|
||||
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
|
||||
break;
|
||||
default:
|
||||
// shut up compiler
|
||||
dist1 = dist2 = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if( dist1 >= p->dist )
|
||||
sides = 1;
|
||||
if( dist2 < p->dist )
|
||||
sides |= 2;
|
||||
|
||||
return sides;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -333,7 +333,7 @@ void EmitBothSkyLayers (msurface_t *fa);
|
|||
void EmitUnderWaterPolys (void);
|
||||
void EmitDetailPolys (void);
|
||||
void R_DrawSkyChain (msurface_t *s);
|
||||
qboolean R_CullBox (vec3_t emins, vec3_t emaxs);
|
||||
int R_CullBox (vec3_t emins, vec3_t emaxs);
|
||||
qboolean R_CullSphere (vec3_t centre, float radius);
|
||||
void R_MarkLights (dlight_t *light, int bit, mnode_t *node);
|
||||
void R_RotateForEntity (entity_t *e, int shadow);
|
||||
|
|
|
@ -314,59 +314,29 @@ void R_RotateForViewEntity (entity_t *ent)
|
|||
|
||||
/*
|
||||
=================
|
||||
R_CullBox -- replaced with new function from lordhavoc
|
||||
|
||||
Returns true if the box is completely outside the frustum
|
||||
R_CullBox
|
||||
Returns true if the box is completely outside the frustom
|
||||
=================
|
||||
*/
|
||||
qboolean R_CullBox (vec3_t emins, vec3_t emaxs)
|
||||
int R_CullBox (vec3_t mins, vec3_t maxs)
|
||||
{
|
||||
int i;
|
||||
mplane_t *p;
|
||||
int result = 1; // Default to "all inside".
|
||||
int i;
|
||||
|
||||
|
||||
|
||||
for (i = 0;i < 4;i++)
|
||||
for (i=0 ; i<4 ; i++)
|
||||
{
|
||||
p = frustum + i;
|
||||
switch(p->signbits)
|
||||
const int plane_result = BoxOnPlaneSide(mins, maxs, &frustum[i]);
|
||||
if (plane_result == 2)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
if (p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2] < p->dist)
|
||||
return qtrue;
|
||||
break;
|
||||
case 1:
|
||||
if (p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2] < p->dist)
|
||||
return qtrue;
|
||||
break;
|
||||
case 2:
|
||||
if (p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2] < p->dist)
|
||||
return qtrue;
|
||||
break;
|
||||
case 3:
|
||||
if (p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2] < p->dist)
|
||||
return qtrue;
|
||||
break;
|
||||
case 4:
|
||||
if (p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2] < p->dist)
|
||||
return qtrue;
|
||||
break;
|
||||
case 5:
|
||||
if (p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2] < p->dist)
|
||||
return qtrue;
|
||||
break;
|
||||
case 6:
|
||||
if (p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2] < p->dist)
|
||||
return qtrue;
|
||||
break;
|
||||
case 7:
|
||||
if (p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2] < p->dist)
|
||||
return qtrue;
|
||||
break;
|
||||
return 2;
|
||||
}
|
||||
else if (plane_result == 3)
|
||||
{
|
||||
result = 3;
|
||||
}
|
||||
}
|
||||
return qfalse;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2060,7 +2030,7 @@ void R_DrawTransparentAliasModel (entity_t *e)
|
|||
VectorAdd (e->origin, clmodel->mins, mins);
|
||||
VectorAdd (e->origin, clmodel->maxs, maxs);
|
||||
|
||||
if (R_CullBox(mins, maxs))
|
||||
if (R_CullBox(mins, maxs) == 2)
|
||||
return;
|
||||
|
||||
VectorCopy (e->origin, r_entorigin);
|
||||
|
@ -2194,7 +2164,7 @@ void R_DrawAliasModel (entity_t *e)
|
|||
VectorAdd (e->origin, clmodel->mins, mins);
|
||||
VectorAdd (e->origin, clmodel->maxs, maxs);
|
||||
|
||||
if (R_CullBox(mins, maxs))
|
||||
if (R_CullBox(mins, maxs) == 2)
|
||||
return;
|
||||
|
||||
//=============================================================================================== 97% at this point
|
||||
|
@ -2544,7 +2514,7 @@ void R_DrawMD2Model (entity_t *e)
|
|||
//}
|
||||
//else
|
||||
//{
|
||||
if (R_CullBox(mins, maxs))
|
||||
if (R_CullBox(mins, maxs) == 2)
|
||||
return;
|
||||
//}
|
||||
|
||||
|
@ -3279,7 +3249,7 @@ void R_DrawQ3Model (entity_t *ent)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (R_CullBox(mins, maxs))
|
||||
if (R_CullBox(mins, maxs) == 2)
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1254,7 +1254,7 @@ void R_DrawBrushModel (entity_t *e)
|
|||
VectorAdd (e->origin, clmodel->mins, mins);
|
||||
VectorAdd (e->origin, clmodel->maxs, maxs);
|
||||
|
||||
if (R_CullBox (mins, maxs))
|
||||
if (R_CullBox (mins, maxs) == 2)
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1435,7 +1435,7 @@ void R_RecursiveWorldNode (mnode_t *node)
|
|||
|
||||
if (node->visframe != r_visframecount)
|
||||
return;
|
||||
if (R_CullBox (node->minmaxs, node->minmaxs+3))
|
||||
if (R_CullBox (node->minmaxs, node->minmaxs+3) == 2)
|
||||
return;
|
||||
|
||||
// if a leaf node, draw stuff
|
||||
|
|
Loading…
Reference in a new issue