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() 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(); BeginBSPFile();
models = 1;
for( mapEntityNum = 0; mapEntityNum < numEntities; mapEntityNum++ ) for( mapEntityNum = 0; mapEntityNum < numEntities; mapEntityNum++ )
{ {
/* get entity */ /* get entity */
@ -1441,12 +1459,42 @@ void PseudoCompileBSP()
if( entity->brushes == NULL && entity->patches == NULL ) if( entity->brushes == NULL && entity->patches == NULL )
continue; continue;
if(mapEntityNum != 0)
{
sprintf( modelValue, "*%d", models++);
SetKeyValue(entity, "model", modelValue);
}
/* process the model */ /* process the model */
Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels ); Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels );
BeginModel(); BeginModel();
entity>firstDrawSurf = 0;
EmitBrushes(entity->brushes, &entity>firstBrush, &entity>numBrushes ); entity->firstDrawSurf = numMapDrawSurfs;
EndModel(entity, NULL);
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); StripExtension(source);
DefaultExtension(source, ".map"); DefaultExtension(source, ".map");
Sys_Printf("Loading %s\n", source); Sys_Printf("Loading %s\n", source);
LoadMapFile(name, qfalse, qtrue); LoadMapFile(source, qfalse, qtrue);
ParseEntities();
PseudoCompileBSP(); PseudoCompileBSP();
} }
else else

View File

@ -620,7 +620,7 @@ static void MergeOrigin(entity_t *ent, vec3_t origin)
SetKeyValue(ent, "origin", string); SetKeyValue(ent, "origin", string);
} }
brush_t *FinishBrush( void ) brush_t *FinishBrush( qboolean noCollapseGroups )
{ {
brush_t *b; brush_t *b;
@ -665,6 +665,7 @@ brush_t *FinishBrush( void )
} }
/* add bevel planes */ /* add bevel planes */
if(!noCollapseGroups)
AddBrushBevels(); AddBrushBevels();
/* keep it */ /* keep it */
@ -1034,7 +1035,7 @@ ParseBrush()
parses a brush out of a map file and sets it up 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; brush_t *b;
@ -1081,7 +1082,7 @@ static void ParseBrush( qboolean onlyLights )
} }
/* finish the brush */ /* finish the brush */
b = FinishBrush(); b = FinishBrush(noCollapseGroups);
} }
@ -1497,7 +1498,7 @@ static qboolean ParseMapEntity( qboolean onlyLights, qboolean noCollapseGroups )
g_bBrushPrimit = BPRIMIT_NEWBRUSHES; g_bBrushPrimit = BPRIMIT_NEWBRUSHES;
/* parse brush primitive */ /* parse brush primitive */
ParseBrush( onlyLights ); ParseBrush( onlyLights, noCollapseGroups );
} }
else else
{ {
@ -1507,7 +1508,7 @@ static qboolean ParseMapEntity( qboolean onlyLights, qboolean noCollapseGroups )
/* parse old brush format */ /* parse old brush format */
UnGetToken(); UnGetToken();
ParseBrush( onlyLights ); ParseBrush( onlyLights, noCollapseGroups );
} }
entitySourceBrushes++; 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 FindFloatPlane( vec3_t normal, vec_t dist, int numPoints, vec3_t *points );
int PlaneTypeForNormal( vec3_t normal ); int PlaneTypeForNormal( vec3_t normal );
void AddBrushBevels( void ); void AddBrushBevels( void );
brush_t *FinishBrush( void ); brush_t *FinishBrush(qboolean noCollapseGroups);
/* portals.c */ /* portals.c */

View File

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