|
|
@ -95,8 +95,8 @@ void D_ViewChanged (void) |
|
|
|
if (d_pix_max < 1) |
|
|
|
if (d_pix_max < 1) |
|
|
|
d_pix_max = 1; |
|
|
|
d_pix_max = 1; |
|
|
|
|
|
|
|
|
|
|
|
d_vrectx = 0;//r_refdef.vrect.x;
|
|
|
|
d_vrectx = RI.vrect.x; |
|
|
|
d_vrecty = 0;//r_refdef.vrect.y;
|
|
|
|
d_vrecty = RI.vrect.y; |
|
|
|
d_vrectright_particle = gpGlobals->width - d_pix_max; |
|
|
|
d_vrectright_particle = gpGlobals->width - d_pix_max; |
|
|
|
d_vrectbottom_particle = |
|
|
|
d_vrectbottom_particle = |
|
|
|
gpGlobals->height - d_pix_max; |
|
|
|
gpGlobals->height - d_pix_max; |
|
|
@ -223,98 +223,89 @@ Guaranteed to be called before the first refresh |
|
|
|
void R_ViewChanged (vrect_t *vr) |
|
|
|
void R_ViewChanged (vrect_t *vr) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
#if 0 |
|
|
|
float verticalFieldOfView, xOrigin, yOrigin; |
|
|
|
r_refdef.vrect = *vr; |
|
|
|
|
|
|
|
|
|
|
|
RI.vrect = *vr; |
|
|
|
r_refdef.horizontalFieldOfView = 2*tan((float)r_newrefdef.fov_x/360*M_PI);; |
|
|
|
|
|
|
|
verticalFieldOfView = 2*tan((float)r_newrefdef.fov_y/360*M_PI); |
|
|
|
RI.horizontalFieldOfView = 2*tan((float)RI.fov_x/360*M_PI); |
|
|
|
|
|
|
|
verticalFieldOfView = 2*tan((float)RI.fov_y/360*M_PI); |
|
|
|
r_refdef.fvrectx = (float)r_refdef.vrect.x; |
|
|
|
|
|
|
|
r_refdef.fvrectx_adj = (float)r_refdef.vrect.x - 0.5; |
|
|
|
RI.fvrectx = (float)RI.vrect.x; |
|
|
|
r_refdef.vrect_x_adj_shift20 = (r_refdef.vrect.x<<20) + (1<<19) - 1; |
|
|
|
RI.fvrectx_adj = (float)RI.vrect.x - 0.5; |
|
|
|
r_refdef.fvrecty = (float)r_refdef.vrect.y; |
|
|
|
RI.vrect_x_adj_shift20 = (RI.vrect.x<<20) + (1<<19) - 1; |
|
|
|
r_refdef.fvrecty_adj = (float)r_refdef.vrect.y - 0.5; |
|
|
|
RI.fvrecty = (float)RI.vrect.y; |
|
|
|
r_refdef.vrectright = r_refdef.vrect.x + r_refdef.vrect.width; |
|
|
|
RI.fvrecty_adj = (float)RI.vrect.y - 0.5; |
|
|
|
r_refdef.vrectright_adj_shift20 = (r_refdef.vrectright<<20) + (1<<19) - 1; |
|
|
|
RI.vrectright = RI.vrect.x + RI.vrect.width; |
|
|
|
r_refdef.fvrectright = (float)r_refdef.vrectright; |
|
|
|
RI.vrectright_adj_shift20 = (RI.vrectright<<20) + (1<<19) - 1; |
|
|
|
r_refdef.fvrectright_adj = (float)r_refdef.vrectright - 0.5; |
|
|
|
RI.fvrectright = (float)RI.vrectright; |
|
|
|
r_refdef.vrectrightedge = (float)r_refdef.vrectright - 0.99; |
|
|
|
RI.fvrectright_adj = (float)RI.vrectright - 0.5; |
|
|
|
r_refdef.vrectbottom = r_refdef.vrect.y + r_refdef.vrect.height; |
|
|
|
RI.vrectrightedge = (float)RI.vrectright - 0.99; |
|
|
|
r_refdef.fvrectbottom = (float)r_refdef.vrectbottom; |
|
|
|
RI.vrectbottom = RI.vrect.y + RI.vrect.height; |
|
|
|
r_refdef.fvrectbottom_adj = (float)r_refdef.vrectbottom - 0.5; |
|
|
|
RI.fvrectbottom = (float)RI.vrectbottom; |
|
|
|
|
|
|
|
RI.fvrectbottom_adj = (float)RI.vrectbottom - 0.5; |
|
|
|
r_refdef.aliasvrect.x = (int)(r_refdef.vrect.x * r_aliasuvscale); |
|
|
|
|
|
|
|
r_refdef.aliasvrect.y = (int)(r_refdef.vrect.y * r_aliasuvscale); |
|
|
|
//RI.aliasvrect.x = (int)(RI.vrect.x * r_aliasuvscale);
|
|
|
|
r_refdef.aliasvrect.width = (int)(r_refdef.vrect.width * r_aliasuvscale); |
|
|
|
//RI.aliasvrect.y = (int)(RI.vrect.y * r_aliasuvscale);
|
|
|
|
r_refdef.aliasvrect.height = (int)(r_refdef.vrect.height * r_aliasuvscale); |
|
|
|
//RI.aliasvrect.width = (int)(RI.vrect.width * r_aliasuvscale);
|
|
|
|
r_refdef.aliasvrectright = r_refdef.aliasvrect.x + |
|
|
|
//RI.aliasvrect.height = (int)(RI.vrect.height * r_aliasuvscale);
|
|
|
|
r_refdef.aliasvrect.width; |
|
|
|
RI.aliasvrectright = RI.aliasvrect.x + |
|
|
|
r_refdef.aliasvrectbottom = r_refdef.aliasvrect.y + |
|
|
|
RI.aliasvrect.width; |
|
|
|
r_refdef.aliasvrect.height; |
|
|
|
RI.aliasvrectbottom = RI.aliasvrect.y + |
|
|
|
|
|
|
|
RI.aliasvrect.height; |
|
|
|
xOrigin = r_refdef.xOrigin; |
|
|
|
|
|
|
|
yOrigin = r_refdef.yOrigin; |
|
|
|
xOrigin = RI.xOrigin;// = r_origin[0];
|
|
|
|
#endif |
|
|
|
yOrigin = RI.yOrigin;// = r_origin[1];
|
|
|
|
|
|
|
|
#define PLANE_ANYZ 5 |
|
|
|
int fov_x = 2.0 * tan (RI.fov_x/360*M_PI); |
|
|
|
|
|
|
|
int fov_y = 2.0 * tan (RI.fov_y/360*M_PI); |
|
|
|
|
|
|
|
// values for perspective projection
|
|
|
|
// values for perspective projection
|
|
|
|
// if math were exact, the values would range from 0.5 to to range+0.5
|
|
|
|
// if math were exact, the values would range from 0.5 to to range+0.5
|
|
|
|
// hopefully they wll be in the 0.000001 to range+.999999 and truncate
|
|
|
|
// hopefully they wll be in the 0.000001 to range+.999999 and truncate
|
|
|
|
// the polygon rasterization will never render in the first row or column
|
|
|
|
// the polygon rasterization will never render in the first row or column
|
|
|
|
// but will definately render in the [range] row and column, so adjust the
|
|
|
|
// but will definately render in the [range] row and column, so adjust the
|
|
|
|
// buffer origin to get an exact edge to edge fill
|
|
|
|
// buffer origin to get an exact edge to edge fill
|
|
|
|
xcenter = ((float)gpGlobals->width * XCENTERING) + |
|
|
|
xcenter = ((float)RI.vrect.width * XCENTERING) + |
|
|
|
0 - 0.5; |
|
|
|
RI.vrect.x - 0.5; |
|
|
|
//aliasxcenter = xcenter * r_aliasuvscale;
|
|
|
|
//aliasxcenter = xcenter * r_aliasuvscale;
|
|
|
|
ycenter = ((float)gpGlobals->height * YCENTERING) + |
|
|
|
ycenter = ((float)RI.vrect.height * YCENTERING) + |
|
|
|
0 - 0.5; |
|
|
|
RI.vrect.y - 0.5; |
|
|
|
//aliasycenter = ycenter * r_aliasuvscale;
|
|
|
|
// aliasycenter = ycenter * r_aliasuvscale;
|
|
|
|
|
|
|
|
|
|
|
|
xscale = gpGlobals->width * 1.5 / fov_x; |
|
|
|
xscale = RI.vrect.width / RI.horizontalFieldOfView; |
|
|
|
//aliasxscale = xscale * r_aliasuvscale;
|
|
|
|
// aliasxscale = xscale * r_aliasuvscale;
|
|
|
|
xscaleinv = 1.0 / xscale; |
|
|
|
xscaleinv = 1.0 / xscale; |
|
|
|
|
|
|
|
|
|
|
|
yscale = xscale; |
|
|
|
yscale = xscale; |
|
|
|
//aliasyscale = yscale * r_aliasuvscale;
|
|
|
|
// aliasyscale = yscale * r_aliasuvscale;
|
|
|
|
yscaleinv = 1.0 / yscale; |
|
|
|
yscaleinv = 1.0 / yscale; |
|
|
|
xscaleshrink = (gpGlobals->width-6)/fov_x; |
|
|
|
xscaleshrink = (RI.vrect.width-6)/RI.horizontalFieldOfView; |
|
|
|
yscaleshrink = xscaleshrink; |
|
|
|
yscaleshrink = xscaleshrink; |
|
|
|
|
|
|
|
|
|
|
|
// ???
|
|
|
|
|
|
|
|
#define PLANE_ANYZ 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int xOrigin = r_origin[0]; |
|
|
|
|
|
|
|
int yOrigin = r_origin[1]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// left side clip
|
|
|
|
// left side clip
|
|
|
|
screenedge[0].normal[0] = -1.0 / (xOrigin*fov_x); |
|
|
|
screenedge[0].normal[0] = -1.0 / (xOrigin*RI.horizontalFieldOfView); |
|
|
|
screenedge[0].normal[1] = 0; |
|
|
|
screenedge[0].normal[1] = 0; |
|
|
|
screenedge[0].normal[2] = 1; |
|
|
|
screenedge[0].normal[2] = 1; |
|
|
|
screenedge[0].type = PLANE_ANYZ; |
|
|
|
screenedge[0].type = PLANE_ANYZ; |
|
|
|
|
|
|
|
|
|
|
|
// right side clip
|
|
|
|
// right side clip
|
|
|
|
screenedge[1].normal[0] = |
|
|
|
screenedge[1].normal[0] = |
|
|
|
1.0 / ((1.0-xOrigin)*fov_x); |
|
|
|
1.0 / ((1.0-xOrigin)*RI.horizontalFieldOfView); |
|
|
|
screenedge[1].normal[1] = 0; |
|
|
|
screenedge[1].normal[1] = 0; |
|
|
|
screenedge[1].normal[2] = 1; |
|
|
|
screenedge[1].normal[2] = 1; |
|
|
|
screenedge[1].type = PLANE_ANYZ; |
|
|
|
screenedge[1].type = PLANE_ANYZ; |
|
|
|
|
|
|
|
|
|
|
|
// top side clip
|
|
|
|
// top side clip
|
|
|
|
screenedge[2].normal[0] = 0; |
|
|
|
screenedge[2].normal[0] = 0; |
|
|
|
screenedge[2].normal[1] = -1.0 / (yOrigin*fov_y); |
|
|
|
screenedge[2].normal[1] = -1.0 / (yOrigin*verticalFieldOfView); |
|
|
|
screenedge[2].normal[2] = 1; |
|
|
|
screenedge[2].normal[2] = 1; |
|
|
|
screenedge[2].type = PLANE_ANYZ; |
|
|
|
screenedge[2].type = PLANE_ANYZ; |
|
|
|
|
|
|
|
|
|
|
|
// bottom side clip
|
|
|
|
// bottom side clip
|
|
|
|
screenedge[3].normal[0] = 0; |
|
|
|
screenedge[3].normal[0] = 0; |
|
|
|
screenedge[3].normal[1] = 1.0 / ((1.0-yOrigin)*fov_y); |
|
|
|
screenedge[3].normal[1] = 1.0 / ((1.0-yOrigin)*verticalFieldOfView); |
|
|
|
screenedge[3].normal[2] = 1; |
|
|
|
screenedge[3].normal[2] = 1; |
|
|
|
screenedge[3].type = PLANE_ANYZ; |
|
|
|
screenedge[3].type = PLANE_ANYZ; |
|
|
|
|
|
|
|
|
|
|
|
for (i=0 ; i<4 ; i++) |
|
|
|
for (i=0 ; i<4 ; i++) |
|
|
|
VectorNormalize (screenedge[i].normal); |
|
|
|
VectorNormalize (screenedge[i].normal); |
|
|
|
|
|
|
|
|
|
|
|
D_ViewChanged (); |
|
|
|
D_ViewChanged (); |
|
|
|
} |
|
|
|
} |
|
|
|