mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 15:01:41 +00:00
[renderer] Clean up R_SetFrustum
The only global it touches now is frustum, and that needs fixing in mathlib (good grief, we (probably I) did some weird things when merging the code).
This commit is contained in:
parent
c3f38e1c79
commit
b912c2a667
4 changed files with 26 additions and 22 deletions
|
@ -181,6 +181,16 @@ typedef struct entity_s {
|
|||
vec4f_t old_origin;
|
||||
} entity_t;
|
||||
|
||||
typedef union refframe_s {
|
||||
mat4f_t mat;
|
||||
struct {
|
||||
vec4f_t right;
|
||||
vec4f_t forward;
|
||||
vec4f_t up;
|
||||
vec4f_t position;
|
||||
};
|
||||
} refframe_t;
|
||||
|
||||
// !!! if this is changed, it must be changed in asm_draw.h too !!!
|
||||
typedef struct {
|
||||
vrect_t vrect; // subwindow in video for refresh
|
||||
|
@ -203,15 +213,7 @@ typedef struct {
|
|||
float xOrigin; // should probably always be 0.5
|
||||
float yOrigin; // between be around 0.3 to 0.5
|
||||
|
||||
union {
|
||||
mat4f_t mat;
|
||||
struct {
|
||||
vec4f_t right;
|
||||
vec4f_t forward;
|
||||
vec4f_t up;
|
||||
vec4f_t position;
|
||||
};
|
||||
} frame;
|
||||
refframe_t frame;
|
||||
mat4f_t camera;
|
||||
mat4f_t camera_inverse;
|
||||
|
||||
|
|
|
@ -141,7 +141,8 @@ extern vec3_t r_worldmodelorg;
|
|||
extern mat4f_t glsl_projection;
|
||||
extern mat4f_t glsl_view;
|
||||
|
||||
void R_SetFrustum (void);
|
||||
union refframe_s;
|
||||
void R_SetFrustum (const union refframe_s *frame, float fov_x, float fov_y);
|
||||
|
||||
void R_SpriteBegin (void);
|
||||
void R_SpriteEnd (void);
|
||||
|
|
|
@ -89,25 +89,26 @@ SignbitsForPlane (plane_t *out)
|
|||
}
|
||||
|
||||
void
|
||||
R_SetFrustum (void)
|
||||
R_SetFrustum (const refframe_t *frame, float fov_x, float fov_y)
|
||||
{
|
||||
int i;
|
||||
vec4f_t right = r_refdef.frame.right;
|
||||
vec4f_t fwd = r_refdef.frame.forward;
|
||||
vec4f_t up = r_refdef.frame.up;
|
||||
float rot_x = 90 - r_refdef.fov_x / 2;
|
||||
float rot_y = 90 - r_refdef.fov_y / 2;
|
||||
vec4f_t right = frame->right;
|
||||
vec4f_t fwd = frame->forward;
|
||||
vec4f_t up = frame->up;
|
||||
|
||||
fov_x = 90 - fov_x / 2;
|
||||
fov_y = 90 - fov_y / 2;
|
||||
|
||||
// rotate FWD right by FOV_X/2 degrees
|
||||
RotatePointAroundVector (frustum[0].normal, &up[0], &fwd[0], -rot_x);
|
||||
RotatePointAroundVector (frustum[0].normal, &up[0], &fwd[0], -fov_x);
|
||||
// rotate FWD left by FOV_X/2 degrees
|
||||
RotatePointAroundVector (frustum[1].normal, &up[0], &fwd[0], rot_x);
|
||||
RotatePointAroundVector (frustum[1].normal, &up[0], &fwd[0], fov_x);
|
||||
// rotate FWD up by FOV_Y/2 degrees
|
||||
RotatePointAroundVector (frustum[2].normal, &right[0], &fwd[0], rot_y);
|
||||
RotatePointAroundVector (frustum[2].normal, &right[0], &fwd[0], fov_y);
|
||||
// rotate FWD down by FOV_Y/2 degrees
|
||||
RotatePointAroundVector (frustum[3].normal, &right[0], &fwd[0], -rot_y);
|
||||
RotatePointAroundVector (frustum[3].normal, &right[0], &fwd[0], -fov_y);
|
||||
|
||||
vec4f_t origin = r_refdef.frame.position;
|
||||
vec4f_t origin = frame->position;
|
||||
for (i = 0; i < 4; i++) {
|
||||
frustum[i].type = PLANE_ANYZ;
|
||||
frustum[i].dist = DotProduct (origin, frustum[i].normal);
|
||||
|
|
|
@ -177,11 +177,11 @@ 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);
|
||||
|
||||
//FIXME breaks fisheye as it calls the view render many times
|
||||
EntQueue_Clear (r_ent_queue);
|
||||
r_framecount++;
|
||||
R_SetFrustum ();
|
||||
|
||||
r_data->realtime = realtime;
|
||||
scr_copytop = r_data->scr_copyeverything = 0;
|
||||
|
|
Loading…
Reference in a new issue