`merge' gl_refrag.c and sw_refrag.c into r_efrag.c like what was done in qw

This commit is contained in:
Bill Currie 2001-05-11 06:09:01 +00:00
parent 44317f299e
commit 8ce3fa5e8f
3 changed files with 3 additions and 233 deletions

View file

@ -71,7 +71,7 @@ client_LIB_DEPS= libqfnet.a
client_POST_LIBS= $(top_builddir)/libs/video/targets/libQFjs.la
client_SOURCES= cl_cam.c cl_cmd.c cl_demo.c cl_input.c cl_main.c cl_parse.c \
cl_tent.c console.c keys.c sbar.c r_part.c r_view.c \
cl_tent.c console.c keys.c sbar.c r_efrag.c r_part.c r_view.c \
nonintel.c gib.c gib_instructions.c gib_vars.c \
gib_interpret.c gib_modules.c gib_parse.c gib_stack.c \
pcx.c tga.c
@ -87,7 +87,7 @@ combined_SOURCES= $(common_SOURCES) $(client_SOURCES) $(server_SOURCES) \
# ... Common stuff
soft_SOURCES= d_edge.c d_fill.c d_init.c d_modech.c d_part.c d_polyse.c \
d_scan.c d_sky.c d_sprite.c d_surf.c d_vars.c d_zpoint.c \
draw.c sw_raclip.c sw_ralias.c sw_rbsp.c sw_rdraw.c sw_redge.c sw_refrag.c \
draw.c sw_raclip.c sw_ralias.c sw_rbsp.c sw_rdraw.c sw_redge.c \
sw_rlight.c sw_rmain.c sw_rmisc.c sw_rpart.c sw_rsky.c sw_rsprite.c \
sw_rsurf.c sw_rvars.c screen.c \
sw_view.c $(soft_ASM)
@ -122,7 +122,7 @@ nq_x11_DEPENDENCIES=$(client_LIB_DEPS)
# ... Common stuff
ogl_SOURCES= noisetextures.c gl_textures.c gl_draw.c gl_dyn_fires.c \
gl_dyn_part.c gl_dyn_textures.c \
gl_refrag.c gl_rlight.c gl_rmain.c gl_rmisc.c gl_rsurf.c \
gl_rlight.c gl_rmain.c gl_rmisc.c gl_rsurf.c \
gl_screen.c gl_sky.c gl_view.c gl_warp.c
# ... 3Dfx Voodoo 1 and 2 SVGAlib-based console GL

View file

@ -1,230 +0,0 @@
/*
gl_refrag.c
@description@
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
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "QF/model.h"
#include "QF/sys.h"
#include "QF/console.h"
#include "client.h"
// #include "d_iface.h"
#include "glquake.h"
#include "render.h"
#include "r_local.h"
mnode_t *r_pefragtopnode;
//===========================================================================
/*
===============================================================================
ENTITY FRAGMENT FUNCTIONS
===============================================================================
*/
efrag_t **lastlink;
vec3_t r_emins, r_emaxs;
entity_t *r_addent;
/*
================
R_RemoveEfrags
Call when removing an object from the world or moving it to another position
================
*/
void
R_RemoveEfrags (entity_t *ent)
{
efrag_t *ef, *old, *walk, **prev;
ef = ent->efrag;
while (ef) {
prev = &ef->leaf->efrags;
while (1) {
walk = *prev;
if (!walk)
break;
if (walk == ef) { // remove this fragment
*prev = ef->leafnext;
break;
} else
prev = &walk->leafnext;
}
old = ef;
ef = ef->entnext;
// put it on the free list
old->entnext = cl.free_efrags;
cl.free_efrags = old;
}
ent->efrag = NULL;
}
void
R_SplitEntityOnNode (mnode_t *node)
{
efrag_t *ef;
mplane_t *splitplane;
mleaf_t *leaf;
int sides;
if (node->contents == CONTENTS_SOLID) {
return;
}
// add an efrag if the node is a leaf
if (node->contents < 0) {
if (!r_pefragtopnode)
r_pefragtopnode = node;
leaf = (mleaf_t *) node;
// grab an efrag off the free list
ef = cl.free_efrags;
if (!ef) {
Con_Printf ("Too many efrags!\n");
return; // no free fragments...
}
cl.free_efrags = cl.free_efrags->entnext;
ef->entity = r_addent;
// add the entity link
*lastlink = ef;
lastlink = &ef->entnext;
ef->entnext = NULL;
// set the leaf links
ef->leaf = leaf;
ef->leafnext = leaf->efrags;
leaf->efrags = ef;
return;
}
// NODE_MIXED
splitplane = node->plane;
sides = BOX_ON_PLANE_SIDE (r_emins, r_emaxs, splitplane);
if (sides == 3) {
// split on this plane
// if this is the first splitter of this bmodel, remember it
if (!r_pefragtopnode)
r_pefragtopnode = node;
}
// recurse down the contacted sides
if (sides & 1)
R_SplitEntityOnNode (node->children[0]);
if (sides & 2)
R_SplitEntityOnNode (node->children[1]);
}
void
R_AddEfrags (entity_t *ent)
{
model_t *entmodel;
int i;
if (!ent->model)
return;
r_addent = ent;
lastlink = &ent->efrag;
r_pefragtopnode = NULL;
entmodel = ent->model;
for (i = 0; i < 3; i++) {
r_emins[i] = ent->origin[i] + entmodel->mins[i];
r_emaxs[i] = ent->origin[i] + entmodel->maxs[i];
}
R_SplitEntityOnNode (cl.worldmodel->nodes);
ent->topnode = r_pefragtopnode;
}
/*
================
R_StoreEfrags
// FIXME: a lot of this goes away with edge-based
================
*/
void
R_StoreEfrags (efrag_t **ppefrag)
{
entity_t *pent;
model_t *clmodel;
efrag_t *pefrag;
while ((pefrag = *ppefrag) != NULL) {
pent = pefrag->entity;
clmodel = pent->model;
switch (clmodel->type) {
case mod_alias:
case mod_brush:
case mod_sprite:
pent = pefrag->entity;
if ((pent->visframe != r_framecount) &&
(cl_numvisedicts < MAX_VISEDICTS)) {
cl_visedicts[cl_numvisedicts++] = pent;
// mark that we've recorded this entity for this frame
pent->visframe = r_framecount;
}
ppefrag = &pefrag->leafnext;
break;
default:
Sys_Error ("R_StoreEfrags: Bad entity type %d\n", clmodel->type);
}
}
}