whitespace...

This commit is contained in:
Ragnvald Maartmann-Moe IV 2001-05-15 21:13:07 +00:00
parent 8826182522
commit e7c2ed82db
28 changed files with 539 additions and 1145 deletions

View file

@ -39,16 +39,12 @@ static auxvert_t av[8];
void R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av); void R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av);
void R_Alias_clip_top (finalvert_t *pfv0, finalvert_t *pfv1, void R_Alias_clip_top (finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out); finalvert_t *out);
void R_Alias_clip_bottom (finalvert_t *pfv0, finalvert_t *pfv1, void R_Alias_clip_bottom (finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out); finalvert_t *out);
void R_Alias_clip_left (finalvert_t *pfv0, finalvert_t *pfv1, void R_Alias_clip_left (finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out); finalvert_t *out);
void R_Alias_clip_right (finalvert_t *pfv0, finalvert_t *pfv1, void R_Alias_clip_right (finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out); finalvert_t *out);
@ -228,9 +224,6 @@ R_AliasClip (finalvert_t *in, finalvert_t *out, int flag, int count,
} }
/*
R_AliasClipTriangle
*/
void void
R_AliasClipTriangle (mtriangle_t *ptri) R_AliasClipTriangle (mtriangle_t *ptri)
{ {
@ -238,7 +231,7 @@ R_AliasClipTriangle (mtriangle_t *ptri)
mtriangle_t mtri; mtriangle_t mtri;
unsigned int clipflags; unsigned int clipflags;
// copy vertexes and fix seam texture coordinates // copy vertexes and fix seam texture coordinates
if (ptri->facesfront) { if (ptri->facesfront) {
fv[0][0] = pfinalverts[ptri->vertindex[0]]; fv[0][0] = pfinalverts[ptri->vertindex[0]];
fv[0][1] = pfinalverts[ptri->vertindex[1]]; fv[0][1] = pfinalverts[ptri->vertindex[1]];
@ -252,7 +245,7 @@ R_AliasClipTriangle (mtriangle_t *ptri)
} }
} }
// clip // clip
clipflags = fv[0][0].flags | fv[0][1].flags | fv[0][2].flags; clipflags = fv[0][0].flags | fv[0][1].flags | fv[0][2].flags;
if (clipflags & ALIAS_Z_CLIP) { if (clipflags & ALIAS_Z_CLIP) {
@ -320,7 +313,7 @@ R_AliasClipTriangle (mtriangle_t *ptri)
fv[pingpong][i].flags = 0; fv[pingpong][i].flags = 0;
} }
// draw triangles // draw triangles
mtri.facesfront = ptri->facesfront; mtri.facesfront = ptri->facesfront;
r_affinetridesc.ptriangles = &mtri; r_affinetridesc.ptriangles = &mtri;
r_affinetridesc.pfinalverts = fv[pingpong]; r_affinetridesc.pfinalverts = fv[pingpong];

View file

@ -37,8 +37,8 @@
#include "r_local.h" #include "r_local.h"
#define LIGHT_MIN 5 // lowest light value we'll allow, to #define LIGHT_MIN 5 // lowest light value we'll allow, to
// avoid the // avoid the need for inner-loop light
// need for inner-loop light clamping // clamping
mtriangle_t *ptriangles; mtriangle_t *ptriangles;
affinetridesc_t r_affinetridesc; affinetridesc_t r_affinetridesc;
@ -86,7 +86,6 @@ float r_avertexnormals[NUMVERTEXNORMALS][3] = {
}; };
void R_AliasTransformAndProjectFinalVerts (finalvert_t *fv, void R_AliasTransformAndProjectFinalVerts (finalvert_t *fv,
stvert_t *pstverts); stvert_t *pstverts);
void R_AliasSetUpTransform (int trivial_accept); void R_AliasSetUpTransform (int trivial_accept);
void R_AliasTransformVector (vec3_t in, vec3_t out); void R_AliasTransformVector (vec3_t in, vec3_t out);
@ -95,9 +94,6 @@ void R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av,
void R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av); void R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av);
/*
R_AliasCheckBBox
*/
qboolean qboolean
R_AliasCheckBBox (void) R_AliasCheckBBox (void)
{ {
@ -111,8 +107,7 @@ R_AliasCheckBBox (void)
unsigned int anyclip, allclip; unsigned int anyclip, allclip;
int minz; int minz;
// expand, rotate, and translate points into worldspace // expand, rotate, and translate points into worldspace
currententity->trivial_accept = 0; currententity->trivial_accept = 0;
pmodel = currententity->model; pmodel = currententity->model;
pahdr = Mod_Extradata (pmodel); pahdr = Mod_Extradata (pmodel);
@ -120,7 +115,7 @@ R_AliasCheckBBox (void)
R_AliasSetUpTransform (0); R_AliasSetUpTransform (0);
// construct the base bounding box for this frame // construct the base bounding box for this frame
frame = currententity->frame; frame = currententity->frame;
// TODO: don't repeat this check when drawing? // TODO: don't repeat this check when drawing?
if ((frame >= pmdl->numframes) || (frame < 0)) { if ((frame >= pmdl->numframes) || (frame < 0)) {
@ -130,19 +125,19 @@ R_AliasCheckBBox (void)
pframedesc = &pahdr->frames[frame]; pframedesc = &pahdr->frames[frame];
// x worldspace coordinates // x worldspace coordinates
basepts[0][0] = basepts[1][0] = basepts[2][0] = basepts[3][0] = basepts[0][0] = basepts[1][0] = basepts[2][0] = basepts[3][0] =
(float) pframedesc->bboxmin.v[0]; (float) pframedesc->bboxmin.v[0];
basepts[4][0] = basepts[5][0] = basepts[6][0] = basepts[7][0] = basepts[4][0] = basepts[5][0] = basepts[6][0] = basepts[7][0] =
(float) pframedesc->bboxmax.v[0]; (float) pframedesc->bboxmax.v[0];
// y worldspace coordinates // y worldspace coordinates
basepts[0][1] = basepts[3][1] = basepts[5][1] = basepts[6][1] = basepts[0][1] = basepts[3][1] = basepts[5][1] = basepts[6][1] =
(float) pframedesc->bboxmin.v[1]; (float) pframedesc->bboxmin.v[1];
basepts[1][1] = basepts[2][1] = basepts[4][1] = basepts[7][1] = basepts[1][1] = basepts[2][1] = basepts[4][1] = basepts[7][1] =
(float) pframedesc->bboxmax.v[1]; (float) pframedesc->bboxmax.v[1];
// z worldspace coordinates // z worldspace coordinates
basepts[0][2] = basepts[1][2] = basepts[4][2] = basepts[5][2] = basepts[0][2] = basepts[1][2] = basepts[4][2] = basepts[5][2] =
(float) pframedesc->bboxmin.v[2]; (float) pframedesc->bboxmin.v[2];
basepts[2][2] = basepts[3][2] = basepts[6][2] = basepts[7][2] = basepts[2][2] = basepts[3][2] = basepts[6][2] = basepts[7][2] =
@ -176,8 +171,7 @@ R_AliasCheckBBox (void)
if (zclipped) { if (zclipped) {
// organize points by edges, use edges to get new points (possible // organize points by edges, use edges to get new points (possible
// trivial // trivial reject)
// reject)
for (i = 0; i < 12; i++) { for (i = 0; i < 12; i++) {
// edge endpoints // edge endpoints
pv0 = &viewpts[aedges[i].index0]; pv0 = &viewpts[aedges[i].index0];
@ -199,7 +193,7 @@ R_AliasCheckBBox (void)
} }
} }
} }
// project the vertices that remain after clipping // project the vertices that remain after clipping
anyclip = 0; anyclip = 0;
allclip = ALIAS_XY_CLIP_MASK; allclip = ALIAS_XY_CLIP_MASK;
@ -245,9 +239,6 @@ R_AliasCheckBBox (void)
} }
/*
R_AliasTransformVector
*/
void void
R_AliasTransformVector (vec3_t in, vec3_t out) R_AliasTransformVector (vec3_t in, vec3_t out)
{ {
@ -295,9 +286,7 @@ R_AliasPreparePoints (void)
} }
} }
// // clip and draw all triangles
// clip and draw all triangles
//
r_affinetridesc.numtriangles = 1; r_affinetridesc.numtriangles = 1;
ptri = (mtriangle_t *) ((byte *) paliashdr + paliashdr->triangles); ptri = (mtriangle_t *) ((byte *) paliashdr + paliashdr->triangles);
@ -322,9 +311,6 @@ R_AliasPreparePoints (void)
} }
/*
R_AliasSetUpTransform
*/
void void
R_AliasSetUpTransform (int trivial_accept) R_AliasSetUpTransform (int trivial_accept)
{ {
@ -396,9 +382,6 @@ R_AliasSetUpTransform (int trivial_accept)
} }
/*
R_AliasTransformFinalVert
*/
void void
R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av, R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av,
trivertx_t *pverts, stvert_t *pstverts) trivertx_t *pverts, stvert_t *pstverts)
@ -418,7 +401,7 @@ R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av,
fv->flags = pstverts->onseam; fv->flags = pstverts->onseam;
// lighting // lighting
plightnormal = r_avertexnormals[pverts->lightnormalindex]; plightnormal = r_avertexnormals[pverts->lightnormalindex];
lightcos = DotProduct (plightnormal, r_plightvec); lightcos = DotProduct (plightnormal, r_plightvec);
temp = r_ambientlight; temp = r_ambientlight;
@ -427,8 +410,7 @@ R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av,
temp += (int) (r_shadelight * lightcos); temp += (int) (r_shadelight * lightcos);
// clamp; because we limited the minimum ambient and shading light, // clamp; because we limited the minimum ambient and shading light,
// we // we don't have to clamp low light, just bright
// don't have to clamp low light, just bright
if (temp < 0) if (temp < 0)
temp = 0; temp = 0;
} }
@ -438,10 +420,6 @@ R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av,
#ifndef USE_INTEL_ASM #ifndef USE_INTEL_ASM
/*
R_AliasTransformAndProjectFinalVerts
*/
void void
R_AliasTransformAndProjectFinalVerts (finalvert_t *fv, stvert_t *pstverts) R_AliasTransformAndProjectFinalVerts (finalvert_t *fv, stvert_t *pstverts)
{ {
@ -489,19 +467,15 @@ R_AliasTransformAndProjectFinalVerts (finalvert_t *fv, stvert_t *pstverts)
fv->v[4] = temp; fv->v[4] = temp;
} }
} }
#endif #endif
/*
R_AliasProjectFinalVert
*/
void void
R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av) R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av)
{ {
float zi; float zi;
// project points // project points
zi = 1.0 / av->fv[2]; zi = 1.0 / av->fv[2];
fv->v[5] = zi * ziscale; fv->v[5] = zi * ziscale;
@ -511,9 +485,6 @@ R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av)
} }
/*
R_AliasPrepareUnclippedPoints
*/
void void
R_AliasPrepareUnclippedPoints (void) R_AliasPrepareUnclippedPoints (void)
{ {
@ -538,9 +509,7 @@ R_AliasPrepareUnclippedPoints (void)
D_PolysetDraw (); D_PolysetDraw ();
} }
/*
R_AliasSetupSkin
*/
void void
R_AliasSetupSkin (void) R_AliasSetupSkin (void)
{ {
@ -590,15 +559,12 @@ R_AliasSetupSkin (void)
r_affinetridesc.skinheight = pmdl->skinheight; r_affinetridesc.skinheight = pmdl->skinheight;
} }
/*
R_AliasSetupLighting
*/
void void
R_AliasSetupLighting (alight_t *plighting) R_AliasSetupLighting (alight_t *plighting)
{ {
// guarantee that no vertex will ever be lit below LIGHT_MIN, so we don't
// guarantee that no vertex will ever be lit below LIGHT_MIN, so we don't have // have to clamp off the bottom
// to clamp off the bottom
r_ambientlight = plighting->ambientlight; r_ambientlight = plighting->ambientlight;
if (r_ambientlight < LIGHT_MIN) if (r_ambientlight < LIGHT_MIN)
@ -616,12 +582,13 @@ R_AliasSetupLighting (alight_t *plighting)
r_shadelight *= VID_GRADES; r_shadelight *= VID_GRADES;
// rotate the lighting vector into the model's frame of reference // rotate the lighting vector into the model's frame of reference
r_plightvec[0] = DotProduct (plighting->plightvec, alias_forward); r_plightvec[0] = DotProduct (plighting->plightvec, alias_forward);
r_plightvec[1] = -DotProduct (plighting->plightvec, alias_right); r_plightvec[1] = -DotProduct (plighting->plightvec, alias_right);
r_plightvec[2] = DotProduct (plighting->plightvec, alias_up); r_plightvec[2] = DotProduct (plighting->plightvec, alias_up);
} }
/* /*
R_AliasSetupFrame R_AliasSetupFrame
@ -655,10 +622,8 @@ R_AliasSetupFrame (void)
time = cl.time + currententity->syncbase; time = cl.time + currententity->syncbase;
// // when loading in Mod_LoadAliasGroup, we guaranteed all interval values
// when loading in Mod_LoadAliasGroup, we guaranteed all interval values // are positive, so we don't have to worry about division by 0
// are positive, so we don't have to worry about division by 0
//
targettime = time - ((int) (time / fullinterval)) * fullinterval; targettime = time - ((int) (time / fullinterval)) * fullinterval;
for (i = 0; i < (numframes - 1); i++) { for (i = 0; i < (numframes - 1); i++) {
@ -671,9 +636,6 @@ R_AliasSetupFrame (void)
} }
/*
R_AliasDrawModel
*/
void void
R_AliasDrawModel (alight_t *plighting) R_AliasDrawModel (alight_t *plighting)
{ {
@ -683,7 +645,7 @@ R_AliasDrawModel (alight_t *plighting)
r_amodels_drawn++; r_amodels_drawn++;
// cache align // cache align
pfinalverts = (finalvert_t *) pfinalverts = (finalvert_t *)
(((long) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1)); (((long) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
pauxverts = &auxverts[0]; pauxverts = &auxverts[0];

View file

@ -39,24 +39,16 @@
#include "r_local.h" #include "r_local.h"
#include "render.h" #include "render.h"
//
// current entity info // current entity info
//
qboolean insubmodel; qboolean insubmodel;
entity_t *currententity; entity_t *currententity;
vec3_t modelorg, base_modelorg; vec3_t modelorg, base_modelorg;
// modelorg is the viewpoint reletive to // modelorg is the viewpoint reletive to
// the currently rendering entity // the currently rendering entity
vec3_t r_entorigin; // the currently rendering entity in vec3_t r_entorigin; // the currently rendering entity in world
// world
// coordinates // coordinates
float entity_rotation[3][3]; float entity_rotation[3][3];
vec3_t r_worldmodelorg; vec3_t r_worldmodelorg;
int r_currentbkey; int r_currentbkey;
typedef enum { touchessolid, drawnode, nodrawnode } solidstate_t; typedef enum { touchessolid, drawnode, nodrawnode } solidstate_t;
@ -73,11 +65,6 @@ static mvertex_t *pfrontenter, *pfrontexit;
static qboolean makeclippededge; static qboolean makeclippededge;
//===========================================================================
/*
R_EntityRotate
*/
void void
R_EntityRotate (vec3_t vec) R_EntityRotate (vec3_t vec)
{ {
@ -90,9 +77,6 @@ R_EntityRotate (vec3_t vec)
} }
/*
R_RotateBmodel
*/
void void
R_RotateBmodel (void) R_RotateBmodel (void)
{ {
@ -103,7 +87,7 @@ R_RotateBmodel (void)
// TODO: could cache lazily, stored in the entity // TODO: could cache lazily, stored in the entity
// TODO: share work with R_SetUpAliasTransform // TODO: share work with R_SetUpAliasTransform
// yaw // yaw
angle = currententity->angles[YAW]; angle = currententity->angles[YAW];
angle = angle * M_PI * 2 / 360; angle = angle * M_PI * 2 / 360;
s = sin (angle); s = sin (angle);
@ -119,8 +103,7 @@ R_RotateBmodel (void)
temp1[2][1] = 0; temp1[2][1] = 0;
temp1[2][2] = 1; temp1[2][2] = 1;
// pitch
// pitch
angle = currententity->angles[PITCH]; angle = currententity->angles[PITCH];
angle = angle * M_PI * 2 / 360; angle = angle * M_PI * 2 / 360;
s = sin (angle); s = sin (angle);
@ -138,7 +121,7 @@ R_RotateBmodel (void)
R_ConcatRotations (temp2, temp1, temp3); R_ConcatRotations (temp2, temp1, temp3);
// roll // roll
angle = currententity->angles[ROLL]; angle = currententity->angles[ROLL];
angle = angle * M_PI * 2 / 360; angle = angle * M_PI * 2 / 360;
s = sin (angle); s = sin (angle);
@ -156,9 +139,7 @@ R_RotateBmodel (void)
R_ConcatRotations (temp1, temp3, entity_rotation); R_ConcatRotations (temp1, temp3, entity_rotation);
// // rotate modelorg and the transformation matrix
// rotate modelorg and the transformation matrix
//
R_EntityRotate (modelorg); R_EntityRotate (modelorg);
R_EntityRotate (vpn); R_EntityRotate (vpn);
R_EntityRotate (vright); R_EntityRotate (vright);
@ -168,9 +149,6 @@ R_RotateBmodel (void)
} }
/*
R_RecursiveClipBPoly
*/
void void
R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf) R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
{ {
@ -185,7 +163,7 @@ R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
makeclippededge = false; makeclippededge = false;
// transform the BSP plane into model space // transform the BSP plane into model space
// FIXME: cache these? // FIXME: cache these?
splitplane = pnode->plane; splitplane = pnode->plane;
tplane.dist = splitplane->dist - tplane.dist = splitplane->dist -
@ -194,12 +172,12 @@ R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
tplane.normal[1] = DotProduct (entity_rotation[1], splitplane->normal); tplane.normal[1] = DotProduct (entity_rotation[1], splitplane->normal);
tplane.normal[2] = DotProduct (entity_rotation[2], splitplane->normal); tplane.normal[2] = DotProduct (entity_rotation[2], splitplane->normal);
// clip edges to BSP plane // clip edges to BSP plane
for (; pedges; pedges = pnextedge) { for (; pedges; pedges = pnextedge) {
pnextedge = pedges->pnext; pnextedge = pedges->pnext;
// set the status for the last point as the previous point // set the status for the last point as the previous point
// FIXME: cache this stuff somehow? // FIXME: cache this stuff somehow?
plastvert = pedges->v[0]; plastvert = pedges->v[0];
lastdist = DotProduct (plastvert->position, tplane.normal) - lastdist = DotProduct (plastvert->position, tplane.normal) -
tplane.dist; tplane.dist;
@ -235,7 +213,7 @@ R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
// split into two edges, one on each side, and remember entering // split into two edges, one on each side, and remember entering
// and exiting points // and exiting points
// FIXME: share the clip edge by having a winding direction flag? // FIXME: share the clip edge by having a winding direction flag?
if (numbedges >= (MAX_BMODEL_EDGES - 1)) { if (numbedges >= (MAX_BMODEL_EDGES - 1)) {
Con_Printf ("Out of edges for bmodel\n"); Con_Printf ("Out of edges for bmodel\n");
return; return;
@ -270,8 +248,8 @@ R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
} }
} }
// if anything was clipped, reconstitute and add the edges along the clip // if anything was clipped, reconstitute and add the edges along the clip
// plane to both sides (but in opposite directions) // plane to both sides (but in opposite directions)
if (makeclippededge) { if (makeclippededge) {
if (numbedges >= (MAX_BMODEL_EDGES - 2)) { if (numbedges >= (MAX_BMODEL_EDGES - 2)) {
Con_Printf ("Out of edges for bmodel\n"); Con_Printf ("Out of edges for bmodel\n");
@ -292,16 +270,14 @@ R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
numbedges += 2; numbedges += 2;
} }
// draw or recurse further // draw or recurse further
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
if (psideedges[i]) { if (psideedges[i]) {
// draw if we've reached a non-solid leaf, done if all that's // draw if we've reached a non-solid leaf, done if all that's left
// left is a // is a solid leaf, and continue down the tree if it's not a leaf
// solid leaf, and continue down the tree if it's not a leaf
pn = pnode->children[i]; pn = pnode->children[i];
// we're done with this branch if the node or leaf isn't in the // we're done with this branch if the node or leaf isn't in the PVS
// PVS
if (pn->visframe == r_visframecount) { if (pn->visframe == r_visframecount) {
if (pn->contents < 0) { if (pn->contents < 0) {
if (pn->contents != CONTENTS_SOLID) { if (pn->contents != CONTENTS_SOLID) {
@ -318,9 +294,6 @@ R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
} }
/*
R_DrawSolidClippedSubmodelPolygons
*/
void void
R_DrawSolidClippedSubmodelPolygons (model_t *pmodel) R_DrawSolidClippedSubmodelPolygons (model_t *pmodel)
{ {
@ -348,13 +321,11 @@ R_DrawSolidClippedSubmodelPolygons (model_t *pmodel)
// draw the polygon // draw the polygon
if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) || if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
(!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) { (!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) {
// FIXME: use bounding-box-based frustum clipping info? // FIXME: use bounding-box-based frustum clipping info?
// copy the edges to bedges, flipping if necessary so always // copy the edges to bedges, flipping if necessary so always
// clockwise winding // clockwise winding
// FIXME: if edges and vertices get caches, these assignments // FIXME: if edges and vertices get caches, these assignments must move
// must move // outside the loop, and overflow checking must be done here
// outside the loop, and overflow checking must be done here
pbverts = bverts; pbverts = bverts;
pbedges = bedges; pbedges = bedges;
numbverts = numbedges = 0; numbverts = numbedges = 0;
@ -391,9 +362,6 @@ R_DrawSolidClippedSubmodelPolygons (model_t *pmodel)
} }
/*
R_DrawSubmodelPolygons
*/
void void
R_DrawSubmodelPolygons (model_t *pmodel, int clipflags) R_DrawSubmodelPolygons (model_t *pmodel, int clipflags)
{ {
@ -426,9 +394,6 @@ R_DrawSubmodelPolygons (model_t *pmodel, int clipflags)
} }
/*
R_RecursiveWorldNode
*/
void void
R_RecursiveWorldNode (mnode_t *node, int clipflags) R_RecursiveWorldNode (mnode_t *node, int clipflags)
{ {
@ -445,7 +410,7 @@ R_RecursiveWorldNode (mnode_t *node, int clipflags)
if (node->visframe != r_visframecount) if (node->visframe != r_visframecount)
return; return;
// cull the clipping planes if not trivial accept // cull the clipping planes if not trivial accept
// FIXME: the compiler is doing a lousy job of optimizing here; it could be // FIXME: the compiler is doing a lousy job of optimizing here; it could be
// twice as fast in ASM // twice as fast in ASM
if (clipflags) { if (clipflags) {
@ -454,9 +419,8 @@ R_RecursiveWorldNode (mnode_t *node, int clipflags)
continue; // don't need to clip against it continue; // don't need to clip against it
// generate accept and reject points // generate accept and reject points
// FIXME: do with fast look-ups or integer tests based on the // FIXME: do with fast look-ups or integer tests based on the
// sign bit // sign bit of the floating point values
// of the floating point values
pindex = pfrustum_indexes[i]; pindex = pfrustum_indexes[i];
@ -481,7 +445,7 @@ R_RecursiveWorldNode (mnode_t *node, int clipflags)
clipflags &= ~(1 << i); // node is entirely on screen clipflags &= ~(1 << i); // node is entirely on screen
} }
} }
// if a leaf node, draw stuff // if a leaf node, draw stuff
if (node->contents < 0) { if (node->contents < 0) {
pleaf = (mleaf_t *) node; pleaf = (mleaf_t *) node;
@ -590,10 +554,6 @@ R_RecursiveWorldNode (mnode_t *node, int clipflags)
} }
/*
R_RenderWorld
*/
void void
R_RenderWorld (void) R_RenderWorld (void)
{ {
@ -610,8 +570,8 @@ R_RenderWorld (void)
R_RecursiveWorldNode (clmodel->nodes, 15); R_RecursiveWorldNode (clmodel->nodes, 15);
// if the driver wants the polygons back to front, play the visible ones back // if the driver wants the polygons back to front, play the visible ones
// in that order // back in that order
if (r_worldpolysbacktofront) { if (r_worldpolysbacktofront) {
for (i = numbtofpolys - 1; i >= 0; i--) { for (i = numbtofpolys - 1; i >= 0; i--) {
R_RenderPoly (btofpolys[i].psurf, btofpolys[i].clipflags); R_RenderPoly (btofpolys[i].psurf, btofpolys[i].clipflags);

View file

@ -47,8 +47,6 @@ zpointdesc_t r_zpointdesc;
polydesc_t r_polydesc; polydesc_t r_polydesc;
clipplane_t *entity_clipplanes; clipplane_t *entity_clipplanes;
clipplane_t view_clipplanes[4]; clipplane_t view_clipplanes[4];
clipplane_t world_clipplanes[16]; clipplane_t world_clipplanes[16];
@ -80,9 +78,6 @@ qboolean r_lastvertvalid;
#ifndef USE_INTEL_ASM #ifndef USE_INTEL_ASM
/*
R_EmitEdge
*/
void void
R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1) R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
{ {
@ -132,7 +127,7 @@ R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
world = &pv1->position[0]; world = &pv1->position[0];
// transform and project // transform and project
VectorSubtract (world, modelorg, local); VectorSubtract (world, modelorg, local);
TransformVector (local, transformed); TransformVector (local, transformed);
@ -161,7 +156,7 @@ R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
if (lzi0 > r_nearzi) // for mipmap finding if (lzi0 > r_nearzi) // for mipmap finding
r_nearzi = lzi0; r_nearzi = lzi0;
// for right edges, all we want is the effect on 1/z // for right edges, all we want is the effect on 1/z
if (r_nearzionly) if (r_nearzionly)
return; return;
@ -169,8 +164,7 @@ R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
r_ceilv1 = (int) ceil (r_v1); r_ceilv1 = (int) ceil (r_v1);
// create the edge
// create the edge
if (ceilv0 == r_ceilv1) { if (ceilv0 == r_ceilv1) {
// we cache unclipped horizontal edges as fully clipped // we cache unclipped horizontal edges as fully clipped
if (cacheoffset != 0x7FFFFFFF) { if (cacheoffset != 0x7FFFFFFF) {
@ -214,19 +208,17 @@ R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
edge->u_step = u_step * 0x100000; edge->u_step = u_step * 0x100000;
edge->u = u * 0x100000 + 0xFFFFF; edge->u = u * 0x100000 + 0xFFFFF;
// we need to do this to avoid stepping off the edges if a very nearly // we need to do this to avoid stepping off the edges if a very nearly
// horizontal edge is less than epsilon above a scan, and numeric error causes // horizontal edge is less than epsilon above a scan, and numeric error
// it to incorrectly extend to the scan, and the extension of the line goes off // causes it to incorrectly extend to the scan, and the extension of the
// the edge of the screen // line goes off the edge of the screen
// FIXME: is this actually needed? // FIXME: is this actually needed?
if (edge->u < r_refdef.vrect_x_adj_shift20) if (edge->u < r_refdef.vrect_x_adj_shift20)
edge->u = r_refdef.vrect_x_adj_shift20; edge->u = r_refdef.vrect_x_adj_shift20;
if (edge->u > r_refdef.vrectright_adj_shift20) if (edge->u > r_refdef.vrectright_adj_shift20)
edge->u = r_refdef.vrectright_adj_shift20; edge->u = r_refdef.vrectright_adj_shift20;
// // sort the edge in normally
// sort the edge in normally
//
u_check = edge->u; u_check = edge->u;
if (edge->surfs[0]) if (edge->surfs[0])
u_check++; // sort trailers after leaders u_check++; // sort trailers after leaders
@ -247,9 +239,6 @@ R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
} }
/*
R_ClipEdge
*/
void void
R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip) R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
{ {
@ -327,16 +316,13 @@ R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
} }
} while ((clip = clip->next) != NULL); } while ((clip = clip->next) != NULL);
} }
// add the edge // add the edge
R_EmitEdge (pv0, pv1); R_EmitEdge (pv0, pv1);
} }
#endif // !USE_INTEL_ASM #endif // !USE_INTEL_ASM
/*
R_EmitCachedEdge
*/
void void
R_EmitCachedEdge (void) R_EmitCachedEdge (void)
{ {
@ -356,9 +342,6 @@ R_EmitCachedEdge (void)
} }
/*
R_RenderFace
*/
void void
R_RenderFace (msurface_t *fa, int clipflags) R_RenderFace (msurface_t *fa, int clipflags)
{ {
@ -370,12 +353,12 @@ R_RenderFace (msurface_t *fa, int clipflags)
medge_t *pedges, tedge; medge_t *pedges, tedge;
clipplane_t *pclip; clipplane_t *pclip;
// skip out if no more surfs // skip out if no more surfs
if ((surface_p) >= surf_max) { if ((surface_p) >= surf_max) {
r_outofsurfaces++; r_outofsurfaces++;
return; return;
} }
// ditto if not enough edges left, or switch to auxedges if possible // ditto if not enough edges left, or switch to auxedges if possible
if ((edge_p + fa->numedges + 4) >= edge_max) { if ((edge_p + fa->numedges + 4) >= edge_max) {
r_outofedges += fa->numedges; r_outofedges += fa->numedges;
return; return;
@ -383,7 +366,7 @@ R_RenderFace (msurface_t *fa, int clipflags)
c_faceclip++; c_faceclip++;
// set up clip planes // set up clip planes
pclip = NULL; pclip = NULL;
for (i = 3, mask = 0x08; i >= 0; i--, mask >>= 1) { for (i = 3, mask = 0x08; i >= 0; i--, mask >>= 1) {
@ -393,7 +376,7 @@ R_RenderFace (msurface_t *fa, int clipflags)
} }
} }
// push the edges through // push the edges through
r_emitted = 0; r_emitted = 0;
r_nearzi = 0; r_nearzi = 0;
r_nearzionly = false; r_nearzionly = false;
@ -479,7 +462,7 @@ R_RenderFace (msurface_t *fa, int clipflags)
} }
} }
// if there was a clip off the left edge, add that edge too // if there was a clip off the left edge, add that edge too
// FIXME: faster to do in screen space? // FIXME: faster to do in screen space?
// FIXME: share clipped edges? // FIXME: share clipped edges?
if (makeleftedge) { if (makeleftedge) {
@ -487,14 +470,14 @@ R_RenderFace (msurface_t *fa, int clipflags)
r_lastvertvalid = false; r_lastvertvalid = false;
R_ClipEdge (&r_leftexit, &r_leftenter, pclip->next); R_ClipEdge (&r_leftexit, &r_leftenter, pclip->next);
} }
// if there was a clip off the right edge, get the right r_nearzi // if there was a clip off the right edge, get the right r_nearzi
if (makerightedge) { if (makerightedge) {
r_pedge = &tedge; r_pedge = &tedge;
r_lastvertvalid = false; r_lastvertvalid = false;
r_nearzionly = true; r_nearzionly = true;
R_ClipEdge (&r_rightexit, &r_rightenter, view_clipplanes[1].next); R_ClipEdge (&r_rightexit, &r_rightenter, view_clipplanes[1].next);
} }
// if no edges made it out, return without posting the surface // if no edges made it out, return without posting the surface
if (!r_emitted) if (!r_emitted)
return; return;
@ -525,9 +508,6 @@ R_RenderFace (msurface_t *fa, int clipflags)
} }
/*
R_RenderBmodelFace
*/
void void
R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf) R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
{ {
@ -539,12 +519,12 @@ R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
medge_t tedge; medge_t tedge;
clipplane_t *pclip; clipplane_t *pclip;
// skip out if no more surfs // skip out if no more surfs
if (surface_p >= surf_max) { if (surface_p >= surf_max) {
r_outofsurfaces++; r_outofsurfaces++;
return; return;
} }
// ditto if not enough edges left, or switch to auxedges if possible // ditto if not enough edges left, or switch to auxedges if possible
if ((edge_p + psurf->numedges + 4) >= edge_max) { if ((edge_p + psurf->numedges + 4) >= edge_max) {
r_outofedges += psurf->numedges; r_outofedges += psurf->numedges;
return; return;
@ -552,10 +532,10 @@ R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
c_faceclip++; c_faceclip++;
// this is a dummy to give the caching mechanism someplace to write to // this is a dummy to give the caching mechanism someplace to write to
r_pedge = &tedge; r_pedge = &tedge;
// set up clip planes // set up clip planes
pclip = NULL; pclip = NULL;
for (i = 3, mask = 0x08; i >= 0; i--, mask >>= 1) { for (i = 3, mask = 0x08; i >= 0; i--, mask >>= 1) {
@ -565,7 +545,7 @@ R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
} }
} }
// push the edges through // push the edges through
r_emitted = 0; r_emitted = 0;
r_nearzi = 0; r_nearzi = 0;
r_nearzionly = false; r_nearzionly = false;
@ -584,20 +564,20 @@ R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
makerightedge = true; makerightedge = true;
} }
// if there was a clip off the left edge, add that edge too // if there was a clip off the left edge, add that edge too
// FIXME: faster to do in screen space? // FIXME: faster to do in screen space?
// FIXME: share clipped edges? // FIXME: share clipped edges?
if (makeleftedge) { if (makeleftedge) {
r_pedge = &tedge; r_pedge = &tedge;
R_ClipEdge (&r_leftexit, &r_leftenter, pclip->next); R_ClipEdge (&r_leftexit, &r_leftenter, pclip->next);
} }
// if there was a clip off the right edge, get the right r_nearzi // if there was a clip off the right edge, get the right r_nearzi
if (makerightedge) { if (makerightedge) {
r_pedge = &tedge; r_pedge = &tedge;
r_nearzionly = true; r_nearzionly = true;
R_ClipEdge (&r_rightexit, &r_rightenter, view_clipplanes[1].next); R_ClipEdge (&r_rightexit, &r_rightenter, view_clipplanes[1].next);
} }
// if no edges made it out, return without posting the surface // if no edges made it out, return without posting the surface
if (!r_emitted) if (!r_emitted)
return; return;
@ -628,9 +608,6 @@ R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
} }
/*
R_RenderPoly
*/
void void
R_RenderPoly (msurface_t *fa, int clipflags) R_RenderPoly (msurface_t *fa, int clipflags)
{ {
@ -651,7 +628,7 @@ R_RenderPoly (msurface_t *fa, int clipflags)
s_axis = t_axis = 0; // keep compiler happy s_axis = t_axis = 0; // keep compiler happy
// set up clip planes // set up clip planes
pclip = NULL; pclip = NULL;
for (i = 3, mask = 0x08; i >= 0; i--, mask >>= 1) { for (i = 3, mask = 0x08; i >= 0; i--, mask >>= 1) {
@ -661,7 +638,7 @@ R_RenderPoly (msurface_t *fa, int clipflags)
} }
} }
// reconstruct the polygon // reconstruct the polygon
// FIXME: these should be precalculated and loaded off disk // FIXME: these should be precalculated and loaded off disk
pedges = currententity->model->edges; pedges = currententity->model->edges;
lnumverts = fa->numedges; lnumverts = fa->numedges;
@ -679,7 +656,7 @@ R_RenderPoly (msurface_t *fa, int clipflags)
} }
} }
// clip the polygon, done if not visible // clip the polygon, done if not visible
while (pclip) { while (pclip) {
lastvert = lnumverts - 1; lastvert = lnumverts - 1;
lastdist = DotProduct (verts[vertpage][lastvert].position, lastdist = DotProduct (verts[vertpage][lastvert].position,
@ -728,25 +705,25 @@ R_RenderPoly (msurface_t *fa, int clipflags)
pclip = pclip->next; pclip = pclip->next;
} }
// transform and project, remembering the z values at the vertices and // transform and project, remembering the z values at the vertices and
// r_nearzi, and extract the s and t coordinates at the vertices // r_nearzi, and extract the s and t coordinates at the vertices
pplane = fa->plane; pplane = fa->plane;
switch (pplane->type) { switch (pplane->type) {
case PLANE_X: case PLANE_X:
case PLANE_ANYX: case PLANE_ANYX:
s_axis = 1; s_axis = 1;
t_axis = 2; t_axis = 2;
break; break;
case PLANE_Y: case PLANE_Y:
case PLANE_ANYY: case PLANE_ANYY:
s_axis = 0; s_axis = 0;
t_axis = 2; t_axis = 2;
break; break;
case PLANE_Z: case PLANE_Z:
case PLANE_ANYZ: case PLANE_ANYZ:
s_axis = 0; s_axis = 0;
t_axis = 1; t_axis = 1;
break; break;
} }
r_nearzi = 0; r_nearzi = 0;
@ -786,21 +763,18 @@ R_RenderPoly (msurface_t *fa, int clipflags)
pverts[i].t = verts[vertpage][i].position[t_axis]; pverts[i].t = verts[vertpage][i].position[t_axis];
} }
// build the polygon descriptor, including fa, r_nearzi, and u, v, s, t, and z // build the polygon descriptor, including fa, r_nearzi, and u, v, s, t,
// for each vertex // and z for each vertex
r_polydesc.numverts = lnumverts; r_polydesc.numverts = lnumverts;
r_polydesc.nearzi = r_nearzi; r_polydesc.nearzi = r_nearzi;
r_polydesc.pcurrentface = fa; r_polydesc.pcurrentface = fa;
r_polydesc.pverts = pverts; r_polydesc.pverts = pverts;
// draw the polygon // draw the polygon
D_DrawPoly (); D_DrawPoly ();
} }
/*
R_ZDrawSubmodelPolys
*/
void void
R_ZDrawSubmodelPolys (model_t *pmodel) R_ZDrawSubmodelPolys (model_t *pmodel)
{ {

View file

@ -36,13 +36,12 @@
#if 0 #if 0
// FIXME // FIXME
the complex cases add new polys on most lines, the complex cases add new polys on most lines, so dont optimize for
so dont optimize for keeping them the same have multiple free span lists to keeping them the same have multiple free span lists to try to get better
try to get better coherence ? low depth complexity-- 1 to 3 or so this coherence ? low depth complexity-- 1 to 3 or so this breaks spans at every
breaks spans at every edge, even hidden edge, even hidden ones (bad)
ones (bad)
have a sentinal at both ends ? have a sentinal at both ends ?
#endif #endif
edge_t *auxedges; edge_t *auxedges;
edge_t *r_edges, *edge_p, *edge_max; edge_t *r_edges, *edge_p, *edge_max;
@ -75,25 +74,14 @@ edge_t edge_sentinel;
float fv; float fv;
void void R_GenerateSpans (void);
R_GenerateSpans (void); void R_GenerateSpansBackward (void);
void
R_GenerateSpansBackward (void);
void void R_LeadingEdge (edge_t *edge);
R_LeadingEdge (edge_t *edge); void R_LeadingEdgeBackwards (edge_t *edge);
void void R_TrailingEdge (surf_t *surf, edge_t *edge);
R_LeadingEdgeBackwards (edge_t *edge);
void
R_TrailingEdge (surf_t *surf, edge_t *edge);
//=============================================================================
/*
R_DrawCulledPolys
*/
void void
R_DrawCulledPolys (void) R_DrawCulledPolys (void)
{ {
@ -126,9 +114,6 @@ R_DrawCulledPolys (void)
} }
/*
R_BeginEdgeFrame
*/
void void
R_BeginEdgeFrame (void) R_BeginEdgeFrame (void)
{ {
@ -142,7 +127,7 @@ R_BeginEdgeFrame (void)
surfaces[1].spans = NULL; // no background spans yet surfaces[1].spans = NULL; // no background spans yet
surfaces[1].flags = SURF_DRAWBACKGROUND; surfaces[1].flags = SURF_DRAWBACKGROUND;
// put the background behind everything in the world // put the background behind everything in the world
if (r_draworder->int_val) { if (r_draworder->int_val) {
pdrawfunc = R_GenerateSpansBackward; pdrawfunc = R_GenerateSpansBackward;
surfaces[1].key = 0; surfaces[1].key = 0;
@ -203,9 +188,6 @@ R_InsertNewEdges (edge_t *edgestoadd, edge_t *edgelist)
} }
/*
R_RemoveEdges
*/
void void
R_RemoveEdges (edge_t *pedge) R_RemoveEdges (edge_t *pedge)
{ {
@ -217,9 +199,6 @@ R_RemoveEdges (edge_t *pedge)
} }
/*
R_StepActiveU
*/
void void
R_StepActiveU (edge_t *pedge) R_StepActiveU (edge_t *pedge)
{ {
@ -282,9 +261,6 @@ R_StepActiveU (edge_t *pedge)
#endif // !USE_INTEL_ASM #endif // !USE_INTEL_ASM
/*
R_CleanupSpan
*/
void void
R_CleanupSpan (void) R_CleanupSpan (void)
{ {
@ -292,8 +268,8 @@ R_CleanupSpan (void)
int iu; int iu;
espan_t *span; espan_t *span;
// now that we've reached the right edge of the screen, we're done with any // now that we've reached the right edge of the screen, we're done with any
// unfinished surfaces, so emit a span for whatever's on top // unfinished surfaces, so emit a span for whatever's on top
surf = surfaces[1].next; surf = surfaces[1].next;
iu = edge_tail_u_shift20; iu = edge_tail_u_shift20;
if (iu > surf->last_u) { if (iu > surf->last_u) {
@ -304,7 +280,7 @@ R_CleanupSpan (void)
span->pnext = surf->spans; span->pnext = surf->spans;
surf->spans = span; surf->spans = span;
} }
// reset spanstate for all surfaces in the surface stack // reset spanstate for all surfaces in the surface stack
do { do {
surf->spanstate = 0; surf->spanstate = 0;
surf = surf->next; surf = surf->next;
@ -312,9 +288,6 @@ R_CleanupSpan (void)
} }
/*
R_LeadingEdgeBackwards
*/
void void
R_LeadingEdgeBackwards (edge_t *edge) R_LeadingEdgeBackwards (edge_t *edge)
{ {
@ -322,12 +295,12 @@ R_LeadingEdgeBackwards (edge_t *edge)
surf_t *surf, *surf2; surf_t *surf, *surf2;
int iu; int iu;
// it's adding a new surface in, so find the correct place // it's adding a new surface in, so find the correct place
surf = &surfaces[edge->surfs[1]]; surf = &surfaces[edge->surfs[1]];
// don't start a span if this is an inverted span, with the end // don't start a span if this is an inverted span, with the end
// edge preceding the start edge (that is, we've already seen the // edge preceding the start edge (that is, we've already seen the
// end edge) // end edge)
if (++surf->spanstate == 1) { if (++surf->spanstate == 1) {
surf2 = surfaces[1].next; surf2 = surfaces[1].next;
@ -338,8 +311,7 @@ R_LeadingEdgeBackwards (edge_t *edge)
// active is in front, so keep going unless it's a bmodel // active is in front, so keep going unless it's a bmodel
if (surf->insubmodel && (surf->key == surf2->key)) { if (surf->insubmodel && (surf->key == surf2->key)) {
// must be two bmodels in the same leaf; don't care, because // must be two bmodels in the same leaf; don't care, because
// they'll // they'll never be farthest anyway
// never be farthest anyway
goto newtop; goto newtop;
} }
@ -355,8 +327,7 @@ R_LeadingEdgeBackwards (edge_t *edge)
if (!surf->insubmodel) if (!surf->insubmodel)
goto continue_search; goto continue_search;
// must be two bmodels in the same leaf; don't care which is // must be two bmodels in the same leaf; don't care which is really
// really
// in front, because they'll never be farthest anyway // in front, because they'll never be farthest anyway
} }
@ -387,18 +358,14 @@ R_LeadingEdgeBackwards (edge_t *edge)
} }
/*
R_TrailingEdge
*/
void void
R_TrailingEdge (surf_t *surf, edge_t *edge) R_TrailingEdge (surf_t *surf, edge_t *edge)
{ {
espan_t *span; espan_t *span;
int iu; int iu;
// don't generate a span if this is an inverted span, with the end // don't generate a span if this is an inverted span, with the end edge
// edge preceding the start edge (that is, we haven't seen the // preceding the start edge (that is, we haven't seen the start edge yet)
// start edge yet)
if (--surf->spanstate == 0) { if (--surf->spanstate == 0) {
if (surf->insubmodel) if (surf->insubmodel)
r_bmodelactive--; r_bmodelactive--;
@ -426,9 +393,6 @@ R_TrailingEdge (surf_t *surf, edge_t *edge)
#ifndef USE_INTEL_ASM #ifndef USE_INTEL_ASM
/*
R_LeadingEdge
*/
void void
R_LeadingEdge (edge_t *edge) R_LeadingEdge (edge_t *edge)
{ {
@ -441,9 +405,8 @@ R_LeadingEdge (edge_t *edge)
// it's adding a new surface in, so find the correct place // it's adding a new surface in, so find the correct place
surf = &surfaces[edge->surfs[1]]; surf = &surfaces[edge->surfs[1]];
// don't start a span if this is an inverted span, with the end // don't start a span if this is an inverted span, with the end edge
// edge preceding the start edge (that is, we've already seen the // preceding the start edge (that is, we've already seen the end edge)
// end edge)
if (++surf->spanstate == 1) { if (++surf->spanstate == 1) {
if (surf->insubmodel) if (surf->insubmodel)
r_bmodelactive++; r_bmodelactive++;
@ -541,9 +504,6 @@ R_LeadingEdge (edge_t *edge)
} }
/*
R_GenerateSpans
*/
void void
R_GenerateSpans (void) R_GenerateSpans (void)
{ {
@ -552,15 +512,14 @@ R_GenerateSpans (void)
r_bmodelactive = 0; r_bmodelactive = 0;
// clear active surfaces to just the background surface // clear active surfaces to just the background surface
surfaces[1].next = surfaces[1].prev = &surfaces[1]; surfaces[1].next = surfaces[1].prev = &surfaces[1];
surfaces[1].last_u = edge_head_u_shift20; surfaces[1].last_u = edge_head_u_shift20;
// generate spans // generate spans
for (edge = edge_head.next; edge != &edge_tail; edge = edge->next) { for (edge = edge_head.next; edge != &edge_tail; edge = edge->next) {
if (edge->surfs[0]) { if (edge->surfs[0]) {
// it has a left surface, so a surface is going away for this // it has a left surface, so a surface is going away for this span
// span
surf = &surfaces[edge->surfs[0]]; surf = &surfaces[edge->surfs[0]];
R_TrailingEdge (surf, edge); R_TrailingEdge (surf, edge);
@ -578,9 +537,6 @@ R_GenerateSpans (void)
#endif // !USE_INTEL_ASM #endif // !USE_INTEL_ASM
/*
R_GenerateSpansBackward
*/
void void
R_GenerateSpansBackward (void) R_GenerateSpansBackward (void)
{ {
@ -588,11 +544,11 @@ R_GenerateSpansBackward (void)
r_bmodelactive = 0; r_bmodelactive = 0;
// clear active surfaces to just the background surface // clear active surfaces to just the background surface
surfaces[1].next = surfaces[1].prev = &surfaces[1]; surfaces[1].next = surfaces[1].prev = &surfaces[1];
surfaces[1].last_u = edge_head_u_shift20; surfaces[1].last_u = edge_head_u_shift20;
// generate spans // generate spans
for (edge = edge_head.next; edge != &edge_tail; edge = edge->next) { for (edge = edge_head.next; edge != &edge_tail; edge = edge->next) {
if (edge->surfs[0]) if (edge->surfs[0])
R_TrailingEdge (&surfaces[edge->surfs[0]], edge); R_TrailingEdge (&surfaces[edge->surfs[0]], edge);
@ -629,7 +585,7 @@ R_ScanEdges (void)
span_p = basespan_p; span_p = basespan_p;
// clear active edges to just the background edges around the whole screen // clear active edges to just the background edges around the whole screen
// FIXME: most of this only needs to be set up once // FIXME: most of this only needs to be set up once
edge_head.u = r_refdef.vrect.x << 20; edge_head.u = r_refdef.vrect.x << 20;
edge_head_u_shift20 = edge_head.u >> 20; edge_head_u_shift20 = edge_head.u >> 20;
@ -656,9 +612,7 @@ R_ScanEdges (void)
edge_sentinel.u = 2000 << 24; // make sure nothing sorts past this edge_sentinel.u = 2000 << 24; // make sure nothing sorts past this
edge_sentinel.prev = &edge_aftertail; edge_sentinel.prev = &edge_aftertail;
// // process all scan lines
// process all scan lines
//
bottom = r_refdef.vrectbottom - 1; bottom = r_refdef.vrectbottom - 1;
for (iv = r_refdef.vrect.y; iv < bottom; iv++) { for (iv = r_refdef.vrect.y; iv < bottom; iv++) {
@ -675,8 +629,7 @@ R_ScanEdges (void)
(*pdrawfunc) (); (*pdrawfunc) ();
// flush the span list if we can't be sure we have enough spans left // flush the span list if we can't be sure we have enough spans left
// for // for the next scan
// the next scan
if (span_p >= max_span_p) { if (span_p >= max_span_p) {
VID_UnlockBuffer (); VID_UnlockBuffer ();
S_ExtraUpdate (); // don't let sound get messed up if S_ExtraUpdate (); // don't let sound get messed up if
@ -702,12 +655,11 @@ R_ScanEdges (void)
R_StepActiveU (edge_head.next); R_StepActiveU (edge_head.next);
} }
// do the last scan (no need to step or sort or remove on the last scan) // do the last scan (no need to step or sort or remove on the last scan)
current_iv = iv; current_iv = iv;
fv = (float) iv; fv = (float) iv;
// mark that the head (background start) span is pre-included // mark that the head (background start) span is pre-included
surfaces[1].spanstate = 1; surfaces[1].spanstate = 1;
if (newedges[iv]) if (newedges[iv])
@ -715,7 +667,7 @@ R_ScanEdges (void)
(*pdrawfunc) (); (*pdrawfunc) ();
// draw whatever's left in the span list // draw whatever's left in the span list
if (r_drawculledpolys) if (r_drawculledpolys)
R_DrawCulledPolys (); R_DrawCulledPolys ();
else else

View file

@ -36,17 +36,13 @@
int r_dlightframecount; int r_dlightframecount;
/*
R_AnimateLight
*/
void void
R_AnimateLight (void) R_AnimateLight (void)
{ {
int i, j, k; int i, j, k;
// // light animations
// light animations // 'm' is normal light, 'a' is no light, 'z' is double bright
// 'm' is normal light, 'a' is no light, 'z' is double bright
i = (int) (cl.time * 10); i = (int) (cl.time * 10);
for (j = 0; j < MAX_LIGHTSTYLES; j++) { for (j = 0; j < MAX_LIGHTSTYLES; j++) {
if (!cl_lightstyle[j].length) { if (!cl_lightstyle[j].length) {
@ -65,9 +61,7 @@ R_AnimateLight (void)
DYNAMIC LIGHTS DYNAMIC LIGHTS
*/ */
/*
R_MarkLights
*/
void void
R_MarkLights (vec3_t lightorigin, dlight_t *light, int bit, mnode_t *node) R_MarkLights (vec3_t lightorigin, dlight_t *light, int bit, mnode_t *node)
{ {
@ -90,7 +84,7 @@ R_MarkLights (vec3_t lightorigin, dlight_t *light, int bit, mnode_t *node)
R_MarkLights (lightorigin, light, bit, node->children[1]); R_MarkLights (lightorigin, light, bit, node->children[1]);
return; return;
} }
// mark the polygons // mark the polygons
surf = cl.worldmodel->surfaces + node->firstsurface; surf = cl.worldmodel->surfaces + node->firstsurface;
for (i = 0; i < node->numsurfaces; i++, surf++) { for (i = 0; i < node->numsurfaces; i++, surf++) {
if (surf->dlightframe != r_dlightframecount) { if (surf->dlightframe != r_dlightframecount) {
@ -105,9 +99,6 @@ R_MarkLights (vec3_t lightorigin, dlight_t *light, int bit, mnode_t *node)
} }
/*
R_PushDlights
*/
void void
R_PushDlights (vec3_t entorigin) R_PushDlights (vec3_t entorigin)
{ {
@ -132,6 +123,7 @@ R_PushDlights (vec3_t entorigin)
LIGHT SAMPLING LIGHT SAMPLING
*/ */
int int
RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end) RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end)
{ {
@ -151,8 +143,7 @@ RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end)
if (node->contents < 0) if (node->contents < 0)
return -1; // didn't hit anything return -1; // didn't hit anything
// calculate mid point // calculate mid point
// FIXME: optimize for axial // FIXME: optimize for axial
plane = node->plane; plane = node->plane;
front = DotProduct (start, plane->normal) - plane->dist; front = DotProduct (start, plane->normal) - plane->dist;
@ -167,7 +158,7 @@ RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end)
mid[1] = start[1] + (end[1] - start[1]) * frac; mid[1] = start[1] + (end[1] - start[1]) * frac;
mid[2] = start[2] + (end[2] - start[2]) * frac; mid[2] = start[2] + (end[2] - start[2]) * frac;
// go down front side // go down front side
r = RecursiveLightPoint (node->children[side], start, mid); r = RecursiveLightPoint (node->children[side], start, mid);
if (r >= 0) if (r >= 0)
return r; // hit something return r; // hit something
@ -175,7 +166,7 @@ RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end)
if ((back < 0) == side) if ((back < 0) == side)
return -1; // didn't hit anything return -1; // didn't hit anything
// check for impact on this node // check for impact on this node
surf = cl.worldmodel->surfaces + node->firstsurface; surf = cl.worldmodel->surfaces + node->firstsurface;
for (i = 0; i < node->numsurfaces; i++, surf++) { for (i = 0; i < node->numsurfaces; i++, surf++) {
@ -222,10 +213,11 @@ RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end)
return r; return r;
} }
// go down back side // go down back side
return RecursiveLightPoint (node->children[!side], mid, end); return RecursiveLightPoint (node->children[!side], mid, end);
} }
int int
R_LightPoint (vec3_t p) R_LightPoint (vec3_t p)
{ {

View file

@ -85,17 +85,13 @@ byte *r_stack_start;
qboolean r_fov_greater_than_90; qboolean r_fov_greater_than_90;
//
// view origin // view origin
//
vec3_t vup, base_vup; vec3_t vup, base_vup;
vec3_t vpn, base_vpn; vec3_t vpn, base_vpn;
vec3_t vright, base_vright; vec3_t vright, base_vright;
vec3_t r_origin; vec3_t r_origin;
//
// screen size info // screen size info
//
refdef_t r_refdef; refdef_t r_refdef;
float xcenter, ycenter; float xcenter, ycenter;
float xscale, yscale; float xscale, yscale;
@ -112,11 +108,8 @@ float xOrigin, yOrigin;
mplane_t screenedge[4]; mplane_t screenedge[4];
//
// refresh flags // refresh flags
//
int r_framecount = 1; // so frame counts initialized to 0 int r_framecount = 1; // so frame counts initialized to 0
// don't match // don't match
int r_visframecount; int r_visframecount;
int d_spanpixcount; int d_spanpixcount;
@ -132,10 +125,8 @@ int *pfrustum_indexes[4];
int r_frustum_indexes[4 * 6]; int r_frustum_indexes[4 * 6];
int reinit_surfcache = 1; // if 1, surface cache is currently int reinit_surfcache = 1; // if 1, surface cache is currently
// empty and must be reinitialized
// empty and // for current cache size
// must be reinitialized for current cache
// size
mleaf_t *r_viewleaf, *r_oldviewleaf; mleaf_t *r_viewleaf, *r_oldviewleaf;
@ -155,16 +146,13 @@ extern cvar_t *scr_fov;
void R_NetGraph (void); void R_NetGraph (void);
void R_ZGraph (void); void R_ZGraph (void);
/*
R_Textures_Init
*/
void void
R_Textures_Init (void) R_Textures_Init (void)
{ {
int x, y, m; int x, y, m;
byte *dest; byte *dest;
// create a simple checkerboard texture for the default // create a simple checkerboard texture for the default
r_notexture_mip = r_notexture_mip =
Hunk_AllocName (sizeof (texture_t) + 16 * 16 + 8 * 8 + 4 * 4 + 2 * 2, Hunk_AllocName (sizeof (texture_t) + 16 * 16 + 8 * 8 + 4 * 4 + 2 * 2,
"notexture"); "notexture");
@ -188,11 +176,9 @@ R_Textures_Init (void)
} }
} }
void R_LoadSky_f (void);
/* void R_LoadSky_f (void);
R_Init
*/
void void
R_Init (void) R_Init (void)
{ {
@ -203,8 +189,10 @@ R_Init (void)
R_InitTurb (); R_InitTurb ();
Cmd_AddCommand ("timerefresh", R_TimeRefresh_f, "Tests the current refresh rate for the current location"); Cmd_AddCommand ("timerefresh", R_TimeRefresh_f, "Tests the current "
Cmd_AddCommand ("pointfile", R_ReadPointFile_f, "Load a pointfile to determine map leaks"); "refresh rate for the current location");
Cmd_AddCommand ("pointfile", R_ReadPointFile_f, "Load a pointfile to "
"determine map leaks");
Cmd_AddCommand ("loadsky", R_LoadSky_f, "Load a skybox"); Cmd_AddCommand ("loadsky", R_LoadSky_f, "Load a skybox");
Cvar_SetValue (r_maxedges, (float) NUMSTACKEDGES); Cvar_SetValue (r_maxedges, (float) NUMSTACKEDGES);
@ -231,15 +219,13 @@ R_Init (void)
D_Init (); D_Init ();
} }
/*
R_NewMap
*/
void void
R_NewMap (void) R_NewMap (void)
{ {
int i; int i;
// clear out efrags in case the level hasn't been reloaded // clear out efrags in case the level hasn't been reloaded
// FIXME: is this one short? // FIXME: is this one short?
for (i = 0; i < cl.worldmodel->numleafs; i++) for (i = 0; i < cl.worldmodel->numleafs; i++)
cl.worldmodel->leafs[i].efrags = NULL; cl.worldmodel->leafs[i].efrags = NULL;
@ -286,9 +272,6 @@ R_NewMap (void)
} }
/*
R_SetVrect
*/
void void
R_SetVrect (vrect_t *pvrectin, vrect_t *pvrect, int lineadj) R_SetVrect (vrect_t *pvrectin, vrect_t *pvrect, int lineadj)
{ {
@ -420,26 +403,26 @@ R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect)
xscaleshrink = (r_refdef.vrect.width - 6) / r_refdef.horizontalFieldOfView; xscaleshrink = (r_refdef.vrect.width - 6) / r_refdef.horizontalFieldOfView;
yscaleshrink = xscaleshrink * pixelAspect; yscaleshrink = xscaleshrink * pixelAspect;
// left side clip // left side clip
screenedge[0].normal[0] = -1.0 / (xOrigin * r_refdef.horizontalFieldOfView); screenedge[0].normal[0] = -1.0 / (xOrigin * r_refdef.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) * r_refdef.horizontalFieldOfView); 1.0 / ((1.0 - xOrigin) * r_refdef.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 * verticalFieldOfView); 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) * verticalFieldOfView); screenedge[3].normal[1] = 1.0 / ((1.0 - yOrigin) * verticalFieldOfView);
screenedge[3].normal[2] = 1; screenedge[3].normal[2] = 1;
@ -477,9 +460,6 @@ R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect)
} }
/*
R_MarkLeaves
*/
void void
R_MarkLeaves (void) R_MarkLeaves (void)
{ {
@ -508,11 +488,7 @@ R_MarkLeaves (void)
} }
} }
/*
=============
R_ShowNearestLoc
=============
*/
static void static void
R_ShowNearestLoc (void) R_ShowNearestLoc (void)
{ {
@ -535,9 +511,7 @@ R_ShowNearestLoc (void)
} }
} }
/*
R_DrawEntitiesOnList
*/
void void
R_DrawEntitiesOnList (void) R_DrawEntitiesOnList (void)
{ {
@ -577,8 +551,7 @@ R_DrawEntitiesOnList (void)
VectorSubtract (r_origin, r_entorigin, modelorg); VectorSubtract (r_origin, r_entorigin, modelorg);
// see if the bounding box lets us trivially reject, also // see if the bounding box lets us trivially reject, also
// sets // sets trivial accept status
// trivial accept status
if (R_AliasCheckBBox ()) { if (R_AliasCheckBBox ()) {
j = R_LightPoint (currententity->origin); j = R_LightPoint (currententity->origin);
@ -615,9 +588,7 @@ R_DrawEntitiesOnList (void)
} }
} }
/*
R_DrawViewModel
*/
void void
R_DrawViewModel (void) R_DrawViewModel (void)
{ {
@ -659,7 +630,7 @@ R_DrawViewModel (void)
r_viewlighting.ambientlight = j; r_viewlighting.ambientlight = j;
r_viewlighting.shadelight = j; r_viewlighting.shadelight = j;
// add dynamic lights // add dynamic lights
for (lnum = 0; lnum < MAX_DLIGHTS; lnum++) { for (lnum = 0; lnum < MAX_DLIGHTS; lnum++) {
dl = &cl_dlights[lnum]; dl = &cl_dlights[lnum];
if (!dl->radius) if (!dl->radius)
@ -675,7 +646,7 @@ R_DrawViewModel (void)
r_viewlighting.ambientlight += add; r_viewlighting.ambientlight += add;
} }
// clamp lighting so it doesn't overbright as much // clamp lighting so it doesn't overbright as much
if (r_viewlighting.ambientlight > 128) if (r_viewlighting.ambientlight > 128)
r_viewlighting.ambientlight = 128; r_viewlighting.ambientlight = 128;
if (r_viewlighting.ambientlight + r_viewlighting.shadelight > 192) if (r_viewlighting.ambientlight + r_viewlighting.shadelight > 192)
@ -687,9 +658,6 @@ R_DrawViewModel (void)
} }
/*
R_BmodelCheckBBox
*/
int int
R_BmodelCheckBBox (model_t *clmodel, float *minmaxs) R_BmodelCheckBBox (model_t *clmodel, float *minmaxs)
{ {
@ -714,9 +682,8 @@ R_BmodelCheckBBox (model_t *clmodel, float *minmaxs)
} else { } else {
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
// generate accept and reject points // generate accept and reject points
// FIXME: do with fast look-ups or integer tests based on the // FIXME: do with fast look-ups or integer tests based on the
// sign bit // sign bit of the floating point values
// of the floating point values
pindex = pfrustum_indexes[i]; pindex = pfrustum_indexes[i];
@ -746,9 +713,6 @@ R_BmodelCheckBBox (model_t *clmodel, float *minmaxs)
} }
/*
R_DrawBEntitiesOnList
*/
void void
R_DrawBEntitiesOnList (void) R_DrawBEntitiesOnList (void)
{ {
@ -773,8 +737,7 @@ R_DrawBEntitiesOnList (void)
clmodel = currententity->model; clmodel = currententity->model;
// see if the bounding box lets us trivially reject, also // see if the bounding box lets us trivially reject, also
// sets // sets trivial accept status
// trivial accept status
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
minmaxs[j] = currententity->origin[j] + clmodel->mins[j]; minmaxs[j] = currententity->origin[j] + clmodel->mins[j];
minmaxs[3 + j] = currententity->origin[j] + minmaxs[3 + j] = currententity->origin[j] +
@ -786,12 +749,12 @@ R_DrawBEntitiesOnList (void)
if (clipflags != BMODEL_FULLY_CLIPPED) { if (clipflags != BMODEL_FULLY_CLIPPED) {
VectorCopy (currententity->origin, r_entorigin); VectorCopy (currententity->origin, r_entorigin);
VectorSubtract (r_origin, r_entorigin, modelorg); VectorSubtract (r_origin, r_entorigin, modelorg);
// FIXME: is this needed? // FIXME: is this needed?
VectorCopy (modelorg, r_worldmodelorg); VectorCopy (modelorg, r_worldmodelorg);
r_pcurrentvertbase = clmodel->vertexes; r_pcurrentvertbase = clmodel->vertexes;
// FIXME: stop transforming twice // FIXME: stop transforming twice
R_RotateBmodel (); R_RotateBmodel ();
// calculate dynamic lighting for bmodel if it's not an // calculate dynamic lighting for bmodel if it's not an
@ -811,10 +774,8 @@ R_DrawBEntitiesOnList (void)
} }
} }
// if the driver wants polygons, deliver those. // if the driver wants polygons, deliver those.
// Z-buffering is on // Z-buffering is on at this point, so no clipping to the
// at this point, so no clipping to the world tree is // world tree is needed, just frustum clipping
// needed, just
// frustum clipping
if (r_drawpolys | r_drawculledpolys) { if (r_drawpolys | r_drawculledpolys) {
R_ZDrawSubmodelPolys (clmodel); R_ZDrawSubmodelPolys (clmodel);
} else { } else {
@ -837,10 +798,8 @@ R_DrawBEntitiesOnList (void)
R_DrawSolidClippedSubmodelPolygons (clmodel); R_DrawSolidClippedSubmodelPolygons (clmodel);
} else { } else {
// falls entirely in one leaf, so we just put // falls entirely in one leaf, so we just put
// all the // all the edges in the edge list and let 1/z
// edges in the edge list and let 1/z sorting // sorting handle drawing order
// handle
// drawing order
R_DrawSubmodelPolygons (clmodel, clipflags); R_DrawSubmodelPolygons (clmodel, clipflags);
} }
@ -849,7 +808,7 @@ R_DrawBEntitiesOnList (void)
} }
// put back world rotation and frustum clipping // put back world rotation and frustum clipping
// FIXME: R_RotateBmodel should just work off base_vxx // FIXME: R_RotateBmodel should just work off base_vxx
VectorCopy (base_vpn, vpn); VectorCopy (base_vpn, vpn);
VectorCopy (base_vup, vup); VectorCopy (base_vup, vup);
VectorCopy (base_vright, vright); VectorCopy (base_vright, vright);
@ -869,17 +828,12 @@ R_DrawBEntitiesOnList (void)
} }
/*
R_EdgeDrawing
*/
void void
R_EdgeDrawing (void) R_EdgeDrawing (void)
{ {
edge_t ledges[NUMSTACKEDGES + edge_t ledges[NUMSTACKEDGES +
((CACHE_SIZE - 1) / sizeof (edge_t)) + 1]; ((CACHE_SIZE - 1) / sizeof (edge_t)) + 1];
surf_t lsurfs[NUMSTACKSURFACES + surf_t lsurfs[NUMSTACKSURFACES +
((CACHE_SIZE - 1) / sizeof (surf_t)) + 1]; ((CACHE_SIZE - 1) / sizeof (surf_t)) + 1];
if (auxedges) { if (auxedges) {
@ -910,8 +864,8 @@ R_EdgeDrawing (void)
if (r_drawculledpolys) if (r_drawculledpolys)
R_ScanEdges (); R_ScanEdges ();
// only the world can be drawn back to front with no z reads or compares, just // only the world can be drawn back to front with no z reads or compares,
// z writes, so have the driver turn z compares on now // just z writes, so have the driver turn z compares on now
D_TurnZOn (); D_TurnZOn ();
if (r_dspeeds->int_val) { if (r_dspeeds->int_val) {
@ -928,8 +882,7 @@ R_EdgeDrawing (void)
if (!r_dspeeds->int_val) { if (!r_dspeeds->int_val) {
VID_UnlockBuffer (); VID_UnlockBuffer ();
S_ExtraUpdate (); // don't let sound get messed up if S_ExtraUpdate (); // don't let sound get messed up if going slow
// going slow
VID_LockBuffer (); VID_LockBuffer ();
} }
@ -957,8 +910,7 @@ R_RenderView_ (void)
R_SetupFrame (); R_SetupFrame ();
R_MarkLeaves (); // done here so we know if we're in R_MarkLeaves (); // done here so we know if we're in water
// water
// make FDIV fast. This reduces timing precision after we've been running for a // make FDIV fast. This reduces timing precision after we've been running for a
// while, so we don't do it globally. This also sets chop mode, and we do it // while, so we don't do it globally. This also sets chop mode, and we do it
@ -971,8 +923,7 @@ R_RenderView_ (void)
if (!r_dspeeds->int_val) { if (!r_dspeeds->int_val) {
VID_UnlockBuffer (); VID_UnlockBuffer ();
S_ExtraUpdate (); // don't let sound get messed up if S_ExtraUpdate (); // don't let sound get messed up if going slow
// going slow
VID_LockBuffer (); VID_LockBuffer ();
} }
@ -980,8 +931,7 @@ R_RenderView_ (void)
if (!r_dspeeds->int_val) { if (!r_dspeeds->int_val) {
VID_UnlockBuffer (); VID_UnlockBuffer ();
S_ExtraUpdate (); // don't let sound get messed up if S_ExtraUpdate (); // don't let sound get messed up if going slow
// going slow
VID_LockBuffer (); VID_LockBuffer ();
} }
@ -1032,10 +982,11 @@ R_RenderView_ (void)
if (r_reportedgeout->int_val && r_outofedges) if (r_reportedgeout->int_val && r_outofedges)
Con_Printf ("Short roughly %d edges\n", r_outofedges * 2 / 3); Con_Printf ("Short roughly %d edges\n", r_outofedges * 2 / 3);
// back to high floating-point precision // back to high floating-point precision
Sys_HighFPPrecision (); Sys_HighFPPrecision ();
} }
void void
R_RenderView (void) R_RenderView (void)
{ {
@ -1058,9 +1009,7 @@ R_RenderView (void)
R_RenderView_ (); R_RenderView_ ();
} }
/*
R_InitTurb
*/
void void
R_InitTurb (void) R_InitTurb (void)
{ {

View file

@ -43,9 +43,7 @@
#include "server.h" #include "server.h"
#include "view.h" #include "view.h"
qboolean allowskybox; // whether or not to allow skyboxes qboolean allowskybox; // whether or not to allow skyboxes --KB
// --KB
void void
@ -145,8 +143,8 @@ R_LineGraph (int x, int y, int h)
// FIXME: should be disabled on no-buffer adapters, or should be in the driver // FIXME: should be disabled on no-buffer adapters, or should be in the driver
// x += r_refdef.vrect.x; // x += r_refdef.vrect.x;
// y += r_refdef.vrect.y; // y += r_refdef.vrect.y;
dest = vid.buffer + vid.rowbytes * y + x; dest = vid.buffer + vid.rowbytes * y + x;
@ -166,7 +164,7 @@ R_LineGraph (int x, int y, int h)
for (i = 0; i < h; i++, dest -= vid.rowbytes) { for (i = 0; i < h; i++, dest -= vid.rowbytes) {
dest[0] = color; dest[0] = color;
// *(dest-vid.rowbytes) = 0x30; // *(dest-vid.rowbytes) = 0x30;
} }
#if 0 #if 0
for (; i < s; i++, dest -= vid.rowbytes * 2) { for (; i < s; i++, dest -= vid.rowbytes * 2) {
@ -176,14 +174,16 @@ R_LineGraph (int x, int y, int h)
#endif #endif
} }
#define MAX_TIMINGS 100
extern float mouse_x, mouse_y;
int graphval;
/* /*
R_TimeGraph R_TimeGraph
Performance monitoring tool Performance monitoring tool
*/ */
#define MAX_TIMINGS 100
extern float mouse_x, mouse_y;
int graphval;
void void
R_TimeGraph (void) R_TimeGraph (void)
{ {
@ -196,13 +196,13 @@ R_TimeGraph (void)
r_time2 = Sys_DoubleTime (); r_time2 = Sys_DoubleTime ();
a = (r_time2 - r_time1) / 0.01; a = (r_time2 - r_time1) / 0.01;
//a = fabs(mouse_y * 0.05); // a = fabs(mouse_y * 0.05);
//a = (int)((r_refdef.vieworg[2] + 1024)/1)%(int)r_graphheight->value; // a = (int)((r_refdef.vieworg[2] + 1024)/1)%(int)r_graphheight->value;
//a = (int)((pmove.velocity[2] + 500)/10); // a = (int)((pmove.velocity[2] + 500)/10);
//a = fabs(velocity[0])/20; // a = fabs(velocity[0])/20;
//a = ((int)fabs(origin[0])/8)%20; // a = ((int)fabs(origin[0])/8)%20;
//a = (cl.idealpitch + 30)/5; // a = (cl.idealpitch + 30)/5;
//a = (int)(cl.simangles[YAW] * 64/360) & 63; // a = (int)(cl.simangles[YAW] * 64/360) & 63;
a = graphval; a = graphval;
r_timings[timex] = a; r_timings[timex] = a;
@ -215,8 +215,7 @@ R_TimeGraph (void)
do { do {
R_LineGraph (x, r_refdef.vrect.height - 2, r_timings[a]); R_LineGraph (x, r_refdef.vrect.height - 2, r_timings[a]);
if (x == 0) if (x == 0)
break; // screen too small to hold entire break; // screen too small to hold entire thing
// thing
x--; x--;
a--; a--;
if (a == -1) if (a == -1)
@ -341,7 +340,7 @@ WarpPalette (void)
basecolor[1] = 80; basecolor[1] = 80;
basecolor[2] = 50; basecolor[2] = 50;
// pull the colors halfway to bright brown // pull the colors halfway to bright brown
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
newpalette[i * 3 + j] = newpalette[i * 3 + j] =
@ -376,7 +375,6 @@ R_TransformFrustum (void)
#ifndef USE_INTEL_ASM #ifndef USE_INTEL_ASM
void void
TransformVector (vec3_t in, vec3_t out) TransformVector (vec3_t in, vec3_t out)
{ {
@ -384,7 +382,6 @@ TransformVector (vec3_t in, vec3_t out)
out[1] = DotProduct (in, vup); out[1] = DotProduct (in, vup);
out[2] = DotProduct (in, vpn); out[2] = DotProduct (in, vpn);
} }
#endif #endif
@ -418,7 +415,7 @@ R_SetUpFrustumIndexes (void)
} }
} }
// FIXME: do just once at start // FIXME: do just once at start
pfrustum_indexes[i] = pindex; pfrustum_indexes[i] = pindex;
pindex += 6; pindex += 6;
} }
@ -458,8 +455,7 @@ R_SetupFrame (void)
r_refdef.ambientlight = max (r_ambient->value, 0); r_refdef.ambientlight = max (r_ambient->value, 0);
if (!sv.active) if (!sv.active)
Cvar_SetValue (r_draworder, 0); // don't let cheaters look behind Cvar_SetValue (r_draworder, 0); // don't let cheaters look behind walls
// walls
R_CheckVariables (); R_CheckVariables ();
@ -538,10 +534,10 @@ R_SetupFrame (void)
r_viewchanged = false; r_viewchanged = false;
} }
// start off with just the four screen edge clip planes // start off with just the four screen edge clip planes
R_TransformFrustum (); R_TransformFrustum ();
// save base values // save base values
VectorCopy (vpn, base_vpn); VectorCopy (vpn, base_vpn);
VectorCopy (vright, base_vright); VectorCopy (vright, base_vright);
VectorCopy (vup, base_vup); VectorCopy (vup, base_vup);
@ -553,7 +549,7 @@ R_SetupFrame (void)
r_cache_thrash = false; r_cache_thrash = false;
// clear frame counts // clear frame counts
c_faceclip = 0; c_faceclip = 0;
d_spanpixcount = 0; d_spanpixcount = 0;
r_polycount = 0; r_polycount = 0;
@ -566,6 +562,7 @@ R_SetupFrame (void)
D_SetupFrame (); D_SetupFrame ();
} }
void void
R_TranslatePlayerSkin (int playernum) R_TranslatePlayerSkin (int playernum)
{ {

View file

@ -53,14 +53,17 @@ int r_numparticles;
vec3_t r_pright, r_pup, r_ppn; vec3_t r_pright, r_pup, r_ppn;
/* /*
R_MaxParticlesCheck R_MaxParticlesCheck
Misty-chan: EXTREME heavy lifting and bugfixing thanks goes out to taniwha - I built this, and he got it working :)
Misty-chan: EXTREME heavy lifting and bugfixing thanks goes out to taniwha
- I built this, and he got it working :)
*/ */
void void
R_MaxParticlesCheck (cvar_t *var) R_MaxParticlesCheck (cvar_t *var)
{ {
// Do not use 0 in this! sw doesn't grok 0 and it's going to segfault if we do! // Do not use 0 in this! sw doesn't grok 0 and it'll segfault if we do!
r_numparticles = max(var->int_val, 1); r_numparticles = max(var->int_val, 1);
/* /*
@ -83,7 +86,7 @@ R_Particles_Init_Cvars (void)
{ {
// Does a callback to R_MaxParticleCheck when the cvar changes. Neat trick. // Does a callback to R_MaxParticleCheck when the cvar changes. Neat trick.
Cvar_Get ("cl_max_particles", "2048", CVAR_ARCHIVE, R_MaxParticlesCheck, Cvar_Get ("cl_max_particles", "2048", CVAR_ARCHIVE, R_MaxParticlesCheck,
"Maximum amount of particles to display. No maximum, minimum is 1."); "Maximum amount of particles to display. No maximum, minimum is 1.");
} }

View file

@ -50,12 +50,10 @@ int r_skydirect; // not used?
byte bottomsky[128 * 131]; byte bottomsky[128 * 131];
byte bottommask[128 * 131]; byte bottommask[128 * 131];
byte newsky[128 * 256]; // newsky and topsky both pack in byte newsky[128 * 256]; // newsky and topsky both pack in here, 128
// bytes of newsky on the left of each scan,
// here, 128 bytes // 128 bytes of topsky on the right, because
// of newsky on the left of each scan, 128 bytes // the low-level drawers need 256-byte widths
// of topsky on the right, because the low-level
// drawers need 256-byte scan widths
/* /*
@ -93,9 +91,6 @@ R_InitSky (texture_t *mt)
} }
/*
R_MakeSky
*/
void void
R_MakeSky (void) R_MakeSky (void)
{ {
@ -121,7 +116,6 @@ R_MakeSky (void)
// FIXME: clean this up // FIXME: clean this up
#if UNALIGNED_OK #if UNALIGNED_OK
for (x = 0; x < SKYSIZE; x += 4) { for (x = 0; x < SKYSIZE; x += 4) {
ofs = baseofs + ((x + xshift) & SKYMASK); ofs = baseofs + ((x + xshift) & SKYMASK);
@ -133,9 +127,7 @@ R_MakeSky (void)
pnewsky++; pnewsky++;
} }
#else #else
for (x = 0; x < SKYSIZE; x++) { for (x = 0; x < SKYSIZE; x++) {
ofs = baseofs + ((x + xshift) & SKYMASK); ofs = baseofs + ((x + xshift) & SKYMASK);
@ -144,7 +136,6 @@ R_MakeSky (void)
*(byte *) & bottomsky[ofs]; *(byte *) & bottomsky[ofs];
pnewsky = (unsigned int *) ((byte *) pnewsky + 1); pnewsky = (unsigned int *) ((byte *) pnewsky + 1);
} }
#endif #endif
pnewsky += 128 / sizeof (unsigned int); pnewsky += 128 / sizeof (unsigned int);
@ -154,9 +145,6 @@ R_MakeSky (void)
} }
/*
R_GenSkyTile
*/
void void
R_GenSkyTile (void *pdest) R_GenSkyTile (void *pdest)
{ {
@ -177,7 +165,6 @@ R_GenSkyTile (void *pdest)
// FIXME: clean this up // FIXME: clean this up
#if UNALIGNED_OK #if UNALIGNED_OK
for (x = 0; x < SKYSIZE; x += 4) { for (x = 0; x < SKYSIZE; x += 4) {
ofs = baseofs + ((x + xshift) & SKYMASK); ofs = baseofs + ((x + xshift) & SKYMASK);
@ -190,9 +177,7 @@ R_GenSkyTile (void *pdest)
pnewsky++; pnewsky++;
pd++; pd++;
} }
#else #else
for (x = 0; x < SKYSIZE; x++) { for (x = 0; x < SKYSIZE; x++) {
ofs = baseofs + ((x + xshift) & SKYMASK); ofs = baseofs + ((x + xshift) & SKYMASK);
@ -202,7 +187,6 @@ R_GenSkyTile (void *pdest)
pnewsky = (unsigned int *) ((byte *) pnewsky + 1); pnewsky = (unsigned int *) ((byte *) pnewsky + 1);
pd = (unsigned int *) ((byte *) pd + 1); pd = (unsigned int *) ((byte *) pd + 1);
} }
#endif #endif
pnewsky += 128 / sizeof (unsigned int); pnewsky += 128 / sizeof (unsigned int);
@ -210,9 +194,6 @@ R_GenSkyTile (void *pdest)
} }
/*
R_GenSkyTile16
*/
void void
R_GenSkyTile16 (void *pdest) R_GenSkyTile16 (void *pdest)
{ {
@ -248,9 +229,6 @@ R_GenSkyTile16 (void *pdest)
} }
/*
R_SetSkyFrame
*/
void void
R_SetSkyFrame (void) R_SetSkyFrame (void)
{ {

View file

@ -51,9 +51,6 @@ static int sprite_width, sprite_height;
spritedesc_t r_spritedesc; spritedesc_t r_spritedesc;
/*
R_RotateSprite
*/
void void
R_RotateSprite (float beamlength) R_RotateSprite (float beamlength)
{ {
@ -85,7 +82,7 @@ R_ClipSpriteFace (int nump, clipplane_t *pclipplane)
clipdist = pclipplane->dist; clipdist = pclipplane->dist;
pclipnormal = pclipplane->normal; pclipnormal = pclipplane->normal;
// calc dists // calc dists
if (clip_current) { if (clip_current) {
in = clip_verts[1][0]; in = clip_verts[1][0];
outstep = clip_verts[0][0]; outstep = clip_verts[0][0];
@ -101,12 +98,11 @@ R_ClipSpriteFace (int nump, clipplane_t *pclipplane)
dists[i] = DotProduct (instep, pclipnormal) - clipdist; dists[i] = DotProduct (instep, pclipnormal) - clipdist;
} }
// handle wraparound case // handle wraparound case
dists[nump] = dists[0]; dists[nump] = dists[0];
memcpy (instep, in, sizeof (vec5_t)); memcpy (instep, in, sizeof (vec5_t));
// clip the winding
// clip the winding
instep = in; instep = in;
outcount = 0; outcount = 0;
@ -114,7 +110,6 @@ R_ClipSpriteFace (int nump, clipplane_t *pclipplane)
if (dists[i] >= 0) { if (dists[i] >= 0) {
memcpy (outstep, instep, sizeof (vec5_t)); memcpy (outstep, instep, sizeof (vec5_t));
outstep += sizeof (vec5_t) / sizeof (float); outstep += sizeof (vec5_t) / sizeof (float);
outcount++; outcount++;
} }
@ -144,9 +139,6 @@ R_ClipSpriteFace (int nump, clipplane_t *pclipplane)
} }
/*
R_SetupAndDrawSprite
*/
void void
R_SetupAndDrawSprite (void) R_SetupAndDrawSprite (void)
{ {
@ -158,11 +150,11 @@ R_SetupAndDrawSprite (void)
dot = DotProduct (r_spritedesc.vpn, modelorg); dot = DotProduct (r_spritedesc.vpn, modelorg);
// backface cull // backface cull
if (dot >= 0) if (dot >= 0)
return; return;
// build the sprite poster in worldspace // build the sprite poster in worldspace
VectorScale (r_spritedesc.vright, r_spritedesc.pspriteframe->right, right); VectorScale (r_spritedesc.vright, r_spritedesc.pspriteframe->right, right);
VectorScale (r_spritedesc.vup, r_spritedesc.pspriteframe->up, up); VectorScale (r_spritedesc.vup, r_spritedesc.pspriteframe->up, up);
VectorScale (r_spritedesc.vright, r_spritedesc.pspriteframe->left, left); VectorScale (r_spritedesc.vright, r_spritedesc.pspriteframe->left, left);
@ -194,7 +186,7 @@ R_SetupAndDrawSprite (void)
pverts[3][3] = 0; pverts[3][3] = 0;
pverts[3][4] = sprite_height; pverts[3][4] = sprite_height;
// clip to the frustum in worldspace // clip to the frustum in worldspace
nump = 4; nump = 4;
clip_current = 0; clip_current = 0;
@ -206,7 +198,7 @@ R_SetupAndDrawSprite (void)
Sys_Error ("R_SetupAndDrawSprite: too many points"); Sys_Error ("R_SetupAndDrawSprite: too many points");
} }
// transform vertices into viewspace and project // transform vertices into viewspace and project
pv = &clip_verts[clip_current][0][0]; pv = &clip_verts[clip_current][0][0];
r_spritedesc.nearzi = -999999; r_spritedesc.nearzi = -999999;
@ -234,16 +226,13 @@ R_SetupAndDrawSprite (void)
pv += sizeof (vec5_t) / sizeof (*pv); pv += sizeof (vec5_t) / sizeof (*pv);
} }
// draw it // draw it
r_spritedesc.nump = nump; r_spritedesc.nump = nump;
r_spritedesc.pverts = outverts; r_spritedesc.pverts = outverts;
D_DrawSprite (); D_DrawSprite ();
} }
/*
R_GetSpriteframe
*/
mspriteframe_t * mspriteframe_t *
R_GetSpriteframe (msprite_t *psprite) R_GetSpriteframe (msprite_t *psprite)
{ {
@ -270,8 +259,7 @@ R_GetSpriteframe (msprite_t *psprite)
time = cl.time + currententity->syncbase; time = cl.time + currententity->syncbase;
// when loading in Mod_LoadSpriteGroup, we guaranteed all interval // when loading in Mod_LoadSpriteGroup, we guaranteed all interval
// values // values are positive, so we don't have to worry about division by 0
// are positive, so we don't have to worry about division by 0
targettime = time - ((int) (time / fullinterval)) * fullinterval; targettime = time - ((int) (time / fullinterval)) * fullinterval;
for (i = 0; i < (numframes - 1); i++) { for (i = 0; i < (numframes - 1); i++) {
@ -286,9 +274,6 @@ R_GetSpriteframe (msprite_t *psprite)
} }
/*
R_DrawSprite
*/
void void
R_DrawSprite (void) R_DrawSprite (void)
{ {
@ -306,16 +291,12 @@ R_DrawSprite (void)
// TODO: make this caller-selectable // TODO: make this caller-selectable
if (psprite->type == SPR_FACING_UPRIGHT) { if (psprite->type == SPR_FACING_UPRIGHT) {
// generate the sprite's axes, with vup straight up in worldspace, // generate the sprite's axes, with vup straight up in worldspace, and
// and
// r_spritedesc.vright perpendicular to modelorg. // r_spritedesc.vright perpendicular to modelorg.
// This will not work if the view direction is very close to straight // This will not work if the view direction is very close to straight
// up or // up or down, because the cross product will be between two nearly
// down, because the cross product will be between two nearly // parallel vectors and starts to approach an undefined state, so we
// parallel // don't draw if the two vectors are less than 1 degree apart
// vectors and starts to approach an undefined state, so we don't
// draw if
// the two vectors are less than 1 degree apart
tvec[0] = -modelorg[0]; tvec[0] = -modelorg[0];
tvec[1] = -modelorg[1]; tvec[1] = -modelorg[1];
tvec[2] = -modelorg[2]; tvec[2] = -modelorg[2];
@ -330,38 +311,32 @@ R_DrawSprite (void)
r_spritedesc.vup[1] = 0; r_spritedesc.vup[1] = 0;
r_spritedesc.vup[2] = 1; r_spritedesc.vup[2] = 1;
r_spritedesc.vright[0] = tvec[1]; r_spritedesc.vright[0] = tvec[1];
// CrossProduct(r_spritedesc.vup, -modelorg, // CrossProduct(r_spritedesc.vup, -modelorg,
r_spritedesc.vright[1] = -tvec[0]; r_spritedesc.vright[1] = -tvec[0];
// r_spritedesc.vright) // r_spritedesc.vright)
r_spritedesc.vright[2] = 0; r_spritedesc.vright[2] = 0;
VectorNormalize (r_spritedesc.vright); VectorNormalize (r_spritedesc.vright);
r_spritedesc.vpn[0] = -r_spritedesc.vright[1]; r_spritedesc.vpn[0] = -r_spritedesc.vright[1];
r_spritedesc.vpn[1] = r_spritedesc.vright[0]; r_spritedesc.vpn[1] = r_spritedesc.vright[0];
r_spritedesc.vpn[2] = 0; r_spritedesc.vpn[2] = 0;
// CrossProduct (r_spritedesc.vright, r_spritedesc.vup, // CrossProduct (r_spritedesc.vright, r_spritedesc.vup,
// r_spritedesc.vpn) // r_spritedesc.vpn)
} else if (psprite->type == SPR_VP_PARALLEL) { } else if (psprite->type == SPR_VP_PARALLEL) {
// generate the sprite's axes, completely parallel to the viewplane. // generate the sprite's axes, completely parallel to the viewplane.
// There // There are no problem situations, because the sprite is always in the
// are no problem situations, because the sprite is always in the // same position relative to the viewer
// same
// position relative to the viewer
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
r_spritedesc.vup[i] = vup[i]; r_spritedesc.vup[i] = vup[i];
r_spritedesc.vright[i] = vright[i]; r_spritedesc.vright[i] = vright[i];
r_spritedesc.vpn[i] = vpn[i]; r_spritedesc.vpn[i] = vpn[i];
} }
} else if (psprite->type == SPR_VP_PARALLEL_UPRIGHT) { } else if (psprite->type == SPR_VP_PARALLEL_UPRIGHT) {
// generate the sprite's axes, with vup straight up in worldspace, // generate the sprite's axes, with vup straight up in worldspace, and
// and
// r_spritedesc.vright parallel to the viewplane. // r_spritedesc.vright parallel to the viewplane.
// This will not work if the view direction is very close to straight // This will not work if the view direction is very close to straight
// up or // up or down, because the cross product will be between two nearly
// down, because the cross product will be between two nearly // parallel vectors and starts to approach an undefined state, so we
// parallel // don't draw if the two vectors are less than 1 degree apart
// vectors and starts to approach an undefined state, so we don't
// draw if
// the two vectors are less than 1 degree apart
dot = vpn[2]; // same as DotProduct (vpn, dot = vpn[2]; // same as DotProduct (vpn,
// r_spritedesc.vup) because // r_spritedesc.vup) because
// r_spritedesc.vup is 0, 0, 1 // r_spritedesc.vup is 0, 0, 1
@ -372,25 +347,24 @@ R_DrawSprite (void)
r_spritedesc.vup[1] = 0; r_spritedesc.vup[1] = 0;
r_spritedesc.vup[2] = 1; r_spritedesc.vup[2] = 1;
r_spritedesc.vright[0] = vpn[1]; r_spritedesc.vright[0] = vpn[1];
// CrossProduct (r_spritedesc.vup, vpn, // CrossProduct (r_spritedesc.vup, vpn,
r_spritedesc.vright[1] = -vpn[0]; // r_spritedesc.vright) r_spritedesc.vright[1] = -vpn[0]; // r_spritedesc.vright)
r_spritedesc.vright[2] = 0; r_spritedesc.vright[2] = 0;
VectorNormalize (r_spritedesc.vright); VectorNormalize (r_spritedesc.vright);
r_spritedesc.vpn[0] = -r_spritedesc.vright[1]; r_spritedesc.vpn[0] = -r_spritedesc.vright[1];
r_spritedesc.vpn[1] = r_spritedesc.vright[0]; r_spritedesc.vpn[1] = r_spritedesc.vright[0];
r_spritedesc.vpn[2] = 0; r_spritedesc.vpn[2] = 0;
// CrossProduct (r_spritedesc.vright, r_spritedesc.vup, // CrossProduct (r_spritedesc.vright, r_spritedesc.vup,
// r_spritedesc.vpn) // r_spritedesc.vpn)
} else if (psprite->type == SPR_ORIENTED) { } else if (psprite->type == SPR_ORIENTED) {
// generate the sprite's axes, according to the sprite's world // generate the sprite's axes, according to the sprite's world
// orientation // orientation
AngleVectors (currententity->angles, r_spritedesc.vpn, AngleVectors (currententity->angles, r_spritedesc.vpn,
r_spritedesc.vright, r_spritedesc.vup); r_spritedesc.vright, r_spritedesc.vup);
} else if (psprite->type == SPR_VP_PARALLEL_ORIENTED) { } else if (psprite->type == SPR_VP_PARALLEL_ORIENTED) {
// generate the sprite's axes, parallel to the viewplane, but rotated // generate the sprite's axes, parallel to the viewplane, but rotated
// in // in that plane around the center according to the sprite entity's
// that plane around the center according to the sprite entity's roll // roll angle. So vpn stays the same, but vright and vup rotate
// angle. So vpn stays the same, but vright and vup rotate
angle = currententity->angles[ROLL] * (M_PI * 2 / 360); angle = currententity->angles[ROLL] * (M_PI * 2 / 360);
sr = sin (angle); sr = sin (angle);
cr = cos (angle); cr = cos (angle);

View file

@ -60,13 +60,9 @@ static void (*surfmiptable[4]) (void) = {
R_DrawSurfaceBlock8_mip1, R_DrawSurfaceBlock8_mip1,
R_DrawSurfaceBlock8_mip2, R_DrawSurfaceBlock8_mip3}; R_DrawSurfaceBlock8_mip2, R_DrawSurfaceBlock8_mip3};
unsigned int blocklights[18 * 18]; unsigned int blocklights[18 * 18];
/*
R_AddDynamicLights
*/
void void
R_AddDynamicLights (void) R_AddDynamicLights (void)
{ {
@ -128,6 +124,7 @@ R_AddDynamicLights (void)
} }
} }
/* /*
R_BuildLightMap R_BuildLightMap
@ -156,12 +153,11 @@ R_BuildLightMap (void)
blocklights[i] = 0; blocklights[i] = 0;
return; return;
} }
// clear to ambient // clear to ambient
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
blocklights[i] = r_refdef.ambientlight << 8; blocklights[i] = r_refdef.ambientlight << 8;
// add all the lightmaps
// add all the lightmaps
if (lightmap) if (lightmap)
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255; maps++) { for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255; maps++) {
scale = r_drawsurf.lightadj[maps]; // 8.8 fraction scale = r_drawsurf.lightadj[maps]; // 8.8 fraction
@ -169,11 +165,11 @@ R_BuildLightMap (void)
blocklights[i] += lightmap[i] * scale; blocklights[i] += lightmap[i] * scale;
lightmap += size; // skip to next lightmap lightmap += size; // skip to next lightmap
} }
// add all the dynamic lights // add all the dynamic lights
if (surf->dlightframe == r_framecount) if (surf->dlightframe == r_framecount)
R_AddDynamicLights (); R_AddDynamicLights ();
// bound, invert, and shift // bound, invert, and shift
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
t = (255 * 256 - (int) blocklights[i]) >> (8 - VID_CBITS); t = (255 * 256 - (int) blocklights[i]) >> (8 - VID_CBITS);
@ -219,9 +215,6 @@ R_TextureAnimation (texture_t *base)
} }
/*
R_DrawSurface
*/
void void
R_DrawSurface (void) R_DrawSurface (void)
{ {
@ -234,7 +227,7 @@ R_DrawSurface (void)
void (*pblockdrawer) (void); void (*pblockdrawer) (void);
texture_t *mt; texture_t *mt;
// calculate the lightings // calculate the lightings
R_BuildLightMap (); R_BuildLightMap ();
surfrowbytes = r_drawsurf.rowbytes; surfrowbytes = r_drawsurf.rowbytes;
@ -243,8 +236,8 @@ R_DrawSurface (void)
r_source = (byte *) mt + mt->offsets[r_drawsurf.surfmip]; r_source = (byte *) mt + mt->offsets[r_drawsurf.surfmip];
// the fractional light values should range from 0 to (VID_GRADES - 1) << 16 // the fractional light values should range from 0 to
// from a source range of 0 - 255 // (VID_GRADES - 1) << 16 from a source range of 0 - 255
texwidth = mt->width >> r_drawsurf.surfmip; texwidth = mt->width >> r_drawsurf.surfmip;
@ -280,7 +273,7 @@ R_DrawSurface (void)
soffset = r_drawsurf.surf->texturemins[0]; soffset = r_drawsurf.surf->texturemins[0];
basetoffset = r_drawsurf.surf->texturemins[1]; basetoffset = r_drawsurf.surf->texturemins[1];
// << 16 components are to guarantee positive values for % // << 16 components are to guarantee positive values for %
soffset = ((soffset >> r_drawsurf.surfmip) + (smax << 16)) % smax; soffset = ((soffset >> r_drawsurf.surfmip) + (smax << 16)) % smax;
basetptr = &r_source[((((basetoffset >> r_drawsurf.surfmip) basetptr = &r_source[((((basetoffset >> r_drawsurf.surfmip)
+ (tmax << 16)) % tmax) * twidth)]; + (tmax << 16)) % tmax) * twidth)];
@ -305,13 +298,8 @@ R_DrawSurface (void)
} }
//=============================================================================
#ifndef USE_INTEL_ASM #ifndef USE_INTEL_ASM
/*
R_DrawSurfaceBlock8_mip0
*/
void void
R_DrawSurfaceBlock8_mip0 (void) R_DrawSurfaceBlock8_mip0 (void)
{ {
@ -355,9 +343,6 @@ R_DrawSurfaceBlock8_mip0 (void)
} }
/*
R_DrawSurfaceBlock8_mip1
*/
void void
R_DrawSurfaceBlock8_mip1 (void) R_DrawSurfaceBlock8_mip1 (void)
{ {
@ -368,8 +353,8 @@ R_DrawSurfaceBlock8_mip1 (void)
prowdest = prowdestbase; prowdest = prowdestbase;
for (v = 0; v < r_numvblocks; v++) { for (v = 0; v < r_numvblocks; v++) {
// FIXME: make these locals? // FIXME: make these locals?
// FIXME: use delta rather than both right and left, like ASM? // FIXME: use delta rather than both right and left, like ASM?
lightleft = r_lightptr[0]; lightleft = r_lightptr[0];
lightright = r_lightptr[1]; lightright = r_lightptr[1];
r_lightptr += r_lightwidth; r_lightptr += r_lightwidth;
@ -401,9 +386,6 @@ R_DrawSurfaceBlock8_mip1 (void)
} }
/*
R_DrawSurfaceBlock8_mip2
*/
void void
R_DrawSurfaceBlock8_mip2 (void) R_DrawSurfaceBlock8_mip2 (void)
{ {
@ -414,8 +396,8 @@ R_DrawSurfaceBlock8_mip2 (void)
prowdest = prowdestbase; prowdest = prowdestbase;
for (v = 0; v < r_numvblocks; v++) { for (v = 0; v < r_numvblocks; v++) {
// FIXME: make these locals? // FIXME: make these locals?
// FIXME: use delta rather than both right and left, like ASM? // FIXME: use delta rather than both right and left, like ASM?
lightleft = r_lightptr[0]; lightleft = r_lightptr[0];
lightright = r_lightptr[1]; lightright = r_lightptr[1];
r_lightptr += r_lightwidth; r_lightptr += r_lightwidth;
@ -447,9 +429,6 @@ R_DrawSurfaceBlock8_mip2 (void)
} }
/*
R_DrawSurfaceBlock8_mip3
*/
void void
R_DrawSurfaceBlock8_mip3 (void) R_DrawSurfaceBlock8_mip3 (void)
{ {
@ -460,8 +439,8 @@ R_DrawSurfaceBlock8_mip3 (void)
prowdest = prowdestbase; prowdest = prowdestbase;
for (v = 0; v < r_numvblocks; v++) { for (v = 0; v < r_numvblocks; v++) {
// FIXME: make these locals? // FIXME: make these locals?
// FIXME: use delta rather than both right and left, like ASM? // FIXME: use delta rather than both right and left, like ASM?
lightleft = r_lightptr[0]; lightleft = r_lightptr[0];
lightright = r_lightptr[1]; lightright = r_lightptr[1];
r_lightptr += r_lightwidth; r_lightptr += r_lightwidth;
@ -540,11 +519,6 @@ R_DrawSurfaceBlock16 (void)
#endif #endif
//============================================================================
/*
R_GenTurbTile
*/
void void
R_GenTurbTile (pixel_t *pbasetex, void *pdest) R_GenTurbTile (pixel_t *pbasetex, void *pdest)
{ {
@ -565,9 +539,6 @@ R_GenTurbTile (pixel_t *pbasetex, void *pdest)
} }
/*
R_GenTurbTile16
*/
void void
R_GenTurbTile16 (pixel_t *pbasetex, void *pdest) R_GenTurbTile16 (pixel_t *pbasetex, void *pdest)
{ {
@ -588,9 +559,6 @@ R_GenTurbTile16 (pixel_t *pbasetex, void *pdest)
} }
/*
R_GenTile
*/
void void
R_GenTile (msurface_t *psurf, void *pdest) R_GenTile (msurface_t *psurf, void *pdest)
{ {
@ -617,6 +585,7 @@ R_GenTile (msurface_t *psurf, void *pdest)
} }
} }
void void
R_ForceLightUpdate (void) R_ForceLightUpdate (void)
{ {

View file

@ -35,9 +35,7 @@
// all global and static refresh variables are collected in a contiguous block // all global and static refresh variables are collected in a contiguous block
// to avoid cache conflicts. // to avoid cache conflicts.
//------------------------------------------------------- // global refresh variables -----------------------------
// global refresh variables
//-------------------------------------------------------
// FIXME: make into one big structure, like cl or sv // FIXME: make into one big structure, like cl or sv
// FIXME: do separately for refresh engine and driver // FIXME: do separately for refresh engine and driver

View file

@ -43,6 +43,7 @@ extern byte gammatable[256];
qboolean V_CheckGamma (void); qboolean V_CheckGamma (void);
void void
V_CalcPowerupCshift (void) V_CalcPowerupCshift (void)
{ {

View file

@ -39,16 +39,12 @@ static auxvert_t av[8];
void R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av); void R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av);
void R_Alias_clip_top (finalvert_t *pfv0, finalvert_t *pfv1, void R_Alias_clip_top (finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out); finalvert_t *out);
void R_Alias_clip_bottom (finalvert_t *pfv0, finalvert_t *pfv1, void R_Alias_clip_bottom (finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out); finalvert_t *out);
void R_Alias_clip_left (finalvert_t *pfv0, finalvert_t *pfv1, void R_Alias_clip_left (finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out); finalvert_t *out);
void R_Alias_clip_right (finalvert_t *pfv0, finalvert_t *pfv1, void R_Alias_clip_right (finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out); finalvert_t *out);
@ -228,9 +224,6 @@ R_AliasClip (finalvert_t *in, finalvert_t *out, int flag, int count,
} }
/*
R_AliasClipTriangle
*/
void void
R_AliasClipTriangle (mtriangle_t *ptri) R_AliasClipTriangle (mtriangle_t *ptri)
{ {
@ -238,7 +231,7 @@ R_AliasClipTriangle (mtriangle_t *ptri)
mtriangle_t mtri; mtriangle_t mtri;
unsigned int clipflags; unsigned int clipflags;
// copy vertexes and fix seam texture coordinates // copy vertexes and fix seam texture coordinates
if (ptri->facesfront) { if (ptri->facesfront) {
fv[0][0] = pfinalverts[ptri->vertindex[0]]; fv[0][0] = pfinalverts[ptri->vertindex[0]];
fv[0][1] = pfinalverts[ptri->vertindex[1]]; fv[0][1] = pfinalverts[ptri->vertindex[1]];
@ -252,7 +245,7 @@ R_AliasClipTriangle (mtriangle_t *ptri)
} }
} }
// clip // clip
clipflags = fv[0][0].flags | fv[0][1].flags | fv[0][2].flags; clipflags = fv[0][0].flags | fv[0][1].flags | fv[0][2].flags;
if (clipflags & ALIAS_Z_CLIP) { if (clipflags & ALIAS_Z_CLIP) {
@ -320,7 +313,7 @@ R_AliasClipTriangle (mtriangle_t *ptri)
fv[pingpong][i].flags = 0; fv[pingpong][i].flags = 0;
} }
// draw triangles // draw triangles
mtri.facesfront = ptri->facesfront; mtri.facesfront = ptri->facesfront;
r_affinetridesc.ptriangles = &mtri; r_affinetridesc.ptriangles = &mtri;
r_affinetridesc.pfinalverts = fv[pingpong]; r_affinetridesc.pfinalverts = fv[pingpong];

View file

@ -40,9 +40,8 @@
#include "r_local.h" #include "r_local.h"
#include "render.h" #include "render.h"
#define LIGHT_MIN 5 // lowest light value we'll allow, to #define LIGHT_MIN 5 // lowest light value we'll allow, to
// avoid the // avoid the need for inner-loop light clamping
// need for inner-loop light clamping
mtriangle_t *ptriangles; mtriangle_t *ptriangles;
affinetridesc_t r_affinetridesc; affinetridesc_t r_affinetridesc;
@ -90,7 +89,6 @@ float r_avertexnormals[NUMVERTEXNORMALS][3] = {
}; };
void R_AliasTransformAndProjectFinalVerts (finalvert_t *fv, void R_AliasTransformAndProjectFinalVerts (finalvert_t *fv,
stvert_t *pstverts); stvert_t *pstverts);
void R_AliasSetUpTransform (int trivial_accept); void R_AliasSetUpTransform (int trivial_accept);
void R_AliasTransformVector (vec3_t in, vec3_t out); void R_AliasTransformVector (vec3_t in, vec3_t out);
@ -99,9 +97,6 @@ void R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av,
void R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av); void R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av);
/*
R_AliasCheckBBox
*/
qboolean qboolean
R_AliasCheckBBox (void) R_AliasCheckBBox (void)
{ {
@ -115,8 +110,7 @@ R_AliasCheckBBox (void)
unsigned int anyclip, allclip; unsigned int anyclip, allclip;
int minz; int minz;
// expand, rotate, and translate points into worldspace // expand, rotate, and translate points into worldspace
currententity->trivial_accept = 0; currententity->trivial_accept = 0;
pmodel = currententity->model; pmodel = currententity->model;
pahdr = Mod_Extradata (pmodel); pahdr = Mod_Extradata (pmodel);
@ -124,7 +118,7 @@ R_AliasCheckBBox (void)
R_AliasSetUpTransform (0); R_AliasSetUpTransform (0);
// construct the base bounding box for this frame // construct the base bounding box for this frame
frame = currententity->frame; frame = currententity->frame;
// TODO: don't repeat this check when drawing? // TODO: don't repeat this check when drawing?
if ((frame >= pmdl->numframes) || (frame < 0)) { if ((frame >= pmdl->numframes) || (frame < 0)) {
@ -134,19 +128,19 @@ R_AliasCheckBBox (void)
pframedesc = &pahdr->frames[frame]; pframedesc = &pahdr->frames[frame];
// x worldspace coordinates // x worldspace coordinates
basepts[0][0] = basepts[1][0] = basepts[2][0] = basepts[3][0] = basepts[0][0] = basepts[1][0] = basepts[2][0] = basepts[3][0] =
(float) pframedesc->bboxmin.v[0]; (float) pframedesc->bboxmin.v[0];
basepts[4][0] = basepts[5][0] = basepts[6][0] = basepts[7][0] = basepts[4][0] = basepts[5][0] = basepts[6][0] = basepts[7][0] =
(float) pframedesc->bboxmax.v[0]; (float) pframedesc->bboxmax.v[0];
// y worldspace coordinates // y worldspace coordinates
basepts[0][1] = basepts[3][1] = basepts[5][1] = basepts[6][1] = basepts[0][1] = basepts[3][1] = basepts[5][1] = basepts[6][1] =
(float) pframedesc->bboxmin.v[1]; (float) pframedesc->bboxmin.v[1];
basepts[1][1] = basepts[2][1] = basepts[4][1] = basepts[7][1] = basepts[1][1] = basepts[2][1] = basepts[4][1] = basepts[7][1] =
(float) pframedesc->bboxmax.v[1]; (float) pframedesc->bboxmax.v[1];
// z worldspace coordinates // z worldspace coordinates
basepts[0][2] = basepts[1][2] = basepts[4][2] = basepts[5][2] = basepts[0][2] = basepts[1][2] = basepts[4][2] = basepts[5][2] =
(float) pframedesc->bboxmin.v[2]; (float) pframedesc->bboxmin.v[2];
basepts[2][2] = basepts[3][2] = basepts[6][2] = basepts[7][2] = basepts[2][2] = basepts[3][2] = basepts[6][2] = basepts[7][2] =
@ -171,7 +165,6 @@ R_AliasCheckBBox (void)
} }
} }
if (zfullyclipped) { if (zfullyclipped) {
return false; // everything was near-z-clipped return false; // everything was near-z-clipped
} }
@ -180,8 +173,7 @@ R_AliasCheckBBox (void)
if (zclipped) { if (zclipped) {
// organize points by edges, use edges to get new points (possible // organize points by edges, use edges to get new points (possible
// trivial // trivial reject)
// reject)
for (i = 0; i < 12; i++) { for (i = 0; i < 12; i++) {
// edge endpoints // edge endpoints
pv0 = &viewpts[aedges[i].index0]; pv0 = &viewpts[aedges[i].index0];
@ -203,7 +195,7 @@ R_AliasCheckBBox (void)
} }
} }
} }
// project the vertices that remain after clipping // project the vertices that remain after clipping
anyclip = 0; anyclip = 0;
allclip = ALIAS_XY_CLIP_MASK; allclip = ALIAS_XY_CLIP_MASK;
@ -249,9 +241,6 @@ R_AliasCheckBBox (void)
} }
/*
R_AliasTransformVector
*/
void void
R_AliasTransformVector (vec3_t in, vec3_t out) R_AliasTransformVector (vec3_t in, vec3_t out)
{ {
@ -299,9 +288,7 @@ R_AliasPreparePoints (void)
} }
} }
// // clip and draw all triangles
// clip and draw all triangles
//
r_affinetridesc.numtriangles = 1; r_affinetridesc.numtriangles = 1;
ptri = (mtriangle_t *) ((byte *) paliashdr + paliashdr->triangles); ptri = (mtriangle_t *) ((byte *) paliashdr + paliashdr->triangles);
@ -326,9 +313,6 @@ R_AliasPreparePoints (void)
} }
/*
R_AliasSetUpTransform
*/
void void
R_AliasSetUpTransform (int trivial_accept) R_AliasSetUpTransform (int trivial_accept)
{ {
@ -376,9 +360,9 @@ R_AliasSetUpTransform (int trivial_accept)
VectorInverse (viewmatrix[1]); VectorInverse (viewmatrix[1]);
VectorCopy (vpn, viewmatrix[2]); VectorCopy (vpn, viewmatrix[2]);
// viewmatrix[0][3] = 0; // viewmatrix[0][3] = 0;
// viewmatrix[1][3] = 0; // viewmatrix[1][3] = 0;
// viewmatrix[2][3] = 0; // viewmatrix[2][3] = 0;
R_ConcatTransforms (viewmatrix, rotationmatrix, aliastransform); R_ConcatTransforms (viewmatrix, rotationmatrix, aliastransform);
@ -400,9 +384,6 @@ R_AliasSetUpTransform (int trivial_accept)
} }
/*
R_AliasTransformFinalVert
*/
void void
R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av, R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av,
trivertx_t *pverts, stvert_t *pstverts) trivertx_t *pverts, stvert_t *pstverts)
@ -422,7 +403,7 @@ R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av,
fv->flags = pstverts->onseam; fv->flags = pstverts->onseam;
// lighting // lighting
plightnormal = r_avertexnormals[pverts->lightnormalindex]; plightnormal = r_avertexnormals[pverts->lightnormalindex];
lightcos = DotProduct (plightnormal, r_plightvec); lightcos = DotProduct (plightnormal, r_plightvec);
temp = r_ambientlight; temp = r_ambientlight;
@ -431,8 +412,7 @@ R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av,
temp += (int) (r_shadelight * lightcos); temp += (int) (r_shadelight * lightcos);
// clamp; because we limited the minimum ambient and shading light, // clamp; because we limited the minimum ambient and shading light,
// we // we don't have to clamp low light, just bright
// don't have to clamp low light, just bright
if (temp < 0) if (temp < 0)
temp = 0; temp = 0;
} }
@ -442,10 +422,6 @@ R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av,
#ifndef USE_INTEL_ASM #ifndef USE_INTEL_ASM
/*
R_AliasTransformAndProjectFinalVerts
*/
void void
R_AliasTransformAndProjectFinalVerts (finalvert_t *fv, stvert_t *pstverts) R_AliasTransformAndProjectFinalVerts (finalvert_t *fv, stvert_t *pstverts)
{ {
@ -462,8 +438,7 @@ R_AliasTransformAndProjectFinalVerts (finalvert_t *fv, stvert_t *pstverts)
// x, y, and z are scaled down by 1/2**31 in the transform, so 1/z is // x, y, and z are scaled down by 1/2**31 in the transform, so 1/z is
// scaled up by 1/2**31, and the scaling cancels out for x and y in // scaled up by 1/2**31, and the scaling cancels out for x and y in
// the // the projection
// projection
fv->v[5] = zi; fv->v[5] = zi;
fv->v[0] = ((DotProduct (pverts->v, aliastransform[0]) + fv->v[0] = ((DotProduct (pverts->v, aliastransform[0]) +
@ -493,19 +468,15 @@ R_AliasTransformAndProjectFinalVerts (finalvert_t *fv, stvert_t *pstverts)
fv->v[4] = temp; fv->v[4] = temp;
} }
} }
#endif #endif
/*
R_AliasProjectFinalVert
*/
void void
R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av) R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av)
{ {
float zi; float zi;
// project points // project points
zi = 1.0 / av->fv[2]; zi = 1.0 / av->fv[2];
fv->v[5] = zi * ziscale; fv->v[5] = zi * ziscale;
@ -515,9 +486,6 @@ R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av)
} }
/*
R_AliasPrepareUnclippedPoints
*/
void void
R_AliasPrepareUnclippedPoints (void) R_AliasPrepareUnclippedPoints (void)
{ {
@ -542,9 +510,7 @@ R_AliasPrepareUnclippedPoints (void)
D_PolysetDraw (); D_PolysetDraw ();
} }
/*
R_AliasSetupSkin
*/
void void
R_AliasSetupSkin (void) R_AliasSetupSkin (void)
{ {
@ -607,15 +573,13 @@ R_AliasSetupSkin (void)
} }
} }
/*
R_AliasSetupLighting
*/
void void
R_AliasSetupLighting (alight_t *plighting) R_AliasSetupLighting (alight_t *plighting)
{ {
// guarantee that no vertex will ever be lit below LIGHT_MIN, so we don't have // guarantee that no vertex will ever be lit below LIGHT_MIN, so we don't
// to clamp off the bottom // have to clamp off the bottom
r_ambientlight = plighting->ambientlight; r_ambientlight = plighting->ambientlight;
if (r_ambientlight < LIGHT_MIN) if (r_ambientlight < LIGHT_MIN)
@ -633,12 +597,13 @@ R_AliasSetupLighting (alight_t *plighting)
r_shadelight *= VID_GRADES; r_shadelight *= VID_GRADES;
// rotate the lighting vector into the model's frame of reference // rotate the lighting vector into the model's frame of reference
r_plightvec[0] = DotProduct (plighting->plightvec, alias_forward); r_plightvec[0] = DotProduct (plighting->plightvec, alias_forward);
r_plightvec[1] = -DotProduct (plighting->plightvec, alias_right); r_plightvec[1] = -DotProduct (plighting->plightvec, alias_right);
r_plightvec[2] = DotProduct (plighting->plightvec, alias_up); r_plightvec[2] = DotProduct (plighting->plightvec, alias_up);
} }
/* /*
R_AliasSetupFrame R_AliasSetupFrame
@ -672,10 +637,8 @@ R_AliasSetupFrame (void)
time = cl.time + currententity->syncbase; time = cl.time + currententity->syncbase;
// // when loading in Mod_LoadAliasGroup, we guaranteed all interval values
// when loading in Mod_LoadAliasGroup, we guaranteed all interval values // are positive, so we don't have to worry about division by 0
// are positive, so we don't have to worry about division by 0
//
targettime = time - ((int) (time / fullinterval)) * fullinterval; targettime = time - ((int) (time / fullinterval)) * fullinterval;
for (i = 0; i < (numframes - 1); i++) { for (i = 0; i < (numframes - 1); i++) {
@ -688,9 +651,6 @@ R_AliasSetupFrame (void)
} }
/*
R_AliasDrawModel
*/
void void
R_AliasDrawModel (alight_t *plighting) R_AliasDrawModel (alight_t *plighting)
{ {
@ -700,7 +660,7 @@ R_AliasDrawModel (alight_t *plighting)
r_amodels_drawn++; r_amodels_drawn++;
// cache align // cache align
pfinalverts = (finalvert_t *) pfinalverts = (finalvert_t *)
(((long) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1)); (((long) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
pauxverts = &auxverts[0]; pauxverts = &auxverts[0];

View file

@ -39,18 +39,13 @@
#include "r_local.h" #include "r_local.h"
#include "render.h" #include "render.h"
//
// current entity info // current entity info
//
qboolean insubmodel; qboolean insubmodel;
entity_t *currententity; entity_t *currententity;
vec3_t modelorg, base_modelorg; vec3_t modelorg, base_modelorg;
// modelorg is the viewpoint reletive to // modelorg is the viewpoint reletive to
// the currently rendering entity // the currently rendering entity
vec3_t r_entorigin; // the currently rendering entity in vec3_t r_entorigin; // the currently rendering entity in world
// world
// coordinates // coordinates
float entity_rotation[3][3]; float entity_rotation[3][3];
@ -73,11 +68,6 @@ static mvertex_t *pfrontenter, *pfrontexit;
static qboolean makeclippededge; static qboolean makeclippededge;
//===========================================================================
/*
R_EntityRotate
*/
void void
R_EntityRotate (vec3_t vec) R_EntityRotate (vec3_t vec)
{ {
@ -90,9 +80,6 @@ R_EntityRotate (vec3_t vec)
} }
/*
R_RotateBmodel
*/
void void
R_RotateBmodel (void) R_RotateBmodel (void)
{ {
@ -103,7 +90,7 @@ R_RotateBmodel (void)
// TODO: could cache lazily, stored in the entity // TODO: could cache lazily, stored in the entity
// TODO: share work with R_SetUpAliasTransform // TODO: share work with R_SetUpAliasTransform
// yaw // yaw
angle = currententity->angles[YAW]; angle = currententity->angles[YAW];
angle = angle * M_PI * 2 / 360; angle = angle * M_PI * 2 / 360;
s = sin (angle); s = sin (angle);
@ -119,8 +106,7 @@ R_RotateBmodel (void)
temp1[2][1] = 0; temp1[2][1] = 0;
temp1[2][2] = 1; temp1[2][2] = 1;
// pitch
// pitch
angle = currententity->angles[PITCH]; angle = currententity->angles[PITCH];
angle = angle * M_PI * 2 / 360; angle = angle * M_PI * 2 / 360;
s = sin (angle); s = sin (angle);
@ -138,7 +124,7 @@ R_RotateBmodel (void)
R_ConcatRotations (temp2, temp1, temp3); R_ConcatRotations (temp2, temp1, temp3);
// roll // roll
angle = currententity->angles[ROLL]; angle = currententity->angles[ROLL];
angle = angle * M_PI * 2 / 360; angle = angle * M_PI * 2 / 360;
s = sin (angle); s = sin (angle);
@ -156,9 +142,7 @@ R_RotateBmodel (void)
R_ConcatRotations (temp1, temp3, entity_rotation); R_ConcatRotations (temp1, temp3, entity_rotation);
// // rotate modelorg and the transformation matrix
// rotate modelorg and the transformation matrix
//
R_EntityRotate (modelorg); R_EntityRotate (modelorg);
R_EntityRotate (vpn); R_EntityRotate (vpn);
R_EntityRotate (vright); R_EntityRotate (vright);
@ -168,9 +152,6 @@ R_RotateBmodel (void)
} }
/*
R_RecursiveClipBPoly
*/
void void
R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf) R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
{ {
@ -185,7 +166,7 @@ R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
makeclippededge = false; makeclippededge = false;
// transform the BSP plane into model space // transform the BSP plane into model space
// FIXME: cache these? // FIXME: cache these?
splitplane = pnode->plane; splitplane = pnode->plane;
tplane.dist = splitplane->dist - tplane.dist = splitplane->dist -
@ -194,12 +175,12 @@ R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
tplane.normal[1] = DotProduct (entity_rotation[1], splitplane->normal); tplane.normal[1] = DotProduct (entity_rotation[1], splitplane->normal);
tplane.normal[2] = DotProduct (entity_rotation[2], splitplane->normal); tplane.normal[2] = DotProduct (entity_rotation[2], splitplane->normal);
// clip edges to BSP plane // clip edges to BSP plane
for (; pedges; pedges = pnextedge) { for (; pedges; pedges = pnextedge) {
pnextedge = pedges->pnext; pnextedge = pedges->pnext;
// set the status for the last point as the previous point // set the status for the last point as the previous point
// FIXME: cache this stuff somehow? // FIXME: cache this stuff somehow?
plastvert = pedges->v[0]; plastvert = pedges->v[0];
lastdist = DotProduct (plastvert->position, tplane.normal) - lastdist = DotProduct (plastvert->position, tplane.normal) -
tplane.dist; tplane.dist;
@ -235,7 +216,7 @@ R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
// split into two edges, one on each side, and remember entering // split into two edges, one on each side, and remember entering
// and exiting points // and exiting points
// FIXME: share the clip edge by having a winding direction flag? // FIXME: share the clip edge by having a winding direction flag?
if (numbedges >= (MAX_BMODEL_EDGES - 1)) { if (numbedges >= (MAX_BMODEL_EDGES - 1)) {
Con_Printf ("Out of edges for bmodel\n"); Con_Printf ("Out of edges for bmodel\n");
return; return;
@ -270,8 +251,8 @@ R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
} }
} }
// if anything was clipped, reconstitute and add the edges along the clip // if anything was clipped, reconstitute and add the edges along the clip
// plane to both sides (but in opposite directions) // plane to both sides (but in opposite directions)
if (makeclippededge) { if (makeclippededge) {
if (numbedges >= (MAX_BMODEL_EDGES - 2)) { if (numbedges >= (MAX_BMODEL_EDGES - 2)) {
Con_Printf ("Out of edges for bmodel\n"); Con_Printf ("Out of edges for bmodel\n");
@ -292,16 +273,14 @@ R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
numbedges += 2; numbedges += 2;
} }
// draw or recurse further // draw or recurse further
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
if (psideedges[i]) { if (psideedges[i]) {
// draw if we've reached a non-solid leaf, done if all that's // draw if we've reached a non-solid leaf, done if all that's left
// left is a // is a solid leaf, and continue down the tree if it's not a leaf
// solid leaf, and continue down the tree if it's not a leaf
pn = pnode->children[i]; pn = pnode->children[i];
// we're done with this branch if the node or leaf isn't in the // we're done with this branch if the node or leaf isn't in the PVS
// PVS
if (pn->visframe == r_visframecount) { if (pn->visframe == r_visframecount) {
if (pn->contents < 0) { if (pn->contents < 0) {
if (pn->contents != CONTENTS_SOLID) { if (pn->contents != CONTENTS_SOLID) {
@ -318,9 +297,6 @@ R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
} }
/*
R_DrawSolidClippedSubmodelPolygons
*/
void void
R_DrawSolidClippedSubmodelPolygons (model_t *pmodel) R_DrawSolidClippedSubmodelPolygons (model_t *pmodel)
{ {
@ -348,13 +324,12 @@ R_DrawSolidClippedSubmodelPolygons (model_t *pmodel)
// draw the polygon // draw the polygon
if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) || if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
(!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) { (!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) {
// FIXME: use bounding-box-based frustum clipping info? // FIXME: use bounding-box-based frustum clipping info?
// copy the edges to bedges, flipping if necessary so always // copy the edges to bedges, flipping if necessary so always
// clockwise winding // clockwise winding
// FIXME: if edges and vertices get caches, these assignments // FIXME: if edges and vertices get caches, these assignments must move
// must move // outside the loop, and overflow checking must be done here
// outside the loop, and overflow checking must be done here
pbverts = bverts; pbverts = bverts;
pbedges = bedges; pbedges = bedges;
numbverts = numbedges = 0; numbverts = numbedges = 0;
@ -391,9 +366,6 @@ R_DrawSolidClippedSubmodelPolygons (model_t *pmodel)
} }
/*
R_DrawSubmodelPolygons
*/
void void
R_DrawSubmodelPolygons (model_t *pmodel, int clipflags) R_DrawSubmodelPolygons (model_t *pmodel, int clipflags)
{ {
@ -419,16 +391,13 @@ R_DrawSubmodelPolygons (model_t *pmodel, int clipflags)
(!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) { (!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) {
r_currentkey = ((mleaf_t *) currententity->topnode)->key; r_currentkey = ((mleaf_t *) currententity->topnode)->key;
// FIXME: use bounding-box-based frustum clipping info? // FIXME: use bounding-box-based frustum clipping info?
R_RenderFace (psurf, clipflags); R_RenderFace (psurf, clipflags);
} }
} }
} }
/*
R_RecursiveWorldNode
*/
void void
R_RecursiveWorldNode (mnode_t *node, int clipflags) R_RecursiveWorldNode (mnode_t *node, int clipflags)
{ {
@ -445,7 +414,7 @@ R_RecursiveWorldNode (mnode_t *node, int clipflags)
if (node->visframe != r_visframecount) if (node->visframe != r_visframecount)
return; return;
// cull the clipping planes if not trivial accept // cull the clipping planes if not trivial accept
// FIXME: the compiler is doing a lousy job of optimizing here; it could be // FIXME: the compiler is doing a lousy job of optimizing here; it could be
// twice as fast in ASM // twice as fast in ASM
if (clipflags) { if (clipflags) {
@ -454,9 +423,8 @@ R_RecursiveWorldNode (mnode_t *node, int clipflags)
continue; // don't need to clip against it continue; // don't need to clip against it
// generate accept and reject points // generate accept and reject points
// FIXME: do with fast look-ups or integer tests based on the // FIXME: do with fast look-ups or integer tests based on the sign bit
// sign bit // of the floating point values
// of the floating point values
pindex = pfrustum_indexes[i]; pindex = pfrustum_indexes[i];
@ -481,7 +449,7 @@ R_RecursiveWorldNode (mnode_t *node, int clipflags)
clipflags &= ~(1 << i); // node is entirely on screen clipflags &= ~(1 << i); // node is entirely on screen
} }
} }
// if a leaf node, draw stuff // if a leaf node, draw stuff
if (node->contents < 0) { if (node->contents < 0) {
pleaf = (mleaf_t *) node; pleaf = (mleaf_t *) node;
@ -500,7 +468,7 @@ R_RecursiveWorldNode (mnode_t *node, int clipflags)
} }
pleaf->key = r_currentkey; pleaf->key = r_currentkey;
r_currentkey++; // all bmodels in a leaf share the same key r_currentkey++; // all bmodels in a leaf share the same key
} else { } else {
// node is just a decision point, so go down the apropriate sides // node is just a decision point, so go down the apropriate sides
@ -590,10 +558,6 @@ R_RecursiveWorldNode (mnode_t *node, int clipflags)
} }
/*
R_RenderWorld
*/
void void
R_RenderWorld (void) R_RenderWorld (void)
{ {
@ -610,8 +574,8 @@ R_RenderWorld (void)
R_RecursiveWorldNode (clmodel->nodes, 15); R_RecursiveWorldNode (clmodel->nodes, 15);
// if the driver wants the polygons back to front, play the visible ones back // if the driver wants the polygons back to front, play the visible ones
// in that order // back in that order
if (r_worldpolysbacktofront) { if (r_worldpolysbacktofront) {
for (i = numbtofpolys - 1; i >= 0; i--) { for (i = numbtofpolys - 1; i >= 0; i--) {
R_RenderPoly (btofpolys[i].psurf, btofpolys[i].clipflags); R_RenderPoly (btofpolys[i].psurf, btofpolys[i].clipflags);

View file

@ -47,8 +47,6 @@ zpointdesc_t r_zpointdesc;
polydesc_t r_polydesc; polydesc_t r_polydesc;
clipplane_t *entity_clipplanes; clipplane_t *entity_clipplanes;
clipplane_t view_clipplanes[4]; clipplane_t view_clipplanes[4];
clipplane_t world_clipplanes[16]; clipplane_t world_clipplanes[16];
@ -80,9 +78,6 @@ qboolean r_lastvertvalid;
#ifndef USE_INTEL_ASM #ifndef USE_INTEL_ASM
/*
R_EmitEdge
*/
void void
R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1) R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
{ {
@ -132,7 +127,7 @@ R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
world = &pv1->position[0]; world = &pv1->position[0];
// transform and project // transform and project
VectorSubtract (world, modelorg, local); VectorSubtract (world, modelorg, local);
TransformVector (local, transformed); TransformVector (local, transformed);
@ -161,7 +156,7 @@ R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
if (lzi0 > r_nearzi) // for mipmap finding if (lzi0 > r_nearzi) // for mipmap finding
r_nearzi = lzi0; r_nearzi = lzi0;
// for right edges, all we want is the effect on 1/z // for right edges, all we want is the effect on 1/z
if (r_nearzionly) if (r_nearzionly)
return; return;
@ -169,8 +164,7 @@ R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
r_ceilv1 = (int) ceil (r_v1); r_ceilv1 = (int) ceil (r_v1);
// create the edge
// create the edge
if (ceilv0 == r_ceilv1) { if (ceilv0 == r_ceilv1) {
// we cache unclipped horizontal edges as fully clipped // we cache unclipped horizontal edges as fully clipped
if (cacheoffset != 0x7FFFFFFF) { if (cacheoffset != 0x7FFFFFFF) {
@ -214,19 +208,17 @@ R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
edge->u_step = u_step * 0x100000; edge->u_step = u_step * 0x100000;
edge->u = u * 0x100000 + 0xFFFFF; edge->u = u * 0x100000 + 0xFFFFF;
// we need to do this to avoid stepping off the edges if a very nearly // we need to do this to avoid stepping off the edges if a very nearly
// horizontal edge is less than epsilon above a scan, and numeric error causes // horizontal edge is less than epsilon above a scan, and numeric error
// it to incorrectly extend to the scan, and the extension of the line goes off // causes it to incorrectly extend to the scan, and the extension of the
// the edge of the screen // line goes off the edge of the screen
// FIXME: is this actually needed? // FIXME: is this actually needed?
if (edge->u < r_refdef.vrect_x_adj_shift20) if (edge->u < r_refdef.vrect_x_adj_shift20)
edge->u = r_refdef.vrect_x_adj_shift20; edge->u = r_refdef.vrect_x_adj_shift20;
if (edge->u > r_refdef.vrectright_adj_shift20) if (edge->u > r_refdef.vrectright_adj_shift20)
edge->u = r_refdef.vrectright_adj_shift20; edge->u = r_refdef.vrectright_adj_shift20;
// // sort the edge in normally
// sort the edge in normally
//
u_check = edge->u; u_check = edge->u;
if (edge->surfs[0]) if (edge->surfs[0])
u_check++; // sort trailers after leaders u_check++; // sort trailers after leaders
@ -247,9 +239,6 @@ R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
} }
/*
R_ClipEdge
*/
void void
R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip) R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
{ {
@ -327,16 +316,13 @@ R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
} }
} while ((clip = clip->next) != NULL); } while ((clip = clip->next) != NULL);
} }
// add the edge // add the edge
R_EmitEdge (pv0, pv1); R_EmitEdge (pv0, pv1);
} }
#endif // !USE_INTEL_ASM #endif // !USE_INTEL_ASM
/*
R_EmitCachedEdge
*/
void void
R_EmitCachedEdge (void) R_EmitCachedEdge (void)
{ {
@ -356,9 +342,6 @@ R_EmitCachedEdge (void)
} }
/*
R_RenderFace
*/
void void
R_RenderFace (msurface_t *fa, int clipflags) R_RenderFace (msurface_t *fa, int clipflags)
{ {
@ -370,12 +353,12 @@ R_RenderFace (msurface_t *fa, int clipflags)
medge_t *pedges, tedge; medge_t *pedges, tedge;
clipplane_t *pclip; clipplane_t *pclip;
// skip out if no more surfs // skip out if no more surfs
if ((surface_p) >= surf_max) { if ((surface_p) >= surf_max) {
r_outofsurfaces++; r_outofsurfaces++;
return; return;
} }
// ditto if not enough edges left, or switch to auxedges if possible // ditto if not enough edges left, or switch to auxedges if possible
if ((edge_p + fa->numedges + 4) >= edge_max) { if ((edge_p + fa->numedges + 4) >= edge_max) {
r_outofedges += fa->numedges; r_outofedges += fa->numedges;
return; return;
@ -383,7 +366,7 @@ R_RenderFace (msurface_t *fa, int clipflags)
c_faceclip++; c_faceclip++;
// set up clip planes // set up clip planes
pclip = NULL; pclip = NULL;
for (i = 3, mask = 0x08; i >= 0; i--, mask >>= 1) { for (i = 3, mask = 0x08; i >= 0; i--, mask >>= 1) {
@ -393,7 +376,7 @@ R_RenderFace (msurface_t *fa, int clipflags)
} }
} }
// push the edges through // push the edges through
r_emitted = 0; r_emitted = 0;
r_nearzi = 0; r_nearzi = 0;
r_nearzionly = false; r_nearzionly = false;
@ -479,7 +462,7 @@ R_RenderFace (msurface_t *fa, int clipflags)
} }
} }
// if there was a clip off the left edge, add that edge too // if there was a clip off the left edge, add that edge too
// FIXME: faster to do in screen space? // FIXME: faster to do in screen space?
// FIXME: share clipped edges? // FIXME: share clipped edges?
if (makeleftedge) { if (makeleftedge) {
@ -487,14 +470,14 @@ R_RenderFace (msurface_t *fa, int clipflags)
r_lastvertvalid = false; r_lastvertvalid = false;
R_ClipEdge (&r_leftexit, &r_leftenter, pclip->next); R_ClipEdge (&r_leftexit, &r_leftenter, pclip->next);
} }
// if there was a clip off the right edge, get the right r_nearzi // if there was a clip off the right edge, get the right r_nearzi
if (makerightedge) { if (makerightedge) {
r_pedge = &tedge; r_pedge = &tedge;
r_lastvertvalid = false; r_lastvertvalid = false;
r_nearzionly = true; r_nearzionly = true;
R_ClipEdge (&r_rightexit, &r_rightenter, view_clipplanes[1].next); R_ClipEdge (&r_rightexit, &r_rightenter, view_clipplanes[1].next);
} }
// if no edges made it out, return without posting the surface // if no edges made it out, return without posting the surface
if (!r_emitted) if (!r_emitted)
return; return;
@ -525,9 +508,6 @@ R_RenderFace (msurface_t *fa, int clipflags)
} }
/*
R_RenderBmodelFace
*/
void void
R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf) R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
{ {
@ -539,12 +519,12 @@ R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
medge_t tedge; medge_t tedge;
clipplane_t *pclip; clipplane_t *pclip;
// skip out if no more surfs // skip out if no more surfs
if (surface_p >= surf_max) { if (surface_p >= surf_max) {
r_outofsurfaces++; r_outofsurfaces++;
return; return;
} }
// ditto if not enough edges left, or switch to auxedges if possible // ditto if not enough edges left, or switch to auxedges if possible
if ((edge_p + psurf->numedges + 4) >= edge_max) { if ((edge_p + psurf->numedges + 4) >= edge_max) {
r_outofedges += psurf->numedges; r_outofedges += psurf->numedges;
return; return;
@ -552,10 +532,10 @@ R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
c_faceclip++; c_faceclip++;
// this is a dummy to give the caching mechanism someplace to write to // this is a dummy to give the caching mechanism someplace to write to
r_pedge = &tedge; r_pedge = &tedge;
// set up clip planes // set up clip planes
pclip = NULL; pclip = NULL;
for (i = 3, mask = 0x08; i >= 0; i--, mask >>= 1) { for (i = 3, mask = 0x08; i >= 0; i--, mask >>= 1) {
@ -565,7 +545,7 @@ R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
} }
} }
// push the edges through // push the edges through
r_emitted = 0; r_emitted = 0;
r_nearzi = 0; r_nearzi = 0;
r_nearzionly = false; r_nearzionly = false;
@ -584,20 +564,20 @@ R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
makerightedge = true; makerightedge = true;
} }
// if there was a clip off the left edge, add that edge too // if there was a clip off the left edge, add that edge too
// FIXME: faster to do in screen space? // FIXME: faster to do in screen space?
// FIXME: share clipped edges? // FIXME: share clipped edges?
if (makeleftedge) { if (makeleftedge) {
r_pedge = &tedge; r_pedge = &tedge;
R_ClipEdge (&r_leftexit, &r_leftenter, pclip->next); R_ClipEdge (&r_leftexit, &r_leftenter, pclip->next);
} }
// if there was a clip off the right edge, get the right r_nearzi // if there was a clip off the right edge, get the right r_nearzi
if (makerightedge) { if (makerightedge) {
r_pedge = &tedge; r_pedge = &tedge;
r_nearzionly = true; r_nearzionly = true;
R_ClipEdge (&r_rightexit, &r_rightenter, view_clipplanes[1].next); R_ClipEdge (&r_rightexit, &r_rightenter, view_clipplanes[1].next);
} }
// if no edges made it out, return without posting the surface // if no edges made it out, return without posting the surface
if (!r_emitted) if (!r_emitted)
return; return;
@ -628,9 +608,6 @@ R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
} }
/*
R_RenderPoly
*/
void void
R_RenderPoly (msurface_t *fa, int clipflags) R_RenderPoly (msurface_t *fa, int clipflags)
{ {
@ -651,7 +628,7 @@ R_RenderPoly (msurface_t *fa, int clipflags)
s_axis = t_axis = 0; // keep compiler happy s_axis = t_axis = 0; // keep compiler happy
// set up clip planes // set up clip planes
pclip = NULL; pclip = NULL;
for (i = 3, mask = 0x08; i >= 0; i--, mask >>= 1) { for (i = 3, mask = 0x08; i >= 0; i--, mask >>= 1) {
@ -661,7 +638,7 @@ R_RenderPoly (msurface_t *fa, int clipflags)
} }
} }
// reconstruct the polygon // reconstruct the polygon
// FIXME: these should be precalculated and loaded off disk // FIXME: these should be precalculated and loaded off disk
pedges = currententity->model->edges; pedges = currententity->model->edges;
lnumverts = fa->numedges; lnumverts = fa->numedges;
@ -679,7 +656,7 @@ R_RenderPoly (msurface_t *fa, int clipflags)
} }
} }
// clip the polygon, done if not visible // clip the polygon, done if not visible
while (pclip) { while (pclip) {
lastvert = lnumverts - 1; lastvert = lnumverts - 1;
lastdist = DotProduct (verts[vertpage][lastvert].position, lastdist = DotProduct (verts[vertpage][lastvert].position,
@ -728,8 +705,8 @@ R_RenderPoly (msurface_t *fa, int clipflags)
pclip = pclip->next; pclip = pclip->next;
} }
// transform and project, remembering the z values at the vertices and // transform and project, remembering the z values at the vertices and
// r_nearzi, and extract the s and t coordinates at the vertices // r_nearzi, and extract the s and t coordinates at the vertices
pplane = fa->plane; pplane = fa->plane;
switch (pplane->type) { switch (pplane->type) {
case PLANE_X: case PLANE_X:
@ -786,21 +763,18 @@ R_RenderPoly (msurface_t *fa, int clipflags)
pverts[i].t = verts[vertpage][i].position[t_axis]; pverts[i].t = verts[vertpage][i].position[t_axis];
} }
// build the polygon descriptor, including fa, r_nearzi, and u, v, s, t, and z // build the polygon descriptor, including fa, r_nearzi, and u, v, s, t,
// for each vertex // and z for each vertex
r_polydesc.numverts = lnumverts; r_polydesc.numverts = lnumverts;
r_polydesc.nearzi = r_nearzi; r_polydesc.nearzi = r_nearzi;
r_polydesc.pcurrentface = fa; r_polydesc.pcurrentface = fa;
r_polydesc.pverts = pverts; r_polydesc.pverts = pverts;
// draw the polygon // draw the polygon
D_DrawPoly (); D_DrawPoly ();
} }
/*
R_ZDrawSubmodelPolys
*/
void void
R_ZDrawSubmodelPolys (model_t *pmodel) R_ZDrawSubmodelPolys (model_t *pmodel)
{ {
@ -821,7 +795,7 @@ R_ZDrawSubmodelPolys (model_t *pmodel)
// draw the polygon // draw the polygon
if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) || if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
(!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) { (!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) {
// FIXME: use bounding-box-based frustum clipping info? // FIXME: use bounding-box-based frustum clipping info?
R_RenderPoly (psurf, 15); R_RenderPoly (psurf, 15);
} }
} }

View file

@ -37,15 +37,15 @@
#include "render.h" #include "render.h"
#if 0 #if 0
// FIXME FIXME
the complex cases add new polys on most lines, the complex cases add new polys on most lines,
so dont optimize for keeping them the same have multiple free span lists to so dont optimize for keeping them the same have multiple free span lists to
try to get better coherence ? low depth complexity-- 1 to 3 or so this try to get better coherence ? low depth complexity-- 1 to 3 or so this
breaks spans at every edge, even hidden breaks spans at every edge, even hidden ones (bad)
ones (bad)
have a sentinal at both ends ? have a sentinal at both ends ?
#endif #endif
edge_t *auxedges; edge_t *auxedges;
edge_t *r_edges, *edge_p, *edge_max; edge_t *r_edges, *edge_p, *edge_max;
@ -77,25 +77,13 @@ edge_t edge_sentinel;
float fv; float fv;
void void R_GenerateSpans (void);
R_GenerateSpans (void); void R_GenerateSpansBackward (void);
void void R_LeadingEdge (edge_t *edge);
R_GenerateSpansBackward (void); void R_LeadingEdgeBackwards (edge_t *edge);
void R_TrailingEdge (surf_t *surf, edge_t *edge);
void
R_LeadingEdge (edge_t *edge);
void
R_LeadingEdgeBackwards (edge_t *edge);
void
R_TrailingEdge (surf_t *surf, edge_t *edge);
//=============================================================================
/*
R_DrawCulledPolys
*/
void void
R_DrawCulledPolys (void) R_DrawCulledPolys (void)
{ {
@ -128,9 +116,6 @@ R_DrawCulledPolys (void)
} }
/*
R_BeginEdgeFrame
*/
void void
R_BeginEdgeFrame (void) R_BeginEdgeFrame (void)
{ {
@ -140,11 +125,11 @@ R_BeginEdgeFrame (void)
edge_max = &r_edges[r_numallocatededges]; edge_max = &r_edges[r_numallocatededges];
surface_p = &surfaces[2]; // background is surface 1, surface_p = &surfaces[2]; // background is surface 1,
// surface 0 is a dummy // surface 0 is a dummy
surfaces[1].spans = NULL; // no background spans yet surfaces[1].spans = NULL; // no background spans yet
surfaces[1].flags = SURF_DRAWBACKGROUND; surfaces[1].flags = SURF_DRAWBACKGROUND;
// put the background behind everything in the world // put the background behind everything in the world
if (r_draworder->int_val) { if (r_draworder->int_val) {
pdrawfunc = R_GenerateSpansBackward; pdrawfunc = R_GenerateSpansBackward;
surfaces[1].key = 0; surfaces[1].key = 0;
@ -205,9 +190,6 @@ R_InsertNewEdges (edge_t *edgestoadd, edge_t *edgelist)
} }
/*
R_RemoveEdges
*/
void void
R_RemoveEdges (edge_t *pedge) R_RemoveEdges (edge_t *pedge)
{ {
@ -219,9 +201,6 @@ R_RemoveEdges (edge_t *pedge)
} }
/*
R_StepActiveU
*/
void void
R_StepActiveU (edge_t *pedge) R_StepActiveU (edge_t *pedge)
{ {
@ -284,9 +263,6 @@ R_StepActiveU (edge_t *pedge)
#endif // !USE_INTEL_ASM #endif // !USE_INTEL_ASM
/*
R_CleanupSpan
*/
void void
R_CleanupSpan (void) R_CleanupSpan (void)
{ {
@ -294,8 +270,8 @@ R_CleanupSpan (void)
int iu; int iu;
espan_t *span; espan_t *span;
// now that we've reached the right edge of the screen, we're done with any // now that we've reached the right edge of the screen, we're done with any
// unfinished surfaces, so emit a span for whatever's on top // unfinished surfaces, so emit a span for whatever's on top
surf = surfaces[1].next; surf = surfaces[1].next;
iu = edge_tail_u_shift20; iu = edge_tail_u_shift20;
if (iu > surf->last_u) { if (iu > surf->last_u) {
@ -306,7 +282,7 @@ R_CleanupSpan (void)
span->pnext = surf->spans; span->pnext = surf->spans;
surf->spans = span; surf->spans = span;
} }
// reset spanstate for all surfaces in the surface stack // reset spanstate for all surfaces in the surface stack
do { do {
surf->spanstate = 0; surf->spanstate = 0;
surf = surf->next; surf = surf->next;
@ -314,9 +290,6 @@ R_CleanupSpan (void)
} }
/*
R_LeadingEdgeBackwards
*/
void void
R_LeadingEdgeBackwards (edge_t *edge) R_LeadingEdgeBackwards (edge_t *edge)
{ {
@ -324,12 +297,12 @@ R_LeadingEdgeBackwards (edge_t *edge)
surf_t *surf, *surf2; surf_t *surf, *surf2;
int iu; int iu;
// it's adding a new surface in, so find the correct place // it's adding a new surface in, so find the correct place
surf = &surfaces[edge->surfs[1]]; surf = &surfaces[edge->surfs[1]];
// don't start a span if this is an inverted span, with the end // don't start a span if this is an inverted span, with the end
// edge preceding the start edge (that is, we've already seen the // edge preceding the start edge (that is, we've already seen the
// end edge) // end edge)
if (++surf->spanstate == 1) { if (++surf->spanstate == 1) {
surf2 = surfaces[1].next; surf2 = surfaces[1].next;
@ -340,8 +313,7 @@ R_LeadingEdgeBackwards (edge_t *edge)
// active is in front, so keep going unless it's a bmodel // active is in front, so keep going unless it's a bmodel
if (surf->insubmodel && (surf->key == surf2->key)) { if (surf->insubmodel && (surf->key == surf2->key)) {
// must be two bmodels in the same leaf; don't care, because // must be two bmodels in the same leaf; don't care, because
// they'll // they'll never be farthest anyway
// never be farthest anyway
goto newtop; goto newtop;
} }
@ -358,8 +330,7 @@ R_LeadingEdgeBackwards (edge_t *edge)
goto continue_search; goto continue_search;
// must be two bmodels in the same leaf; don't care which is // must be two bmodels in the same leaf; don't care which is
// really // really in front, because they'll never be farthest anyway
// in front, because they'll never be farthest anyway
} }
goto gotposition; goto gotposition;
@ -389,18 +360,14 @@ R_LeadingEdgeBackwards (edge_t *edge)
} }
/*
R_TrailingEdge
*/
void void
R_TrailingEdge (surf_t *surf, edge_t *edge) R_TrailingEdge (surf_t *surf, edge_t *edge)
{ {
espan_t *span; espan_t *span;
int iu; int iu;
// don't generate a span if this is an inverted span, with the end // don't generate a span if this is an inverted span, with the end edge
// edge preceding the start edge (that is, we haven't seen the // preceding the start edge (that is, we haven't seen the start edge yet)
// start edge yet)
if (--surf->spanstate == 0) { if (--surf->spanstate == 0) {
if (surf->insubmodel) if (surf->insubmodel)
r_bmodelactive--; r_bmodelactive--;
@ -428,9 +395,6 @@ R_TrailingEdge (surf_t *surf, edge_t *edge)
#ifndef USE_INTEL_ASM #ifndef USE_INTEL_ASM
/*
R_LeadingEdge
*/
void void
R_LeadingEdge (edge_t *edge) R_LeadingEdge (edge_t *edge)
{ {
@ -487,8 +451,8 @@ R_LeadingEdge (edge_t *edge)
if (surf->key == surf2->key) { if (surf->key == surf2->key) {
// if it's two surfaces on the same plane, the one that's // if it's two surfaces on the same plane, the one that's
// already // already active is in front, so keep going unless it's a
// active is in front, so keep going unless it's a bmodel // bmodel
if (!surf->insubmodel) if (!surf->insubmodel)
goto continue_search; goto continue_search;
@ -554,15 +518,14 @@ R_GenerateSpans (void)
r_bmodelactive = 0; r_bmodelactive = 0;
// clear active surfaces to just the background surface // clear active surfaces to just the background surface
surfaces[1].next = surfaces[1].prev = &surfaces[1]; surfaces[1].next = surfaces[1].prev = &surfaces[1];
surfaces[1].last_u = edge_head_u_shift20; surfaces[1].last_u = edge_head_u_shift20;
// generate spans // generate spans
for (edge = edge_head.next; edge != &edge_tail; edge = edge->next) { for (edge = edge_head.next; edge != &edge_tail; edge = edge->next) {
if (edge->surfs[0]) { if (edge->surfs[0]) {
// it has a left surface, so a surface is going away for this // it has a left surface, so a surface is going away for this span
// span
surf = &surfaces[edge->surfs[0]]; surf = &surfaces[edge->surfs[0]];
R_TrailingEdge (surf, edge); R_TrailingEdge (surf, edge);
@ -580,9 +543,6 @@ R_GenerateSpans (void)
#endif // !USE_INTEL_ASM #endif // !USE_INTEL_ASM
/*
R_GenerateSpansBackward
*/
void void
R_GenerateSpansBackward (void) R_GenerateSpansBackward (void)
{ {
@ -590,11 +550,11 @@ R_GenerateSpansBackward (void)
r_bmodelactive = 0; r_bmodelactive = 0;
// clear active surfaces to just the background surface // clear active surfaces to just the background surface
surfaces[1].next = surfaces[1].prev = &surfaces[1]; surfaces[1].next = surfaces[1].prev = &surfaces[1];
surfaces[1].last_u = edge_head_u_shift20; surfaces[1].last_u = edge_head_u_shift20;
// generate spans // generate spans
for (edge = edge_head.next; edge != &edge_tail; edge = edge->next) { for (edge = edge_head.next; edge != &edge_tail; edge = edge->next) {
if (edge->surfs[0]) if (edge->surfs[0])
R_TrailingEdge (&surfaces[edge->surfs[0]], edge); R_TrailingEdge (&surfaces[edge->surfs[0]], edge);
@ -631,7 +591,7 @@ R_ScanEdges (void)
span_p = basespan_p; span_p = basespan_p;
// clear active edges to just the background edges around the whole screen // clear active edges to just the background edges around the whole screen
// FIXME: most of this only needs to be set up once // FIXME: most of this only needs to be set up once
edge_head.u = r_refdef.vrect.x << 20; edge_head.u = r_refdef.vrect.x << 20;
edge_head_u_shift20 = edge_head.u >> 20; edge_head_u_shift20 = edge_head.u >> 20;
@ -658,9 +618,7 @@ R_ScanEdges (void)
edge_sentinel.u = 2000 << 24; // make sure nothing sorts past this edge_sentinel.u = 2000 << 24; // make sure nothing sorts past this
edge_sentinel.prev = &edge_aftertail; edge_sentinel.prev = &edge_aftertail;
// // process all scan lines
// process all scan lines
//
bottom = r_refdef.vrectbottom - 1; bottom = r_refdef.vrectbottom - 1;
for (iv = r_refdef.vrect.y; iv < bottom; iv++) { for (iv = r_refdef.vrect.y; iv < bottom; iv++) {
@ -677,12 +635,10 @@ R_ScanEdges (void)
(*pdrawfunc) (); (*pdrawfunc) ();
// flush the span list if we can't be sure we have enough spans left // flush the span list if we can't be sure we have enough spans left
// for // for the next scan
// the next scan
if (span_p > max_span_p) { if (span_p > max_span_p) {
VID_UnlockBuffer (); VID_UnlockBuffer ();
S_ExtraUpdate (); // don't let sound get messed up if S_ExtraUpdate (); // don't let sound get messed up if going slow
// going slow
VID_LockBuffer (); VID_LockBuffer ();
if (r_drawculledpolys) if (r_drawculledpolys)
@ -704,12 +660,11 @@ R_ScanEdges (void)
R_StepActiveU (edge_head.next); R_StepActiveU (edge_head.next);
} }
// do the last scan (no need to step or sort or remove on the last scan) // do the last scan (no need to step or sort or remove on the last scan)
current_iv = iv; current_iv = iv;
fv = (float) iv; fv = (float) iv;
// mark that the head (background start) span is pre-included // mark that the head (background start) span is pre-included
surfaces[1].spanstate = 1; surfaces[1].spanstate = 1;
if (newedges[iv]) if (newedges[iv])
@ -717,7 +672,7 @@ R_ScanEdges (void)
(*pdrawfunc) (); (*pdrawfunc) ();
// draw whatever's left in the span list // draw whatever's left in the span list
if (r_drawculledpolys) if (r_drawculledpolys)
R_DrawCulledPolys (); R_DrawCulledPolys ();
else else

View file

@ -36,17 +36,13 @@
int r_dlightframecount; int r_dlightframecount;
/*
R_AnimateLight
*/
void void
R_AnimateLight (void) R_AnimateLight (void)
{ {
int i, j, k; int i, j, k;
// // light animations
// light animations // 'm' is normal light, 'a' is no light, 'z' is double bright
// 'm' is normal light, 'a' is no light, 'z' is double bright
i = (int) (cl.time * 10); i = (int) (cl.time * 10);
for (j = 0; j < MAX_LIGHTSTYLES; j++) { for (j = 0; j < MAX_LIGHTSTYLES; j++) {
if (!cl_lightstyle[j].length) { if (!cl_lightstyle[j].length) {
@ -65,9 +61,7 @@ R_AnimateLight (void)
DYNAMIC LIGHTS DYNAMIC LIGHTS
*/ */
/*
R_MarkLights
*/
void void
R_MarkLights (vec3_t lightorigin, dlight_t *light, int bit, mnode_t *node) R_MarkLights (vec3_t lightorigin, dlight_t *light, int bit, mnode_t *node)
{ {
@ -90,7 +84,7 @@ R_MarkLights (vec3_t lightorigin, dlight_t *light, int bit, mnode_t *node)
R_MarkLights (lightorigin, light, bit, node->children[1]); R_MarkLights (lightorigin, light, bit, node->children[1]);
return; return;
} }
// mark the polygons // mark the polygons
surf = cl.worldmodel->surfaces + node->firstsurface; surf = cl.worldmodel->surfaces + node->firstsurface;
for (i = 0; i < node->numsurfaces; i++, surf++) { for (i = 0; i < node->numsurfaces; i++, surf++) {
if (surf->dlightframe != r_dlightframecount) { if (surf->dlightframe != r_dlightframecount) {
@ -105,9 +99,6 @@ R_MarkLights (vec3_t lightorigin, dlight_t *light, int bit, mnode_t *node)
} }
/*
R_PushDlights
*/
void void
R_PushDlights (vec3_t entorigin) R_PushDlights (vec3_t entorigin)
{ {
@ -132,6 +123,7 @@ R_PushDlights (vec3_t entorigin)
LIGHT SAMPLING LIGHT SAMPLING
*/ */
int int
RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end) RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end)
{ {
@ -151,8 +143,7 @@ RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end)
if (node->contents < 0) if (node->contents < 0)
return -1; // didn't hit anything return -1; // didn't hit anything
// calculate mid point // calculate mid point
// FIXME: optimize for axial // FIXME: optimize for axial
plane = node->plane; plane = node->plane;
front = DotProduct (start, plane->normal) - plane->dist; front = DotProduct (start, plane->normal) - plane->dist;
@ -167,7 +158,7 @@ RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end)
mid[1] = start[1] + (end[1] - start[1]) * frac; mid[1] = start[1] + (end[1] - start[1]) * frac;
mid[2] = start[2] + (end[2] - start[2]) * frac; mid[2] = start[2] + (end[2] - start[2]) * frac;
// go down front side // go down front side
r = RecursiveLightPoint (node->children[side], start, mid); r = RecursiveLightPoint (node->children[side], start, mid);
if (r >= 0) if (r >= 0)
return r; // hit something return r; // hit something
@ -175,8 +166,7 @@ RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end)
if ((back < 0) == side) if ((back < 0) == side)
return -1; // didn't hit anything return -1; // didn't hit anything
// check for impact on this node // check for impact on this node
surf = cl.worldmodel->surfaces + node->firstsurface; surf = cl.worldmodel->surfaces + node->firstsurface;
for (i = 0; i < node->numsurfaces; i++, surf++) { for (i = 0; i < node->numsurfaces; i++, surf++) {
if (surf->flags & SURF_DRAWTILED) if (surf->flags & SURF_DRAWTILED)
@ -222,10 +212,11 @@ RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end)
return r; return r;
} }
// go down back side // go down back side
return RecursiveLightPoint (node->children[!side], mid, end); return RecursiveLightPoint (node->children[!side], mid, end);
} }
int int
R_LightPoint (vec3_t p) R_LightPoint (vec3_t p)
{ {

View file

@ -88,17 +88,13 @@ qboolean r_fov_greater_than_90;
entity_t r_worldentity; entity_t r_worldentity;
//
// view origin // view origin
//
vec3_t vup, base_vup; vec3_t vup, base_vup;
vec3_t vpn, base_vpn; vec3_t vpn, base_vpn;
vec3_t vright, base_vright; vec3_t vright, base_vright;
vec3_t r_origin; vec3_t r_origin;
//
// screen size info // screen size info
//
refdef_t r_refdef; refdef_t r_refdef;
float xcenter, ycenter; float xcenter, ycenter;
float xscale, yscale; float xscale, yscale;
@ -115,12 +111,8 @@ float xOrigin, yOrigin;
mplane_t screenedge[4]; mplane_t screenedge[4];
//
// refresh flags // refresh flags
// int r_framecount = 1; // so frame counts initialized to 0 don't match
int r_framecount = 1; // so frame counts initialized to 0
// don't match
int r_visframecount; int r_visframecount;
int d_spanpixcount; int d_spanpixcount;
int r_polycount; int r_polycount;
@ -130,11 +122,9 @@ int r_wholepolycount;
int *pfrustum_indexes[4]; int *pfrustum_indexes[4];
int r_frustum_indexes[4 * 6]; int r_frustum_indexes[4 * 6];
int reinit_surfcache = 1; // if 1, surface cache is currently int reinit_surfcache = 1; // if 1, surface cache is currently empty
// and must be reinitialized for current
// empty and // cache size
// must be reinitialized for current cache
// size
mleaf_t *r_viewleaf, *r_oldviewleaf; mleaf_t *r_viewleaf, *r_oldviewleaf;
@ -152,16 +142,14 @@ extern cvar_t *scr_fov;
void R_NetGraph (void); void R_NetGraph (void);
void R_ZGraph (void); void R_ZGraph (void);
/*
R_Textures_Init
*/
void void
R_Textures_Init (void) R_Textures_Init (void)
{ {
int x, y, m; int x, y, m;
byte *dest; byte *dest;
// create a simple checkerboard texture for the default // create a simple checkerboard texture for the default
r_notexture_mip = r_notexture_mip =
Hunk_AllocName (sizeof (texture_t) + 16 * 16 + 8 * 8 + 4 * 4 + 2 * 2, Hunk_AllocName (sizeof (texture_t) + 16 * 16 + 8 * 8 + 4 * 4 + 2 * 2,
"notexture"); "notexture");
@ -185,11 +173,10 @@ R_Textures_Init (void)
} }
} }
void R_LoadSky_f (void);
/* void R_LoadSky_f (void);
R_Init
*/
void void
R_Init (void) R_Init (void)
{ {
@ -202,8 +189,10 @@ R_Init (void)
R_InitTurb (); R_InitTurb ();
Cmd_AddCommand ("timerefresh", R_TimeRefresh_f, "Tests the current refresh rate for the current location"); Cmd_AddCommand ("timerefresh", R_TimeRefresh_f, "Tests the current "
Cmd_AddCommand ("pointfile", R_ReadPointFile_f, "Load a pointfile to determine map leaks"); "refresh rate for the current location");
Cmd_AddCommand ("pointfile", R_ReadPointFile_f, "Load a pointfile to "
"determine map leaks");
Cmd_AddCommand ("loadsky", R_LoadSky_f, "Load a skybox"); Cmd_AddCommand ("loadsky", R_LoadSky_f, "Load a skybox");
Cvar_SetValue (r_maxedges, (float) NUMSTACKEDGES); Cvar_SetValue (r_maxedges, (float) NUMSTACKEDGES);
@ -224,13 +213,10 @@ R_Init (void)
Sys_MakeCodeWriteable ((long) R_EdgeCodeStart, Sys_MakeCodeWriteable ((long) R_EdgeCodeStart,
(long) R_EdgeCodeEnd - (long) R_EdgeCodeStart); (long) R_EdgeCodeEnd - (long) R_EdgeCodeStart);
#endif // USE_INTEL_ASM #endif // USE_INTEL_ASM
D_Init (); D_Init ();
} }
/*
R_NewMap
*/
void void
R_NewMap (void) R_NewMap (void)
{ {
@ -239,7 +225,7 @@ R_NewMap (void)
memset (&r_worldentity, 0, sizeof (r_worldentity)); memset (&r_worldentity, 0, sizeof (r_worldentity));
r_worldentity.model = cl.worldmodel; r_worldentity.model = cl.worldmodel;
// clear out efrags in case the level hasn't been reloaded // clear out efrags in case the level hasn't been reloaded
// FIXME: is this one short? // FIXME: is this one short?
for (i = 0; i < cl.worldmodel->numleafs; i++) for (i = 0; i < cl.worldmodel->numleafs; i++)
cl.worldmodel->leafs[i].efrags = NULL; cl.worldmodel->leafs[i].efrags = NULL;
@ -286,9 +272,6 @@ R_NewMap (void)
} }
/*
R_SetVrect
*/
void void
R_SetVrect (vrect_t *pvrectin, vrect_t *pvrect, int lineadj) R_SetVrect (vrect_t *pvrectin, vrect_t *pvrect, int lineadj)
{ {
@ -398,12 +381,12 @@ R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect)
verticalFieldOfView = r_refdef.horizontalFieldOfView / screenAspect; verticalFieldOfView = r_refdef.horizontalFieldOfView / screenAspect;
// 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) r_refdef.vrect.width * XCENTERING) + xcenter = ((float) r_refdef.vrect.width * XCENTERING) +
r_refdef.vrect.x - 0.5; r_refdef.vrect.x - 0.5;
aliasxcenter = xcenter * r_aliasuvscale; aliasxcenter = xcenter * r_aliasuvscale;
@ -420,26 +403,26 @@ R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect)
xscaleshrink = (r_refdef.vrect.width - 6) / r_refdef.horizontalFieldOfView; xscaleshrink = (r_refdef.vrect.width - 6) / r_refdef.horizontalFieldOfView;
yscaleshrink = xscaleshrink * pixelAspect; yscaleshrink = xscaleshrink * pixelAspect;
// left side clip // left side clip
screenedge[0].normal[0] = -1.0 / (xOrigin * r_refdef.horizontalFieldOfView); screenedge[0].normal[0] = -1.0 / (xOrigin * r_refdef.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) * r_refdef.horizontalFieldOfView); 1.0 / ((1.0 - xOrigin) * r_refdef.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 * verticalFieldOfView); 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) * verticalFieldOfView); screenedge[3].normal[1] = 1.0 / ((1.0 - yOrigin) * verticalFieldOfView);
screenedge[3].normal[2] = 1; screenedge[3].normal[2] = 1;
@ -477,9 +460,6 @@ R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect)
} }
/*
R_MarkLeaves
*/
void void
R_MarkLeaves (void) R_MarkLeaves (void)
{ {
@ -508,11 +488,7 @@ R_MarkLeaves (void)
} }
} }
/*
=============
R_ShowNearestLoc
=============
*/
static void static void
R_ShowNearestLoc (void) R_ShowNearestLoc (void)
{ {
@ -535,9 +511,7 @@ R_ShowNearestLoc (void)
} }
} }
/*
R_DrawEntitiesOnList
*/
void void
R_DrawEntitiesOnList (void) R_DrawEntitiesOnList (void)
{ {
@ -608,9 +582,7 @@ R_DrawEntitiesOnList (void)
} }
} }
/*
R_DrawViewModel
*/
void void
R_DrawViewModel (void) R_DrawViewModel (void)
{ {
@ -650,7 +622,7 @@ R_DrawViewModel (void)
r_viewlighting.ambientlight = j; r_viewlighting.ambientlight = j;
r_viewlighting.shadelight = j; r_viewlighting.shadelight = j;
// add dynamic lights // add dynamic lights
for (lnum = 0; lnum < MAX_DLIGHTS; lnum++) { for (lnum = 0; lnum < MAX_DLIGHTS; lnum++) {
dl = &cl_dlights[lnum]; dl = &cl_dlights[lnum];
if (!dl->radius) if (!dl->radius)
@ -666,7 +638,7 @@ R_DrawViewModel (void)
r_viewlighting.ambientlight += add; r_viewlighting.ambientlight += add;
} }
// clamp lighting so it doesn't overbright as much // clamp lighting so it doesn't overbright as much
if (r_viewlighting.ambientlight > 128) if (r_viewlighting.ambientlight > 128)
r_viewlighting.ambientlight = 128; r_viewlighting.ambientlight = 128;
if (r_viewlighting.ambientlight + r_viewlighting.shadelight > 192) if (r_viewlighting.ambientlight + r_viewlighting.shadelight > 192)
@ -678,9 +650,6 @@ R_DrawViewModel (void)
} }
/*
R_BmodelCheckBBox
*/
int int
R_BmodelCheckBBox (model_t *clmodel, float *minmaxs) R_BmodelCheckBBox (model_t *clmodel, float *minmaxs)
{ {
@ -705,9 +674,8 @@ R_BmodelCheckBBox (model_t *clmodel, float *minmaxs)
} else { } else {
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
// generate accept and reject points // generate accept and reject points
// FIXME: do with fast look-ups or integer tests based on the // FIXME: do with fast look-ups or integer tests based on the
// sign bit // sign bit of the floating point values
// of the floating point values
pindex = pfrustum_indexes[i]; pindex = pfrustum_indexes[i];
@ -737,9 +705,6 @@ R_BmodelCheckBBox (model_t *clmodel, float *minmaxs)
} }
/*
R_DrawBEntitiesOnList
*/
void void
R_DrawBEntitiesOnList (void) R_DrawBEntitiesOnList (void)
{ {
@ -764,8 +729,7 @@ R_DrawBEntitiesOnList (void)
clmodel = currententity->model; clmodel = currententity->model;
// see if the bounding box lets us trivially reject, also // see if the bounding box lets us trivially reject, also
// sets // sets trivial accept status
// trivial accept status
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
minmaxs[j] = currententity->origin[j] + clmodel->mins[j]; minmaxs[j] = currententity->origin[j] + clmodel->mins[j];
minmaxs[3 + j] = currententity->origin[j] + minmaxs[3 + j] = currententity->origin[j] +
@ -777,12 +741,12 @@ R_DrawBEntitiesOnList (void)
if (clipflags != BMODEL_FULLY_CLIPPED) { if (clipflags != BMODEL_FULLY_CLIPPED) {
VectorCopy (currententity->origin, r_entorigin); VectorCopy (currententity->origin, r_entorigin);
VectorSubtract (r_origin, r_entorigin, modelorg); VectorSubtract (r_origin, r_entorigin, modelorg);
// FIXME: is this needed? // FIXME: is this needed?
VectorCopy (modelorg, r_worldmodelorg); VectorCopy (modelorg, r_worldmodelorg);
r_pcurrentvertbase = clmodel->vertexes; r_pcurrentvertbase = clmodel->vertexes;
// FIXME: stop transforming twice // FIXME: stop transforming twice
R_RotateBmodel (); R_RotateBmodel ();
// calculate dynamic lighting for bmodel if it's not an // calculate dynamic lighting for bmodel if it's not an
@ -802,10 +766,8 @@ R_DrawBEntitiesOnList (void)
} }
} }
// if the driver wants polygons, deliver those. // if the driver wants polygons, deliver those.
// Z-buffering is on // Z-buffering is on at this point, so no clipping to the
// at this point, so no clipping to the world tree is // world tree is needed, just frustum clipping
// needed, just
// frustum clipping
if (r_drawpolys | r_drawculledpolys) { if (r_drawpolys | r_drawculledpolys) {
R_ZDrawSubmodelPolys (clmodel); R_ZDrawSubmodelPolys (clmodel);
} else { } else {
@ -828,10 +790,8 @@ R_DrawBEntitiesOnList (void)
R_DrawSolidClippedSubmodelPolygons (clmodel); R_DrawSolidClippedSubmodelPolygons (clmodel);
} else { } else {
// falls entirely in one leaf, so we just put // falls entirely in one leaf, so we just put
// all the // all the edges in the edge list and let 1/z
// edges in the edge list and let 1/z sorting // sorting handle drawing order
// handle
// drawing order
R_DrawSubmodelPolygons (clmodel, clipflags); R_DrawSubmodelPolygons (clmodel, clipflags);
} }
@ -840,7 +800,7 @@ R_DrawBEntitiesOnList (void)
} }
// put back world rotation and frustum clipping // put back world rotation and frustum clipping
// FIXME: R_RotateBmodel should just work off base_vxx // FIXME: R_RotateBmodel should just work off base_vxx
VectorCopy (base_vpn, vpn); VectorCopy (base_vpn, vpn);
VectorCopy (base_vup, vup); VectorCopy (base_vup, vup);
VectorCopy (base_vright, vright); VectorCopy (base_vright, vright);
@ -860,17 +820,12 @@ R_DrawBEntitiesOnList (void)
} }
/*
R_EdgeDrawing
*/
void void
R_EdgeDrawing (void) R_EdgeDrawing (void)
{ {
edge_t ledges[NUMSTACKEDGES + edge_t ledges[NUMSTACKEDGES +
((CACHE_SIZE - 1) / sizeof (edge_t)) + 1]; ((CACHE_SIZE - 1) / sizeof (edge_t)) + 1];
surf_t lsurfs[NUMSTACKSURFACES + surf_t lsurfs[NUMSTACKSURFACES +
((CACHE_SIZE - 1) / sizeof (surf_t)) + 1]; ((CACHE_SIZE - 1) / sizeof (surf_t)) + 1];
if (auxedges) { if (auxedges) {
@ -901,8 +856,8 @@ R_EdgeDrawing (void)
if (r_drawculledpolys) if (r_drawculledpolys)
R_ScanEdges (); R_ScanEdges ();
// only the world can be drawn back to front with no z reads or compares, just // only the world can be drawn back to front with no z reads or compares,
// z writes, so have the driver turn z compares on now // just z writes, so have the driver turn z compares on now
D_TurnZOn (); D_TurnZOn ();
if (r_dspeeds->int_val) { if (r_dspeeds->int_val) {
@ -948,8 +903,7 @@ R_RenderView_ (void)
R_SetupFrame (); R_SetupFrame ();
R_MarkLeaves (); // done here so we know if we're in R_MarkLeaves (); // done here so we know if we're in water
// water
// make FDIV fast. This reduces timing precision after we've been running for a // make FDIV fast. This reduces timing precision after we've been running for a
// while, so we don't do it globally. This also sets chop mode, and we do it // while, so we don't do it globally. This also sets chop mode, and we do it
@ -962,8 +916,7 @@ R_RenderView_ (void)
if (!r_dspeeds->int_val) { if (!r_dspeeds->int_val) {
VID_UnlockBuffer (); VID_UnlockBuffer ();
S_ExtraUpdate (); // don't let sound get messed up if S_ExtraUpdate (); // don't let sound get messed up if going slow
// going slow
VID_LockBuffer (); VID_LockBuffer ();
} }
@ -971,8 +924,7 @@ R_RenderView_ (void)
if (!r_dspeeds->int_val) { if (!r_dspeeds->int_val) {
VID_UnlockBuffer (); VID_UnlockBuffer ();
S_ExtraUpdate (); // don't let sound get messed up if S_ExtraUpdate (); // don't let sound get messed up if going slow
// going slow
VID_LockBuffer (); VID_LockBuffer ();
} }
@ -1029,10 +981,11 @@ R_RenderView_ (void)
if (r_reportedgeout->int_val && r_outofedges) if (r_reportedgeout->int_val && r_outofedges)
Con_Printf ("Short roughly %d edges\n", r_outofedges * 2 / 3); Con_Printf ("Short roughly %d edges\n", r_outofedges * 2 / 3);
// back to high floating-point precision // back to high floating-point precision
Sys_HighFPPrecision (); Sys_HighFPPrecision ();
} }
void void
R_RenderView (void) R_RenderView (void)
{ {
@ -1055,9 +1008,7 @@ R_RenderView (void)
R_RenderView_ (); R_RenderView_ ();
} }
/*
R_InitTurb
*/
void void
R_InitTurb (void) R_InitTurb (void)
{ {

View file

@ -43,9 +43,7 @@
#include "render.h" #include "render.h"
#include "sbar.h" #include "sbar.h"
qboolean allowskybox; // whether or not to allow skyboxes qboolean allowskybox; // whether or not to allow skyboxes --KB
// --KB
void void
@ -139,8 +137,8 @@ R_LineGraph (int x, int y, int h)
// FIXME: should be disabled on no-buffer adapters, or should be in the driver // FIXME: should be disabled on no-buffer adapters, or should be in the driver
// x += r_refdef.vrect.x; // x += r_refdef.vrect.x;
// y += r_refdef.vrect.y; // y += r_refdef.vrect.y;
dest = vid.buffer + vid.rowbytes * y + x; dest = vid.buffer + vid.rowbytes * y + x;
@ -160,7 +158,7 @@ R_LineGraph (int x, int y, int h)
for (i = 0; i < h; i++, dest -= vid.rowbytes) { for (i = 0; i < h; i++, dest -= vid.rowbytes) {
dest[0] = color; dest[0] = color;
// *(dest-vid.rowbytes) = 0x30; // *(dest-vid.rowbytes) = 0x30;
} }
#if 0 #if 0
for (; i < s; i++, dest -= vid.rowbytes * 2) { for (; i < s; i++, dest -= vid.rowbytes * 2) {
@ -170,14 +168,16 @@ R_LineGraph (int x, int y, int h)
#endif #endif
} }
#define MAX_TIMINGS 100
extern float mouse_x, mouse_y;
int graphval;
/* /*
R_TimeGraph R_TimeGraph
Performance monitoring tool Performance monitoring tool
*/ */
#define MAX_TIMINGS 100
extern float mouse_x, mouse_y;
int graphval;
void void
R_TimeGraph (void) R_TimeGraph (void)
{ {
@ -190,13 +190,13 @@ R_TimeGraph (void)
r_time2 = Sys_DoubleTime (); r_time2 = Sys_DoubleTime ();
a = (r_time2 - r_time1) / 0.01; a = (r_time2 - r_time1) / 0.01;
//a = fabs(mouse_y * 0.05); // a = fabs(mouse_y * 0.05);
//a = (int)((r_refdef.vieworg[2] + 1024)/1)%(int)r_graphheight->value; // a = (int)((r_refdef.vieworg[2] + 1024)/1)%(int)r_graphheight->value;
//a = (int)((pmove.velocity[2] + 500)/10); // a = (int)((pmove.velocity[2] + 500)/10);
//a = fabs(velocity[0])/20; // a = fabs(velocity[0])/20;
//a = ((int)fabs(origin[0])/8)%20; // a = ((int)fabs(origin[0])/8)%20;
//a = (cl.idealpitch + 30)/5; // a = (cl.idealpitch + 30)/5;
//a = (int)(cl.simangles[YAW] * 64/360) & 63; // a = (int)(cl.simangles[YAW] * 64/360) & 63;
a = graphval; a = graphval;
r_timings[timex] = a; r_timings[timex] = a;
@ -333,7 +333,7 @@ WarpPalette (void)
basecolor[1] = 80; basecolor[1] = 80;
basecolor[2] = 50; basecolor[2] = 50;
// pull the colors halfway to bright brown // pull the colors halfway to bright brown
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
newpalette[i * 3 + j] = newpalette[i * 3 + j] =
@ -368,7 +368,6 @@ R_TransformFrustum (void)
#ifndef USE_INTEL_ASM #ifndef USE_INTEL_ASM
void void
TransformVector (vec3_t in, vec3_t out) TransformVector (vec3_t in, vec3_t out)
{ {
@ -376,7 +375,6 @@ TransformVector (vec3_t in, vec3_t out)
out[1] = DotProduct (in, vup); out[1] = DotProduct (in, vup);
out[2] = DotProduct (in, vpn); out[2] = DotProduct (in, vpn);
} }
#endif #endif
@ -410,7 +408,7 @@ R_SetUpFrustumIndexes (void)
} }
} }
// FIXME: do just once at start // FIXME: do just once at start
pfrustum_indexes[i] = pindex; pfrustum_indexes[i] = pindex;
pindex += 6; pindex += 6;
} }
@ -528,10 +526,10 @@ R_SetupFrame (void)
r_viewchanged = false; r_viewchanged = false;
} }
// start off with just the four screen edge clip planes // start off with just the four screen edge clip planes
R_TransformFrustum (); R_TransformFrustum ();
// save base values // save base values
VectorCopy (vpn, base_vpn); VectorCopy (vpn, base_vpn);
VectorCopy (vright, base_vright); VectorCopy (vright, base_vright);
VectorCopy (vup, base_vup); VectorCopy (vup, base_vup);
@ -543,7 +541,7 @@ R_SetupFrame (void)
r_cache_thrash = false; r_cache_thrash = false;
// clear frame counts // clear frame counts
c_faceclip = 0; c_faceclip = 0;
d_spanpixcount = 0; d_spanpixcount = 0;
r_polycount = 0; r_polycount = 0;

View file

@ -54,14 +54,17 @@ int r_numparticles;
vec3_t r_pright, r_pup, r_ppn; vec3_t r_pright, r_pup, r_ppn;
cvar_t *r_particles; cvar_t *r_particles;
/* /*
R_MaxParticlesCheck R_MaxParticlesCheck
Misty-chan: EXTREME heavy lifting and bugfixing thanks goes out to taniwha - I built this, and he got it working :)
Misty-chan: EXTREME heavy lifting and bugfixing thanks goes out to taniwha
- I built this, and he got it working :)
*/ */
void void
R_MaxParticlesCheck (cvar_t *var) R_MaxParticlesCheck (cvar_t *var)
{ {
// Do not use 0 in this! sw doesn't grok 0 and it's going to segfault if we do! // Do not use 0 in this! sw doesn't grok 0 and it'll segfault if we do!
r_numparticles = max(var->int_val, 1); r_numparticles = max(var->int_val, 1);
/* /*
@ -78,21 +81,17 @@ R_MaxParticlesCheck (cvar_t *var)
R_ClearParticles (); R_ClearParticles ();
} }
/*
R_Particles_Init_Cvars
*/
void void
R_Particles_Init_Cvars (void) R_Particles_Init_Cvars (void)
{ {
// Does a callback to R_MaxParticleCheck when the cvar changes. Neat trick. // Does a callback to R_MaxParticleCheck when the cvar changes. Neat trick.
Cvar_Get ("cl_max_particles", "2048", CVAR_ARCHIVE, R_MaxParticlesCheck, Cvar_Get ("cl_max_particles", "2048", CVAR_ARCHIVE, R_MaxParticlesCheck,
"Maximum amount of particles to display. No maximum, minimum is 1."); "Maximum amount of particles to display. No maximum, minimum "
"is 1.");
} }
/*
R_ClearParticles
*/
void void
R_ClearParticles (void) R_ClearParticles (void)
{ {
@ -156,6 +155,7 @@ R_ReadPointFile_f (void)
Con_Printf ("%i points read\n", c); Con_Printf ("%i points read\n", c);
} }
void void
R_RunSpikeEffect (vec3_t pos, byte type) R_RunSpikeEffect (vec3_t pos, byte type)
{ {
@ -175,6 +175,7 @@ R_RunSpikeEffect (vec3_t pos, byte type)
} }
} }
void void
R_RunPuffEffect (vec3_t pos, byte type, byte cnt) R_RunPuffEffect (vec3_t pos, byte type, byte cnt)
{ {
@ -194,9 +195,7 @@ R_RunPuffEffect (vec3_t pos, byte type, byte cnt)
} }
} }
/*
R_ParticleExplosion
*/
void void
R_ParticleExplosion (vec3_t org) R_ParticleExplosion (vec3_t org)
{ {
@ -233,9 +232,7 @@ R_ParticleExplosion (vec3_t org)
} }
} }
/*
R_BlobExplosion
*/
void void
R_BlobExplosion (vec3_t org) R_BlobExplosion (vec3_t org)
{ {
@ -273,9 +270,7 @@ R_BlobExplosion (vec3_t org)
} }
} }
/*
R_RunParticleEffect
*/
void void
R_RunParticleEffect (vec3_t org, int color, int count) R_RunParticleEffect (vec3_t org, int color, int count)
{ {
@ -312,9 +307,6 @@ R_RunParticleEffect (vec3_t org, int color, int count)
} }
/*
R_LavaSplash
*/
void void
R_LavaSplash (vec3_t org) R_LavaSplash (vec3_t org)
{ {
@ -354,9 +346,7 @@ R_LavaSplash (vec3_t org)
} }
} }
/*
R_TeleportSplash
*/
void void
R_TeleportSplash (vec3_t org) R_TeleportSplash (vec3_t org)
{ {
@ -396,6 +386,7 @@ R_TeleportSplash (vec3_t org)
} }
} }
void void
R_RocketTrail (int type, entity_t *ent) R_RocketTrail (int type, entity_t *ent)
{ {
@ -479,9 +470,6 @@ R_RocketTrail (int type, entity_t *ent)
} }
/*
R_DrawParticles
*/
void void
R_DrawParticles (void) R_DrawParticles (void)
{ {

View file

@ -50,12 +50,10 @@ int r_skydirect; // not used?
byte bottomsky[128 * 131]; byte bottomsky[128 * 131];
byte bottommask[128 * 131]; byte bottommask[128 * 131];
byte newsky[128 * 256]; // newsky and topsky both pack in byte newsky[128 * 256]; // newsky and topsky both pack in here, 128
// bytes of newsky on the left of each scan,
// here, 128 bytes // 128 bytes of topsky on the right, because
// of newsky on the left of each scan, 128 bytes // the low-level drawers need 256-byte widths
// of topsky on the right, because the low-level
// drawers need 256-byte scan widths
/* /*
@ -93,9 +91,6 @@ R_InitSky (texture_t *mt)
} }
/*
R_MakeSky
*/
void void
R_MakeSky (void) R_MakeSky (void)
{ {
@ -121,7 +116,6 @@ R_MakeSky (void)
// FIXME: clean this up // FIXME: clean this up
#if UNALIGNED_OK #if UNALIGNED_OK
for (x = 0; x < SKYSIZE; x += 4) { for (x = 0; x < SKYSIZE; x += 4) {
ofs = baseofs + ((x + xshift) & SKYMASK); ofs = baseofs + ((x + xshift) & SKYMASK);
@ -133,9 +127,7 @@ R_MakeSky (void)
pnewsky++; pnewsky++;
} }
#else #else
for (x = 0; x < SKYSIZE; x++) { for (x = 0; x < SKYSIZE; x++) {
ofs = baseofs + ((x + xshift) & SKYMASK); ofs = baseofs + ((x + xshift) & SKYMASK);
@ -144,9 +136,7 @@ R_MakeSky (void)
*(byte *) & bottomsky[ofs]; *(byte *) & bottomsky[ofs];
pnewsky = (unsigned int *) ((byte *) pnewsky + 1); pnewsky = (unsigned int *) ((byte *) pnewsky + 1);
} }
#endif #endif
pnewsky += 128 / sizeof (unsigned int); pnewsky += 128 / sizeof (unsigned int);
} }
@ -154,9 +144,6 @@ R_MakeSky (void)
} }
/*
R_GenSkyTile
*/
void void
R_GenSkyTile (void *pdest) R_GenSkyTile (void *pdest)
{ {
@ -177,7 +164,6 @@ R_GenSkyTile (void *pdest)
// FIXME: clean this up // FIXME: clean this up
#if UNALIGNED_OK #if UNALIGNED_OK
for (x = 0; x < SKYSIZE; x += 4) { for (x = 0; x < SKYSIZE; x += 4) {
ofs = baseofs + ((x + xshift) & SKYMASK); ofs = baseofs + ((x + xshift) & SKYMASK);
@ -190,9 +176,7 @@ R_GenSkyTile (void *pdest)
pnewsky++; pnewsky++;
pd++; pd++;
} }
#else #else
for (x = 0; x < SKYSIZE; x++) { for (x = 0; x < SKYSIZE; x++) {
ofs = baseofs + ((x + xshift) & SKYMASK); ofs = baseofs + ((x + xshift) & SKYMASK);
@ -202,17 +186,12 @@ R_GenSkyTile (void *pdest)
pnewsky = (unsigned int *) ((byte *) pnewsky + 1); pnewsky = (unsigned int *) ((byte *) pnewsky + 1);
pd = (unsigned int *) ((byte *) pd + 1); pd = (unsigned int *) ((byte *) pd + 1);
} }
#endif #endif
pnewsky += 128 / sizeof (unsigned int); pnewsky += 128 / sizeof (unsigned int);
} }
} }
/*
R_GenSkyTile16
*/
void void
R_GenSkyTile16 (void *pdest) R_GenSkyTile16 (void *pdest)
{ {
@ -248,9 +227,6 @@ R_GenSkyTile16 (void *pdest)
} }
/*
R_SetSkyFrame
*/
void void
R_SetSkyFrame (void) R_SetSkyFrame (void)
{ {
@ -267,7 +243,6 @@ R_SetSkyFrame (void)
skytime = cl.time - ((int) (cl.time / temp) * temp); skytime = cl.time - ((int) (cl.time / temp) * temp);
r_skymade = 0; r_skymade = 0;
} }

View file

@ -51,9 +51,6 @@ static int sprite_width, sprite_height;
spritedesc_t r_spritedesc; spritedesc_t r_spritedesc;
/*
R_RotateSprite
*/
void void
R_RotateSprite (float beamlength) R_RotateSprite (float beamlength)
{ {
@ -85,7 +82,7 @@ R_ClipSpriteFace (int nump, clipplane_t *pclipplane)
clipdist = pclipplane->dist; clipdist = pclipplane->dist;
pclipnormal = pclipplane->normal; pclipnormal = pclipplane->normal;
// calc dists // calc dists
if (clip_current) { if (clip_current) {
in = clip_verts[1][0]; in = clip_verts[1][0];
outstep = clip_verts[0][0]; outstep = clip_verts[0][0];
@ -101,12 +98,11 @@ R_ClipSpriteFace (int nump, clipplane_t *pclipplane)
dists[i] = DotProduct (instep, pclipnormal) - clipdist; dists[i] = DotProduct (instep, pclipnormal) - clipdist;
} }
// handle wraparound case // handle wraparound case
dists[nump] = dists[0]; dists[nump] = dists[0];
memcpy (instep, in, sizeof (vec5_t)); memcpy (instep, in, sizeof (vec5_t));
// clip the winding
// clip the winding
instep = in; instep = in;
outcount = 0; outcount = 0;
@ -144,9 +140,6 @@ R_ClipSpriteFace (int nump, clipplane_t *pclipplane)
} }
/*
R_SetupAndDrawSprite
*/
void void
R_SetupAndDrawSprite (void) R_SetupAndDrawSprite (void)
{ {
@ -158,11 +151,11 @@ R_SetupAndDrawSprite (void)
dot = DotProduct (r_spritedesc.vpn, modelorg); dot = DotProduct (r_spritedesc.vpn, modelorg);
// backface cull // backface cull
if (dot >= 0) if (dot >= 0)
return; return;
// build the sprite poster in worldspace // build the sprite poster in worldspace
VectorScale (r_spritedesc.vright, r_spritedesc.pspriteframe->right, right); VectorScale (r_spritedesc.vright, r_spritedesc.pspriteframe->right, right);
VectorScale (r_spritedesc.vup, r_spritedesc.pspriteframe->up, up); VectorScale (r_spritedesc.vup, r_spritedesc.pspriteframe->up, up);
VectorScale (r_spritedesc.vright, r_spritedesc.pspriteframe->left, left); VectorScale (r_spritedesc.vright, r_spritedesc.pspriteframe->left, left);
@ -194,7 +187,7 @@ R_SetupAndDrawSprite (void)
pverts[3][3] = 0; pverts[3][3] = 0;
pverts[3][4] = sprite_height; pverts[3][4] = sprite_height;
// clip to the frustum in worldspace // clip to the frustum in worldspace
nump = 4; nump = 4;
clip_current = 0; clip_current = 0;
@ -206,7 +199,7 @@ R_SetupAndDrawSprite (void)
Sys_Error ("R_SetupAndDrawSprite: too many points"); Sys_Error ("R_SetupAndDrawSprite: too many points");
} }
// transform vertices into viewspace and project // transform vertices into viewspace and project
pv = &clip_verts[clip_current][0][0]; pv = &clip_verts[clip_current][0][0];
r_spritedesc.nearzi = -999999; r_spritedesc.nearzi = -999999;
@ -234,16 +227,13 @@ R_SetupAndDrawSprite (void)
pv += sizeof (vec5_t) / sizeof (*pv); pv += sizeof (vec5_t) / sizeof (*pv);
} }
// draw it // draw it
r_spritedesc.nump = nump; r_spritedesc.nump = nump;
r_spritedesc.pverts = outverts; r_spritedesc.pverts = outverts;
D_DrawSprite (); D_DrawSprite ();
} }
/*
R_GetSpriteframe
*/
mspriteframe_t * mspriteframe_t *
R_GetSpriteframe (msprite_t *psprite) R_GetSpriteframe (msprite_t *psprite)
{ {
@ -270,8 +260,7 @@ R_GetSpriteframe (msprite_t *psprite)
time = cl.time + currententity->syncbase; time = cl.time + currententity->syncbase;
// when loading in Mod_LoadSpriteGroup, we guaranteed all interval // when loading in Mod_LoadSpriteGroup, we guaranteed all interval
// values // values are positive, so we don't have to worry about division by 0
// are positive, so we don't have to worry about division by 0
targettime = time - ((int) (time / fullinterval)) * fullinterval; targettime = time - ((int) (time / fullinterval)) * fullinterval;
for (i = 0; i < (numframes - 1); i++) { for (i = 0; i < (numframes - 1); i++) {
@ -286,9 +275,6 @@ R_GetSpriteframe (msprite_t *psprite)
} }
/*
R_DrawSprite
*/
void void
R_DrawSprite (void) R_DrawSprite (void)
{ {
@ -306,16 +292,12 @@ R_DrawSprite (void)
// TODO: make this caller-selectable // TODO: make this caller-selectable
if (psprite->type == SPR_FACING_UPRIGHT) { if (psprite->type == SPR_FACING_UPRIGHT) {
// generate the sprite's axes, with vup straight up in worldspace, // generate the sprite's axes, with vup straight up in worldspace, and
// and
// r_spritedesc.vright perpendicular to modelorg. // r_spritedesc.vright perpendicular to modelorg.
// This will not work if the view direction is very close to straight // This will not work if the view direction is very close to straight
// up or // up or down, because the cross product will be between two nearly
// down, because the cross product will be between two nearly // parallel vectors and starts to approach an undefined state, so we
// parallel // don't draw if the two vectors are less than 1 degree apart
// vectors and starts to approach an undefined state, so we don't
// draw if
// the two vectors are less than 1 degree apart
tvec[0] = -modelorg[0]; tvec[0] = -modelorg[0];
tvec[1] = -modelorg[1]; tvec[1] = -modelorg[1];
tvec[2] = -modelorg[2]; tvec[2] = -modelorg[2];
@ -338,30 +320,23 @@ R_DrawSprite (void)
r_spritedesc.vpn[0] = -r_spritedesc.vright[1]; r_spritedesc.vpn[0] = -r_spritedesc.vright[1];
r_spritedesc.vpn[1] = r_spritedesc.vright[0]; r_spritedesc.vpn[1] = r_spritedesc.vright[0];
r_spritedesc.vpn[2] = 0; r_spritedesc.vpn[2] = 0;
// CrossProduct (r_spritedesc.vright, r_spritedesc.vup, // CrossProduct (r_spritedesc.vright, r_spritedesc.vup, r_spritedesc.vpn)
// r_spritedesc.vpn)
} else if (psprite->type == SPR_VP_PARALLEL) { } else if (psprite->type == SPR_VP_PARALLEL) {
// generate the sprite's axes, completely parallel to the viewplane. // generate the sprite's axes, completely parallel to the viewplane.
// There // There are no problem situations, because the sprite is always in the
// are no problem situations, because the sprite is always in the // same position relative to the viewer
// same
// position relative to the viewer
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
r_spritedesc.vup[i] = vup[i]; r_spritedesc.vup[i] = vup[i];
r_spritedesc.vright[i] = vright[i]; r_spritedesc.vright[i] = vright[i];
r_spritedesc.vpn[i] = vpn[i]; r_spritedesc.vpn[i] = vpn[i];
} }
} else if (psprite->type == SPR_VP_PARALLEL_UPRIGHT) { } else if (psprite->type == SPR_VP_PARALLEL_UPRIGHT) {
// generate the sprite's axes, with vup straight up in worldspace, // generate the sprite's axes, with vup straight up in worldspace, and
// and
// r_spritedesc.vright parallel to the viewplane. // r_spritedesc.vright parallel to the viewplane.
// This will not work if the view direction is very close to straight // This will not work if the view direction is very close to straight
// up or // up or down, because the cross product will be between two nearly
// down, because the cross product will be between two nearly // parallel vectors and starts to approach an undefined state, so we
// parallel // don't draw if the two vectors are less than 1 degree apart
// vectors and starts to approach an undefined state, so we don't
// draw if
// the two vectors are less than 1 degree apart
dot = vpn[2]; // same as DotProduct (vpn, dot = vpn[2]; // same as DotProduct (vpn,
// r_spritedesc.vup) because // r_spritedesc.vup) because
// r_spritedesc.vup is 0, 0, 1 // r_spritedesc.vup is 0, 0, 1
@ -379,18 +354,16 @@ R_DrawSprite (void)
r_spritedesc.vpn[0] = -r_spritedesc.vright[1]; r_spritedesc.vpn[0] = -r_spritedesc.vright[1];
r_spritedesc.vpn[1] = r_spritedesc.vright[0]; r_spritedesc.vpn[1] = r_spritedesc.vright[0];
r_spritedesc.vpn[2] = 0; r_spritedesc.vpn[2] = 0;
// CrossProduct (r_spritedesc.vright, r_spritedesc.vup, // CrossProduct (r_spritedesc.vright, r_spritedesc.vup, r_spritedesc.vpn)
// r_spritedesc.vpn)
} else if (psprite->type == SPR_ORIENTED) { } else if (psprite->type == SPR_ORIENTED) {
// generate the sprite's axes, according to the sprite's world // generate the sprite's axes, according to the sprite's world
// orientation // orientation
AngleVectors (currententity->angles, r_spritedesc.vpn, AngleVectors (currententity->angles, r_spritedesc.vpn,
r_spritedesc.vright, r_spritedesc.vup); r_spritedesc.vright, r_spritedesc.vup);
} else if (psprite->type == SPR_VP_PARALLEL_ORIENTED) { } else if (psprite->type == SPR_VP_PARALLEL_ORIENTED) {
// generate the sprite's axes, parallel to the viewplane, but rotated // generate the sprite's axes, parallel to the viewplane, but rotated
// in // in that plane around the center according to the sprite entity's
// that plane around the center according to the sprite entity's roll // roll angle. So vpn stays the same, but vright and vup rotate
// angle. So vpn stays the same, but vright and vup rotate
angle = currententity->angles[ROLL] * (M_PI * 2 / 360); angle = currententity->angles[ROLL] * (M_PI * 2 / 360);
sr = sin (angle); sr = sin (angle);
cr = cos (angle); cr = cos (angle);

View file

@ -56,17 +56,12 @@ void R_DrawSurfaceBlock8_mip2 (void);
void R_DrawSurfaceBlock8_mip3 (void); void R_DrawSurfaceBlock8_mip3 (void);
static void (*surfmiptable[4]) (void) = { static void (*surfmiptable[4]) (void) = {
R_DrawSurfaceBlock8_mip0, R_DrawSurfaceBlock8_mip0, R_DrawSurfaceBlock8_mip1,
R_DrawSurfaceBlock8_mip1, R_DrawSurfaceBlock8_mip2, R_DrawSurfaceBlock8_mip3};
R_DrawSurfaceBlock8_mip2, R_DrawSurfaceBlock8_mip3};
unsigned int blocklights[18 * 18]; unsigned int blocklights[18 * 18];
/*
R_AddDynamicLights
*/
void void
R_AddDynamicLights (void) R_AddDynamicLights (void)
{ {
@ -128,6 +123,7 @@ R_AddDynamicLights (void)
} }
} }
/* /*
R_BuildLightMap R_BuildLightMap
@ -156,12 +152,11 @@ R_BuildLightMap (void)
blocklights[i] = 0; blocklights[i] = 0;
return; return;
} }
// clear to ambient // clear to ambient
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
blocklights[i] = r_refdef.ambientlight << 8; blocklights[i] = r_refdef.ambientlight << 8;
// add all the lightmaps
// add all the lightmaps
if (lightmap) if (lightmap)
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255; maps++) { for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255; maps++) {
scale = r_drawsurf.lightadj[maps]; // 8.8 fraction scale = r_drawsurf.lightadj[maps]; // 8.8 fraction
@ -169,11 +164,11 @@ R_BuildLightMap (void)
blocklights[i] += lightmap[i] * scale; blocklights[i] += lightmap[i] * scale;
lightmap += size; // skip to next lightmap lightmap += size; // skip to next lightmap
} }
// add all the dynamic lights // add all the dynamic lights
if (surf->dlightframe == r_framecount) if (surf->dlightframe == r_framecount)
R_AddDynamicLights (); R_AddDynamicLights ();
// bound, invert, and shift // bound, invert, and shift
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
t = (255 * 256 - (int) blocklights[i]) >> (8 - VID_CBITS); t = (255 * 256 - (int) blocklights[i]) >> (8 - VID_CBITS);
@ -190,7 +185,7 @@ R_BuildLightMap (void)
Returns the proper texture for a given time and base texture Returns the proper texture for a given time and base texture
*/ */
texture_t * texture_t *
R_TextureAnimation (texture_t *base) R_TextureAnimation (texture_t *base)
{ {
int reletive; int reletive;
@ -219,9 +214,6 @@ R_TextureAnimation (texture_t *base)
} }
/*
R_DrawSurface
*/
void void
R_DrawSurface (void) R_DrawSurface (void)
{ {
@ -234,7 +226,7 @@ R_DrawSurface (void)
void (*pblockdrawer) (void); void (*pblockdrawer) (void);
texture_t *mt; texture_t *mt;
// calculate the lightings // calculate the lightings
R_BuildLightMap (); R_BuildLightMap ();
surfrowbytes = r_drawsurf.rowbytes; surfrowbytes = r_drawsurf.rowbytes;
@ -243,8 +235,8 @@ R_DrawSurface (void)
r_source = (byte *) mt + mt->offsets[r_drawsurf.surfmip]; r_source = (byte *) mt + mt->offsets[r_drawsurf.surfmip];
// the fractional light values should range from 0 to (VID_GRADES - 1) << 16 // the fractional light values should range from 0 to
// from a source range of 0 - 255 // (VID_GRADES - 1) << 16 from a source range of 0 - 255
texwidth = mt->width >> r_drawsurf.surfmip; texwidth = mt->width >> r_drawsurf.surfmip;
@ -280,7 +272,7 @@ R_DrawSurface (void)
soffset = r_drawsurf.surf->texturemins[0]; soffset = r_drawsurf.surf->texturemins[0];
basetoffset = r_drawsurf.surf->texturemins[1]; basetoffset = r_drawsurf.surf->texturemins[1];
// << 16 components are to guarantee positive values for % // << 16 components are to guarantee positive values for %
soffset = ((soffset >> r_drawsurf.surfmip) + (smax << 16)) % smax; soffset = ((soffset >> r_drawsurf.surfmip) + (smax << 16)) % smax;
basetptr = &r_source[((((basetoffset >> r_drawsurf.surfmip) basetptr = &r_source[((((basetoffset >> r_drawsurf.surfmip)
+ (tmax << 16)) % tmax) * twidth)]; + (tmax << 16)) % tmax) * twidth)];
@ -305,13 +297,8 @@ R_DrawSurface (void)
} }
//=============================================================================
#ifndef USE_INTEL_ASM #ifndef USE_INTEL_ASM
/*
R_DrawSurfaceBlock8_mip0
*/
void void
R_DrawSurfaceBlock8_mip0 (void) R_DrawSurfaceBlock8_mip0 (void)
{ {
@ -322,8 +309,8 @@ R_DrawSurfaceBlock8_mip0 (void)
prowdest = prowdestbase; prowdest = prowdestbase;
for (v = 0; v < r_numvblocks; v++) { for (v = 0; v < r_numvblocks; v++) {
// FIXME: make these locals? // FIXME: make these locals?
// FIXME: use delta rather than both right and left, like ASM? // FIXME: use delta rather than both right and left, like ASM?
lightleft = r_lightptr[0]; lightleft = r_lightptr[0];
lightright = r_lightptr[1]; lightright = r_lightptr[1];
r_lightptr += r_lightwidth; r_lightptr += r_lightwidth;
@ -355,9 +342,6 @@ R_DrawSurfaceBlock8_mip0 (void)
} }
/*
R_DrawSurfaceBlock8_mip1
*/
void void
R_DrawSurfaceBlock8_mip1 (void) R_DrawSurfaceBlock8_mip1 (void)
{ {
@ -368,8 +352,8 @@ R_DrawSurfaceBlock8_mip1 (void)
prowdest = prowdestbase; prowdest = prowdestbase;
for (v = 0; v < r_numvblocks; v++) { for (v = 0; v < r_numvblocks; v++) {
// FIXME: make these locals? ./ FIXME: make these locals?
// FIXME: use delta rather than both right and left, like ASM? // FIXME: use delta rather than both right and left, like ASM?
lightleft = r_lightptr[0]; lightleft = r_lightptr[0];
lightright = r_lightptr[1]; lightright = r_lightptr[1];
r_lightptr += r_lightwidth; r_lightptr += r_lightwidth;
@ -401,9 +385,6 @@ R_DrawSurfaceBlock8_mip1 (void)
} }
/*
R_DrawSurfaceBlock8_mip2
*/
void void
R_DrawSurfaceBlock8_mip2 (void) R_DrawSurfaceBlock8_mip2 (void)
{ {
@ -414,8 +395,8 @@ R_DrawSurfaceBlock8_mip2 (void)
prowdest = prowdestbase; prowdest = prowdestbase;
for (v = 0; v < r_numvblocks; v++) { for (v = 0; v < r_numvblocks; v++) {
// FIXME: make these locals? // FIXME: make these locals?
// FIXME: use delta rather than both right and left, like ASM? // FIXME: use delta rather than both right and left, like ASM?
lightleft = r_lightptr[0]; lightleft = r_lightptr[0];
lightright = r_lightptr[1]; lightright = r_lightptr[1];
r_lightptr += r_lightwidth; r_lightptr += r_lightwidth;
@ -447,9 +428,6 @@ R_DrawSurfaceBlock8_mip2 (void)
} }
/*
R_DrawSurfaceBlock8_mip3
*/
void void
R_DrawSurfaceBlock8_mip3 (void) R_DrawSurfaceBlock8_mip3 (void)
{ {
@ -460,8 +438,8 @@ R_DrawSurfaceBlock8_mip3 (void)
prowdest = prowdestbase; prowdest = prowdestbase;
for (v = 0; v < r_numvblocks; v++) { for (v = 0; v < r_numvblocks; v++) {
// FIXME: make these locals? // FIXME: make these locals?
// FIXME: use delta rather than both right and left, like ASM? // FIXME: use delta rather than both right and left, like ASM?
lightleft = r_lightptr[0]; lightleft = r_lightptr[0];
lightright = r_lightptr[1]; lightright = r_lightptr[1];
r_lightptr += r_lightwidth; r_lightptr += r_lightwidth;
@ -540,11 +518,6 @@ R_DrawSurfaceBlock16 (void)
#endif #endif
//============================================================================
/*
R_GenTurbTile
*/
void void
R_GenTurbTile (pixel_t *pbasetex, void *pdest) R_GenTurbTile (pixel_t *pbasetex, void *pdest)
{ {
@ -565,9 +538,6 @@ R_GenTurbTile (pixel_t *pbasetex, void *pdest)
} }
/*
R_GenTurbTile16
*/
void void
R_GenTurbTile16 (pixel_t *pbasetex, void *pdest) R_GenTurbTile16 (pixel_t *pbasetex, void *pdest)
{ {
@ -588,9 +558,6 @@ R_GenTurbTile16 (pixel_t *pbasetex, void *pdest)
} }
/*
R_GenTile
*/
void void
R_GenTile (msurface_t *psurf, void *pdest) R_GenTile (msurface_t *psurf, void *pdest)
{ {
@ -617,6 +584,7 @@ R_GenTile (msurface_t *psurf, void *pdest)
} }
} }
void void
R_ForceLightUpdate (void) R_ForceLightUpdate (void)
{ {

View file

@ -35,9 +35,7 @@
// all global and static refresh variables are collected in a contiguous block // all global and static refresh variables are collected in a contiguous block
// to avoid cache conflicts. // to avoid cache conflicts.
//------------------------------------------------------- // global refresh variables -----------------------------
// global refresh variables
//-------------------------------------------------------
// FIXME: make into one big structure, like cl or sv // FIXME: make into one big structure, like cl or sv
// FIXME: do separately for refresh engine and driver // FIXME: do separately for refresh engine and driver

View file

@ -1,5 +1,5 @@
/* /*
cl_trans.c sw_skin.c
(description) (description)
@ -41,6 +41,7 @@
#include "render.h" #include "render.h"
void void
Skin_Set_Translate (int top, int bottom, byte *dest) Skin_Set_Translate (int top, int bottom, byte *dest)
{ {
@ -69,16 +70,19 @@ Skin_Set_Translate (int top, int bottom, byte *dest)
} }
} }
void void
Skin_Do_Translation (skin_t *player_skin, int slot) Skin_Do_Translation (skin_t *player_skin, int slot)
{ {
} }
void void
Skin_Init_Translation (void) Skin_Init_Translation (void)
{ {
} }
void void
Skin_Process (skin_t *skin, struct tex_s *tex) Skin_Process (skin_t *skin, struct tex_s *tex)
{ {