/* version */
-#define Q3MAP_VERSION "2.5.17-div0"
+#ifndef Q3MAP_VERSION
+#error no Q3MAP_VERSION defined
+#endif
#define Q3MAP_MOTD "Your map saw the pretty lights from q3map2's BFG"
+
/* -------------------------------------------------------------------------------
dependencies
/* bsp */
#define MAX_PATCH_SIZE 32
-#define MAX_BRUSH_SIDES 4096
+#define MAX_BRUSH_SIDES 1024
#define MAX_BUILD_SIDES 300
#define MAX_EXPANDED_AXIS 128
#define MAX_PORTALS 32768
#define MAX_SEPERATORS MAX_POINTS_ON_WINDING
-#define MAX_POINTS_ON_FIXED_WINDING 36 /* ydnar: increased this from 12 at the expense of more memory */
+#define MAX_POINTS_ON_FIXED_WINDING 24 /* ydnar: increased this from 12 at the expense of more memory */
#define MAX_PORTALS_ON_LEAF 128
#define GRID_EPSILON 0.0f
#define DEFAULT_LIGHTMAP_SAMPLE_SIZE 16
+#define DEFAULT_LIGHTMAP_MIN_SAMPLE_SIZE 0
#define DEFAULT_LIGHTMAP_SAMPLE_OFFSET 1.0f
#define DEFAULT_SUBDIVIDE_THRESHOLD 1.0f
#define MAX_LIGHTMAP_SHADERS 256
/* ok to increase these at the expense of more memory */
-#define MAX_MAP_MODELS 0x400
-#define MAX_MAP_BRUSHES 0x8000
-#define MAX_MAP_ENTITIES 0x8000 //% 0x800 /* ydnar */
+#define MAX_MAP_ENTITIES 0x1000 //% 0x800 /* ydnar */
#define MAX_MAP_ENTSTRING 0x80000 //% 0x40000 /* ydnar */
-#define MAX_MAP_SHADERS 0x800 //% 0x400 /* ydnar */
#define MAX_MAP_AREAS 0x100 /* MAX_MAP_AREA_BYTES in q_shared must match! */
#define MAX_MAP_FOGS 30 //& 0x100 /* RBSP (32 - world fog - goggles) */
-#define MAX_MAP_PLANES 0x400000 //% 0x20000 /* ydnar for md */
-#define MAX_MAP_NODES 0x20000
-#define MAX_MAP_BRUSHSIDES 0x400000 //% 0x20000 /* ydnar */
#define MAX_MAP_LEAFS 0x20000
-#define MAX_MAP_LEAFFACES 0x100000 //% 0x20000 /* ydnar */
-#define MAX_MAP_LEAFBRUSHES 0x40000
#define MAX_MAP_PORTALS 0x20000
#define MAX_MAP_LIGHTING 0x800000
#define MAX_MAP_LIGHTGRID 0x100000 //% 0x800000 /* ydnar: set to points, not bytes */
-#define MAX_MAP_VISIBILITY 0x800000
+#define MAX_MAP_VISIBILITY 0x200000
#define MAX_MAP_DRAW_SURFS 0x20000
-#define MAX_MAP_DRAW_VERTS 0x80000
#define MAX_MAP_DRAW_INDEXES 0x80000
#define MAX_MAP_ADVERTISEMENTS 30
vec3_t normal;
vec_t dist;
int type;
- struct plane_s *hash_chain;
+ int hash_chain;
}
plane_t;
int mapEntityNum, firstDrawSurf;
int firstBrush, numBrushes; /* only valid during BSP compile */
epair_t *epairs;
+ vec3_t originbrush_origin;
}
entity_t;
typedef struct surfaceInfo_s
{
- bspModel_t *model;
+ int modelindex;
shaderInfo_t *si;
rawLightmap_t *lm;
int parentSurfaceNum, childSurfaceNum;
void FixMetaTJunctions( void );
void SmoothMetaTriangles( void );
void MergeMetaTriangles( void );
+void EmitMetaStats(); // vortex: print meta statistics even in no-verbose mode
/* surface_extra.c */
int GetSurfaceExtraCastShadows( int num );
int GetSurfaceExtraRecvShadows( int num );
int GetSurfaceExtraSampleSize( int num );
+int GetSurfaceExtraMinSampleSize( int num );
float GetSurfaceExtraLongestCurve( int num );
void GetSurfaceExtraLightmapAxis( int num, vec3_t lightmapAxis );
int GetLumpElements( bspHeader_t *header, int lump, int size );
void *GetLump( bspHeader_t *header, int lump );
int CopyLump( bspHeader_t *header, int lump, void *dest, int size );
+int CopyLump_Allocate( bspHeader_t *header, int lump, void **dest, int size, int *allocationVariable );
void AddLump( FILE *file, bspHeader_t *header, int lumpNum, const void *data, int length );
void LoadBSPFile( const char *filename );
void UnparseEntities( void );
void PrintEntity( const entity_t *ent );
void SetKeyValue( entity_t *ent, const char *key, const char *value );
+qboolean KeyExists( const entity_t *ent, const char *key ); /* VorteX: check if key exists */
const char *ValueForKey( const entity_t *ent, const char *key );
int IntForKey( const entity_t *ent, const char *key );
vec_t FloatForKey( const entity_t *ent, const char *key );
void GetVectorForKey( const entity_t *ent, const char *key, vec3_t vec );
entity_t *FindTargetEntity( const char *target );
void GetEntityShadowFlags( const entity_t *ent, const entity_t *ent2, int *castShadows, int *recvShadows );
+void InjectCommandLine(char **argv, int beginArgs, int endArgs);
+
/* bspfile_ibsp.c */
Q_EXTERN qboolean debugSurfaces Q_ASSIGN( qfalse );
Q_EXTERN qboolean debugInset Q_ASSIGN( qfalse );
Q_EXTERN qboolean debugPortals Q_ASSIGN( qfalse );
-
+Q_EXTERN qboolean lightmapTriangleCheck Q_ASSIGN(qfalse);
+Q_EXTERN qboolean lightmapExtraVisClusterNudge Q_ASSIGN(qfalse);
Q_EXTERN double normalEpsilon Q_ASSIGN( 0.00001 );
Q_EXTERN double distanceEpsilon Q_ASSIGN( 0.01 );
Q_EXTERN char outbase[ 32 ];
Q_EXTERN int sampleSize; /* lightmap sample size in units */
+Q_EXTERN int minSampleSize; /* minimum sample size to use at all */
Q_EXTERN int mapEntityNum Q_ASSIGN( 0 );
Q_EXTERN int entitySourceBrushes;
-Q_EXTERN plane_t mapplanes[ MAX_MAP_PLANES ]; /* mapplanes[ num ^ 1 ] will always be the mirror or mapplanes[ num ] */
-Q_EXTERN int nummapplanes; /* nummapplanes will always be even */
+Q_EXTERN plane_t *mapplanes Q_ASSIGN(NULL); /* mapplanes[ num ^ 1 ] will always be the mirror or mapplanes[ num ] */
+Q_EXTERN int nummapplanes Q_ASSIGN(0); /* nummapplanes will always be even */
+Q_EXTERN int allocatedmapplanes Q_ASSIGN(0);
Q_EXTERN int numMapPatches;
Q_EXTERN vec3_t mapMins, mapMaxs;
Q_EXTERN qboolean saveprt;
Q_EXTERN qboolean hint; /* ydnar */
Q_EXTERN char inbase[ MAX_QPATH ];
+Q_EXTERN char globalCelShader[ MAX_QPATH ];
/* other bits */
Q_EXTERN int totalvis;
Q_EXTERN qboolean noStyles Q_ASSIGN( qfalse );
Q_EXTERN int sampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_SAMPLE_SIZE );
+Q_EXTERN int minSampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_MIN_SAMPLE_SIZE );
Q_EXTERN qboolean noVertexLighting Q_ASSIGN( qfalse );
Q_EXTERN qboolean noGridLighting Q_ASSIGN( qfalse );
Q_EXTERN qboolean exportLightmaps Q_ASSIGN( qfalse );
Q_EXTERN qboolean externalLightmaps Q_ASSIGN( qfalse );
Q_EXTERN int lmCustomSize Q_ASSIGN( LIGHTMAP_WIDTH );
+Q_EXTERN char * lmCustomDir Q_ASSIGN( NULL );
Q_EXTERN qboolean dirty Q_ASSIGN( qfalse );
Q_EXTERN qboolean dirtDebug Q_ASSIGN( qfalse );
Q_EXTERN float formFactorValueScale Q_ASSIGN( 3.0f );
Q_EXTERN float linearScale Q_ASSIGN( 1.0f / 8000.0f );
+// for .ase conversion
+Q_EXTERN qboolean shadersAsBitmap Q_ASSIGN( qfalse );
+
Q_EXTERN light_t *lights;
Q_EXTERN int numPointLights;
Q_EXTERN int numSpotLights;
Q_EXTERN entity_t entities[ MAX_MAP_ENTITIES ];
Q_EXTERN int numBSPModels Q_ASSIGN( 0 );
-Q_EXTERN bspModel_t bspModels[ MAX_MAP_MODELS ];
+Q_EXTERN int allocatedBSPModels Q_ASSIGN( 0 );
+Q_EXTERN bspModel_t* bspModels Q_ASSIGN(NULL);
Q_EXTERN int numBSPShaders Q_ASSIGN( 0 );
-Q_EXTERN bspShader_t bspShaders[ MAX_MAP_MODELS ];
+Q_EXTERN int allocatedBSPShaders Q_ASSIGN( 0 );
+Q_EXTERN bspShader_t* bspShaders Q_ASSIGN(0);
Q_EXTERN int bspEntDataSize Q_ASSIGN( 0 );
Q_EXTERN char bspEntData[ MAX_MAP_ENTSTRING ];
Q_EXTERN bspLeaf_t bspLeafs[ MAX_MAP_LEAFS ];
Q_EXTERN int numBSPPlanes Q_ASSIGN( 0 );
-Q_EXTERN bspPlane_t bspPlanes[ MAX_MAP_PLANES ];
+Q_EXTERN int allocatedBSPPlanes Q_ASSIGN(0);
+Q_EXTERN bspPlane_t *bspPlanes;
Q_EXTERN int numBSPNodes Q_ASSIGN( 0 );
-Q_EXTERN bspNode_t bspNodes[ MAX_MAP_NODES ];
+Q_EXTERN int allocatedBSPNodes Q_ASSIGN( 0 );
+Q_EXTERN bspNode_t* bspNodes Q_ASSIGN(NULL);
Q_EXTERN int numBSPLeafSurfaces Q_ASSIGN( 0 );
-Q_EXTERN int bspLeafSurfaces[ MAX_MAP_LEAFFACES ];
+Q_EXTERN int allocatedBSPLeafSurfaces Q_ASSIGN( 0 );
+Q_EXTERN int* bspLeafSurfaces Q_ASSIGN(NULL);
Q_EXTERN int numBSPLeafBrushes Q_ASSIGN( 0 );
-Q_EXTERN int bspLeafBrushes[ MAX_MAP_LEAFBRUSHES ];
+Q_EXTERN int allocatedBSPLeafBrushes Q_ASSIGN( 0 );
+Q_EXTERN int* bspLeafBrushes Q_ASSIGN(NULL);
Q_EXTERN int numBSPBrushes Q_ASSIGN( 0 );
-Q_EXTERN bspBrush_t bspBrushes[ MAX_MAP_BRUSHES ];
+Q_EXTERN int allocatedBSPBrushes Q_ASSIGN( 0 );
+Q_EXTERN bspBrush_t* bspBrushes Q_ASSIGN(NULL);
Q_EXTERN int numBSPBrushSides Q_ASSIGN( 0 );
-Q_EXTERN bspBrushSide_t bspBrushSides[ MAX_MAP_BRUSHSIDES ];
+Q_EXTERN int allocatedBSPBrushSides Q_ASSIGN( 0 );
+Q_EXTERN bspBrushSide_t* bspBrushSides Q_ASSIGN(NULL);
Q_EXTERN int numBSPLightBytes Q_ASSIGN( 0 );
Q_EXTERN byte *bspLightBytes Q_ASSIGN( NULL );
Q_EXTERN int numBSPAds Q_ASSIGN( 0 );
Q_EXTERN bspAdvertisement_t bspAds[ MAX_MAP_ADVERTISEMENTS ];
+#define AUTOEXPAND_BY_REALLOC(ptr, reqitem, allocated, def) \
+ do \
+ { \
+ if(reqitem >= allocated) \
+ { \
+ if(allocated == 0) \
+ allocated = def; \
+ while(reqitem >= allocated && allocated) \
+ allocated *= 2; \
+ if(!allocated || allocated > 2147483647 / sizeof(*ptr)) \
+ { \
+ Error(#ptr " over 2 GB"); \
+ } \
+ ptr = realloc(ptr, sizeof(*ptr) * allocated); \
+ if(!ptr) \
+ Error(#ptr " out of memory"); \
+ } \
+ } \
+ while(0)
+
+#define AUTOEXPAND_BY_REALLOC_BSP(suffix, def) AUTOEXPAND_BY_REALLOC(bsp##suffix, numBSP##suffix, allocatedBSP##suffix, def)
/* end marker */
#endif