From: havoc Date: Fri, 23 May 2003 06:58:34 +0000 (+0000) Subject: more preparation for quake2 bsp support X-Git-Tag: xonotic-v0.1.0preview~6633 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f1ad1e170799ce0b162b1738628006516a36d902;p=xonotic%2Fdarkplaces.git more preparation for quake2 bsp support git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3017 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/bspfile.h b/bspfile.h index f1e27880..acae753f 100644 --- a/bspfile.h +++ b/bspfile.h @@ -8,7 +8,7 @@ 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. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -19,31 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// upper design bounds - #define MAX_MAP_HULLS 4 - -#define MAX_MAP_MODELS 256 -#define MAX_MAP_BRUSHES 4096 -#define MAX_MAP_ENTITIES 1024 -#define MAX_MAP_ENTSTRING 65536 - -#define MAX_MAP_PLANES 32767 -#define MAX_MAP_NODES 32767 // because negative shorts are contents -#define MAX_MAP_CLIPNODES 32767 // -#define MAX_MAP_LEAFS 32767 // was 8192 -#define MAX_MAP_VERTS 65535 -#define MAX_MAP_FACES 65535 -#define MAX_MAP_MARKSURFACES 65535 -#define MAX_MAP_TEXINFO 4096 -#define MAX_MAP_EDGES 256000 -#define MAX_MAP_SURFEDGES 512000 -#define MAX_MAP_TEXTURES 512 -#define MAX_MAP_MIPTEX 0x200000 -#define MAX_MAP_LIGHTING 0x100000 -#define MAX_MAP_VISIBILITY 0x100000 - -#define MAX_MAP_PORTALS 65536 +#define MAX_MAP_LEAFS 65536 // was 8192 // key / value pair sizes @@ -76,7 +53,6 @@ typedef struct #define LUMP_EDGES 12 #define LUMP_SURFEDGES 13 #define LUMP_MODELS 14 - #define HEADER_LUMPS 15 typedef struct @@ -90,7 +66,7 @@ typedef struct typedef struct { - int version; + int version; lump_t lumps[HEADER_LUMPS]; } dheader_t; @@ -171,7 +147,7 @@ typedef struct } dclipnode_t; -typedef struct texinfo_s +typedef struct { float vecs[2][4]; // [s/t][xyz offset] int miptex; @@ -189,11 +165,12 @@ typedef struct #define MAXLIGHTMAPS 4 typedef struct { - short planenum; + // LordHavoc: changed from short to unsigned short for q2 support + unsigned short planenum; short side; int firstedge; // we must support > 64k edges - short numedges; + short numedges; short texinfo; // lighting info @@ -226,101 +203,3 @@ typedef struct qbyte ambient_level[NUM_AMBIENTS]; } dleaf_t; - -//============================================================================ - -#ifndef QUAKE_GAME - -#define ANGLE_UP -1 -#define ANGLE_DOWN -2 - - -// the utilities get to be lazy and just use large static arrays - -extern int nummodels; -extern dmodel_t dmodels[MAX_MAP_MODELS]; - -extern int visdatasize; -extern qbyte dvisdata[MAX_MAP_VISIBILITY]; - -extern int lightdatasize; -extern qbyte dlightdata[MAX_MAP_LIGHTING]; - -extern int texdatasize; -extern qbyte dtexdata[MAX_MAP_MIPTEX]; // (dmiptexlump_t) - -extern int entdatasize; -extern char dentdata[MAX_MAP_ENTSTRING]; - -extern int numleafs; -extern dleaf_t dleafs[MAX_MAP_LEAFS]; - -extern int numplanes; -extern dplane_t dplanes[MAX_MAP_PLANES]; - -extern int numvertexes; -extern dvertex_t dvertexes[MAX_MAP_VERTS]; - -extern int numnodes; -extern dnode_t dnodes[MAX_MAP_NODES]; - -extern int numtexinfo; -extern texinfo_t texinfo[MAX_MAP_TEXINFO]; - -extern int numfaces; -extern dface_t dfaces[MAX_MAP_FACES]; - -extern int numclipnodes; -extern dclipnode_t dclipnodes[MAX_MAP_CLIPNODES]; - -extern int numedges; -extern dedge_t dedges[MAX_MAP_EDGES]; - -extern int nummarksurfaces; -extern unsigned short dmarksurfaces[MAX_MAP_MARKSURFACES]; - -extern int numsurfedges; -extern int dsurfedges[MAX_MAP_SURFEDGES]; - - -void DecompressVis (qbyte *in, qbyte *decompressed); -int CompressVis (qbyte *vis, qbyte *dest); - -void LoadBSPFile (char *filename); -void WriteBSPFile (char *filename); -void PrintBSPFileSizes (void); - -//=============== - - -typedef struct epair_s -{ - struct epair_s *next; - char *key; - char *value; -} epair_t; - -typedef struct -{ - vec3_t origin; - int firstbrush; - int numbrushes; - epair_t *epairs; -} entity_t; - -extern entity_t entities[MAX_MAP_ENTITIES]; - -void ParseEntities (void); -void UnparseEntities (void); - -void SetKeyValue (entity_t *ent, char *key, char *value); -char *ValueForKey (entity_t *ent, char *key); -// will return "" if not present - -vec_t FloatForKey (entity_t *ent, char *key); -void GetVectorForKey (entity_t *ent, char *key, vec3_t vec); - -epair_t *ParseEpair (void); - -#endif - diff --git a/model_brush.c b/model_brush.c index ecf2e180..870dfdb9 100644 --- a/model_brush.c +++ b/model_brush.c @@ -2937,9 +2937,432 @@ void Mod_LoadBrushModelQ1orHL (model_t *mod, void *buffer) //Mod_ProcessLightList (); } +static void Mod_Q2LoadEntities (lump_t *l) +{ +} + +static void Mod_Q2LoadPlanes (lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q2LoadVertices (lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q2LoadVisibility (lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q2LoadNodes (lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q2LoadTexInfo (lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q2LoadFaces (lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q2LoadLighting (lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q2LoadLeafs (lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q2LoadLeafFaces (lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q2LoadLeafBrushes (lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q2LoadEdges (lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q2LoadSurfEdges (lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q2LoadBrushes (lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q2LoadBrushSides (lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q2LoadAreas (lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q2LoadAreaPortals (lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q2LoadModels (lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + void Mod_LoadBrushModelQ2 (model_t *mod, void *buffer) { - Host_Error("Mod_LoadBrushModelQ2: not yet implemented\n"); + int i; + q2dheader_t *header; + + mod->type = mod_brushq2; + + header = (q2dheader_t *)buffer; + + i = LittleLong (header->version); + if (i != Q2BSPVERSION) + Host_Error ("Mod_LoadBrushModelQ2: %s has wrong version number (%i should be %i)", mod->name, i, BSPVERSION); + mod->ishlbsp = false; + if (loadmodel->isworldmodel) + { + Cvar_SetValue("halflifebsp", mod->ishlbsp); + // until we get a texture for it... + R_ResetQuakeSky(); + } + + mod_base = (qbyte *)header; + + // swap all the lumps + for (i = 0;i < (int) sizeof(dheader_t) / 4;i++) + ((int *)header)[i] = LittleLong ( ((int *)header)[i]); + + // store which lightmap format to use + mod->lightmaprgba = r_lightmaprgba.integer; + + Mod_Q2LoadEntities(&header->lumps[Q2LUMP_ENTITIES]); + Mod_Q2LoadPlanes(&header->lumps[Q2LUMP_PLANES]); + Mod_Q2LoadVertices(&header->lumps[Q2LUMP_VERTEXES]); + Mod_Q2LoadVisibility(&header->lumps[Q2LUMP_VISIBILITY]); + Mod_Q2LoadNodes(&header->lumps[Q2LUMP_NODES]); + Mod_Q2LoadTexInfo(&header->lumps[Q2LUMP_TEXINFO]); + Mod_Q2LoadFaces(&header->lumps[Q2LUMP_FACES]); + Mod_Q2LoadLighting(&header->lumps[Q2LUMP_LIGHTING]); + Mod_Q2LoadLeafs(&header->lumps[Q2LUMP_LEAFS]); + Mod_Q2LoadLeafFaces(&header->lumps[Q2LUMP_LEAFFACES]); + Mod_Q2LoadLeafBrushes(&header->lumps[Q2LUMP_LEAFBRUSHES]); + Mod_Q2LoadEdges(&header->lumps[Q2LUMP_EDGES]); + Mod_Q2LoadSurfEdges(&header->lumps[Q2LUMP_SURFEDGES]); + Mod_Q2LoadBrushes(&header->lumps[Q2LUMP_BRUSHES]); + Mod_Q2LoadBrushSides(&header->lumps[Q2LUMP_BRUSHSIDES]); + Mod_Q2LoadAreas(&header->lumps[Q2LUMP_AREAS]); + Mod_Q2LoadAreaPortals(&header->lumps[Q2LUMP_AREAPORTALS]); + // LordHavoc: must go last because this makes the submodels + Mod_Q2LoadModels(&header->lumps[Q2LUMP_MODELS]); } void Mod_LoadBrushModelQ3 (model_t *mod, void *buffer) diff --git a/model_shared.c b/model_shared.c index 0ef5f31e..fcc3a252 100644 --- a/model_shared.c +++ b/model_shared.c @@ -141,6 +141,7 @@ Mod_Init =============== */ static void Mod_Print (void); +static void Mod_Precache (void); void Mod_Init (void) { Mod_BrushInit(); @@ -148,6 +149,7 @@ void Mod_Init (void) Mod_SpriteInit(); Cmd_AddCommand ("modellist", Mod_Print); + Cmd_AddCommand ("modelprecache", Mod_Precache); } void Mod_RenderInit(void) @@ -425,6 +427,19 @@ static void Mod_Print (void) Con_Printf ("%4iK %s\n", mod->mempool ? (mod->mempool->totalsize + 1023) / 1024 : 0, mod->name); } +/* +================ +Mod_Precache +================ +*/ +static void Mod_Precache (void) +{ + if (Cmd_Argc() == 2) + Mod_ForName(Cmd_Argv(1), false, true, cl.worldmodel && !strcasecmp(Cmd_Argv(1), cl.worldmodel->name)); + else + Con_Printf("usage: modelprecache \n"); +} + int Mod_FindTriangleWithEdge(const int *elements, int numtriangles, int start, int end, int ignore) { int i, match, count; diff --git a/model_shared.h b/model_shared.h index 73bfe0a0..6bec208f 100644 --- a/model_shared.h +++ b/model_shared.h @@ -33,7 +33,7 @@ m*_t structures are in-memory */ -typedef enum {mod_invalid, mod_brush, mod_sprite, mod_alias} modtype_t; +typedef enum {mod_invalid, mod_brush, mod_sprite, mod_alias, mod_brushq2, mod_brushq3} modtype_t; typedef struct animscene_s {