the decompiler now can convert .map files too

This commit is contained in:
Rudolf Polzer 2010-10-09 19:28:19 +02:00
parent 205771e916
commit 1b73f1f78b
4 changed files with 62 additions and 15 deletions

View File

@ -1430,10 +1430,28 @@ int ScaleBSPMain( int argc, char **argv )
}
/*
PseudoCompileBSP()
a stripped down ProcessModels
*/
void PseudoCompileBSP()
{
// a stripped down ProcessModels
int models;
char modelValue[10];
entity_t *entity;
tree_t *tree;
node_t *node;
brush_t *brush;
side_t *side;
int i;
SetDrawSurfacesBuffer();
mapDrawSurfs = safe_malloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
memset( mapDrawSurfs, 0, sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
numMapDrawSurfs = 0;
BeginBSPFile();
models = 1;
for( mapEntityNum = 0; mapEntityNum < numEntities; mapEntityNum++ )
{
/* get entity */
@ -1441,12 +1459,42 @@ void PseudoCompileBSP()
if( entity->brushes == NULL && entity->patches == NULL )
continue;
if(mapEntityNum != 0)
{
sprintf( modelValue, "*%d", models++);
SetKeyValue(entity, "model", modelValue);
}
/* process the model */
Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels );
BeginModel();
entity>firstDrawSurf = 0;
EmitBrushes(entity->brushes, &entity>firstBrush, &entity>numBrushes );
EndModel(entity, NULL);
entity->firstDrawSurf = numMapDrawSurfs;
node = AllocNode();
node->planenum = PLANENUM_LEAF;
tree = AllocTree();
tree->headnode = node;
/* a minimized ClipSidesIntoTree */
for( brush = entity->brushes; brush; brush = brush->next )
{
/* walk the brush sides */
for( i = 0; i < brush->numsides; i++ )
{
/* get side */
side = &brush->sides[ i ];
if( side->winding == NULL )
continue;
/* save this winding as a visible surface */
DrawSurfaceForSide(entity, brush, side, side->winding);
}
}
FilterDrawsurfsIntoTree(entity, tree);
EmitBrushes(entity->brushes, &entity->firstBrush, &entity->numBrushes );
EndModel(entity, node);
}
}
@ -1530,8 +1578,7 @@ int ConvertBSPMain( int argc, char **argv )
StripExtension(source);
DefaultExtension(source, ".map");
Sys_Printf("Loading %s\n", source);
LoadMapFile(name, qfalse, qtrue);
ParseEntities();
LoadMapFile(source, qfalse, qtrue);
PseudoCompileBSP();
}
else

View File

@ -620,7 +620,7 @@ static void MergeOrigin(entity_t *ent, vec3_t origin)
SetKeyValue(ent, "origin", string);
}
brush_t *FinishBrush( void )
brush_t *FinishBrush( qboolean noCollapseGroups )
{
brush_t *b;
@ -665,7 +665,8 @@ brush_t *FinishBrush( void )
}
/* add bevel planes */
AddBrushBevels();
if(!noCollapseGroups)
AddBrushBevels();
/* keep it */
b = CopyBrush( buildBrush );
@ -1034,7 +1035,7 @@ ParseBrush()
parses a brush out of a map file and sets it up
*/
static void ParseBrush( qboolean onlyLights )
static void ParseBrush( qboolean onlyLights, qboolean noCollapseGroups )
{
brush_t *b;
@ -1081,7 +1082,7 @@ static void ParseBrush( qboolean onlyLights )
}
/* finish the brush */
b = FinishBrush();
b = FinishBrush(noCollapseGroups);
}
@ -1497,7 +1498,7 @@ static qboolean ParseMapEntity( qboolean onlyLights, qboolean noCollapseGroups )
g_bBrushPrimit = BPRIMIT_NEWBRUSHES;
/* parse brush primitive */
ParseBrush( onlyLights );
ParseBrush( onlyLights, noCollapseGroups );
}
else
{
@ -1507,7 +1508,7 @@ static qboolean ParseMapEntity( qboolean onlyLights, qboolean noCollapseGroups )
/* parse old brush format */
UnGetToken();
ParseBrush( onlyLights );
ParseBrush( onlyLights, noCollapseGroups );
}
entitySourceBrushes++;
}

View File

@ -1580,7 +1580,7 @@ void LoadMapFile( char *filename, qboolean onlyLights, qboolean noCollapse
int FindFloatPlane( vec3_t normal, vec_t dist, int numPoints, vec3_t *points );
int PlaneTypeForNormal( vec3_t normal );
void AddBrushBevels( void );
brush_t *FinishBrush( void );
brush_t *FinishBrush(qboolean noCollapseGroups);
/* portals.c */

View File

@ -630,8 +630,7 @@ void EndModel( entity_t *e, node_t *headnode )
/* emit the bsp */
mod = &bspModels[ numBSPModels ];
if(headnode)
EmitDrawNode_r( headnode );
EmitDrawNode_r( headnode );
/* set surfaces and brushes */
mod->numBSPSurfaces = numBSPDrawSurfaces - mod->firstBSPSurface;