/*
================
idCollisionModelManagerLocal::CountBrushMemory
================
*/
int idCollisionModelManagerLocal::CountBrushMemory( cm_node_t* node ) const
{
	cm_brushRef_t* bref;
	cm_brush_t* b;
	int memory;
	
	memory = 0;
	for( bref = node->brushes; bref; bref = bref->next )
	{
		b = bref->b;
		if( b->checkcount == checkCount )
		{
			continue;
		}
		b->checkcount = checkCount;
		
		memory += sizeof( cm_brush_t ) + ( b->numPlanes - 1 ) * sizeof( b->planes[0] );
	}
	if( node->planeType != -1 )
	{
		memory += CountBrushMemory( node->children[0] );
		memory += CountBrushMemory( node->children[1] );
	}
	return memory;
}
예제 #2
0
/*
================
idCollisionModelManagerLocal::WriteCollisionModel
================
*/
void idCollisionModelManagerLocal::WriteCollisionModel( idFile *fp, cm_model_t *model )
{
	int i, polygonMemory, brushMemory;
	
	fp->WriteFloatString( "collisionModel \"%s\" {\n", model->name.c_str() );
	
	// vertices
	fp->WriteFloatString( "\tvertices { /* numVertices = */ %d\n", model->numVertices );
	
	for( i = 0; i < model->numVertices; i++ )
	{
		fp->WriteFloatString( "\t/* %d */ (%f %f %f)\n", i, model->vertices[i].p[0], model->vertices[i].p[1], model->vertices[i].p[2] );
	}
	fp->WriteFloatString( "\t}\n" );
	
	// edges
	fp->WriteFloatString( "\tedges { /* numEdges = */ %d\n", model->numEdges );
	
	for( i = 0; i < model->numEdges; i++ )
	{
		fp->WriteFloatString( "\t/* %d */ (%d %d) %d %d\n", i, model->edges[i].vertexNum[0], model->edges[i].vertexNum[1], model->edges[i].internal, model->edges[i].numUsers );
	}
	fp->WriteFloatString( "\t}\n" );
	
	// nodes
	fp->WriteFloatString( "\tnodes {\n" );
	WriteNodes( fp, model->node );
	fp->WriteFloatString( "\t}\n" );
	
	// polygons
	checkCount++;
	polygonMemory = CountPolygonMemory( model->node );
	fp->WriteFloatString( "\tpolygons /* polygonMemory = */ %d {\n", polygonMemory );
	checkCount++;
	WritePolygons( fp, model->node );
	fp->WriteFloatString( "\t}\n" );
	
	// brushes
	checkCount++;
	brushMemory = CountBrushMemory( model->node );
	fp->WriteFloatString( "\tbrushes /* brushMemory = */ %d {\n", brushMemory );
	checkCount++;
	WriteBrushes( fp, model->node );
	fp->WriteFloatString( "\t}\n" );
	
	// closing brace
	fp->WriteFloatString( "}\n" );
}