Merge R_MarkLeaves from gl, sw, and sw32.

Other than novis, they're functionally identical. Now sw and sw32 have
novis as well.
This commit is contained in:
Bill Currie 2012-01-03 21:04:27 +09:00
parent 091b714e4c
commit 0797183201
6 changed files with 92 additions and 134 deletions

View file

@ -10,8 +10,8 @@ EXTRA_LTLIBRARIES= libQFrenderer_sw.la libQFrenderer_sw32.la \
libQFrenderer_gl.la libQFrenderer_glsl.la
common_sources= \
crosshair.c r_alias.c r_cvar.c r_efrag.c r_ent.c r_graph.c r_light.c \
r_main.c r_part.c r_progs.c r_screen.c
crosshair.c r_alias.c r_bsp.c r_cvar.c r_efrag.c r_ent.c r_graph.c \
r_light.c r_main.c r_part.c r_progs.c r_screen.c
libQFrenderer_gl_la_LDFLAGS= -version-info $(QUAKE_LIBRARY_VERSION_INFO) -rpath $(libdir)
libQFrenderer_gl_la_LIBADD= gl/libgl.la

View file

@ -97,8 +97,6 @@ float r_base_world_matrix[16];
// screen size info
VISIBLE refdef_t r_refdef;
mleaf_t *r_viewleaf, *r_oldviewleaf;
int d_lightstylevalue[256]; // 8.8 fraction of base light value
vec3_t shadecolor; // Ender (Extend) Colormod

View file

@ -836,50 +836,6 @@ R_DrawWorld (void)
clear_texture_chains ();
}
void
R_MarkLeaves (void)
{
byte solid[4096];
byte *vis;
int c;
unsigned int i;
mleaf_t *leaf;
mnode_t *node;
msurface_t **mark;
if (r_oldviewleaf == r_viewleaf && !r_novis->int_val)
return;
r_visframecount++;
r_oldviewleaf = r_viewleaf;
if (r_novis->int_val) {
vis = solid;
memset (solid, 0xff, (r_worldentity.model->numleafs + 7) >> 3);
} else
vis = Mod_LeafPVS (r_viewleaf, r_worldentity.model);
for (i = 0; (int) i < r_worldentity.model->numleafs; i++) {
if (vis[i >> 3] & (1 << (i & 7))) {
leaf = &r_worldentity.model->leafs[i + 1];
if ((c = leaf->nummarksurfaces)) {
mark = leaf->firstmarksurface;
do {
(*mark)->visframe = r_visframecount;
mark++;
} while (--c);
}
node = (mnode_t *) leaf;
do {
if (node->visframe == r_visframecount)
break;
node->visframe = r_visframecount;
node = node->parent;
} while (node);
}
}
}
int nColinElim;
model_t *currentmodel;
mvertex_t *r_pcurrentvertbase;

View file

@ -0,0 +1,90 @@
/*
r_bsp.c
Common bsp rendering.
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
static __attribute__ ((used)) const char rcsid[] = "$Id$";
#ifdef HAVE_STRING_H
# include "string.h"
#endif
#ifdef HAVE_STRINGS_H
# include "strings.h"
#endif
#include "QF/cvar.h"
#include "r_cvar.h"
#include "r_local.h"
#include "r_shared.h"
mleaf_t *r_viewleaf, *r_oldviewleaf;
void
R_MarkLeaves (void)
{
byte solid[8192];
byte *vis;
int c;
unsigned int i;
mleaf_t *leaf;
mnode_t *node;
msurface_t **mark;
if (r_oldviewleaf == r_viewleaf && !r_novis->int_val)
return;
r_visframecount++;
r_oldviewleaf = r_viewleaf;
if (r_novis->int_val) {
vis = solid;
memset (solid, 0xff, (r_worldentity.model->numleafs + 7) >> 3);
} else
vis = Mod_LeafPVS (r_viewleaf, r_worldentity.model);
for (i = 0; (int) i < r_worldentity.model->numleafs; i++) {
if (vis[i >> 3] & (1 << (i & 7))) {
leaf = &r_worldentity.model->leafs[i + 1];
if ((c = leaf->nummarksurfaces)) {
mark = leaf->firstmarksurface;
do {
(*mark)->visframe = r_visframecount;
mark++;
} while (--c);
}
node = (mnode_t *) leaf;
do {
if (node->visframe == r_visframecount)
break;
node->visframe = r_visframecount;
node = node->parent;
} while (node);
}
}
}

View file

@ -133,8 +133,6 @@ int reinit_surfcache = 1; // if 1, surface cache is currently empty
// and must be reinitialized for current
// cache size
mleaf_t *r_viewleaf, *r_oldviewleaf;
float r_aliastransition, r_resfudge;
int d_lightstylevalue[256]; // 8.8 fraction of base light value
@ -367,47 +365,6 @@ R_ViewChanged (float aspect)
D_ViewChanged ();
}
void
R_MarkLeaves (void)
{
byte *vis;
mnode_t *node;
mleaf_t *leaf;
msurface_t **mark;
int c;
int i;
if (r_oldviewleaf == r_viewleaf)
return;
r_visframecount++;
r_oldviewleaf = r_viewleaf;
vis = Mod_LeafPVS (r_viewleaf, r_worldentity.model);
for (i = 0; i < r_worldentity.model->numleafs; i++) {
if (vis[i >> 3] & (1 << (i & 7))) {
leaf = &r_worldentity.model->leafs[i + 1];
mark = leaf->firstmarksurface;
c = leaf->nummarksurfaces;
if (c) {
do {
(*mark)->visframe = r_visframecount;
mark++;
} while (--c);
}
node = (mnode_t *) leaf;
do {
if (node->visframe == r_visframecount)
break;
node->visframe = r_visframecount;
node = node->parent;
} while (node);
}
}
}
static void
R_DrawEntitiesOnList (void)
{

View file

@ -127,8 +127,6 @@ int reinit_surfcache = 1; // if 1, surface cache is currently empty
// and must be reinitialized for current
// cache size
mleaf_t *r_viewleaf, *r_oldviewleaf;
float r_aliastransition, r_resfudge;
int d_lightstylevalue[256]; // 8.8 fraction of base light value
@ -387,47 +385,6 @@ R_ViewChanged (float aspect)
D_ViewChanged ();
}
void
R_MarkLeaves (void)
{
byte *vis;
mnode_t *node;
mleaf_t *leaf;
msurface_t **mark;
int c;
int i;
if (r_oldviewleaf == r_viewleaf)
return;
r_visframecount++;
r_oldviewleaf = r_viewleaf;
vis = Mod_LeafPVS (r_viewleaf, r_worldentity.model);
for (i = 0; i < r_worldentity.model->numleafs; i++) {
if (vis[i >> 3] & (1 << (i & 7))) {
leaf = &r_worldentity.model->leafs[i + 1];
mark = leaf->firstmarksurface;
c = leaf->nummarksurfaces;
if (c) {
do {
(*mark)->visframe = r_visframecount;
mark++;
} while (--c);
}
node = (mnode_t *) leaf;
do {
if (node->visframe == r_visframecount)
break;
node->visframe = r_visframecount;
node = node->parent;
} while (node);
}
}
}
static void
R_DrawEntitiesOnList (void)
{