[mathlib] Remove frustum global

It should never have been there and is now in the refdef (not its final
home: it should probably be part of the camera).
This commit is contained in:
Bill Currie 2022-03-19 12:33:12 +09:00
parent b912c2a667
commit 65af7fb4a4
11 changed files with 24 additions and 23 deletions

View file

@ -141,7 +141,7 @@ void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right,
void AngleQuat (const vec3_t angles, quat_t q);
void VectorVectors (const vec3_t forward, vec3_t right, vec3_t up);
int BoxOnPlaneSide (const vec3_t emins, const vec3_t emaxs,
struct plane_s *plane) __attribute__((pure));
const plane_t *plane) __attribute__((pure));
float anglemod (float a) __attribute__((const));
void RotatePointAroundVector (vec3_t dst, const vec3_t axis,
@ -175,9 +175,8 @@ void RotatePointAroundVector (vec3_t dst, const vec3_t axis,
VectorNegate ((sp)->normal, (dp)->normal); \
} while (0)
extern plane_t * const frustum;
GNU89INLINE inline qboolean R_CullBox (const vec3_t mins, const vec3_t maxs) __attribute__((pure));
GNU89INLINE inline qboolean R_CullSphere (const vec3_t origin, const float radius);
GNU89INLINE inline qboolean R_CullBox (const plane_t *frustum, const vec3_t mins, const vec3_t maxs) __attribute__((pure));
GNU89INLINE inline qboolean R_CullSphere (const plane_t *frustum, const vec3_t origin, const float radius);
#ifndef IMPLEMENT_R_Cull
GNU89INLINE inline
@ -185,7 +184,7 @@ GNU89INLINE inline
VISIBLE
#endif
qboolean
R_CullBox (const vec3_t mins, const vec3_t maxs)
R_CullBox (const plane_t *frustum, const vec3_t mins, const vec3_t maxs)
{
int i;
@ -203,7 +202,7 @@ GNU89INLINE inline
VISIBLE
#endif
qboolean
R_CullSphere (const vec3_t origin, const float radius)
R_CullSphere (const plane_t *frustum, const vec3_t origin, const float radius)
{
int i;
float r;

View file

@ -214,6 +214,7 @@ typedef struct {
float yOrigin; // between be around 0.3 to 0.5
refframe_t frame;
plane_t frustum[4];
mat4f_t camera;
mat4f_t camera_inverse;

View file

@ -142,7 +142,8 @@ extern mat4f_t glsl_projection;
extern mat4f_t glsl_view;
union refframe_s;
void R_SetFrustum (const union refframe_s *frame, float fov_x, float fov_y);
void R_SetFrustum (plane_t *frustum, const union refframe_s *frame,
float fov_x, float fov_y);
void R_SpriteBegin (void);
void R_SpriteEnd (void);

View file

@ -48,8 +48,6 @@
#include "QF/sys.h"
VISIBLE int nanmask = 255 << 23;
static plane_t _frustum[4];
VISIBLE plane_t *const frustum = _frustum;
static vec3_t _vec3_origin = { 0, 0, 0 };
VISIBLE const vec_t * const vec3_origin = _vec3_origin;
static quat_t _quat_origin = { 0, 0, 0, 0 };
@ -393,7 +391,7 @@ BOPS_Error (void)
Returns 1, 2, or 1 + 2
*/
VISIBLE int
BoxOnPlaneSide (const vec3_t emins, const vec3_t emaxs, plane_t *p)
BoxOnPlaneSide (const vec3_t emins, const vec3_t emaxs, const plane_t *p)
{
float dist1, dist2;
int sides;

View file

@ -434,7 +434,7 @@ gl_R_DrawAliasModel (entity_t *e)
if (scale[0] != 1.0) {
radius *= scale[0];
}
if (R_CullSphere (&origin[0], radius)) {//FIXME
if (R_CullSphere (r_refdef.frustum, &origin[0], radius)) {//FIXME
return;
}

View file

@ -544,7 +544,7 @@ gl_R_DrawBrushModel (entity_t *e)
if (e->scale != 1.0)
radius *= e->scale;
#endif
if (R_CullSphere (&worldMatrix[3][0], radius)) {//FIXME
if (R_CullSphere (r_refdef.frustum, &worldMatrix[3][0], radius)) {//FIXME
return;
}
} else {
@ -557,7 +557,7 @@ gl_R_DrawBrushModel (entity_t *e)
VectorScale (maxs, e->scale, maxs);
}
#endif
if (R_CullBox (mins, maxs))
if (R_CullBox (r_refdef.frustum, mins, maxs))
return;
}
@ -660,7 +660,7 @@ test_node (mnode_t *node)
return 0;
if (node->visframe != r_visframecount)
return 0;
if (R_CullBox (node->minmaxs, node->minmaxs + 3))
if (R_CullBox (r_refdef.frustum, node->minmaxs, node->minmaxs + 3))
return 0;
return 1;
}

View file

@ -677,14 +677,14 @@ R_DrawBrushModel (entity_t *e)
if (mat[0][0] != 1 || mat[1][1] != 1 || mat[2][2] != 1) {
rotated = true;
radius = model->radius;
if (R_CullSphere (&mat[3][0], radius)) { // FIXME
if (R_CullSphere (r_refdef.frustum, &mat[3][0], radius)) { // FIXME
return;
}
} else {
rotated = false;
VectorAdd (mat[3], model->mins, mins);
VectorAdd (mat[3], model->maxs, maxs);
if (R_CullBox (mins, maxs))
if (R_CullBox (r_refdef.frustum, mins, maxs))
return;
}
@ -779,7 +779,7 @@ test_node (mnode_t *node)
return 0;
if (node->visframe != r_visframecount)
return 0;
if (R_CullBox (node->minmaxs, node->minmaxs + 3))
if (R_CullBox (r_refdef.frustum, node->minmaxs, node->minmaxs + 3))
return 0;
return 1;
}

View file

@ -297,7 +297,7 @@ R_MarkLights (const vec3_t lightorigin, dlight_t *light, int lightnum,
|| leaf->mins[1] > maxs[1] || leaf->maxs[1] < mins[1]
|| leaf->mins[2] > maxs[2] || leaf->maxs[2] < mins[2])
continue;
if (R_CullBox (leaf->mins, leaf->maxs))
if (R_CullBox (r_refdef.frustum, leaf->mins, leaf->maxs))
continue;
for (m = 0; m < leaf->nummarksurfaces; m++) {
msurface_t *surf = leaf->firstmarksurface[m];

View file

@ -89,7 +89,8 @@ SignbitsForPlane (plane_t *out)
}
void
R_SetFrustum (const refframe_t *frame, float fov_x, float fov_y)
R_SetFrustum (plane_t *frustum, const refframe_t *frame,
float fov_x, float fov_y)
{
int i;
vec4f_t right = frame->right;

View file

@ -177,7 +177,8 @@ SCR_UpdateScreen (transform_t *camera, double realtime, SCR_Func *scr_funcs)
refdef->frame.mat[1] = refdef->camera[0];
refdef->frame.mat[2] = refdef->camera[2];
refdef->frame.mat[3] = refdef->camera[3];
R_SetFrustum (&refdef->frame, refdef->fov_x, refdef->fov_y);
R_SetFrustum (refdef->frustum, &refdef->frame,
refdef->fov_x, refdef->fov_y);
//FIXME breaks fisheye as it calls the view render many times
EntQueue_Clear (r_ent_queue);

View file

@ -604,14 +604,14 @@ R_DrawBrushModel (entity_t *e, vulkan_ctx_t *ctx)
if (mat[0][0] != 1 || mat[1][1] != 1 || mat[2][2] != 1) {
rotated = true;
radius = model->radius;
if (R_CullSphere (&mat[3][0], radius)) { //FIXME
if (R_CullSphere (r_refdef.frustum, &mat[3][0], radius)) { //FIXME
return;
}
} else {
rotated = false;
VectorAdd (mat[3], model->mins, mins);
VectorAdd (mat[3], model->maxs, maxs);
if (R_CullBox (mins, maxs))
if (R_CullBox (r_refdef.frustum, mins, maxs))
return;
}
@ -691,7 +691,7 @@ test_node (mnode_t *node)
return 0;
if (node->visframe != r_visframecount)
return 0;
if (R_CullBox (node->minmaxs, node->minmaxs + 3))
if (R_CullBox (r_refdef.frustum, node->minmaxs, node->minmaxs + 3))
return 0;
return 1;
}