Skip to content

Commit

Permalink
More software renderer code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
skullernet committed Mar 20, 2013
1 parent 30f75a5 commit f538327
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 231 deletions.
2 changes: 0 additions & 2 deletions inc/refresh/refresh.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ typedef struct entity_s {
int skinnum; // also used as RF_BEAM's palette index,
// -1 => use rgba

int lightstyle; // for flashing entities
float alpha; // ignore if RF_TRANSLUCENT isn't set

color_t rgba;

qhandle_t skin; // NULL for inline skin
Expand Down
8 changes: 2 additions & 6 deletions src/refresh/sw/aclip.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#include "sw.h"

static finalvert_t fv[2][8];

void R_AliasProjectAndClipTestFinalVert(finalvert_t *fv);


/*
================
R_Alias_clip_z
Expand Down Expand Up @@ -153,7 +148,7 @@ static void R_Alias_clip_bottom(finalvert_t *pfv0, finalvert_t *pfv1,
}

static int R_AliasClip(finalvert_t *in, finalvert_t *out, int flag, int count,
void(*clip)(finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out))
void (*clip)(finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out))
{
int i, j, k;
int flags, oldflags;
Expand Down Expand Up @@ -196,6 +191,7 @@ R_AliasClipTriangle
*/
void R_AliasClipTriangle(finalvert_t *index0, finalvert_t *index1, finalvert_t *index2)
{
finalvert_t fv[2][8];
int i, k, pingpong;
unsigned clipflags;

Expand Down
9 changes: 4 additions & 5 deletions src/refresh/sw/alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ static void R_AliasTransformFinalVerts(int numpoints, finalvert_t *fv, maliasver

plightnormal = bytedirs[newv->lightnormalindex];

// PMM - added double damage shell
if (currententity->flags & (RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM)) {
if (currententity->flags & RF_SHELL_MASK) {
lerped_vert[0] += plightnormal[0] * POWERSUIT_SCALE;
lerped_vert[1] += plightnormal[1] * POWERSUIT_SCALE;
lerped_vert[2] += plightnormal[2] * POWERSUIT_SCALE;
Expand Down Expand Up @@ -443,9 +442,9 @@ static qboolean R_AliasSetupSkin(void)
int skinnum;
image_t *pskindesc;

if (currententity->skin)
if (currententity->skin) {
pskindesc = IMG_ForHandle(currententity->skin);
else {
} else {
skinnum = currententity->skinnum;
if ((skinnum >= currentmodel->numskins) || (skinnum < 0)) {
Com_DPrintf("R_AliasSetupSkin %s: no such skin # %d\n",
Expand Down Expand Up @@ -607,7 +606,7 @@ static void R_AliasSetupBlend(void)
/*
** select the proper span routine based on translucency
*/
mask = currententity->flags & (RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM);
mask = currententity->flags & RF_SHELL_MASK;
if (mask) {
if (mask == RF_SHELL_RED)
color.u32 = d_8to24table[SHELL_RED_COLOR];
Expand Down
2 changes: 1 addition & 1 deletion src/refresh/sw/bsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ void R_DrawSolidClippedSubmodelPolygons(mmodel_t *pmodel, mnode_t *topnode)

pbedge[j - 1].pnext = NULL; // mark end of edges

if (!(psurf->texinfo->c.flags & (SURF_TRANS66 | SURF_TRANS33)))
if (!(psurf->texinfo->c.flags & SURF_TRANS_MASK))
R_RecursiveClipBPoly(pbedge, topnode, psurf);
else
R_RenderBmodelFace(pbedge, psurf);
Expand Down
16 changes: 8 additions & 8 deletions src/refresh/sw/edge.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void R_BeginEdgeFrame(void)
edge_max = &r_edges[r_numallocatededges];

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].flags = DSURF_BACKGROUND;

Expand Down Expand Up @@ -660,7 +660,6 @@ SURFACE FILLING

static vec3_t transformed_modelorg;
static vec3_t world_transformed_modelorg;
static vec3_t local_modelorg;

/*
=============
Expand Down Expand Up @@ -806,12 +805,13 @@ static void D_TurbulentSurf(surf_t *s)
cachewidth = TURB_SIZE * TEX_BYTES;

if (s->insubmodel) {
vec3_t local_modelorg;

// FIXME: we don't want to do all this for every polygon!
// TODO: store once at start of frame
currententity = s->entity; // FIXME: make this passed in to
// R_RotateBmodel ()
VectorSubtract(r_origin, currententity->origin,
local_modelorg);
VectorSubtract(r_origin, currententity->origin, local_modelorg);
R_TransformVector(local_modelorg, transformed_modelorg);

R_RotateBmodel(); // FIXME: don't mess with the frustum,
Expand All @@ -835,8 +835,7 @@ static void D_TurbulentSurf(surf_t *s)
// TODO: speed up
//
currententity = NULL; // &r_worldentity;
VectorCopy(world_transformed_modelorg,
transformed_modelorg);
VectorCopy(world_transformed_modelorg, transformed_modelorg);
VectorCopy(base_vpn, vpn);
VectorCopy(base_vup, vup);
VectorCopy(base_vright, vright);
Expand Down Expand Up @@ -897,6 +896,8 @@ static void D_SolidSurf(surf_t *s)
d_ziorigin = s->d_ziorigin;

if (s->insubmodel) {
vec3_t local_modelorg;

// FIXME: we don't want to do all this for every polygon!
// TODO: store once at start of frame
currententity = s->entity; // FIXME: make this passed in to
Expand Down Expand Up @@ -932,8 +933,7 @@ static void D_SolidSurf(surf_t *s)
// FIXME: we don't want to do this every time!
// TODO: speed up
//
VectorCopy(world_transformed_modelorg,
transformed_modelorg);
VectorCopy(world_transformed_modelorg, transformed_modelorg);
VectorCopy(base_vpn, vpn);
VectorCopy(base_vup, vup);
VectorCopy(base_vright, vright);
Expand Down
36 changes: 8 additions & 28 deletions src/refresh/sw/light.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static void R_MarkLights(dlight_t *light, int bit, mnode_t *node)
{
cplane_t *splitplane;
float dist;
mface_t *surf;
mface_t *surf;
int i;

if (!node->plane)
Expand All @@ -48,19 +48,15 @@ static void R_MarkLights(dlight_t *light, int bit, mnode_t *node)
splitplane = node->plane;
dist = DotProduct(light->origin, splitplane->normal) - splitplane->dist;

//=====
//PGM
i = light->intensity;
if (i < 0)
i = -i;
//PGM
//=====

if (dist > i) { // PGM (dist > light->intensity)
if (dist > i) {
R_MarkLights(light, bit, node->children[0]);
return;
}
if (dist < -i) { // PGM (dist < -light->intensity)
if (dist < -i) {
R_MarkLights(light, bit, node->children[1]);
return;
}
Expand Down Expand Up @@ -208,7 +204,7 @@ static void R_AddDynamicLights(void)
int smax, tmax;
mtexinfo_t *tex;
dlight_t *dl;
int negativeLight; //PGM
int negativeLight;
blocklight_t *block;

surf = r_drawsurf.surf;
Expand Down Expand Up @@ -295,15 +291,13 @@ R_BuildLightMap
Combine and scale multiple lightmaps into the 8.8 format in blocklights
===============
*/

void R_BuildLightMap(void)
{
int smax, tmax;
blocklight_t t;
int i, size;
byte *lightmap;
int maps;
mface_t *surf;
mface_t *surf;
blocklight_t *dst;

surf = r_drawsurf.surf;
Expand Down Expand Up @@ -345,22 +339,8 @@ void R_BuildLightMap(void)
if (surf->dlightframe == r_framecount)
R_AddDynamicLights();

// bound, invert, and shift
for (i = 0; i < size * LIGHTMAP_BYTES; i++) {
t = blocklights[i];
#if 0
if (t < 0)
t = 0;
t = (255 * 256 - t) >> (8 - VID_CBITS);

if (t < (1 << 6))
t = (1 << 6);
#else
clamp(t, 255, 65535);
#endif

blocklights[i] = t;
}

// bound
for (i = 0; i < size * LIGHTMAP_BYTES; i++)
clamp(blocklights[i], 255, 65535);
}

Loading

0 comments on commit f538327

Please sign in to comment.