diff options
-rw-r--r-- | src/refresh/sw/aclip.c | 53 | ||||
-rw-r--r-- | src/refresh/sw/alias.c | 16 | ||||
-rw-r--r-- | src/refresh/sw/edge.c | 18 | ||||
-rw-r--r-- | src/refresh/sw/main.c | 15 | ||||
-rw-r--r-- | src/refresh/sw/misc.c | 140 | ||||
-rw-r--r-- | src/refresh/sw/part.c | 26 | ||||
-rw-r--r-- | src/refresh/sw/poly.c | 26 | ||||
-rw-r--r-- | src/refresh/sw/raster.c | 32 | ||||
-rw-r--r-- | src/refresh/sw/sw.h | 43 |
9 files changed, 139 insertions, 230 deletions
diff --git a/src/refresh/sw/aclip.c b/src/refresh/sw/aclip.c index 5a11110..20e280a 100644 --- a/src/refresh/sw/aclip.c +++ b/src/refresh/sw/aclip.c @@ -30,8 +30,7 @@ static void R_Alias_clip_z(finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *ou { float scale; - scale = (ALIAS_Z_CLIP_PLANE - pfv0->xyz[2]) / - (pfv1->xyz[2] - pfv0->xyz[2]); + scale = (ALIAS_Z_CLIP_PLANE - pfv0->xyz[2]) / (pfv1->xyz[2] - pfv0->xyz[2]); out->xyz[0] = pfv0->xyz[0] + (pfv1->xyz[0] - pfv0->xyz[0]) * scale; out->xyz[1] = pfv0->xyz[1] + (pfv1->xyz[1] - pfv0->xyz[1]) * scale; @@ -49,8 +48,7 @@ static void R_Alias_clip_left(finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t float scale; if (pfv0->v >= pfv1->v) { - scale = (float)(r_refdef.aliasvrect.x - pfv0->u) / - (pfv1->u - pfv0->u); + scale = (float)(r_refdef.vrect.x - pfv0->u) / (pfv1->u - pfv0->u); out->u = pfv0->u + (pfv1->u - pfv0->u) * scale + 0.5; out->v = pfv0->v + (pfv1->v - pfv0->v) * scale + 0.5; out->s = pfv0->s + (pfv1->s - pfv0->s) * scale + 0.5; @@ -58,8 +56,7 @@ static void R_Alias_clip_left(finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t out->l = pfv0->l + (pfv1->l - pfv0->l) * scale + 0.5; out->zi = pfv0->zi + (pfv1->zi - pfv0->zi) * scale + 0.5; } else { - scale = (float)(r_refdef.aliasvrect.x - pfv1->u) / - (pfv0->u - pfv1->u); + scale = (float)(r_refdef.vrect.x - pfv1->u) / (pfv0->u - pfv1->u); out->u = pfv1->u + (pfv0->u - pfv1->u) * scale + 0.5; out->v = pfv1->v + (pfv0->v - pfv1->v) * scale + 0.5; out->s = pfv1->s + (pfv0->s - pfv1->s) * scale + 0.5; @@ -74,8 +71,7 @@ static void R_Alias_clip_right(finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t float scale; if (pfv0->v >= pfv1->v) { - scale = (float)(r_refdef.aliasvrectright - pfv0->u) / - (pfv1->u - pfv0->u); + scale = (float)(r_refdef.vrectright - pfv0->u) / (pfv1->u - pfv0->u); out->u = pfv0->u + (pfv1->u - pfv0->u) * scale + 0.5; out->v = pfv0->v + (pfv1->v - pfv0->v) * scale + 0.5; out->s = pfv0->s + (pfv1->s - pfv0->s) * scale + 0.5; @@ -83,8 +79,7 @@ static void R_Alias_clip_right(finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t out->l = pfv0->l + (pfv1->l - pfv0->l) * scale + 0.5; out->zi = pfv0->zi + (pfv1->zi - pfv0->zi) * scale + 0.5; } else { - scale = (float)(r_refdef.aliasvrectright - pfv1->u) / - (pfv0->u - pfv1->u); + scale = (float)(r_refdef.vrectright - pfv1->u) / (pfv0->u - pfv1->u); out->u = pfv1->u + (pfv0->u - pfv1->u) * scale + 0.5; out->v = pfv1->v + (pfv0->v - pfv1->v) * scale + 0.5; out->s = pfv1->s + (pfv0->s - pfv1->s) * scale + 0.5; @@ -99,8 +94,7 @@ static void R_Alias_clip_top(finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t * float scale; if (pfv0->v >= pfv1->v) { - scale = (float)(r_refdef.aliasvrect.y - pfv0->v) / - (pfv1->v - pfv0->v); + scale = (float)(r_refdef.vrect.y - pfv0->v) / (pfv1->v - pfv0->v); out->u = pfv0->u + (pfv1->u - pfv0->u) * scale + 0.5; out->v = pfv0->v + (pfv1->v - pfv0->v) * scale + 0.5; out->s = pfv0->s + (pfv1->s - pfv0->s) * scale + 0.5; @@ -108,8 +102,7 @@ static void R_Alias_clip_top(finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t * out->l = pfv0->l + (pfv1->l - pfv0->l) * scale + 0.5; out->zi = pfv0->zi + (pfv1->zi - pfv0->zi) * scale + 0.5; } else { - scale = (float)(r_refdef.aliasvrect.y - pfv1->v) / - (pfv0->v - pfv1->v); + scale = (float)(r_refdef.vrect.y - pfv1->v) / (pfv0->v - pfv1->v); out->u = pfv1->u + (pfv0->u - pfv1->u) * scale + 0.5; out->v = pfv1->v + (pfv0->v - pfv1->v) * scale + 0.5; out->s = pfv1->s + (pfv0->s - pfv1->s) * scale + 0.5; @@ -125,8 +118,7 @@ static void R_Alias_clip_bottom(finalvert_t *pfv0, finalvert_t *pfv1, float scale; if (pfv0->v >= pfv1->v) { - scale = (float)(r_refdef.aliasvrectbottom - pfv0->v) / - (pfv1->v - pfv0->v); + scale = (float)(r_refdef.vrectbottom - pfv0->v) / (pfv1->v - pfv0->v); out->u = pfv0->u + (pfv1->u - pfv0->u) * scale + 0.5; out->v = pfv0->v + (pfv1->v - pfv0->v) * scale + 0.5; @@ -135,8 +127,7 @@ static void R_Alias_clip_bottom(finalvert_t *pfv0, finalvert_t *pfv1, out->l = pfv0->l + (pfv1->l - pfv0->l) * scale + 0.5; out->zi = pfv0->zi + (pfv1->zi - pfv0->zi) * scale + 0.5; } else { - scale = (float)(r_refdef.aliasvrectbottom - pfv1->v) / - (pfv0->v - pfv1->v); + scale = (float)(r_refdef.vrectbottom - pfv1->v) / (pfv0->v - pfv1->v); out->u = pfv1->u + (pfv0->u - pfv1->u) * scale + 0.5; out->v = pfv1->v + (pfv0->v - pfv1->v) * scale + 0.5; @@ -164,13 +155,13 @@ static int R_AliasClip(finalvert_t *in, finalvert_t *out, int flag, int count, if (oldflags ^ flags) { clip(&in[j], &in[i], &out[k]); out[k].flags = 0; - if (out[k].u < r_refdef.aliasvrect.x) + if (out[k].u < r_refdef.vrect.x) out[k].flags |= ALIAS_LEFT_CLIP; - if (out[k].v < r_refdef.aliasvrect.y) + if (out[k].v < r_refdef.vrect.y) out[k].flags |= ALIAS_TOP_CLIP; - if (out[k].u > r_refdef.aliasvrectright) + if (out[k].u > r_refdef.vrectright) out[k].flags |= ALIAS_RIGHT_CLIP; - if (out[k].v > r_refdef.aliasvrectbottom) + if (out[k].v > r_refdef.vrectbottom) out[k].flags |= ALIAS_BOTTOM_CLIP; k++; } @@ -252,15 +243,15 @@ void R_AliasClipTriangle(finalvert_t *index0, finalvert_t *index1, finalvert_t * } for (i = 0; i < k; i++) { - if (fv[pingpong][i].u < r_refdef.aliasvrect.x) - fv[pingpong][i].u = r_refdef.aliasvrect.x; - else if (fv[pingpong][i].u > r_refdef.aliasvrectright) - fv[pingpong][i].u = r_refdef.aliasvrectright; - - if (fv[pingpong][i].v < r_refdef.aliasvrect.y) - fv[pingpong][i].v = r_refdef.aliasvrect.y; - else if (fv[pingpong][i].v > r_refdef.aliasvrectbottom) - fv[pingpong][i].v = r_refdef.aliasvrectbottom; + if (fv[pingpong][i].u < r_refdef.vrect.x) + fv[pingpong][i].u = r_refdef.vrect.x; + else if (fv[pingpong][i].u > r_refdef.vrectright) + fv[pingpong][i].u = r_refdef.vrectright; + + if (fv[pingpong][i].v < r_refdef.vrect.y) + fv[pingpong][i].v = r_refdef.vrect.y; + else if (fv[pingpong][i].v > r_refdef.vrectbottom) + fv[pingpong][i].v = r_refdef.vrectbottom; fv[pingpong][i].flags = 0; } diff --git a/src/refresh/sw/alias.c b/src/refresh/sw/alias.c index b7f0a81..5d1f730 100644 --- a/src/refresh/sw/alias.c +++ b/src/refresh/sw/alias.c @@ -198,16 +198,16 @@ void R_AliasProjectAndClipTestFinalVert(finalvert_t *fv) fv->zi = zi * s_ziscale; - fv->u = (x * aliasxscale * zi) + aliasxcenter; - fv->v = (y * aliasyscale * zi) + aliasycenter; + fv->u = (x * r_refdef.xscale * zi) + r_refdef.xcenter; + fv->v = (y * r_refdef.yscale * zi) + r_refdef.ycenter; - if (fv->u < r_refdef.aliasvrect.x) + if (fv->u < r_refdef.vrect.x) fv->flags |= ALIAS_LEFT_CLIP; - if (fv->v < r_refdef.aliasvrect.y) + if (fv->v < r_refdef.vrect.y) fv->flags |= ALIAS_TOP_CLIP; - if (fv->u > r_refdef.aliasvrectright) + if (fv->u > r_refdef.vrectright) fv->flags |= ALIAS_RIGHT_CLIP; - if (fv->v > r_refdef.aliasvrectbottom) + if (fv->v > r_refdef.vrectbottom) fv->flags |= ALIAS_BOTTOM_CLIP; } @@ -672,7 +672,7 @@ void R_AliasDrawModel(void) currententity->backlerp = 0; if ((currententity->flags & (RF_WEAPONMODEL | RF_LEFTHAND)) == (RF_WEAPONMODEL | RF_LEFTHAND)) - aliasxscale = -aliasxscale; + r_refdef.xscale = -r_refdef.xscale; /* ** we have to set our frame pointers and transformations before @@ -709,6 +709,6 @@ void R_AliasDrawModel(void) exit: if ((currententity->flags & (RF_WEAPONMODEL | RF_LEFTHAND)) == (RF_WEAPONMODEL | RF_LEFTHAND)) - aliasxscale = -aliasxscale; + r_refdef.xscale = -r_refdef.xscale; } diff --git a/src/refresh/sw/edge.c b/src/refresh/sw/edge.c index 906fcd1..69e2200 100644 --- a/src/refresh/sw/edge.c +++ b/src/refresh/sw/edge.c @@ -60,8 +60,6 @@ static float fv; static int miplevel; -float scale_for_mip; - static void R_GenerateSpans(void); static void R_GenerateSpansBackward(void); @@ -729,18 +727,20 @@ static void D_CalcGradients(mface_t *pface) R_TransformVector(pface->texinfo->axis[0], p_saxis); R_TransformVector(pface->texinfo->axis[1], p_taxis); - t = xscaleinv * mipscale; + t = r_refdef.xscaleinv * mipscale; d_sdivzstepu = p_saxis[0] * t; d_tdivzstepu = p_taxis[0] * t; - t = yscaleinv * mipscale; + t = r_refdef.yscaleinv * mipscale; d_sdivzstepv = -p_saxis[1] * t; d_tdivzstepv = -p_taxis[1] * t; - d_sdivzorigin = p_saxis[2] * mipscale - xcenter * d_sdivzstepu - - ycenter * d_sdivzstepv; - d_tdivzorigin = p_taxis[2] * mipscale - xcenter * d_tdivzstepu - - ycenter * d_tdivzstepv; + d_sdivzorigin = p_saxis[2] * mipscale - + r_refdef.xcenter * d_sdivzstepu - + r_refdef.ycenter * d_sdivzstepv; + d_tdivzorigin = p_taxis[2] * mipscale - + r_refdef.xcenter * d_tdivzstepu - + r_refdef.ycenter * d_tdivzstepv; VectorScale(transformed_modelorg, mipscale, p_temp1); @@ -913,7 +913,7 @@ static void D_SolidSurf(surf_t *s) pface = s->msurf; - miplevel = D_MipLevelForScale(s->nearzi * scale_for_mip * pface->texinfo->mipadjust); + miplevel = D_MipLevelForScale(s->nearzi * r_refdef.scale_for_mip * pface->texinfo->mipadjust); // FIXME: make this passed in to D_CacheSurface pcurrentcache = D_CacheSurface(pface, miplevel); diff --git a/src/refresh/sw/main.c b/src/refresh/sw/main.c index 23e7950..ad589b8 100644 --- a/src/refresh/sw/main.c +++ b/src/refresh/sw/main.c @@ -34,7 +34,6 @@ byte r_warpbuffer[WARP_WIDTH * WARP_HEIGHT * VID_BYTES]; float r_time1; int r_numallocatededges; -float r_aliasuvscale = 1.0; int r_outofsurfaces; int r_outofedges; @@ -56,17 +55,9 @@ vec3_t r_origin; // screen size info // oldrefdef_t r_refdef; -float xcenter, ycenter; -float xscale, yscale; -float xscaleinv, yscaleinv; -float xscaleshrink, yscaleshrink; -float aliasxscale, aliasyscale, aliasxcenter, aliasycenter; int r_screenrowbytes; -float verticalFieldOfView; -float xOrigin, yOrigin; - cplane_t screenedge[4]; // @@ -272,9 +263,6 @@ qboolean R_Init(qboolean total) view_clipplanes[2].rightedge = view_clipplanes[3].rightedge = qfalse; - r_refdef.xOrigin = XCENTERING; - r_refdef.yOrigin = YCENTERING; - R_InitTurb(); return qtrue; @@ -825,9 +813,6 @@ void R_RenderFrame(refdef_t *fd) if (!r_worldmodel && !(r_newrefdef.rdflags & RDF_NOWORLDMODEL)) Com_Error(ERR_FATAL, "R_RenderView: NULL worldmodel"); - VectorCopy(fd->vieworg, r_refdef.vieworg); - VectorCopy(fd->viewangles, r_refdef.viewangles); - if (!sw_dynamic->integer) r_newrefdef.num_dlights = 0; diff --git a/src/refresh/sw/misc.c b/src/refresh/sw/misc.c index 82dbea8..e8dce06 100644 --- a/src/refresh/sw/misc.c +++ b/src/refresh/sw/misc.c @@ -29,61 +29,9 @@ float d_scalemip[NUM_MIPS - 1]; static const float basemip[NUM_MIPS - 1] = {1.0, 0.5 * 0.8, 0.25 * 0.8}; -int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle; - -int d_pix_min, d_pix_max, d_pix_shift; - int d_scantable[MAXHEIGHT]; short *zspantable[MAXHEIGHT]; -/* -================ -D_ViewChanged -================ -*/ -void D_ViewChanged(void) -{ - int i; - - scale_for_mip = xscale; - if (yscale > xscale) - scale_for_mip = yscale; - - d_zrowbytes = vid.width * 2; - d_zwidth = vid.width; - - d_pix_min = r_refdef.vrect.width / 640; - if (d_pix_min < 1) - d_pix_min = 1; - - d_pix_max = (int)((float)r_refdef.vrect.width / (640.0 / 4.0) + 0.5); - d_pix_shift = 8 - (int)((float)r_refdef.vrect.width / 640.0 + 0.5); - if (d_pix_max < 1) - d_pix_max = 1; - - d_vrectx = r_refdef.vrect.x; - d_vrecty = r_refdef.vrect.y; - d_vrectright_particle = r_refdef.vrectright - d_pix_max; - d_vrectbottom_particle = - r_refdef.vrectbottom - d_pix_max; - - for (i = 0; i < vid.height; i++) { - d_scantable[i] = i * r_screenrowbytes; - zspantable[i] = d_pzbuffer + i * d_zwidth; - } - - /* - ** clear Z-buffer and color-buffers if we're doing the gallery - */ - if (r_newrefdef.rdflags & RDF_NOWORLDMODEL) { - memset(d_pzbuffer, 0xff, vid.width * vid.height * sizeof(d_pzbuffer[0])); -#if 0 - R_DrawFill8(r_newrefdef.x, r_newrefdef.y, r_newrefdef.width, r_newrefdef.height, /*(int)sw_clearcolor->value & 0xff*/0); -#endif - } -} - - /* ============= @@ -210,12 +158,13 @@ Guaranteed to be called before the first refresh */ static void R_ViewChanged(vrect_t *vr) { + float fov_h, fov_v; int i; r_refdef.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); + fov_h = 2 * tan((float)r_newrefdef.fov_x / 360 * M_PI); + fov_v = 2 * tan((float)r_newrefdef.fov_y / 360 * M_PI); r_refdef.fvrectx = (float)r_refdef.vrect.x; r_refdef.fvrectx_adj = (float)r_refdef.vrect.x - 0.5; @@ -231,70 +180,61 @@ static void R_ViewChanged(vrect_t *vr) r_refdef.fvrectbottom = (float)r_refdef.vrectbottom; r_refdef.fvrectbottom_adj = (float)r_refdef.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); - r_refdef.aliasvrect.width = (int)(r_refdef.vrect.width * r_aliasuvscale); - r_refdef.aliasvrect.height = (int)(r_refdef.vrect.height * r_aliasuvscale); - r_refdef.aliasvrectright = r_refdef.aliasvrect.x + - r_refdef.aliasvrect.width; - r_refdef.aliasvrectbottom = r_refdef.aliasvrect.y + - r_refdef.aliasvrect.height; - - xOrigin = r_refdef.xOrigin; - yOrigin = r_refdef.yOrigin; - // values for perspective projection // 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 // 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 // buffer origin to get an exact edge to edge fill - xcenter = ((float)r_refdef.vrect.width * XCENTERING) + - r_refdef.vrect.x - 0.5; - aliasxcenter = xcenter * r_aliasuvscale; - ycenter = ((float)r_refdef.vrect.height * YCENTERING) + - r_refdef.vrect.y - 0.5; - aliasycenter = ycenter * r_aliasuvscale; - - xscale = r_refdef.vrect.width / r_refdef.horizontalFieldOfView; - aliasxscale = xscale * r_aliasuvscale; - xscaleinv = 1.0 / xscale; - - yscale = xscale; - aliasyscale = yscale * r_aliasuvscale; - yscaleinv = 1.0 / yscale; - xscaleshrink = (r_refdef.vrect.width - 6) / r_refdef.horizontalFieldOfView; - yscaleshrink = xscaleshrink; + r_refdef.xcenter = ((float)r_refdef.vrect.width * 0.5) + r_refdef.vrect.x - 0.5; + r_refdef.ycenter = ((float)r_refdef.vrect.height * 0.5) + r_refdef.vrect.y - 0.5; + r_refdef.xscale = r_refdef.vrect.width / fov_h; + r_refdef.xscaleinv = 1.0 / r_refdef.xscale; + r_refdef.yscale = r_refdef.vrect.height / fov_v; + r_refdef.yscaleinv = 1.0 / r_refdef.yscale; + r_refdef.xscaleshrink = (r_refdef.vrect.width - 6) / fov_h; + r_refdef.yscaleshrink = (r_refdef.vrect.height - 6) / fov_v; + + r_refdef.scale_for_mip = max(r_refdef.xscale, r_refdef.yscale); + + r_refdef.pix_min = r_refdef.vrect.width / 640; + if (r_refdef.pix_min < 1) + r_refdef.pix_min = 1; + + r_refdef.pix_max = (int)((float)r_refdef.vrect.width / (640.0 / 4.0) + 0.5); + r_refdef.pix_shift = 8 - (int)((float)r_refdef.vrect.width / 640.0 + 0.5); + if (r_refdef.pix_max < 1) + r_refdef.pix_max = 1; + + r_refdef.vrectright_particle = r_refdef.vrectright - r_refdef.pix_max; + r_refdef.vrectbottom_particle = r_refdef.vrectbottom - r_refdef.pix_max; // left side clip - screenedge[0].normal[0] = -1.0 / (xOrigin * r_refdef.horizontalFieldOfView); + screenedge[0].normal[0] = -1.0 / (0.5 * fov_h); screenedge[0].normal[1] = 0; screenedge[0].normal[2] = 1; screenedge[0].type = PLANE_ANYZ; // right side clip - screenedge[1].normal[0] = - 1.0 / ((1.0 - xOrigin) * r_refdef.horizontalFieldOfView); + screenedge[1].normal[0] = 1.0 / (0.5 * fov_h); screenedge[1].normal[1] = 0; screenedge[1].normal[2] = 1; screenedge[1].type = PLANE_ANYZ; // top side clip screenedge[2].normal[0] = 0; - screenedge[2].normal[1] = -1.0 / (yOrigin * verticalFieldOfView); + screenedge[2].normal[1] = -1.0 / (0.5 * fov_v); screenedge[2].normal[2] = 1; screenedge[2].type = PLANE_ANYZ; // bottom side clip screenedge[3].normal[0] = 0; - screenedge[3].normal[1] = 1.0 / ((1.0 - yOrigin) * verticalFieldOfView); + screenedge[3].normal[1] = 1.0 / (0.5 * fov_v); screenedge[3].normal[2] = 1; screenedge[3].type = PLANE_ANYZ; for (i = 0; i < 4; i++) VectorNormalize(screenedge[i].normal); - - D_ViewChanged(); } @@ -317,10 +257,10 @@ void R_SetupFrame(void) // build the transformation matrix for the given view angles - VectorCopy(r_refdef.vieworg, modelorg); - VectorCopy(r_refdef.vieworg, r_origin); + VectorCopy(r_newrefdef.vieworg, modelorg); + VectorCopy(r_newrefdef.vieworg, r_origin); - AngleVectors(r_refdef.viewangles, vpn, vright, vup); + AngleVectors(r_newrefdef.viewangles, vpn, vright, vup); // current viewleaf if (!(r_newrefdef.rdflags & RDF_NOWORLDMODEL)) { @@ -373,6 +313,22 @@ void R_SetupFrame(void) r_outofedges = 0; // d_setup + d_zrowbytes = vid.width * 2; + d_zwidth = vid.width; + + for (i = 0; i < vid.height; i++) { + d_scantable[i] = i * r_screenrowbytes; + zspantable[i] = d_pzbuffer + i * d_zwidth; + } + +// clear Z-buffer and color-buffers if we're doing the gallery + if (r_newrefdef.rdflags & RDF_NOWORLDMODEL) { + memset(d_pzbuffer, 0xff, vid.width * vid.height * sizeof(d_pzbuffer[0])); +#if 0 + R_DrawFill8(r_newrefdef.x, r_newrefdef.y, r_newrefdef.width, r_newrefdef.height, /*(int)sw_clearcolor->value & 0xff*/0); +#endif + } + d_minmip = Cvar_ClampInteger(sw_mipcap, 0, NUM_MIPS - 1); for (i = 0; i < (NUM_MIPS - 1); i++) diff --git a/src/refresh/sw/part.c b/src/refresh/sw/part.c index 8813f37..5f91486 100644 --- a/src/refresh/sw/part.c +++ b/src/refresh/sw/part.c @@ -65,13 +65,13 @@ static void R_DrawParticle(void) */ // FIXME: preadjust xcenter and ycenter zi = 1.0 / transformed[2]; - u = (int)(xcenter + zi * transformed[0] + 0.5); - v = (int)(ycenter - zi * transformed[1] + 0.5); + u = (int)(r_refdef.xcenter + zi * transformed[0] + 0.5); + v = (int)(r_refdef.ycenter - zi * transformed[1] + 0.5); - if ((v > d_vrectbottom_particle) || - (u > d_vrectright_particle) || - (v < d_vrecty) || - (u < d_vrectx)) { + if (v > r_refdef.vrectbottom_particle || + u > r_refdef.vrectright_particle || + v < r_refdef.vrect.y || + u < r_refdef.vrect.x) { return; } @@ -87,11 +87,11 @@ static void R_DrawParticle(void) ** determine the screen area covered by the particle, ** which also means clamping to a min and max */ - pix = izi >> d_pix_shift; - if (pix < d_pix_min) - pix = d_pix_min; - else if (pix > d_pix_max) - pix = d_pix_max; + pix = izi >> r_refdef.pix_shift; + if (pix < r_refdef.pix_min) + pix = r_refdef.pix_min; + else if (pix > r_refdef.pix_max) + pix = r_refdef.pix_max; /* ** render the appropriate pixels @@ -122,8 +122,8 @@ void R_DrawParticles(void) int i; int alpha; - VectorScale(vright, xscaleshrink, partparms.right); - VectorScale(vup, yscaleshrink, partparms.up); + VectorScale(vright, r_refdef.xscaleshrink, partparms.right); + VectorScale(vup, r_refdef.yscaleshrink, partparms.up); VectorCopy(vpn, partparms.pn); for (p = r_newrefdef.particles, i = 0; i < r_newrefdef.num_particles; i++, p++) { diff --git a/src/refresh/sw/poly.c b/src/refresh/sw/poly.c index 87125d6..fb2f746 100644 --- a/src/refresh/sw/poly.c +++ b/src/refresh/sw/poly.c @@ -583,11 +583,11 @@ static void R_ClipAndDrawPoly(float alpha, int isturbulent, int textured) pout->s = pv[3]; pout->t = pv[4]; - scale = xscale * pout->zi; - pout->u = (xcenter + scale * transformed[0]); + scale = r_refdef.xscale * pout->zi; + pout->u = (r_refdef.xcenter + scale * transformed[0]); - scale = yscale * pout->zi; - pout->v = (ycenter - scale * transformed[1]); + scale = r_refdef.yscale * pout->zi; + pout->v = (r_refdef.ycenter - scale * transformed[1]); pv += sizeof(vec5_t) / sizeof(vec_t); } @@ -679,17 +679,17 @@ static void R_PolygonCalculateGradients(void) distinv = 1.0 / (-(DotProduct(r_polydesc.viewer_position, r_polydesc.vpn)) + r_polydesc.dist); - d_sdivzstepu = p_saxis[0] * xscaleinv; - d_sdivzstepv = -p_saxis[1] * yscaleinv; - d_sdivzorigin = p_saxis[2] - xcenter * d_sdivzstepu - ycenter * d_sdivzstepv; + d_sdivzstepu = p_saxis[0] * r_refdef.xscaleinv; + d_sdivzstepv = -p_saxis[1] * r_refdef.yscaleinv; + d_sdivzorigin = p_saxis[2] - r_refdef.xcenter * d_sdivzstepu - r_refdef.ycenter * d_sdivzstepv; - d_tdivzstepu = p_taxis[0] * xscaleinv; - d_tdivzstepv = -p_taxis[1] * yscaleinv; - d_tdivzorigin = p_taxis[2] - xcenter * d_tdivzstepu - ycenter * d_tdivzstepv; + d_tdivzstepu = p_taxis[0] * r_refdef.xscaleinv; + d_tdivzstepv = -p_taxis[1] * r_refdef.yscaleinv; + d_tdivzorigin = p_taxis[2] - r_refdef.xcenter * d_tdivzstepu - r_refdef.ycenter * d_tdivzstepv; - d_zistepu = p_normal[0] * xscaleinv * distinv; - d_zistepv = -p_normal[1] * yscaleinv * distinv; - d_ziorigin = p_normal[2] * distinv - xcenter * d_zistepu - ycenter * d_zistepv; + d_zistepu = p_normal[0] * r_refdef.xscaleinv * distinv; + d_zistepv = -p_normal[1] * r_refdef.yscaleinv * distinv; + d_ziorigin = p_normal[2] * distinv - r_refdef.xcenter * d_zistepu - r_refdef.ycenter * d_zistepv; sadjust = (fixed16_t)((DotProduct(r_polydesc.viewer_position, r_polydesc.vright) + r_polydesc.s_offset) * 0x10000); tadjust = (fixed16_t)((DotProduct(r_polydesc.viewer_position, r_polydesc.vup) + r_polydesc.t_offset) * 0x10000); diff --git a/src/refresh/sw/raster.c b/src/refresh/sw/raster.c index 359c348..0a09837 100644 --- a/src/refresh/sw/raster.c +++ b/src/refresh/sw/raster.c @@ -86,15 +86,15 @@ static void R_EmitEdge(mvertex_t *pv0, mvertex_t *pv1) lzi0 = 1.0 / transformed[2]; // FIXME: build x/yscale into transform? - scale = xscale * lzi0; - u0 = (xcenter + scale * transformed[0]); + scale = r_refdef.xscale * lzi0; + u0 = (r_refdef.xcenter + scale * transformed[0]); if (u0 < r_refdef.fvrectx_adj) u0 = r_refdef.fvrectx_adj; if (u0 > r_refdef.fvrectright_adj) u0 = r_refdef.fvrectright_adj; - scale = yscale * lzi0; - v0 = (ycenter - scale * transformed[1]); + scale = r_refdef.yscale * lzi0; + v0 = (r_refdef.ycenter - scale * transformed[1]); if (v0 < r_refdef.fvrecty_adj) v0 = r_refdef.fvrecty_adj; if (v0 > r_refdef.fvrectbottom_adj) @@ -114,15 +114,15 @@ static void R_EmitEdge(mvertex_t *pv0, mvertex_t *pv1) r_lzi1 = 1.0 / transformed[2]; - scale = xscale * r_lzi1; - r_u1 = (xcenter + scale * transformed[0]); + scale = r_refdef.xscale * r_lzi1; + r_u1 = (r_refdef.xcenter + scale * transformed[0]); if (r_u1 < r_refdef.fvrectx_adj) r_u1 = r_refdef.fvrectx_adj; if (r_u1 > r_refdef.fvrectright_adj) r_u1 = r_refdef.fvrectright_adj; - scale = yscale * r_lzi1; - r_v1 = (ycenter - scale * transformed[1]); + scale = r_refdef.yscale * r_lzi1; + r_v1 = (r_refdef.ycenter - scale * transformed[1]); if (r_v1 < r_refdef.fvrecty_adj) r_v1 = r_refdef.fvrecty_adj; if (r_v1 > r_refdef.fvrectbottom_adj) @@ -459,11 +459,11 @@ void R_RenderFace(mface_t *fa, int clipflags) // FIXME: cache this? distinv = 1.0 / (pplane->dist - DotProduct(modelorg, pplane->normal)); - surface_p->d_zistepu = p_normal[0] * xscaleinv * distinv; - surface_p->d_zistepv = -p_normal[1] * yscaleinv * distinv; + surface_p->d_zistepu = p_normal[0] * r_refdef.xscaleinv * distinv; + surface_p->d_zistepv = -p_normal[1] * r_refdef.yscaleinv * distinv; surface_p->d_ziorigin = p_normal[2] * distinv - - xcenter * surface_p->d_zistepu - - ycenter * surface_p->d_zistepv; + r_refdef.xcenter * surface_p->d_zistepu - + r_refdef.ycenter * surface_p->d_zistepv; surface_p++; } @@ -573,11 +573,11 @@ void R_RenderBmodelFace(bedge_t *pedges, mface_t *psurf) // FIXME: cache this? distinv = 1.0 / (pplane->dist - DotProduct(modelorg, pplane->normal)); - surface_p->d_zistepu = p_normal[0] * xscaleinv * distinv; - surface_p->d_zistepv = -p_normal[1] * yscaleinv * distinv; + surface_p->d_zistepu = p_normal[0] * r_refdef.xscaleinv * distinv; + surface_p->d_zistepv = -p_normal[1] * r_refdef.yscaleinv * distinv; surface_p->d_ziorigin = p_normal[2] * distinv - - xcenter * surface_p->d_zistepu - - ycenter * surface_p->d_zistepv; + r_refdef.xcenter * surface_p->d_zistepu - + r_refdef.ycenter * surface_p->d_zistepv; surface_p++; } diff --git a/src/refresh/sw/sw.h b/src/refresh/sw/sw.h index 57d6e41..b65784e 100644 --- a/src/refresh/sw/sw.h +++ b/src/refresh/sw/sw.h @@ -96,9 +96,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #define BMODEL_FULLY_CLIPPED 0x10 // value returned by R_BmodelCheckBBox () // if bbox is trivially rejected -#define XCENTERING (1.0 / 2.0) -#define YCENTERING (1.0 / 2.0) - #define CLIP_EPSILON 0.001 #define BACKFACE_EPSILON 0.01 @@ -134,12 +131,9 @@ typedef struct { typedef struct { vrect_t vrect; // subwindow in video for refresh - // FIXME: not need vrect next field here? - vrect_t aliasvrect; // scaled Alias version int vrectright, vrectbottom; // right & bottom screen coords - int aliasvrectright, aliasvrectbottom; // scaled Alias versions float vrectrightedge; // rightmost right edge we care about, - // for use in edge list + // for use in edge list float fvrectx, fvrecty; // for floating-point compares float fvrectx_adj, fvrecty_adj; // left and top edges, for clamping int vrect_x_adj_shift20; // (vrect.x + 0.5 - epsilon) << 20 @@ -147,15 +141,17 @@ typedef struct { float fvrectright_adj, fvrectbottom_adj; // right and bottom edges, for clamping float fvrectright; // rightmost edge, for Alias clamping float fvrectbottom; // bottommost edge, for Alias clamping - float horizontalFieldOfView; // at Z = 1.0, this many X is visible - // 2.0 = 90 degrees - float xOrigin; // should probably always be 0.5 - float yOrigin; // between be around 0.3 to 0.5 - vec3_t vieworg; - vec3_t viewangles; + // values for perspective projection + float xcenter, ycenter; + float xscale, yscale; + float xscaleinv, yscaleinv; + float xscaleshrink, yscaleshrink; + float scale_for_mip; - int ambientlight; + // particle values + int vrectright_particle, vrectbottom_particle; + int pix_min, pix_max, pix_shift; } oldrefdef_t; typedef struct { @@ -309,14 +305,11 @@ VARS */ extern int r_framecount; // sequence # of current frame since Quake started -extern float r_aliasuvscale; // scale-up factor for screen u and v - // on Alias vertices passed to driver extern qboolean r_dowarp; extern affinetridesc_t r_affinetridesc; void D_DrawSurfaces(void); -void D_ViewChanged(void); void D_WarpScreen(void); //=======================================================================// @@ -327,8 +320,6 @@ extern int c_surf; extern byte r_warpbuffer[WARP_WIDTH * WARP_HEIGHT * VID_BYTES]; -extern float scale_for_mip; - extern float d_sdivzstepu, d_tdivzstepu, d_zistepu; extern float d_sdivzstepv, d_tdivzstepv, d_zistepv; extern float d_sdivzorigin, d_tdivzorigin, d_ziorigin; @@ -342,10 +333,6 @@ void D_DrawZSpans(espan_t *pspans); surfcache_t *D_CacheSurface(mface_t *surface, int miplevel); -extern int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle; - -extern int d_pix_min, d_pix_max, d_pix_shift; - extern pixel_t *d_viewbuffer; extern short *d_pzbuffer; extern unsigned int d_zrowbytes, d_zwidth; @@ -388,11 +375,6 @@ extern surf_t *surfaces, *surface_p, *surf_max; extern vec3_t sxformaxis[4]; // s axis transformed into viewspace extern vec3_t txformaxis[4]; // t axis transformed into viewspac -extern float xcenter, ycenter; -extern float xscale, yscale; -extern float xscaleinv, yscaleinv; -extern float xscaleshrink, yscaleshrink; - extern void R_TransformVector(vec3_t in, vec3_t out); //=========================================================================== @@ -446,9 +428,6 @@ extern vec3_t modelorg; extern vec3_t r_entorigin; extern vec3_t entity_rotation[3]; -extern float verticalFieldOfView; -extern float xOrigin, yOrigin; - extern int r_visframecount; extern mface_t *r_alpha_surfaces; @@ -507,8 +486,6 @@ extern fixed8_t r_aliasblendcolor[3]; extern int r_alias_alpha; extern int r_alias_one_minus_alpha; -extern float aliasxscale, aliasyscale, aliasxcenter, aliasycenter; - extern int r_outofsurfaces; extern int r_outofedges; |