29 #include "../../../idlib/precompiled.h"
53 #define MAX_BUILD_SIDES 300
55 static int entityPrimitive;
56 static int c_numMapPatches;
57 static int c_areaportals;
66 #define NORMAL_EPSILON 0.00001f
67 #define DIST_EPSILON 0.01f
78 if ( fixed && fixedDegeneracies ) {
79 *fixedDegeneracies =
true;
92 static void SetBrushContents(
uBrush_t *
b ) {
107 for ( i=1 ; i<b->
numsides ; i++, s++ ) {
115 if (c2 != contents) {
140 static void FreeBuildBrush(
void ) {
143 for ( i = 0 ; i < buildBrush->
numsides ; i++ ) {
159 static uBrush_t *FinishBrush(
void ) {
172 common->
Printf(
"Entity %i, Brush %i: areaportals only allowed in world\n"
190 memset( prim, 0,
sizeof( *prim ) );
204 static void AdjustEntityForOrigin(
uEntity_t *ent ) {
215 for ( i = 0; i < b->
numsides; i++ ) {
245 static bool RemoveDuplicateBrushPlanes(
uBrush_t * b ) {
251 for ( i = 1 ; i < b->
numsides ; i++ ) {
254 if ( sides[i].planenum == -1) {
255 common->
Printf(
"Entity %i, Brush %i: degenerate plane\n"
258 for ( k = i + 1 ; k < b->
numsides ; k++ ) {
259 sides[k-1] = sides[k];
267 for ( j = 0 ; j <
i ; j++ ) {
268 if ( sides[i].planenum == sides[j].planenum ) {
272 for ( k = i + 1 ; k < b->
numsides ; k++ ) {
273 sides[k-1] = sides[k];
280 if ( sides[i].planenum == (sides[j].planenum ^ 1) ) {
297 static void ParseBrush(
const idMapBrush *mapBrush,
int primitiveNum ) {
302 bool fixedDegeneracies =
false;
305 buildBrush->
brushnum = entityPrimitive;
307 for ( i = 0 ; i < mapBrush->
GetNumSides() ; i++ ) {
308 s = &buildBrush->
sides[
i];
311 memset( s, 0,
sizeof( *s ) );
321 if ( !RemoveDuplicateBrushPlanes( buildBrush ) ) {
326 SetBrushContents( buildBrush );
334 common->
Warning(
"brush %d has degenerate plane equations", primitiveNum );
349 memset( prim, 0,
sizeof( *prim ) );
355 tri->
v[2] = (*surface)[surface->
GetIndexes()[i+0]];
356 tri->
v[1] = (*surface)[surface->
GetIndexes()[i+2]];
357 tri->
v[0] = (*surface)[surface->
GetIndexes()[i+1]];
366 for ( tri = prim->
tris ; tri ; tri = tri->
next ) {
377 static void ParsePatch(
const idMapPatch *patch,
int primitiveNum ) {
396 ParseSurface( patch, cp, mat );
406 static bool ProcessMapEntity(
idMapEntity *mapEnt ) {
410 memset( uEntity, 0,
sizeof(*uEntity) );
414 for ( entityPrimitive = 0; entityPrimitive < mapEnt->
GetNumPrimitives(); entityPrimitive++ ) {
418 ParseBrush( static_cast<idMapBrush*>(prim), entityPrimitive );
421 ParsePatch( static_cast<idMapPatch*>(prim), entityPrimitive );
441 static void CreateMapLight(
const idMapEntity *mapEnt ) {
455 light->
name[0] =
'\0';
471 if ( !light->
name[0] ) {
472 common->
Error(
"Light at (%f,%f,%f) didn't have a name",
479 light->lightShader = light->parms.shader;
492 static void CreateMapLights(
const idMapFile *dmapFile ) {
501 CreateMapLight( mapEnt );
516 int brushes, triSurfs;
562 }
else if ( prim->
tris ) {
568 common->
Printf(
"%5i total world triSurfs\n", triSurfs );
573 common->
Printf(
"size: %5.0f,%5.0f,%5.0f to %5.0f,%5.0f,%5.0f\n", mapBounds[0][0], mapBounds[0][1],mapBounds[0][2],
574 mapBounds[1][0], mapBounds[1][1], mapBounds[1][2] );
587 for ( ; groups ; groups = next ) {
615 for ( prim = ent->
primitives ; prim ; prim = nextPrim ) {
616 nextPrim = prim->
next;
628 for ( j = 0 ; j < ent->
numAreas ; j++ ) {
const int * GetIndexes(void) const
int GetNumSides(void) const
const idPlane & GetPlane(void) const
bool AddBounds(const idBounds &a)
idMapEntity * GetEntity(int i) const
GLsizei const GLfloat * value
int FindFloatPlane(const idPlane &plane, bool *fixedDegeneracies)
const idVec3 & Normal(void) const
idMapBrushSide * GetSide(int i) const
int GetVertSubdivisions(void) const
bool LoadDMapFile(const char *filename)
idList< mapLight_t * > mapLights
void SetGranularity(int newgranularity)
int GetHorzSubdivisions(void) const
const char * GetMaterial(void) const
virtual const idMaterial * FindMaterial(const char *name, bool makeDefault=true)=0
srfTriangles_t * shadowTris
int Icmp(const char *text) const
void SubdivideExplicit(int horzSubdivisions, int vertSubdivisions, bool genNormals, bool removeLinear=false)
int FindPlane(const idPlane &plane, const float normalEps, const float distEps)
void FreeTriList(mapTri_t *a)
void FreeTree(tree_t *tree)
struct optimizeGroup_s * groups
const idMaterial * material
void FreeOptimizeGroupList(optimizeGroup_t *groups)
materialCoverage_t Coverage(void) const
const float DEFAULT_CURVE_MAX_ERROR
void Subdivide(float maxHorizontalError, float maxVerticalError, float maxLength, bool genNormals=false)
const char * GetString(const char *key, const char *defaultString="") const
uBrush_t * CopyBrush(uBrush_t *brush)
int GetNumEntities(void) const
bool Parse(const char *filename, bool ignoreRegion=false, bool osPath=false)
bool GetBool(const char *key, const char *defaultString="0") const
void FreeBrush(uBrush_t *brushes)
const int GetContentFlags(void) const
idVec3 GetVector(const char *key, const char *defaultString=NULL) const
static void Copynz(char *dest, const char *src, int destsize)
bool GetExplicitlySubdivided(void) const
void DeleteContents(bool clear)
bool CreateBrushWindings(uBrush_t *brush)
void GetTextureVectors(idVec4 v[2]) const
virtual void Printf(const char *fmt,...) id_attribute((format(printf
mapTri_t * AllocTri(void)
idDeclManager * declManager
int Append(const type &obj)
struct primitive_s * next
uBrush_t * AllocBrush(int numsides)
void R_RenderLightFrustum(const struct renderLight_s &renderLight, idPlane lightFrustum[6])
idMapPrimitive * GetPrimitive(int i) const
struct bspbrush_s * original
const idMaterial * contentShader
const idMaterial * material
void R_DeriveLightData(idRenderLightLocal *light)
const float DEFAULT_CURVE_MAX_LENGTH
struct optimizeGroup_s * nextGroup
const char * GetMaterial(void) const
virtual void ParseSpawnArgsToRenderLight(const idDict *args, renderLight_t *renderLight)
void * Mem_Alloc(const int size)
struct bspbrush_s * brush
bool FixDegeneracies(float distEpsilon)
dmapGlobals_t dmapGlobals
virtual void Error(const char *fmt,...) id_attribute((format(printf
bool IsDiscrete(void) const
int GetNumPrimitives(void) const
void R_FreeLightDefDerivedData(idRenderLightLocal *ldef)
virtual void virtual void Warning(const char *fmt,...) id_attribute((format(printf
int GetNumIndexes(void) const