15 Dec 2007
This commit is contained in:
parent
d94098b563
commit
aaa4fc04f4
|
@ -37,17 +37,9 @@ scroll = visible_offset
|
|||
Смена формата карты: новая версия bsp 39 XashBSP format
|
||||
|
||||
1. увеличить число лумпов до 32 (должно хватить на все с запасом)
|
||||
2. добавить в dmodel_t firstbrush и numbrushes
|
||||
3. из dplane_t убрать type
|
||||
4. из dnode_t убрать firstface и numfaces (никогда не были использованы в Quake2)
|
||||
5. texinfo_t - удалить value, nexttexinfo, texture расширить до 64 символов
|
||||
6. переработка texinfo_t дабы исключить повторяющиеся текстуры в списке
|
||||
7. перенести vecs в dface_t ?
|
||||
8. заменить word на long там где это нужно
|
||||
9. записывать в texinfo информацию о первоначальном размере текстуры (на стадии компиляции)
|
||||
10. избавиться в корне от edges и surfedges - использовать индексированные вертексы
|
||||
11. избавиться от areaportals и areas лумпов
|
||||
12. сжать виз-дату и лайт-дату зипом ?
|
||||
7. َâهëè÷èٍü يَويûه ëèىèٍû
|
||||
|
||||
//==================================================
|
||||
// то, что уже готово
|
||||
|
|
|
@ -31,7 +31,7 @@ int numnodes;
|
|||
dnode_t dnodes[MAX_MAP_NODES];
|
||||
|
||||
int numtexinfo;
|
||||
texinfo_t texinfo[MAX_MAP_TEXINFO];
|
||||
dsurfdesc_t texinfo[MAX_MAP_TEXINFO];
|
||||
|
||||
int numfaces;
|
||||
dface_t dfaces[MAX_MAP_FACES];
|
||||
|
@ -148,7 +148,7 @@ void SwapBSPFile (bool todisk)
|
|||
|
||||
|
||||
// models
|
||||
for (i=0 ; i<nummodels ; i++)
|
||||
for (i = 0; i < nummodels; i++)
|
||||
{
|
||||
d = &dmodels[i];
|
||||
|
||||
|
@ -156,28 +156,26 @@ void SwapBSPFile (bool todisk)
|
|||
d->numfaces = LittleLong (d->numfaces);
|
||||
d->headnode = LittleLong (d->headnode);
|
||||
|
||||
for (j=0 ; j<3 ; j++)
|
||||
for( j = 0; j < 3; j++ )
|
||||
{
|
||||
d->mins[j] = LittleFloat(d->mins[j]);
|
||||
d->maxs[j] = LittleFloat(d->maxs[j]);
|
||||
d->origin[j] = LittleFloat(d->origin[j]);
|
||||
}
|
||||
}
|
||||
|
||||
// vertexes
|
||||
for (i=0 ; i<numvertexes ; i++)
|
||||
for( i = 0; i < numvertexes; i++)
|
||||
{
|
||||
for (j=0 ; j<3 ; j++)
|
||||
dvertexes[i].point[j] = LittleFloat (dvertexes[i].point[j]);
|
||||
}
|
||||
|
||||
// planes
|
||||
for (i=0 ; i<numplanes ; i++)
|
||||
for(i = 0; i < numplanes; i++)
|
||||
{
|
||||
for (j=0 ; j<3 ; j++)
|
||||
for(j = 0; j < 3; j++)
|
||||
dplanes[i].normal[j] = LittleFloat (dplanes[i].normal[j]);
|
||||
dplanes[i].dist = LittleFloat (dplanes[i].dist);
|
||||
dplanes[i].type = LittleLong (dplanes[i].type);
|
||||
}
|
||||
|
||||
// texinfos
|
||||
|
@ -193,7 +191,7 @@ void SwapBSPFile (bool todisk)
|
|||
// faces
|
||||
for (i=0 ; i<numfaces ; i++)
|
||||
{
|
||||
dfaces[i].texinfo = LittleShort (dfaces[i].texinfo);
|
||||
dfaces[i].desc = LittleShort (dfaces[i].desc);
|
||||
dfaces[i].planenum = LittleShort (dfaces[i].planenum);
|
||||
dfaces[i].side = LittleShort (dfaces[i].side);
|
||||
dfaces[i].lightofs = LittleLong (dfaces[i].lightofs);
|
||||
|
@ -279,7 +277,7 @@ void SwapBSPFile (bool todisk)
|
|||
for (i=0 ; i<numbrushsides ; i++)
|
||||
{
|
||||
dbrushsides[i].planenum = LittleShort (dbrushsides[i].planenum);
|
||||
dbrushsides[i].texinfo = LittleShort (dbrushsides[i].texinfo);
|
||||
dbrushsides[i].surfdesc = LittleShort (dbrushsides[i].surfdesc);
|
||||
}
|
||||
|
||||
// visibility
|
||||
|
@ -340,7 +338,7 @@ bool LoadBSPFile( void )
|
|||
numvertexes = CopyLump (LUMP_VERTEXES, dvertexes, sizeof(dvertex_t));
|
||||
visdatasize = CopyLump (LUMP_VISIBILITY, dvisdata, 1);
|
||||
numnodes = CopyLump (LUMP_NODES, dnodes, sizeof(dnode_t));
|
||||
numtexinfo = CopyLump (LUMP_TEXINFO, texinfo, sizeof(texinfo_t));
|
||||
numtexinfo = CopyLump (LUMP_SURFDESC, texinfo, sizeof(dsurfdesc_t));
|
||||
numfaces = CopyLump (LUMP_FACES, dfaces, sizeof(dface_t));
|
||||
lightdatasize = CopyLump (LUMP_LIGHTING, dlightdata, 1);
|
||||
numleafs = CopyLump (LUMP_LEAFS, dleafs, sizeof(dleaf_t));
|
||||
|
@ -388,14 +386,14 @@ void LoadBSPFileTexinfo( char *filename )
|
|||
if (header->ident != IDBSPMODHEADER) Sys_Error("%s is not a IBSP file", filename);
|
||||
if (header->version != BSPMOD_VERSION) Sys_Error("%s is version %i, not %i", filename, header->version, BSPMOD_VERSION);
|
||||
|
||||
length = header->lumps[LUMP_TEXINFO].filelen;
|
||||
ofs = header->lumps[LUMP_TEXINFO].fileofs;
|
||||
length = header->lumps[LUMP_SURFDESC].filelen;
|
||||
ofs = header->lumps[LUMP_SURFDESC].fileofs;
|
||||
|
||||
FS_Seek(f, ofs, SEEK_SET);
|
||||
FS_Read(f, texinfo, length );
|
||||
FS_Close(f);
|
||||
|
||||
numtexinfo = length / sizeof(texinfo_t);
|
||||
numtexinfo = length / sizeof(dsurfdesc_t);
|
||||
Free (header); // everything has been copied out
|
||||
SwapBSPFile (false);
|
||||
}
|
||||
|
@ -449,7 +447,7 @@ void WriteBSPFile( void )
|
|||
AddLump (LUMP_VERTEXES, dvertexes, numvertexes*sizeof(dvertex_t));
|
||||
AddLump (LUMP_VISIBILITY, dvisdata, visdatasize);
|
||||
AddLump (LUMP_NODES, dnodes, numnodes*sizeof(dnode_t));
|
||||
AddLump (LUMP_TEXINFO, texinfo, numtexinfo*sizeof(texinfo_t));
|
||||
AddLump (LUMP_SURFDESC, texinfo, numtexinfo*sizeof(dsurfdesc_t));
|
||||
AddLump (LUMP_FACES, dfaces, numfaces*sizeof(dface_t));
|
||||
AddLump (LUMP_LIGHTING, dlightdata, lightdatasize);
|
||||
AddLump (LUMP_LEAFS, dleafs, numleafs*sizeof(dleaf_t));
|
||||
|
|
|
@ -108,7 +108,8 @@ typedef struct
|
|||
{
|
||||
char txcommand;
|
||||
vects_u vects;
|
||||
char name[32];
|
||||
char name[128];
|
||||
int size[2];
|
||||
int flags;
|
||||
int value;
|
||||
} brush_texture_t;
|
||||
|
@ -331,7 +332,7 @@ 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 dsurfdesc_t texinfo[MAX_MAP_TEXINFO];
|
||||
extern int numfaces;
|
||||
extern dface_t dfaces[MAX_MAP_FACES];
|
||||
extern int numedges;
|
||||
|
@ -369,12 +370,13 @@ void AddLump (int lumpnum, const void *data, int len);
|
|||
|
||||
typedef struct
|
||||
{
|
||||
char name[64];
|
||||
char name[128];
|
||||
int size[2];
|
||||
int flags;
|
||||
int value;
|
||||
int contents;
|
||||
int numframes;
|
||||
char animname[64];
|
||||
char animname[128];
|
||||
} textureref_t;
|
||||
|
||||
extern textureref_t textureref[MAX_MAP_TEXTURES];
|
||||
|
|
|
@ -821,7 +821,7 @@ void SubdivideFace (node_t *node, face_t *f)
|
|||
float mins, maxs;
|
||||
vec_t v;
|
||||
int axis, i;
|
||||
texinfo_t *tex;
|
||||
dsurfdesc_t *tex;
|
||||
vec3_t temp;
|
||||
vec_t dist;
|
||||
winding_t *w, *frontw, *backw;
|
||||
|
|
|
@ -487,7 +487,7 @@ void CalcFaceExtents (lightinfo_t *l)
|
|||
vec_t mins[2], maxs[2], val;
|
||||
int i,j, e;
|
||||
dvertex_t *v;
|
||||
texinfo_t *tex;
|
||||
dsurfdesc_t *tex;
|
||||
vec3_t vt;
|
||||
|
||||
s = l->face;
|
||||
|
@ -495,7 +495,7 @@ void CalcFaceExtents (lightinfo_t *l)
|
|||
mins[0] = mins[1] = 999999;
|
||||
maxs[0] = maxs[1] = -99999;
|
||||
|
||||
tex = &texinfo[s->texinfo];
|
||||
tex = &texinfo[s->desc];
|
||||
|
||||
for (i=0 ; i<s->numedges ; i++)
|
||||
{
|
||||
|
@ -542,14 +542,14 @@ Fills in texorg, worldtotex. and textoworld
|
|||
*/
|
||||
void CalcFaceVectors (lightinfo_t *l)
|
||||
{
|
||||
texinfo_t *tex;
|
||||
dsurfdesc_t *tex;
|
||||
int i, j;
|
||||
vec3_t texnormal;
|
||||
vec_t distscale;
|
||||
vec_t dist, len;
|
||||
int w, h;
|
||||
|
||||
tex = &texinfo[l->face->texinfo];
|
||||
tex = &texinfo[l->face->desc];
|
||||
|
||||
// convert from float to double
|
||||
for (i=0 ; i<2 ; i++)
|
||||
|
@ -1035,7 +1035,7 @@ void BuildFacelights (int facenum)
|
|||
|
||||
f = &dfaces[facenum];
|
||||
|
||||
if ( texinfo[f->texinfo].flags & (SURF_WARP|SURF_SKY) )
|
||||
if ( texinfo[f->desc].flags & (SURF_WARP|SURF_SKY) )
|
||||
return; // non-lit texture
|
||||
|
||||
memset (styletable,0, sizeof(styletable));
|
||||
|
@ -1147,7 +1147,7 @@ void FinalLightFace (int facenum)
|
|||
f = &dfaces[facenum];
|
||||
fl = &facelight[facenum];
|
||||
|
||||
if ( texinfo[f->texinfo].flags & (SURF_WARP|SURF_SKY) )
|
||||
if ( texinfo[f->desc].flags & (SURF_WARP|SURF_SKY) )
|
||||
return; // non-lit texture
|
||||
|
||||
ThreadLock ();
|
||||
|
|
|
@ -49,27 +49,14 @@ PLANE FINDING
|
|||
PlaneTypeForNormal
|
||||
=================
|
||||
*/
|
||||
int PlaneTypeForNormal (vec3_t normal)
|
||||
int PlaneTypeForNormal (vec3_t normal)
|
||||
{
|
||||
vec_t ax, ay, az;
|
||||
// NOTE: should these have an epsilon around 1.0?
|
||||
if(fabs(normal[0]) == 1.0) return PLANE_X;
|
||||
if(fabs(normal[1]) == 1.0) return PLANE_Y;
|
||||
if(fabs(normal[2]) == 1.0) return PLANE_Z;
|
||||
|
||||
// NOTE: should these have an epsilon around 1.0?
|
||||
if (normal[0] == 1.0 || normal[0] == -1.0)
|
||||
return PLANE_X;
|
||||
if (normal[1] == 1.0 || normal[1] == -1.0)
|
||||
return PLANE_Y;
|
||||
if (normal[2] == 1.0 || normal[2] == -1.0)
|
||||
return PLANE_Z;
|
||||
|
||||
ax = fabs(normal[0]);
|
||||
ay = fabs(normal[1]);
|
||||
az = fabs(normal[2]);
|
||||
|
||||
if (ax >= ay && ax >= az)
|
||||
return PLANE_ANYX;
|
||||
if (ay >= ax && ay >= az)
|
||||
return PLANE_ANYY;
|
||||
return PLANE_ANYZ;
|
||||
return 3;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -673,6 +660,8 @@ void ParseBrush (bsp_entity_t *mapent)
|
|||
|
||||
// find default flags and values
|
||||
mt = FindMiptex (td.name);
|
||||
td.size[0] = textureref[mt].size[0];
|
||||
td.size[1] = textureref[mt].size[1];
|
||||
td.flags = textureref[mt].flags;
|
||||
td.value = textureref[mt].value;
|
||||
side->contents = textureref[mt].contents;
|
||||
|
@ -919,7 +908,7 @@ bool ParseMapEntity (void)
|
|||
if (!strcmp(e->key, "mapversion"))
|
||||
{
|
||||
g_mapversion = atoi(e->value);
|
||||
Msg("mapversion %d\n", g_mapversion );
|
||||
MsgDev(D_NOTE, "mapversion %d\n", g_mapversion );
|
||||
}
|
||||
e->next = mapent->epairs;
|
||||
mapent->epairs = e;
|
||||
|
|
|
@ -158,26 +158,26 @@ BaseLightForFace
|
|||
*/
|
||||
void BaseLightForFace (dface_t *f, vec3_t color)
|
||||
{
|
||||
texinfo_t *tx;
|
||||
dsurfdesc_t *tx;
|
||||
|
||||
//
|
||||
// check for light emited by texture
|
||||
//
|
||||
tx = &texinfo[f->texinfo];
|
||||
tx = &texinfo[f->desc];
|
||||
if (!(tx->flags & SURF_LIGHT) || tx->value == 0)
|
||||
{
|
||||
VectorClear (color);
|
||||
return;
|
||||
}
|
||||
|
||||
VectorScale (texture_reflectivity[f->texinfo], tx->value, color);
|
||||
VectorScale (texture_reflectivity[f->desc], tx->value, color);
|
||||
}
|
||||
|
||||
bool IsSky (dface_t *f)
|
||||
{
|
||||
texinfo_t *tx;
|
||||
dsurfdesc_t *tx;
|
||||
|
||||
tx = &texinfo[f->texinfo];
|
||||
tx = &texinfo[f->desc];
|
||||
if (tx->flags & SURF_SKY)
|
||||
return true;
|
||||
return false;
|
||||
|
@ -238,7 +238,7 @@ void MakePatchForFace (int fn, winding_t *w)
|
|||
patch->area = 1;
|
||||
patch->sky = IsSky (f);
|
||||
|
||||
VectorCopy (texture_reflectivity[f->texinfo], patch->reflectivity);
|
||||
VectorCopy (texture_reflectivity[f->desc], patch->reflectivity);
|
||||
|
||||
// non-bmodel patches can emit light
|
||||
if (fn < dmodels[0].numfaces)
|
||||
|
|
|
@ -10,8 +10,9 @@ textureref_t textureref[MAX_MAP_TEXTURES];
|
|||
|
||||
int FindMiptex (char *name)
|
||||
{
|
||||
int i;
|
||||
shader_t *si;
|
||||
int i;
|
||||
shader_t *si;
|
||||
rgbdata_t *tex;
|
||||
|
||||
for (i = 0; i < nummiptex; i++ )
|
||||
{
|
||||
|
@ -21,7 +22,16 @@ int FindMiptex (char *name)
|
|||
if (nummiptex == MAX_MAP_TEXTURES) Sys_Error ("MAX_MAP_TEXTURES");
|
||||
|
||||
// register texture
|
||||
strcpy (textureref[i].name, name);
|
||||
strcpy (textureref[i].name, name );
|
||||
tex = FS_LoadImage(textureref[i].name, NULL, 0);
|
||||
if(tex)
|
||||
{
|
||||
Msg("load texture %s\n", name );
|
||||
textureref[i].size[0] = tex->width;
|
||||
textureref[i].size[1] = tex->height;
|
||||
FS_FreeImage( tex );
|
||||
}
|
||||
else textureref[i].size[0] = textureref[i].size[1] = -1; // technically an error
|
||||
|
||||
si = FindShader( name );
|
||||
if(si)
|
||||
|
@ -50,9 +60,9 @@ textureAxisFromPlane
|
|||
vec3_t baseaxis[18] =
|
||||
{
|
||||
{0,0,1}, {1,0,0}, {0,-1,0}, // floor
|
||||
{0,0,-1}, {1,0,0}, {0,-1,0}, // ceiling
|
||||
{0,0,-1}, {1,0,0}, {0,-1,0}, // ceiling
|
||||
{1,0,0}, {0,1,0}, {0,0,-1}, // west wall
|
||||
{-1,0,0}, {0,1,0}, {0,0,-1}, // east wall
|
||||
{-1,0,0}, {0,1,0}, {0,0,-1}, // east wall
|
||||
{0,1,0}, {1,0,0}, {0,0,-1}, // south wall
|
||||
{0,-1,0}, {1,0,0}, {0,0,-1} // north wall
|
||||
};
|
||||
|
@ -89,7 +99,7 @@ int TexinfoForBrushTexture (plane_t *plane, brush_texture_t *bt, vec3_t origin)
|
|||
int sv, tv;
|
||||
vec_t ang, sinv, cosv;
|
||||
vec_t ns, nt;
|
||||
texinfo_t tx, *tc;
|
||||
dsurfdesc_t tx, *tc;
|
||||
int i, j, k;
|
||||
brush_texture_t anim;
|
||||
int mt;
|
||||
|
@ -111,6 +121,8 @@ int TexinfoForBrushTexture (plane_t *plane, brush_texture_t *bt, vec3_t origin)
|
|||
}
|
||||
tx.flags = bt->flags;
|
||||
tx.value = bt->value;
|
||||
tx.size[0] = bt->size[0];
|
||||
tx.size[1] = bt->size[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -185,6 +197,8 @@ int TexinfoForBrushTexture (plane_t *plane, brush_texture_t *bt, vec3_t origin)
|
|||
tx.vecs[1][3] = bt->vects.valve.shift[1] + DotProduct(origin, tx.vecs[1]);
|
||||
tx.flags = bt->flags;
|
||||
tx.value = bt->value;
|
||||
tx.size[0] = bt->size[0];
|
||||
tx.size[1] = bt->size[1];
|
||||
}
|
||||
|
||||
// find the texinfo
|
||||
|
@ -195,7 +209,7 @@ int TexinfoForBrushTexture (plane_t *plane, brush_texture_t *bt, vec3_t origin)
|
|||
if (tc->value != tx.value) continue;
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
if (stricmp (tc->texture, tx.texture))
|
||||
if (com.stricmp (tc->texture, tx.texture))
|
||||
goto skip;
|
||||
for (k = 0; k < 4; k++)
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@ void MakeTnode (int nodenum)
|
|||
node = dnodes + nodenum;
|
||||
plane = dplanes + node->planenum;
|
||||
|
||||
t->type = plane->type;
|
||||
t->type = PlaneTypeForNormal( plane->normal );
|
||||
VectorCopy (plane->normal, t->normal);
|
||||
t->dist = plane->dist;
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ void EmitPlanes (void)
|
|||
planetranslate[i] = numplanes;
|
||||
VectorCopy ( mp->normal, dp->normal);
|
||||
dp->dist = mp->dist;
|
||||
dp->type = mp->type;
|
||||
numplanes++;
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +190,7 @@ void EmitFace (face_t *f)
|
|||
|
||||
df->firstedge = numsurfedges;
|
||||
df->numedges = f->numpoints;
|
||||
df->texinfo = f->texinfo;
|
||||
df->desc = f->texinfo;
|
||||
for (i=0 ; i<f->numpoints ; i++)
|
||||
{
|
||||
// e = GetEdge (f->pts[i], f->pts[(i+1)%f->numpoints], f);
|
||||
|
@ -397,7 +396,7 @@ void EmitBrushes (void)
|
|||
cp = &dbrushsides[numbrushsides];
|
||||
numbrushsides++;
|
||||
cp->planenum = b->original_sides[j].planenum;
|
||||
cp->texinfo = b->original_sides[j].texinfo;
|
||||
cp->surfdesc = b->original_sides[j].texinfo;
|
||||
}
|
||||
|
||||
// add any axis planes not contained in the brush to bevel off corners
|
||||
|
@ -421,8 +420,8 @@ void EmitBrushes (void)
|
|||
Sys_Error ("MAX_MAP_BRUSHSIDES");
|
||||
|
||||
dbrushsides[numbrushsides].planenum = planenum;
|
||||
dbrushsides[numbrushsides].texinfo =
|
||||
dbrushsides[numbrushsides-1].texinfo;
|
||||
dbrushsides[numbrushsides].surfdesc =
|
||||
dbrushsides[numbrushsides-1].surfdesc;
|
||||
numbrushsides++;
|
||||
db->numsides++;
|
||||
}
|
||||
|
@ -443,6 +442,7 @@ void BeginBSPFile (void)
|
|||
{
|
||||
// these values may actually be initialized
|
||||
// if the file existed when loaded, so clear them explicitly
|
||||
|
||||
nummodels = 0;
|
||||
numfaces = 0;
|
||||
numnodes = 0;
|
||||
|
@ -451,15 +451,10 @@ void BeginBSPFile (void)
|
|||
numleaffaces = 0;
|
||||
numleafbrushes = 0;
|
||||
numsurfedges = 0;
|
||||
numedges = 1; // edge 0 is not used, because 0 can't be negated
|
||||
numvertexes = 1; // leave vertex 0 as an error
|
||||
numleafs = 1; // leave leaf 0 as an error
|
||||
|
||||
// edge 0 is not used, because 0 can't be negated
|
||||
numedges = 1;
|
||||
|
||||
// leave vertex 0 as an error
|
||||
numvertexes = 1;
|
||||
|
||||
// leave leaf 0 as an error
|
||||
numleafs = 1;
|
||||
dleafs[0].contents = CONTENTS_SOLID;
|
||||
}
|
||||
|
||||
|
@ -489,7 +484,7 @@ int firstmodleaf;
|
|||
extern int firstmodeledge;
|
||||
extern int firstmodelface;
|
||||
|
||||
void BeginModel (void)
|
||||
void BeginModel( void )
|
||||
{
|
||||
dmodel_t *mod;
|
||||
mapbrush_t *b;
|
||||
|
@ -501,15 +496,14 @@ void BeginModel (void)
|
|||
mod = &dmodels[nummodels];
|
||||
|
||||
mod->firstface = numfaces;
|
||||
//mod->firstbrush = numbrushes;
|
||||
|
||||
firstmodleaf = numleafs;
|
||||
firstmodeledge = numedges;
|
||||
firstmodelface = numfaces;
|
||||
|
||||
// bound the brushes
|
||||
e = &entities[entity_num];
|
||||
start = e->firstbrush;
|
||||
mod->firstbrush = start = e->firstbrush;
|
||||
mod->numbrushes = e->numbrushes;
|
||||
end = start + e->numbrushes;
|
||||
ClearBounds (mins, maxs);
|
||||
|
||||
|
@ -537,8 +531,6 @@ void EndModel (void)
|
|||
mod = &dmodels[nummodels];
|
||||
|
||||
mod->numfaces = numfaces - mod->firstface;
|
||||
//mod->numbrushes = numbrushes - mod->firstbrush;
|
||||
|
||||
nummodels++;
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,6 @@ void CMod_LoadSubmodels (lump_t *l)
|
|||
// spread the mins / maxs by a pixel
|
||||
out->mins[j] = LittleFloat (in->mins[j]) - 1;
|
||||
out->maxs[j] = LittleFloat (in->maxs[j]) + 1;
|
||||
out->origin[j] = LittleFloat (in->origin[j]);
|
||||
}
|
||||
out->headnode = LittleLong (in->headnode);
|
||||
}
|
||||
|
@ -168,7 +167,7 @@ CMod_LoadSurfaces
|
|||
*/
|
||||
void CMod_LoadSurfaces (lump_t *l)
|
||||
{
|
||||
texinfo_t *in;
|
||||
dsurfdesc_t *in;
|
||||
mapsurface_t *out;
|
||||
int i, count;
|
||||
|
||||
|
@ -320,10 +319,9 @@ CMod_LoadPlanes
|
|||
void CMod_LoadPlanes (lump_t *l)
|
||||
{
|
||||
int i, j;
|
||||
cplane_t *out;
|
||||
dplane_t *in;
|
||||
cplane_t *out;
|
||||
dplane_t *in;
|
||||
int count;
|
||||
int bits;
|
||||
|
||||
in = (void *)(cmod_base + l->fileofs);
|
||||
if (l->filelen % sizeof(*in)) Host_Error("MOD_LoadBmodel: funny lump size\n");
|
||||
|
@ -338,15 +336,10 @@ void CMod_LoadPlanes (lump_t *l)
|
|||
|
||||
for ( i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
bits = 0;
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
out->normal[j] = LittleFloat (in->normal[j]);
|
||||
if (out->normal[j] < 0) bits |= 1<<j;
|
||||
}
|
||||
for (j = 0; j < 3; j++)
|
||||
out->normal[j] = LittleFloat(in->normal[j]);
|
||||
out->dist = LittleFloat (in->dist);
|
||||
out->type = LittleLong (in->type);
|
||||
out->signbits = bits;
|
||||
PlaneClassify( out );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,7 +395,7 @@ void CMod_LoadBrushSides (lump_t *l)
|
|||
{
|
||||
num = LittleShort (in->planenum);
|
||||
out->plane = &map_planes[num];
|
||||
j = LittleShort (in->texinfo);
|
||||
j = LittleShort (in->surfdesc);
|
||||
if (j >= numtexinfo) Host_Error("Bad brushside texinfo\n");
|
||||
out->surface = &map_surfaces[j];
|
||||
}
|
||||
|
@ -571,7 +564,7 @@ cmodel_t *CM_LoadMap (char *name, bool clientload, unsigned *checksum)
|
|||
cmod_base = (byte *)buf;
|
||||
|
||||
// load into heap
|
||||
CMod_LoadSurfaces (&header.lumps[LUMP_TEXINFO]);
|
||||
CMod_LoadSurfaces (&header.lumps[LUMP_SURFDESC]);
|
||||
CMod_LoadLeafs (&header.lumps[LUMP_LEAFS]);
|
||||
CMod_LoadLeafBrushes (&header.lumps[LUMP_LEAFBRUSHES]);
|
||||
CMod_LoadPlanes (&header.lumps[LUMP_PLANES]);
|
||||
|
|
|
@ -5,14 +5,20 @@
|
|||
|
||||
#include "physic.h"
|
||||
|
||||
typedef struct cfacedesc_s
|
||||
{
|
||||
int flags; // surface description
|
||||
} cfacedesc_t;
|
||||
|
||||
typedef struct collision_tree_s
|
||||
{
|
||||
byte *pmod_base; // buffer
|
||||
dvertex_t *vertices;
|
||||
int *surfedges;
|
||||
csurface_t *surfaces;
|
||||
dface_t *surfaces;
|
||||
dedge_t *edges;
|
||||
dmodel_t *models;
|
||||
cfacedesc_t *surfdesc;
|
||||
|
||||
int num_models;
|
||||
int num_faces; // for bounds checking
|
||||
|
@ -102,8 +108,7 @@ BSP_LoadFaces
|
|||
*/
|
||||
void BSP_LoadFaces( lump_t *l )
|
||||
{
|
||||
dface_t *in;
|
||||
csurface_t *out;
|
||||
dface_t *in, *out;
|
||||
int i;
|
||||
|
||||
in = (void *)(map.pmod_base + l->fileofs);
|
||||
|
@ -115,8 +120,7 @@ void BSP_LoadFaces( lump_t *l )
|
|||
{
|
||||
out->firstedge = LittleLong(in->firstedge);
|
||||
out->numedges = LittleShort(in->numedges);
|
||||
if( in->side ) out->flags |= SURF_PLANEBACK;
|
||||
else out->flags = 0;
|
||||
out->desc = LittleShort(in->desc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,10 +145,33 @@ void BSP_LoadModels( lump_t *l )
|
|||
{
|
||||
CM_ConvertDimensionToMeters( out->mins, in->mins );
|
||||
CM_ConvertDimensionToMeters( out->maxs, in->maxs );
|
||||
CM_ConvertPositionToMeters( out->origin, in->origin );
|
||||
out->headnode = LittleLong( in->headnode );
|
||||
out->firstface = LittleLong( in->firstface );
|
||||
out->numfaces = LittleLong( in->numfaces );
|
||||
out->firstbrush = LittleLong( in->firstbrush );
|
||||
out->numbrushes = LittleLong( in->numbrushes );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
BSP_LoadSurfDesc
|
||||
=================
|
||||
*/
|
||||
void BSP_LoadSurfDesc( lump_t *l )
|
||||
{
|
||||
dsurfdesc_t *in;
|
||||
cfacedesc_t *out;
|
||||
int i, count;
|
||||
|
||||
in = (void *)(map.pmod_base + l->fileofs);
|
||||
if (l->filelen % sizeof(*in)) Host_Error("BSP_LoadSurfDesc: funny lump size\n" );
|
||||
count = l->filelen / sizeof(*in);
|
||||
map.surfdesc = out = Mem_Alloc( physpool, count * sizeof(*out));
|
||||
|
||||
for ( i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
out->flags = LittleLong (in->flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,8 +220,9 @@ void BSP_BeginBuildTree( void )
|
|||
|
||||
void BSP_AddCollisionFace( int facenum )
|
||||
{
|
||||
csurface_t *m_face;
|
||||
dface_t *m_face;
|
||||
int j, k;
|
||||
int flags;
|
||||
|
||||
if(facenum < 0 || facenum >= map.num_faces)
|
||||
{
|
||||
|
@ -203,8 +231,12 @@ void BSP_AddCollisionFace( int facenum )
|
|||
}
|
||||
|
||||
m_face = map.surfaces + facenum;
|
||||
flags = map.surfdesc[m_face->desc].flags;
|
||||
k = m_face->firstedge;
|
||||
|
||||
// sky is noclip for all physobjects
|
||||
if(flags & SURF_SKY) return;
|
||||
|
||||
if( cm_use_triangles->integer )
|
||||
{
|
||||
// convert polygon to triangles
|
||||
|
@ -253,6 +285,7 @@ void CM_LoadBSP( const void *buffer )
|
|||
BSP_LoadSurfedges(&header.lumps[LUMP_SURFEDGES]);
|
||||
BSP_LoadFaces(&header.lumps[LUMP_FACES]);
|
||||
BSP_LoadModels(&header.lumps[LUMP_MODELS]);
|
||||
BSP_LoadSurfDesc(&header.lumps[LUMP_SURFDESC]);
|
||||
BSP_LoadCollision(&header.lumps[LUMP_COLLISION]);
|
||||
map.loaded = true;
|
||||
map.use_thread = true;
|
||||
|
|
|
@ -743,6 +743,20 @@ _inline int ColorStrlen( const char *string )
|
|||
return len;
|
||||
}
|
||||
|
||||
_inline void PlaneClassify( cplane_t *p )
|
||||
{
|
||||
// for optimized plane comparisons
|
||||
if (fabs(p->normal[0]) == 1) p->type = PLANE_X;
|
||||
else if (fabs(p->normal[1]) == 1) p->type = PLANE_Y;
|
||||
else if (fabs(p->normal[2]) == 1) p->type = PLANE_Z;
|
||||
else p->type = 3; // needs alternate calc
|
||||
|
||||
// for BoxOnPlaneSide
|
||||
p->signbits = 0;
|
||||
if (p->normal[0] < 0) p->signbits |= 1;
|
||||
if (p->normal[1] < 0) p->signbits |= 2;
|
||||
if (p->normal[2] < 0) p->signbits |= 4;
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
|
|
|
@ -676,8 +676,8 @@ BRUSH MODELS
|
|||
==============================================================================
|
||||
*/
|
||||
|
||||
//header
|
||||
#define BSPMOD_VERSION 38
|
||||
// header
|
||||
#define BSPMOD_VERSION 39
|
||||
#define IDBSPMODHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I') // little-endian "IBSP"
|
||||
|
||||
// 16 bit short limits
|
||||
|
@ -706,13 +706,13 @@ BRUSH MODELS
|
|||
#define MAX_MAP_VISIBILITY 0x100000
|
||||
#define MAX_MAP_COLLISION 0x400000
|
||||
|
||||
//lump offset
|
||||
// lump offset
|
||||
#define LUMP_ENTITIES 0
|
||||
#define LUMP_PLANES 1
|
||||
#define LUMP_VERTEXES 2
|
||||
#define LUMP_VISIBILITY 3
|
||||
#define LUMP_NODES 4
|
||||
#define LUMP_TEXINFO 5
|
||||
#define LUMP_SURFDESC 5
|
||||
#define LUMP_FACES 6
|
||||
#define LUMP_LIGHTING 7
|
||||
#define LUMP_LEAFS 8
|
||||
|
@ -726,7 +726,8 @@ BRUSH MODELS
|
|||
#define LUMP_COLLISION 16
|
||||
#define LUMP_AREAS 17
|
||||
#define LUMP_AREAPORTALS 18
|
||||
#define HEADER_LUMPS 19
|
||||
|
||||
#define LUMP_TOTALCOUNT 32 // max lumps
|
||||
|
||||
|
||||
// the visibility lump consists of a header with a count, then
|
||||
|
@ -742,16 +743,17 @@ typedef struct
|
|||
{
|
||||
int ident;
|
||||
int version;
|
||||
lump_t lumps[HEADER_LUMPS];
|
||||
lump_t lumps[LUMP_TOTALCOUNT];
|
||||
} dheader_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float mins[3], maxs[3];
|
||||
float origin[3]; // for sounds or lights
|
||||
int headnode;
|
||||
int firstface; // submodels just draw faces
|
||||
int numfaces; // without walking the bsp tree
|
||||
int firstbrush; // physics stuff
|
||||
int numbrushes;
|
||||
} dmodel_t;
|
||||
|
||||
typedef struct
|
||||
|
@ -763,41 +765,40 @@ typedef struct
|
|||
{
|
||||
float normal[3];
|
||||
float dist;
|
||||
int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
|
||||
} dplane_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int planenum;
|
||||
int children[2]; // negative numbers are -(leafs+1), not nodes
|
||||
short mins[3]; // for frustom culling
|
||||
short maxs[3];
|
||||
word firstface;
|
||||
word numfaces; // counting both sides
|
||||
int mins[3]; // for frustom culling
|
||||
int maxs[3];
|
||||
int firstface;
|
||||
int numfaces; // counting both sides
|
||||
} dnode_t;
|
||||
|
||||
typedef struct texinfo_s
|
||||
typedef struct dsurfdesc_s
|
||||
{
|
||||
float vecs[2][4]; // [s/t][xyz offset]
|
||||
int flags; // miptex flags + overrides
|
||||
float vecs[2][4]; // [s/t][xyz offset] texture s\t
|
||||
int size[2]; // valid size for current s\t coords (used for replace texture)
|
||||
int flags; // surface flags
|
||||
int value; // light emission, etc
|
||||
char texture[32]; // texture name (textures/*.jpg)
|
||||
int nexttexinfo; // for animations, -1 = end of chain
|
||||
} texinfo_t;
|
||||
char texture[128]; // texture name (textures/*.jpg)
|
||||
} dsurfdesc_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
word v[2]; // vertex numbers
|
||||
int v[2]; // vertex numbers
|
||||
} dedge_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
word planenum;
|
||||
short side;
|
||||
int firstedge; // we must support > 64k edges
|
||||
short numedges;
|
||||
short texinfo;
|
||||
int planenum;
|
||||
int firstedge;
|
||||
int numedges;
|
||||
int desc;
|
||||
short side; // get rid of this ?
|
||||
|
||||
// lighting info
|
||||
byte styles[MAXLIGHTMAPS];
|
||||
|
@ -806,22 +807,24 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
int contents; // OR of all brushes (not needed?)
|
||||
short cluster;
|
||||
short area;
|
||||
short mins[3]; // for frustum culling
|
||||
short maxs[3];
|
||||
int contents; // or of all brushes (not needed?)
|
||||
|
||||
word firstleafface;
|
||||
word numleaffaces;
|
||||
word firstleafbrush;
|
||||
word numleafbrushes;
|
||||
int cluster;
|
||||
int area;
|
||||
|
||||
int mins[3]; // for frustum culling
|
||||
int maxs[3];
|
||||
|
||||
int firstleafface;
|
||||
int numleaffaces;
|
||||
int firstleafbrush;
|
||||
int numleafbrushes;
|
||||
} dleaf_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
word planenum; // facing out of the leaf
|
||||
short texinfo;
|
||||
int planenum; // facing out of the leaf
|
||||
int surfdesc; // surface description (s/t coords, flags, etc)
|
||||
} dbrushside_t;
|
||||
|
||||
typedef struct
|
||||
|
@ -855,12 +858,9 @@ typedef struct
|
|||
MAP CONTENTS & SURFACES DESCRIPTION
|
||||
==============================================================================
|
||||
*/
|
||||
#define PLANE_X 0 // 0-2 are axial planes
|
||||
#define PLANE_Y 1
|
||||
#define PLANE_X 0 // 0 - 2 are axial planes
|
||||
#define PLANE_Y 1 // 3 needs alternate calc
|
||||
#define PLANE_Z 2
|
||||
#define PLANE_ANYX 3
|
||||
#define PLANE_ANYY 4
|
||||
#define PLANE_ANYZ 5
|
||||
|
||||
// lower bits are stronger, and will eat weaker brushes completely
|
||||
#define CONTENTS_NONE 0 // just a mask for source tabulation
|
||||
|
@ -1417,7 +1417,6 @@ typedef struct cmodel_s
|
|||
byte *mempool; // personal mempool
|
||||
|
||||
vec3_t mins, maxs; // boundbox
|
||||
vec3_t origin; // for sounds or lights
|
||||
int headnode; // bsp info
|
||||
|
||||
int numframes; // sprite framecount
|
||||
|
|
|
@ -383,11 +383,11 @@ void Mod_LoadSubmodels (lump_t *l)
|
|||
|
||||
for ( i=0 ; i<count ; i++, in++, out++)
|
||||
{
|
||||
for (j=0 ; j<3 ; j++)
|
||||
{ // spread the mins / maxs by a pixel
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
// spread the mins / maxs by a pixel
|
||||
out->mins[j] = LittleFloat (in->mins[j]) - 1;
|
||||
out->maxs[j] = LittleFloat (in->maxs[j]) + 1;
|
||||
out->origin[j] = LittleFloat (in->origin[j]);
|
||||
}
|
||||
out->radius = RadiusFromBounds (out->mins, out->maxs);
|
||||
out->headnode = LittleLong (in->headnode);
|
||||
|
@ -425,15 +425,15 @@ void Mod_LoadEdges (lump_t *l)
|
|||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadTexinfo
|
||||
Mod_LoadSurfDesc
|
||||
=================
|
||||
*/
|
||||
void Mod_LoadTexinfo (lump_t *l)
|
||||
void Mod_LoadSurfDesc( lump_t *l )
|
||||
{
|
||||
texinfo_t *in;
|
||||
mtexinfo_t *out, *step;
|
||||
int i, j, count;
|
||||
int next;
|
||||
dsurfdesc_t *in;
|
||||
mtexinfo_t *out, *step;
|
||||
int i, j, count;
|
||||
int next;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
if (l->filelen % sizeof(*in))
|
||||
|
@ -454,6 +454,10 @@ void Mod_LoadTexinfo (lump_t *l)
|
|||
if (next > 0) out->next = loadmodel->texinfo + next;
|
||||
else out->next = NULL;
|
||||
|
||||
// fixed texture size
|
||||
out->size[0] = LittleLong (in->size[0]);
|
||||
out->size[1] = LittleLong (in->size[1]);
|
||||
|
||||
out->image = R_FindImage (in->texture, NULL, 0, it_wall);
|
||||
if(out->image)
|
||||
{
|
||||
|
@ -574,7 +578,7 @@ void Mod_LoadFaces (lump_t *l)
|
|||
|
||||
out->plane = loadmodel->planes + planenum;
|
||||
|
||||
ti = LittleShort (in->texinfo);
|
||||
ti = LittleShort (in->desc);
|
||||
if (ti < 0 || ti >= loadmodel->numtexinfo)
|
||||
Sys_Error("MOD_LoadBmodel: bad texinfo number");
|
||||
out->texinfo = loadmodel->texinfo + ti;
|
||||
|
@ -797,11 +801,10 @@ Mod_LoadPlanes
|
|||
*/
|
||||
void Mod_LoadPlanes (lump_t *l)
|
||||
{
|
||||
int i, j;
|
||||
cplane_t *out;
|
||||
dplane_t *in;
|
||||
int count;
|
||||
int bits;
|
||||
int i, j;
|
||||
cplane_t *out;
|
||||
dplane_t *in;
|
||||
int count;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
if (l->filelen % sizeof(*in))
|
||||
|
@ -812,19 +815,12 @@ void Mod_LoadPlanes (lump_t *l)
|
|||
loadmodel->planes = out;
|
||||
loadmodel->numplanes = count;
|
||||
|
||||
for ( i=0 ; i<count ; i++, in++, out++)
|
||||
for ( i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
bits = 0;
|
||||
for (j=0 ; j<3 ; j++)
|
||||
{
|
||||
for (j = 0; j < 3; j++)
|
||||
out->normal[j] = LittleFloat (in->normal[j]);
|
||||
if (out->normal[j] < 0)
|
||||
bits |= 1<<j;
|
||||
}
|
||||
|
||||
out->dist = LittleFloat (in->dist);
|
||||
out->type = LittleLong (in->type);
|
||||
out->signbits = bits;
|
||||
out->dist = LittleFloat( in->dist );
|
||||
PlaneClassify( out );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -896,7 +892,7 @@ void Mod_LoadBrushModel (model_t *mod, void *buffer)
|
|||
Mod_LoadSurfedges (&header->lumps[LUMP_SURFEDGES]);
|
||||
Mod_LoadLighting (&header->lumps[LUMP_LIGHTING]);
|
||||
Mod_LoadPlanes (&header->lumps[LUMP_PLANES]);
|
||||
Mod_LoadTexinfo (&header->lumps[LUMP_TEXINFO]);
|
||||
Mod_LoadSurfDesc (&header->lumps[LUMP_SURFDESC]);
|
||||
Mod_LoadFaces (&header->lumps[LUMP_FACES]);
|
||||
Mod_LoadMarksurfaces (&header->lumps[LUMP_LEAFFACES]);
|
||||
Mod_LoadVisibility (&header->lumps[LUMP_VISIBILITY]);
|
||||
|
|
|
@ -78,7 +78,6 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
vec3_t mins, maxs;
|
||||
vec3_t origin; // for sounds or lights
|
||||
float radius;
|
||||
int headnode;
|
||||
int visleafs; // not including the solid leaf 0
|
||||
|
@ -94,8 +93,9 @@ typedef struct
|
|||
typedef struct mtexinfo_s
|
||||
{
|
||||
float vecs[2][4];
|
||||
int flags;
|
||||
int numframes;
|
||||
int size[2];
|
||||
int flags;
|
||||
int numframes;
|
||||
struct mtexinfo_s *next; // animation chain
|
||||
image_t *image;
|
||||
} mtexinfo_t;
|
||||
|
@ -153,7 +153,7 @@ typedef struct mnode_s
|
|||
|
||||
struct mnode_s *parent;
|
||||
|
||||
// node specific
|
||||
// node specific
|
||||
cplane_t *plane;
|
||||
struct mnode_s *children[2];
|
||||
|
||||
|
|
|
@ -483,7 +483,7 @@ void R_SetFrustum (void)
|
|||
|
||||
for (i=0 ; i<4 ; i++)
|
||||
{
|
||||
frustum[i].type = PLANE_ANYZ;
|
||||
frustum[i].type = 3;
|
||||
frustum[i].dist = DotProduct (r_origin, frustum[i].normal);
|
||||
frustum[i].signbits = SignbitsForPlane (&frustum[i]);
|
||||
}
|
||||
|
@ -632,8 +632,10 @@ void R_Clear (void)
|
|||
static int trickframe;
|
||||
|
||||
if (gl_clear->value)
|
||||
{
|
||||
qglClearColor( 0.5, 0.5, 0.5, 1 );
|
||||
qglClear (GL_COLOR_BUFFER_BIT);
|
||||
|
||||
}
|
||||
trickframe++;
|
||||
if (trickframe & 1)
|
||||
{
|
||||
|
@ -651,9 +653,11 @@ void R_Clear (void)
|
|||
else
|
||||
{
|
||||
if (gl_clear->value)
|
||||
{
|
||||
qglClearColor( 0.5, 0.5, 0.5, 1 );
|
||||
qglClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
else
|
||||
qglClear (GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
else qglClear (GL_DEPTH_BUFFER_BIT);
|
||||
gldepthmin = 0;
|
||||
gldepthmax = 1;
|
||||
qglDepthFunc (GL_LEQUAL);
|
||||
|
|
|
@ -1389,10 +1389,13 @@ void GL_BuildPolygonFromSurface(msurface_t *fa)
|
|||
vec = currentmodel->vertexes[r_pedge->v[1]].position;
|
||||
}
|
||||
s = DotProduct (vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3];
|
||||
s /= fa->texinfo->image->width;
|
||||
if(fa->texinfo->size[0] != -1) s /= fa->texinfo->size[0];
|
||||
else s /= fa->texinfo->image->width;
|
||||
|
||||
t = DotProduct (vec, fa->texinfo->vecs[1]) + fa->texinfo->vecs[1][3];
|
||||
t /= fa->texinfo->image->height;
|
||||
if(fa->texinfo->size[1] != -1) t /= fa->texinfo->size[1];
|
||||
else t /= fa->texinfo->image->height;
|
||||
|
||||
|
||||
VectorAdd (total, vec, total);
|
||||
VectorCopy (vec, poly->verts[i]);
|
||||
|
|
Reference in New Issue