common: create a struct for instanced bsp data
I'd like to be able to control visibility of the global bsp data as well as having the ability to load two bsp files and do comparisons, etc. Set up a structure to hold all the bsp data and a couple of helper functions to enable a smooth transition for the utils. Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
parent
0258b441c1
commit
89074e10e9
|
|
@ -68,6 +68,105 @@ unsigned short *dmarksurfaces;
|
||||||
int numsurfedges;
|
int numsurfedges;
|
||||||
int *dsurfedges;
|
int *dsurfedges;
|
||||||
|
|
||||||
|
/* Transitional helper functions */
|
||||||
|
void
|
||||||
|
GetBSPGlobals(bspdata_t *bspdata)
|
||||||
|
{
|
||||||
|
bspdata->nummodels = nummodels;
|
||||||
|
bspdata->dmodels = dmodels;
|
||||||
|
|
||||||
|
bspdata->visdatasize = visdatasize;
|
||||||
|
bspdata->dvisdata = dvisdata;
|
||||||
|
|
||||||
|
bspdata->lightdatasize = lightdatasize;
|
||||||
|
bspdata->dlightdata = dlightdata;
|
||||||
|
|
||||||
|
bspdata->texdatasize = texdatasize;
|
||||||
|
bspdata->dtexdata = dtexdata;
|
||||||
|
|
||||||
|
bspdata->entdatasize = entdatasize;
|
||||||
|
bspdata->dentdata = dentdata;
|
||||||
|
|
||||||
|
bspdata->numleafs = numleafs;
|
||||||
|
bspdata->dleafs = dleafs;
|
||||||
|
|
||||||
|
bspdata->numplanes = numplanes;
|
||||||
|
bspdata->dplanes = dplanes;
|
||||||
|
|
||||||
|
bspdata->numvertexes = numvertexes;
|
||||||
|
bspdata->dvertexes = dvertexes;
|
||||||
|
|
||||||
|
bspdata->numnodes = numnodes;
|
||||||
|
bspdata->dnodes = dnodes;
|
||||||
|
|
||||||
|
bspdata->numtexinfo = numtexinfo;
|
||||||
|
bspdata->texinfo = texinfo;
|
||||||
|
|
||||||
|
bspdata->numfaces = numfaces;
|
||||||
|
bspdata->dfaces = dfaces;
|
||||||
|
|
||||||
|
bspdata->numclipnodes = numclipnodes;
|
||||||
|
bspdata->dclipnodes = dclipnodes;
|
||||||
|
|
||||||
|
bspdata->numedges = numedges;
|
||||||
|
bspdata->dedges = dedges;
|
||||||
|
|
||||||
|
bspdata->nummarksurfaces = nummarksurfaces;
|
||||||
|
bspdata->dmarksurfaces = dmarksurfaces;
|
||||||
|
|
||||||
|
bspdata->numsurfedges = numsurfedges;
|
||||||
|
bspdata->dsurfedges = dsurfedges;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SetBSPGlobals(const bspdata_t *bspdata)
|
||||||
|
{
|
||||||
|
nummodels = bspdata->nummodels;
|
||||||
|
dmodels = bspdata->dmodels;
|
||||||
|
|
||||||
|
visdatasize = bspdata->visdatasize;
|
||||||
|
dvisdata = bspdata->dvisdata;
|
||||||
|
|
||||||
|
lightdatasize = bspdata->lightdatasize;
|
||||||
|
dlightdata = bspdata->dlightdata;
|
||||||
|
|
||||||
|
texdatasize = bspdata->texdatasize;
|
||||||
|
dtexdata = bspdata->dtexdata;
|
||||||
|
|
||||||
|
entdatasize = bspdata->entdatasize;
|
||||||
|
dentdata = bspdata->dentdata;
|
||||||
|
|
||||||
|
numleafs = bspdata->numleafs;
|
||||||
|
dleafs = bspdata->dleafs;
|
||||||
|
|
||||||
|
numplanes = bspdata->numplanes;
|
||||||
|
dplanes = bspdata->dplanes;
|
||||||
|
|
||||||
|
numvertexes = bspdata->numvertexes;
|
||||||
|
dvertexes = bspdata->dvertexes;
|
||||||
|
|
||||||
|
numnodes = bspdata->numnodes;
|
||||||
|
dnodes = bspdata->dnodes;
|
||||||
|
|
||||||
|
numtexinfo = bspdata->numtexinfo;
|
||||||
|
texinfo = bspdata->texinfo;
|
||||||
|
|
||||||
|
numfaces = bspdata->numfaces;
|
||||||
|
dfaces = bspdata->dfaces;
|
||||||
|
|
||||||
|
numclipnodes = bspdata->numclipnodes;
|
||||||
|
dclipnodes = bspdata->dclipnodes;
|
||||||
|
|
||||||
|
numedges = bspdata->numedges;
|
||||||
|
dedges = bspdata->dedges;
|
||||||
|
|
||||||
|
nummarksurfaces = bspdata->nummarksurfaces;
|
||||||
|
dmarksurfaces = bspdata->dmarksurfaces;
|
||||||
|
|
||||||
|
numsurfedges = bspdata->numsurfedges;
|
||||||
|
dsurfedges = bspdata->dsurfedges;
|
||||||
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
|
|
||||||
typedef enum { TO_DISK, TO_CPU } swaptype_t;
|
typedef enum { TO_DISK, TO_CPU } swaptype_t;
|
||||||
|
|
|
||||||
|
|
@ -205,8 +205,6 @@ typedef struct {
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
|
|
||||||
/* the utilities get to be lazy and just use large static arrays */
|
|
||||||
|
|
||||||
extern int nummodels;
|
extern int nummodels;
|
||||||
extern dmodel_t *dmodels;
|
extern dmodel_t *dmodels;
|
||||||
|
|
||||||
|
|
@ -252,6 +250,57 @@ extern unsigned short *dmarksurfaces;
|
||||||
extern int numsurfedges;
|
extern int numsurfedges;
|
||||||
extern int *dsurfedges;
|
extern int *dsurfedges;
|
||||||
|
|
||||||
|
/* TODO - Transition utils over to using an instanced struct for bsp data */
|
||||||
|
typedef struct {
|
||||||
|
int nummodels;
|
||||||
|
dmodel_t *dmodels;
|
||||||
|
|
||||||
|
int visdatasize;
|
||||||
|
byte *dvisdata;
|
||||||
|
|
||||||
|
int lightdatasize;
|
||||||
|
byte *dlightdata;
|
||||||
|
|
||||||
|
int texdatasize;
|
||||||
|
byte *dtexdata; /* (dmiptexlump_t) */
|
||||||
|
|
||||||
|
int entdatasize;
|
||||||
|
char *dentdata;
|
||||||
|
|
||||||
|
int numleafs;
|
||||||
|
dleaf_t *dleafs;
|
||||||
|
|
||||||
|
int numplanes;
|
||||||
|
dplane_t *dplanes;
|
||||||
|
|
||||||
|
int numvertexes;
|
||||||
|
dvertex_t *dvertexes;
|
||||||
|
|
||||||
|
int numnodes;
|
||||||
|
dnode_t *dnodes;
|
||||||
|
|
||||||
|
int numtexinfo;
|
||||||
|
texinfo_t *texinfo;
|
||||||
|
|
||||||
|
int numfaces;
|
||||||
|
dface_t *dfaces;
|
||||||
|
|
||||||
|
int numclipnodes;
|
||||||
|
dclipnode_t *dclipnodes;
|
||||||
|
|
||||||
|
int numedges;
|
||||||
|
dedge_t *dedges;
|
||||||
|
|
||||||
|
int nummarksurfaces;
|
||||||
|
unsigned short *dmarksurfaces;
|
||||||
|
|
||||||
|
int numsurfedges;
|
||||||
|
int *dsurfedges;
|
||||||
|
} bspdata_t;
|
||||||
|
|
||||||
|
/* Transitional helper functions */
|
||||||
|
void GetBSPGlobals(bspdata_t *bspdata);
|
||||||
|
void SetBSPGlobals(const bspdata_t *bspdata);
|
||||||
|
|
||||||
/* LoadBSPFile returns the BSP version... */
|
/* LoadBSPFile returns the BSP version... */
|
||||||
int LoadBSPFile(const char *filename);
|
int LoadBSPFile(const char *filename);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue