13 Dec 2012
This commit is contained in:
parent
99a93de377
commit
eaca5b484c
|
@ -28,6 +28,7 @@ BRUSH MODELS
|
|||
// header
|
||||
#define Q1BSP_VERSION 29 // quake1 regular version (beta is 28)
|
||||
#define HLBSP_VERSION 30 // half-life regular version
|
||||
#define XTBSP_VERSION 31 // extended lightmaps and clipnodes limit
|
||||
|
||||
// worldcraft predefined angles
|
||||
#define ANGLE_UP -1
|
||||
|
@ -50,7 +51,6 @@ BRUSH MODELS
|
|||
|
||||
// lightstyle management
|
||||
#define LM_STYLES 4 // MAXLIGHTMAPS
|
||||
#define LM_SAMPLE_SIZE 16 // lightmap resoultion
|
||||
#define LS_NORMAL 0x00
|
||||
#define LS_UNUSED 0xFE
|
||||
#define LS_NONE 0xFF
|
||||
|
@ -70,9 +70,9 @@ BRUSH MODELS
|
|||
#define MAX_MAP_EDGES 0x100000 // can be increased but not needed
|
||||
#define MAX_MAP_SURFEDGES 0x200000 // can be increased but not needed
|
||||
#define MAX_MAP_TEXTURES 2048 // can be increased but not needed
|
||||
#define MAX_MAP_MIPTEX 0x800000 // 8 Mb internal textures data
|
||||
#define MAX_MAP_LIGHTING 0x800000 // 8 Mb lightmap raw data (can contain bumpdata too)
|
||||
#define MAX_MAP_VISIBILITY 0x400000 // 4 Mb visdata
|
||||
#define MAX_MAP_MIPTEX 0x2000000 // 32 Mb internal textures data
|
||||
#define MAX_MAP_LIGHTING 0x2000000 // 32 Mb lightmap raw data (can contain bumpdata too)
|
||||
#define MAX_MAP_VISIBILITY 0x800000 // 8 Mb visdata
|
||||
|
||||
// quake lump ordering
|
||||
#define LUMP_ENTITIES 0
|
||||
|
@ -92,6 +92,10 @@ BRUSH MODELS
|
|||
#define LUMP_MODELS 14 // internal submodels
|
||||
#define HEADER_LUMPS 15
|
||||
|
||||
// version 31
|
||||
#define LUMP_CLIPNODES2 15 // hull0 goes into LUMP_NODES, hull1 goes into LUMP_CLIPNODES
|
||||
#define LUMP_CLIPNODES3 16 // , hull2 goes into LUMP_CLIPNODES2, hull3 goes into LUMP_CLIPNODES3
|
||||
|
||||
// texture flags
|
||||
#define TEX_SPECIAL BIT( 0 ) // sky or slime, no lightmap or 256 subdivision
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ static gltexture_t r_textures[MAX_TEXTURES];
|
|||
static gltexture_t *r_texturesHashTable[TEXTURES_HASH_SIZE];
|
||||
static int r_numTextures;
|
||||
static byte *scaledImage = NULL; // pointer to a scaled image
|
||||
static byte data2D[256*256*4]; // intermediate texbuffer
|
||||
static byte data2D[512*512*4]; // intermediate texbuffer
|
||||
static rgbdata_t r_image; // generic pixelbuffer used for internal textures
|
||||
|
||||
// internal tables
|
||||
|
|
|
@ -280,16 +280,16 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, const vec3
|
|||
if(( s < 0 || s > surf->extents[0] ) || ( t < 0 || t > surf->extents[1] ))
|
||||
continue;
|
||||
|
||||
s >>= 4;
|
||||
t >>= 4;
|
||||
s /= LM_SAMPLE_SIZE;
|
||||
t /= LM_SAMPLE_SIZE;
|
||||
|
||||
if( !surf->samples )
|
||||
return true;
|
||||
|
||||
VectorClear( r_pointColor );
|
||||
|
||||
lm = surf->samples + (t * ((surf->extents[0] >> 4) + 1) + s);
|
||||
size = ((surf->extents[0] >> 4) + 1) * ((surf->extents[1] >> 4) + 1);
|
||||
lm = surf->samples + (t * ((surf->extents[0] / LM_SAMPLE_SIZE) + 1) + s);
|
||||
size = ((surf->extents[0] / LM_SAMPLE_SIZE) + 1) * ((surf->extents[1] / LM_SAMPLE_SIZE) + 1);
|
||||
|
||||
for( map = 0; map < MAXLIGHTMAPS && surf->styles[map] != 255; map++ )
|
||||
{
|
||||
|
|
|
@ -182,13 +182,13 @@ static void SubdividePolygon_r( msurface_t *warpface, int numverts, float *verts
|
|||
s = DotProduct( verts, warpface->texinfo->vecs[0] ) + warpface->texinfo->vecs[0][3];
|
||||
s -= warpface->texturemins[0];
|
||||
s += warpface->light_s * LM_SAMPLE_SIZE;
|
||||
s += 8;
|
||||
s += LM_SAMPLE_SIZE >> 1;
|
||||
s /= BLOCK_WIDTH * LM_SAMPLE_SIZE; //fa->texinfo->texture->width;
|
||||
|
||||
t = DotProduct( verts, warpface->texinfo->vecs[1] ) + warpface->texinfo->vecs[1][3];
|
||||
t -= warpface->texturemins[1];
|
||||
t += warpface->light_t * LM_SAMPLE_SIZE;
|
||||
t += 8;
|
||||
t += LM_SAMPLE_SIZE >> 1;
|
||||
t /= BLOCK_HEIGHT * LM_SAMPLE_SIZE; //fa->texinfo->texture->height;
|
||||
|
||||
poly->verts[i+1][5] = s;
|
||||
|
@ -350,13 +350,13 @@ void GL_BuildPolygonFromSurface( model_t *mod, msurface_t *fa )
|
|||
s = DotProduct( vec, fa->texinfo->vecs[0] ) + fa->texinfo->vecs[0][3];
|
||||
s -= fa->texturemins[0];
|
||||
s += fa->light_s * LM_SAMPLE_SIZE;
|
||||
s += 8;
|
||||
s += LM_SAMPLE_SIZE >> 1;
|
||||
s /= BLOCK_WIDTH * LM_SAMPLE_SIZE; //fa->texinfo->texture->width;
|
||||
|
||||
t = DotProduct( vec, fa->texinfo->vecs[1] ) + fa->texinfo->vecs[1][3];
|
||||
t -= fa->texturemins[1];
|
||||
t += fa->light_t * LM_SAMPLE_SIZE;
|
||||
t += 8;
|
||||
t += LM_SAMPLE_SIZE >> 1;
|
||||
t /= BLOCK_HEIGHT * LM_SAMPLE_SIZE; //fa->texinfo->texture->height;
|
||||
|
||||
poly->verts[i][5] = s;
|
||||
|
@ -435,8 +435,8 @@ void R_AddDynamicLights( msurface_t *surf )
|
|||
// no dlighted surfaces here
|
||||
if( !R_CountSurfaceDlights( surf )) return;
|
||||
|
||||
smax = (surf->extents[0] >> 4) + 1;
|
||||
tmax = (surf->extents[1] >> 4) + 1;
|
||||
smax = (surf->extents[0] / LM_SAMPLE_SIZE) + 1;
|
||||
tmax = (surf->extents[1] / LM_SAMPLE_SIZE) + 1;
|
||||
tex = surf->texinfo;
|
||||
|
||||
for( lnum = 0; lnum < MAX_DLIGHTS; lnum++ )
|
||||
|
@ -619,8 +619,8 @@ static void R_BuildLightMap( msurface_t *surf, byte *dest, int stride )
|
|||
int i, map, size, s, t;
|
||||
color24 *lm;
|
||||
|
||||
smax = ( surf->extents[0] >> 4 ) + 1;
|
||||
tmax = ( surf->extents[1] >> 4 ) + 1;
|
||||
smax = ( surf->extents[0] / LM_SAMPLE_SIZE ) + 1;
|
||||
tmax = ( surf->extents[1] / LM_SAMPLE_SIZE ) + 1;
|
||||
size = smax * tmax;
|
||||
|
||||
lm = surf->samples;
|
||||
|
@ -839,8 +839,8 @@ void R_BlendLightmaps( void )
|
|||
int smax, tmax;
|
||||
byte *base;
|
||||
|
||||
smax = ( surf->extents[0] >> 4 ) + 1;
|
||||
tmax = ( surf->extents[1] >> 4 ) + 1;
|
||||
smax = ( surf->extents[0] / LM_SAMPLE_SIZE ) + 1;
|
||||
tmax = ( surf->extents[1] / LM_SAMPLE_SIZE ) + 1;
|
||||
info = SURF_INFO( surf, RI.currentmodel );
|
||||
|
||||
if( LM_AllocBlock( smax, tmax, &info->dlight_s, &info->dlight_t ))
|
||||
|
@ -865,8 +865,8 @@ void R_BlendLightmaps( void )
|
|||
info = SURF_INFO( drawsurf, RI.currentmodel );
|
||||
|
||||
DrawGLPolyChain( drawsurf->polys,
|
||||
( drawsurf->light_s - info->dlight_s ) * ( 1.0f / 128.0f ),
|
||||
( drawsurf->light_t - info->dlight_t ) * ( 1.0f / 128.0f ));
|
||||
( drawsurf->light_s - info->dlight_s ) * ( 1.0f / (float)BLOCK_WIDTH ),
|
||||
( drawsurf->light_t - info->dlight_t ) * ( 1.0f / (float)BLOCK_HEIGHT ));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -898,8 +898,8 @@ void R_BlendLightmaps( void )
|
|||
info = SURF_INFO( surf, RI.currentmodel );
|
||||
|
||||
DrawGLPolyChain( surf->polys,
|
||||
( surf->light_s - info->dlight_s ) * ( 1.0f / 128.0f ),
|
||||
( surf->light_t - info->dlight_t ) * ( 1.0f / 128.0f ));
|
||||
( surf->light_s - info->dlight_s ) * ( 1.0f / (float)BLOCK_WIDTH ),
|
||||
( surf->light_t - info->dlight_t ) * ( 1.0f / (float)BLOCK_HEIGHT ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1156,11 +1156,11 @@ dynamic:
|
|||
{
|
||||
if(( fa->styles[maps] >= 32 || fa->styles[maps] == 0 ) && ( fa->dlightframe != tr.framecount ))
|
||||
{
|
||||
byte temp[34*34*4];
|
||||
byte temp[132*132*4];
|
||||
int smax, tmax;
|
||||
|
||||
smax = ( fa->extents[0] >> 4 ) + 1;
|
||||
tmax = ( fa->extents[1] >> 4 ) + 1;
|
||||
smax = ( fa->extents[0] / LM_SAMPLE_SIZE ) + 1;
|
||||
tmax = ( fa->extents[1] / LM_SAMPLE_SIZE ) + 1;
|
||||
|
||||
R_BuildLightMap( fa, temp, smax * 4 );
|
||||
R_SetCacheState( fa );
|
||||
|
@ -1979,8 +1979,8 @@ void GL_CreateSurfaceLightmap( msurface_t *surf )
|
|||
if( surf->flags & SURF_DRAWTILED )
|
||||
return;
|
||||
|
||||
smax = ( surf->extents[0] >> 4 ) + 1;
|
||||
tmax = ( surf->extents[1] >> 4 ) + 1;
|
||||
smax = ( surf->extents[0] / LM_SAMPLE_SIZE ) + 1;
|
||||
tmax = ( surf->extents[1] / LM_SAMPLE_SIZE ) + 1;
|
||||
|
||||
if( !LM_AllocBlock( smax, tmax, &surf->light_s, &surf->light_t ))
|
||||
{
|
||||
|
|
|
@ -2640,7 +2640,7 @@ static void GL_StudioDrawShadow( void )
|
|||
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
pglEnable( GL_BLEND );
|
||||
pglShadeModel( GL_FLAT );
|
||||
shadow_alpha2 = 1.0 - shadow_alpha;
|
||||
shadow_alpha2 = 1.0f - shadow_alpha;
|
||||
|
||||
pglColor4f( 0.0f, 0.0f, 0.0f, shadow_alpha2 );
|
||||
|
||||
|
|
|
@ -491,7 +491,7 @@ void R_InitSky( mip_t *mt, texture_t *tx )
|
|||
// NOTE: imagelib detect miptex version by size
|
||||
// 770 additional bytes is indicated custom palette
|
||||
int size = (int)sizeof( mip_t ) + ((mt->width * mt->height * 85)>>6);
|
||||
if( world.version == HLBSP_VERSION ) size += sizeof( short ) + 768;
|
||||
if( world.version >= HLBSP_VERSION ) size += sizeof( short ) + 768;
|
||||
|
||||
r_sky = FS_LoadImage( texname, (byte *)mt, size );
|
||||
}
|
||||
|
|
|
@ -68,7 +68,6 @@ qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
|
|||
const char *ext = FS_FileExtension( t->filenames[i] );
|
||||
char *ents = NULL, *pfile;
|
||||
qboolean gearbox = false;
|
||||
qboolean xash_ext = false;
|
||||
|
||||
if( Q_stricmp( ext, "bsp" )) continue;
|
||||
Q_strncpy( message, "^1error^7", sizeof( message ));
|
||||
|
@ -77,7 +76,6 @@ qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
|
|||
if( f )
|
||||
{
|
||||
dheader_t *header, tmphdr;
|
||||
int xash_ident;
|
||||
|
||||
Q_memset( &tmphdr, 0, sizeof( tmphdr ));
|
||||
FS_Read( f, &tmphdr, sizeof( tmphdr ));
|
||||
|
@ -88,6 +86,7 @@ qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
|
|||
{
|
||||
case Q1BSP_VERSION:
|
||||
case HLBSP_VERSION:
|
||||
case XTBSP_VERSION:
|
||||
if( header->lumps[LUMP_ENTITIES].fileofs <= 1024 && !(header->lumps[LUMP_ENTITIES].filelen % sizeof(dplane_t)))
|
||||
{
|
||||
lumpofs = header->lumps[LUMP_PLANES].fileofs;
|
||||
|
@ -100,9 +99,6 @@ qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
|
|||
lumplen = header->lumps[LUMP_ENTITIES].filelen;
|
||||
gearbox = false;
|
||||
}
|
||||
FS_Read( f, &xash_ident, sizeof( xash_ident ));
|
||||
if( xash_ident == (('H'<<24)+('S'<<16)+('A'<<8)+'X'))
|
||||
xash_ext = true; // we found extra lumps!
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -151,9 +147,11 @@ qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
|
|||
break;
|
||||
case HLBSP_VERSION:
|
||||
if( gearbox ) Q_strncpy( buf, "Blue-Shift", sizeof( buf ));
|
||||
else if( xash_ext ) Q_strncpy( buf, "Xash3D", sizeof( buf ));
|
||||
else Q_strncpy( buf, "Half-Life", sizeof( buf ));
|
||||
break;
|
||||
case XTBSP_VERSION:
|
||||
Q_strncpy( buf, "Xash3D", sizeof( buf ));
|
||||
break;
|
||||
default: Q_strncpy( buf, "??", sizeof( buf )); break;
|
||||
}
|
||||
Msg( "%16s (%s) ^3%s^7\n", matchbuf, buf, message );
|
||||
|
@ -691,6 +689,7 @@ qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
|
|||
{
|
||||
case Q1BSP_VERSION:
|
||||
case HLBSP_VERSION:
|
||||
case XTBSP_VERSION:
|
||||
header = (dheader_t *)buf;
|
||||
if( header->lumps[LUMP_ENTITIES].fileofs <= 1024 )
|
||||
{
|
||||
|
|
|
@ -237,6 +237,7 @@ qboolean CRC32_MapFile( dword *crcvalue, const char *filename )
|
|||
char buffer[1024];
|
||||
int i, num_bytes, lumplen;
|
||||
qboolean blue_shift = false;
|
||||
int NUM_LUMPS;
|
||||
|
||||
if( !crcvalue ) return false;
|
||||
|
||||
|
@ -260,7 +261,7 @@ qboolean CRC32_MapFile( dword *crcvalue, const char *filename )
|
|||
}
|
||||
|
||||
// invalid version ?
|
||||
if( header.version != Q1BSP_VERSION && header.version != HLBSP_VERSION )
|
||||
if( header.version != Q1BSP_VERSION && header.version != HLBSP_VERSION && header.version != XTBSP_VERSION )
|
||||
{
|
||||
FS_Close( f );
|
||||
return false;
|
||||
|
@ -273,7 +274,11 @@ qboolean CRC32_MapFile( dword *crcvalue, const char *filename )
|
|||
if( header.lumps[LUMP_ENTITIES].fileofs <= 1024 && (header.lumps[LUMP_ENTITIES].filelen % sizeof( dplane_t )) == 0 )
|
||||
blue_shift = true;
|
||||
|
||||
for( i = 0; i < HEADER_LUMPS; i++ )
|
||||
if( header.version == XTBSP_VERSION )
|
||||
NUM_LUMPS = 17; // two extra lumps added
|
||||
else NUM_LUMPS = HEADER_LUMPS;
|
||||
|
||||
for( i = 0; i < NUM_LUMPS; i++ )
|
||||
{
|
||||
if( blue_shift && i == LUMP_PLANES ) continue;
|
||||
else if( i == LUMP_ENTITIES ) continue;
|
||||
|
|
|
@ -37,6 +37,8 @@ GNU General Public License for more details.
|
|||
#define PLATE_HUE_START 160
|
||||
#define PLATE_HUE_END 191
|
||||
|
||||
#define LM_SAMPLE_SIZE world.lm_sample_size// lightmap resoultion
|
||||
|
||||
#define SURF_INFO( surf, mod ) ((mextrasurf_t *)mod->cache.data + (surf - mod->surfaces))
|
||||
#define INFO_SURF( surf, mod ) (mod->surfaces + (surf - (mextrasurf_t *)mod->cache.data))
|
||||
|
||||
|
@ -70,6 +72,7 @@ typedef struct
|
|||
qboolean loading; // true if worldmodel is loading
|
||||
qboolean sky_sphere; // true when quake sky-sphere is used
|
||||
qboolean has_mirrors; // one or more brush models contain reflective textures
|
||||
int lm_sample_size; // defaulting to 16 (BSP31 uses 8)
|
||||
|
||||
vec3_t mins; // real accuracy world bounds
|
||||
vec3_t maxs;
|
||||
|
|
|
@ -140,7 +140,10 @@ void Mod_PrintBSPFileSizes_f( void )
|
|||
totalmemory += Mod_ArrayUsage( "nodes", w->numnodes, MAX_MAP_NODES, sizeof( dnode_t ));
|
||||
totalmemory += Mod_ArrayUsage( "texinfos", w->numtexinfo, MAX_MAP_TEXINFO, sizeof( dtexinfo_t ));
|
||||
totalmemory += Mod_ArrayUsage( "faces", w->numsurfaces, MAX_MAP_FACES, sizeof( dface_t ));
|
||||
totalmemory += Mod_ArrayUsage( "clipnodes", w->numclipnodes, MAX_MAP_CLIPNODES, sizeof( dclipnode_t ));
|
||||
if( world.version == XTBSP_VERSION )
|
||||
totalmemory += Mod_ArrayUsage( "clipnodes", w->numclipnodes, MAX_MAP_CLIPNODES * 3, sizeof( dclipnode_t ));
|
||||
else
|
||||
totalmemory += Mod_ArrayUsage( "clipnodes", w->numclipnodes, MAX_MAP_CLIPNODES, sizeof( dclipnode_t ));
|
||||
totalmemory += Mod_ArrayUsage( "leaves", w->numleafs, MAX_MAP_LEAFS, sizeof( dleaf_t ));
|
||||
totalmemory += Mod_ArrayUsage( "marksurfaces", w->nummarksurfaces, MAX_MAP_MARKSURFACES, sizeof( dmarkface_t ));
|
||||
totalmemory += Mod_ArrayUsage( "surfedges", w->numsurfedges, MAX_MAP_SURFEDGES, sizeof( dsurfedge_t ));
|
||||
|
@ -152,6 +155,7 @@ void Mod_PrintBSPFileSizes_f( void )
|
|||
totalmemory += Mod_GlobUsage( "entdata", world.entdatasize, MAX_MAP_ENTSTRING );
|
||||
|
||||
Msg( "=== Total BSP file data space used: %s ===\n", Q_memprint( totalmemory ));
|
||||
Msg( "World size ( %g %g %g ) units\n", world.size[0], world.size[1], world.size[2] );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -767,7 +771,7 @@ load_wad_textures:
|
|||
// NOTE: imagelib detect miptex version by size
|
||||
// 770 additional bytes is indicated custom palette
|
||||
int size = (int)sizeof( mip_t ) + ((mt->width * mt->height * 85)>>6);
|
||||
if( bmodel_version == HLBSP_VERSION ) size += sizeof( short ) + 768;
|
||||
if( bmodel_version >= HLBSP_VERSION ) size += sizeof( short ) + 768;
|
||||
|
||||
tx->gl_texturenum = GL_LoadTexture( texname, (byte *)mt, size, 0, filter );
|
||||
}
|
||||
|
@ -817,7 +821,7 @@ load_wad_textures:
|
|||
// NOTE: imagelib detect miptex version by size
|
||||
// 770 additional bytes is indicated custom palette
|
||||
int size = (int)sizeof( mip_t ) + ((mt->width * mt->height * 85)>>6);
|
||||
if( bmodel_version == HLBSP_VERSION ) size += sizeof( short ) + 768;
|
||||
if( bmodel_version >= HLBSP_VERSION ) size += sizeof( short ) + 768;
|
||||
|
||||
tx->fb_texturenum = GL_LoadTexture( texname, (byte *)mt, size, TF_NOMIPMAP|TF_MAKELUMA, NULL );
|
||||
}
|
||||
|
@ -1080,6 +1084,7 @@ static void Mod_LoadLighting( const dlump_t *l )
|
|||
}
|
||||
break;
|
||||
case HLBSP_VERSION:
|
||||
case XTBSP_VERSION:
|
||||
// load colored lighting
|
||||
loadmodel->lightdata = Mem_Alloc( loadmodel->mempool, l->filelen );
|
||||
Q_memcpy( loadmodel->lightdata, in, l->filelen );
|
||||
|
@ -1804,7 +1809,7 @@ static void Mod_LoadSurfaces( const dlump_t *l )
|
|||
|
||||
if( loadmodel->lightdata && in->lightofs != -1 )
|
||||
{
|
||||
if( bmodel_version == HLBSP_VERSION )
|
||||
if( bmodel_version >= HLBSP_VERSION )
|
||||
out->samples = loadmodel->lightdata + (in->lightofs / 3);
|
||||
else out->samples = loadmodel->lightdata + in->lightofs;
|
||||
}
|
||||
|
@ -2179,6 +2184,86 @@ static void Mod_LoadClipnodes( const dlump_t *l )
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadClipnodes31
|
||||
=================
|
||||
*/
|
||||
static void Mod_LoadClipnodes31( const dlump_t *l, const dlump_t *l2, const dlump_t *l3 )
|
||||
{
|
||||
dclipnode_t *in, *in2, *in3, *out, *out2, *out3;
|
||||
int i, count, count2, count3;
|
||||
hull_t *hull;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
if( l->filelen % sizeof( *in )) Host_Error( "Mod_LoadClipnodes: funny lump size\n" );
|
||||
count = l->filelen / sizeof( *in );
|
||||
out = Mem_Alloc( loadmodel->mempool, count * sizeof( *out ));
|
||||
|
||||
in2 = (void *)(mod_base + l2->fileofs);
|
||||
if( l2->filelen % sizeof( *in2 )) Host_Error( "Mod_LoadClipnodes2: funny lump size\n" );
|
||||
count2 = l2->filelen / sizeof( *in2 );
|
||||
out2 = Mem_Alloc( loadmodel->mempool, count2 * sizeof( *out2 ));
|
||||
|
||||
in3 = (void *)(mod_base + l3->fileofs);
|
||||
if( l3->filelen % sizeof( *in3 )) Host_Error( "Mod_LoadClipnodes3: funny lump size\n" );
|
||||
count3 = l3->filelen / sizeof( *in3 );
|
||||
out3 = Mem_Alloc( loadmodel->mempool, count3 * sizeof( *out3 ));
|
||||
|
||||
loadmodel->clipnodes = out;
|
||||
loadmodel->numclipnodes = count + count2 + count3;
|
||||
|
||||
// hulls[0] is a point hull, always zeroed
|
||||
|
||||
hull = &loadmodel->hulls[1];
|
||||
hull->clipnodes = out;
|
||||
hull->firstclipnode = 0;
|
||||
hull->lastclipnode = count - 1;
|
||||
hull->planes = loadmodel->planes;
|
||||
VectorCopy( GI->client_mins[1], hull->clip_mins ); // copy human hull
|
||||
VectorCopy( GI->client_maxs[1], hull->clip_maxs );
|
||||
VectorSubtract( hull->clip_maxs, hull->clip_mins, world.hull_sizes[1] );
|
||||
|
||||
hull = &loadmodel->hulls[2];
|
||||
hull->clipnodes = out2;
|
||||
hull->firstclipnode = 0;
|
||||
hull->lastclipnode = count2 - 1;
|
||||
hull->planes = loadmodel->planes;
|
||||
VectorCopy( GI->client_mins[2], hull->clip_mins ); // copy large hull
|
||||
VectorCopy( GI->client_maxs[2], hull->clip_maxs );
|
||||
VectorSubtract( hull->clip_maxs, hull->clip_mins, world.hull_sizes[2] );
|
||||
|
||||
hull = &loadmodel->hulls[3];
|
||||
hull->clipnodes = out3;
|
||||
hull->firstclipnode = 0;
|
||||
hull->lastclipnode = count3 - 1;
|
||||
hull->planes = loadmodel->planes;
|
||||
VectorCopy( GI->client_mins[3], hull->clip_mins ); // copy head hull
|
||||
VectorCopy( GI->client_maxs[3], hull->clip_maxs );
|
||||
VectorSubtract( hull->clip_maxs, hull->clip_mins, world.hull_sizes[3] );
|
||||
|
||||
for( i = 0; i < count; i++, out++, in++ )
|
||||
{
|
||||
out->planenum = in->planenum;
|
||||
out->children[0] = in->children[0];
|
||||
out->children[1] = in->children[1];
|
||||
}
|
||||
|
||||
for( i = 0; i < count2; i++, out2++, in2++ )
|
||||
{
|
||||
out2->planenum = in2->planenum;
|
||||
out2->children[0] = in2->children[0];
|
||||
out2->children[1] = in2->children[1];
|
||||
}
|
||||
|
||||
for( i = 0; i < count3; i++, out3++, in3++ )
|
||||
{
|
||||
out3->planenum = in3->planenum;
|
||||
out3->children[0] = in3->children[0];
|
||||
out3->children[1] = in3->children[1];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_FindModelOrigin
|
||||
|
@ -2449,6 +2534,7 @@ Mod_LoadBrushModel
|
|||
static void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *loaded )
|
||||
{
|
||||
int i, j;
|
||||
int sample_size;
|
||||
char *ents;
|
||||
dheader_t *header;
|
||||
dmodel_t *bm;
|
||||
|
@ -2465,6 +2551,10 @@ static void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *load
|
|||
break;
|
||||
case Q1BSP_VERSION:
|
||||
case HLBSP_VERSION:
|
||||
sample_size = 16;
|
||||
break;
|
||||
case XTBSP_VERSION:
|
||||
sample_size = 8;
|
||||
break;
|
||||
default:
|
||||
MsgDev( D_ERROR, "%s has wrong version number (%i should be %i)", loadmodel->name, i, HLBSP_VERSION );
|
||||
|
@ -2472,7 +2562,17 @@ static void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *load
|
|||
}
|
||||
|
||||
// will be merged later
|
||||
if( world.loading ) world.version = i;
|
||||
if( world.loading )
|
||||
{
|
||||
world.lm_sample_size = sample_size;
|
||||
world.version = i;
|
||||
}
|
||||
else if( world.lm_sample_size != sample_size )
|
||||
{
|
||||
// can't mixing world and bmodels with different sample sizes!
|
||||
MsgDev( D_ERROR, "%s has wrong version number (%i should be %i)", loadmodel->name, i, world.version );
|
||||
return;
|
||||
}
|
||||
bmodel_version = i; // share it
|
||||
|
||||
// swap all the lumps
|
||||
|
@ -2504,7 +2604,10 @@ static void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *load
|
|||
Mod_LoadMarkSurfaces( &header->lumps[LUMP_MARKSURFACES] );
|
||||
Mod_LoadLeafs( &header->lumps[LUMP_LEAFS] );
|
||||
Mod_LoadNodes( &header->lumps[LUMP_NODES] );
|
||||
Mod_LoadClipnodes( &header->lumps[LUMP_CLIPNODES] );
|
||||
|
||||
if( bmodel_version == XTBSP_VERSION )
|
||||
Mod_LoadClipnodes31( &header->lumps[LUMP_CLIPNODES], &header->lumps[LUMP_CLIPNODES2], &header->lumps[LUMP_CLIPNODES3] );
|
||||
else Mod_LoadClipnodes( &header->lumps[LUMP_CLIPNODES] );
|
||||
Mod_LoadSubmodels( &header->lumps[LUMP_MODELS] );
|
||||
|
||||
Mod_MakeHull0 ();
|
||||
|
@ -2521,7 +2624,7 @@ static void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *load
|
|||
for( j = 1; j < MAX_MAP_HULLS; j++ )
|
||||
{
|
||||
mod->hulls[j].firstclipnode = bm->headnode[j];
|
||||
mod->hulls[j].lastclipnode = mod->numclipnodes - 1;
|
||||
// mod->hulls[j].lastclipnode = mod->numclipnodes - 1;
|
||||
}
|
||||
|
||||
mod->firstmodelsurface = bm->firstface;
|
||||
|
@ -2697,6 +2800,7 @@ model_t *Mod_LoadModel( model_t *mod, qboolean crash )
|
|||
break;
|
||||
case Q1BSP_VERSION:
|
||||
case HLBSP_VERSION:
|
||||
case XTBSP_VERSION:
|
||||
Mod_LoadBrushModel( mod, buf, &loaded );
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -90,6 +90,10 @@ typedef struct physics_interface_s
|
|||
void ( *ClipPMoveToEntity)( struct physent_s *pe, const float *start, float *mins, float *maxs, const float *end, struct pmtrace_s *tr );
|
||||
// called at end the frame of SV_Physics call
|
||||
void ( *SV_EndFrame )( void );
|
||||
// called through save\restore process
|
||||
void (*pfnCreateEntitiesInTransitionList)( SAVERESTOREDATA*, int levelMask );
|
||||
// called through save\restore process
|
||||
void (*pfnCreateEntitiesInRestoreList)( SAVERESTOREDATA*, int createPlayers );
|
||||
} physics_interface_t;
|
||||
|
||||
#endif//PHYSINT_H
|
|
@ -605,6 +605,7 @@ void SV_WriteEntityPatch( const char *filename )
|
|||
{
|
||||
case Q1BSP_VERSION:
|
||||
case HLBSP_VERSION:
|
||||
case XTBSP_VERSION:
|
||||
header = (dheader_t *)buf;
|
||||
if( header->lumps[LUMP_ENTITIES].fileofs <= 1024 && (header->lumps[LUMP_ENTITIES].filelen % sizeof( dplane_t )) == 0 )
|
||||
{
|
||||
|
@ -671,6 +672,7 @@ char *SV_ReadEntityScript( const char *filename, int *flags )
|
|||
{
|
||||
case Q1BSP_VERSION:
|
||||
case HLBSP_VERSION:
|
||||
case XTBSP_VERSION:
|
||||
header = (dheader_t *)buf;
|
||||
if( header->lumps[LUMP_ENTITIES].fileofs <= 1024 && (header->lumps[LUMP_ENTITIES].filelen % sizeof( dplane_t )) == 0 )
|
||||
{
|
||||
|
|
|
@ -1544,50 +1544,57 @@ int SV_LoadGameState( char const *level, qboolean createPlayers )
|
|||
SaveRestore_Rebase( pSaveData );
|
||||
|
||||
// create entity list
|
||||
for( i = 0; i < pSaveData->tableCount; i++ )
|
||||
if( svgame.physFuncs.pfnCreateEntitiesInRestoreList != NULL )
|
||||
{
|
||||
pEntInfo = &pSaveData->pTable[i];
|
||||
|
||||
if( pEntInfo->classname != 0 && pEntInfo->size && !( pEntInfo->flags & FENTTABLE_REMOVED ))
|
||||
svgame.physFuncs.pfnCreateEntitiesInRestoreList( pSaveData, createPlayers );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = 0; i < pSaveData->tableCount; i++ )
|
||||
{
|
||||
if( pEntInfo->id == 0 ) // worldspawn
|
||||
pEntInfo = &pSaveData->pTable[i];
|
||||
|
||||
if( pEntInfo->classname != 0 && pEntInfo->size && !( pEntInfo->flags & FENTTABLE_REMOVED ))
|
||||
{
|
||||
ASSERT( i == 0 );
|
||||
|
||||
pent = EDICT_NUM( 0 );
|
||||
|
||||
SV_InitEdict( pent );
|
||||
pent = SV_AllocPrivateData( pent, pEntInfo->classname );
|
||||
}
|
||||
else if(( pEntInfo->id > 0 ) && ( pEntInfo->id < svgame.globals->maxClients + 1 ))
|
||||
{
|
||||
edict_t *ed;
|
||||
|
||||
if(!( pEntInfo->flags & FENTTABLE_PLAYER ))
|
||||
if( pEntInfo->id == 0 ) // worldspawn
|
||||
{
|
||||
MsgDev( D_WARN, "ENTITY IS NOT A PLAYER: %d\n", i );
|
||||
ASSERT( 0 );
|
||||
ASSERT( i == 0 );
|
||||
|
||||
pent = EDICT_NUM( 0 );
|
||||
|
||||
SV_InitEdict( pent );
|
||||
pent = SV_AllocPrivateData( pent, pEntInfo->classname );
|
||||
}
|
||||
|
||||
ed = EDICT_NUM( pEntInfo->id );
|
||||
|
||||
if( ed && createPlayers )
|
||||
else if(( pEntInfo->id > 0 ) && ( pEntInfo->id < svgame.globals->maxClients + 1 ))
|
||||
{
|
||||
ASSERT( ed->free == false );
|
||||
// create the player
|
||||
pent = SV_AllocPrivateData( ed, pEntInfo->classname );
|
||||
edict_t *ed;
|
||||
|
||||
if(!( pEntInfo->flags & FENTTABLE_PLAYER ))
|
||||
{
|
||||
MsgDev( D_WARN, "ENTITY IS NOT A PLAYER: %d\n", i );
|
||||
ASSERT( 0 );
|
||||
}
|
||||
|
||||
ed = EDICT_NUM( pEntInfo->id );
|
||||
|
||||
if( ed && createPlayers )
|
||||
{
|
||||
ASSERT( ed->free == false );
|
||||
// create the player
|
||||
pent = SV_AllocPrivateData( ed, pEntInfo->classname );
|
||||
}
|
||||
else pent = NULL;
|
||||
}
|
||||
else pent = NULL;
|
||||
else
|
||||
{
|
||||
pent = SV_AllocPrivateData( NULL, pEntInfo->classname );
|
||||
}
|
||||
pEntInfo->pent = pent;
|
||||
}
|
||||
else
|
||||
{
|
||||
pent = SV_AllocPrivateData( NULL, pEntInfo->classname );
|
||||
pEntInfo->pent = NULL; // invalid
|
||||
}
|
||||
pEntInfo->pent = pent;
|
||||
}
|
||||
else
|
||||
{
|
||||
pEntInfo->pent = NULL; // invalid
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1656,44 +1663,51 @@ int SV_CreateEntityTransitionList( SAVERESTOREDATA *pSaveData, int levelMask )
|
|||
movedCount = 0;
|
||||
|
||||
// create entity list
|
||||
for( i = 0; i < pSaveData->tableCount; i++ )
|
||||
if( svgame.physFuncs.pfnCreateEntitiesInTransitionList != NULL )
|
||||
{
|
||||
pEntInfo = &pSaveData->pTable[i];
|
||||
pent = NULL;
|
||||
|
||||
if( pEntInfo->size && pEntInfo->id != 0 )
|
||||
svgame.physFuncs.pfnCreateEntitiesInTransitionList( pSaveData, levelMask );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = 0; i < pSaveData->tableCount; i++ )
|
||||
{
|
||||
if( pEntInfo->classname != 0 )
|
||||
pEntInfo = &pSaveData->pTable[i];
|
||||
pent = NULL;
|
||||
|
||||
if( pEntInfo->size && pEntInfo->id != 0 )
|
||||
{
|
||||
active = (pEntInfo->flags & levelMask) ? 1 : 0;
|
||||
|
||||
// spawn players
|
||||
if(( pEntInfo->id > 0) && ( pEntInfo->id < svgame.globals->maxClients + 1 ))
|
||||
if( pEntInfo->classname != 0 )
|
||||
{
|
||||
edict_t *ed = EDICT_NUM( pEntInfo->id );
|
||||
active = (pEntInfo->flags & levelMask) ? 1 : 0;
|
||||
|
||||
if( active && ed && !ed->free )
|
||||
// spawn players
|
||||
if(( pEntInfo->id > 0) && ( pEntInfo->id < svgame.globals->maxClients + 1 ))
|
||||
{
|
||||
if(!( pEntInfo->flags & FENTTABLE_PLAYER ))
|
||||
edict_t *ed = EDICT_NUM( pEntInfo->id );
|
||||
|
||||
if( active && ed && !ed->free )
|
||||
{
|
||||
MsgDev( D_WARN, "ENTITY IS NOT A PLAYER: %d\n", i );
|
||||
ASSERT( 0 );
|
||||
if(!( pEntInfo->flags & FENTTABLE_PLAYER ))
|
||||
{
|
||||
MsgDev( D_WARN, "ENTITY IS NOT A PLAYER: %d\n", i );
|
||||
ASSERT( 0 );
|
||||
}
|
||||
pent = SV_AllocPrivateData( ed, pEntInfo->classname );
|
||||
}
|
||||
pent = SV_AllocPrivateData( ed, pEntInfo->classname );
|
||||
}
|
||||
else if( active )
|
||||
{
|
||||
// create named entity
|
||||
pent = SV_AllocPrivateData( NULL, pEntInfo->classname );
|
||||
}
|
||||
}
|
||||
else if( active )
|
||||
else
|
||||
{
|
||||
// create named entity
|
||||
pent = SV_AllocPrivateData( NULL, pEntInfo->classname );
|
||||
MsgDev( D_WARN, "Entity with data saved, but with no classname\n" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MsgDev( D_WARN, "Entity with data saved, but with no classname\n" );
|
||||
}
|
||||
pEntInfo->pent = pent;
|
||||
}
|
||||
pEntInfo->pent = pent;
|
||||
}
|
||||
|
||||
// re-base the savedata since we re-ordered the entity/table / restore fields
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1508,16 +1508,16 @@ static qboolean SV_RecursiveLightPoint( model_t *model, mnode_t *node, const vec
|
|||
if(( s < 0 || s > surf->extents[0] ) || ( t < 0 || t > surf->extents[1] ))
|
||||
continue;
|
||||
|
||||
s >>= 4;
|
||||
t >>= 4;
|
||||
s /= LM_SAMPLE_SIZE;
|
||||
t /= LM_SAMPLE_SIZE;
|
||||
|
||||
if( !surf->samples )
|
||||
return true;
|
||||
|
||||
VectorClear( sv_pointColor );
|
||||
|
||||
lm = surf->samples + (t * ((surf->extents[0] >> 4) + 1) + s);
|
||||
size = ((surf->extents[0] >> 4) + 1) * ((surf->extents[1] >> 4) + 1);
|
||||
lm = surf->samples + (t * ((surf->extents[0] / LM_SAMPLE_SIZE) + 1) + s);
|
||||
size = ((surf->extents[0] / LM_SAMPLE_SIZE) + 1) * ((surf->extents[1] / LM_SAMPLE_SIZE) + 1);
|
||||
|
||||
for( map = 0; map < MAXLIGHTMAPS && surf->styles[map] != 255; map++ )
|
||||
{
|
||||
|
|
Reference in New Issue