Exemplo n.º 1
0
/**
 * @sa PruneNodes
 * @brief Will cut solid nodes by recursing down the bsp tree
 */
static void PruneNodes_r (node_t *node)
{
	bspbrush_t *b, *next;

	if (node->planenum == PLANENUM_LEAF)
		return;
	PruneNodes_r(node->children[0]);
	PruneNodes_r(node->children[1]);

	if ((node->children[0]->contentFlags & CONTENTS_SOLID)
	 && (node->children[1]->contentFlags & CONTENTS_SOLID)) {
		if (node->faces)
			Sys_Error("node->faces seperating CONTENTS_SOLID");
		if (node->children[0]->faces || node->children[1]->faces)
			Sys_Error("!node->faces with children");

		/** @todo free stuff */
		node->planenum = PLANENUM_LEAF;
		node->contentFlags = CONTENTS_SOLID;

		if (node->brushlist)
			Sys_Error("PruneNodes: node->brushlist");

		/* combine brush lists */
		node->brushlist = node->children[1]->brushlist;

		for (b = node->children[0]->brushlist; b; b = next) {
			next = b->next;
			b->next = node->brushlist;
			node->brushlist = b;
		}

		c_pruned++;
	}
}
Exemplo n.º 2
0
/*
============
PruneNodes_r
============
*/
void PruneNodes_r (node_t *node)
{
	bspbrush_t		*b, *next;
//	portal_t	*p, *nextp;
//	int			s;

	if (node->planenum == PLANENUM_LEAF)
		return;
	PruneNodes_r (node->children[0]);
	PruneNodes_r (node->children[1]);

	if ( (node->children[0]->contents & CONTENTS_SOLID)
	&& (node->children[1]->contents & CONTENTS_SOLID) )
	{
		if (node->faces)
			Error ("node->faces seperating CONTENTS_SOLID");
		if (node->children[0]->faces || node->children[1]->faces)
			Error ("!node->faces with children");

		// FIXME: free stuff

		node->pruned = true;
		node->planenum = PLANENUM_LEAF;
		node->contents = CONTENTS_SOLID;
		node->detail_seperator = false;

		if (node->brushlist)
			Error ("PruneNodes: node->brushlist");

		// combine brush lists
		node->brushlist = node->children[1]->brushlist;

		for (b=node->children[0]->brushlist ; b ; b=next)
		{
			next = b->next;
			b->next = node->brushlist;
			node->brushlist = b;
		}

		node->children[0]->brushlist = NULL;
		node->children[1]->brushlist = NULL;

		if(node->children[0]->volume != NULL)
		{
			FreeBrush(node->children[0]->volume);
			node->children[0]->volume = NULL;
		}

		if(node->children[1]->volume != NULL)
		{
			FreeBrush(node->children[1]->volume);
			node->children[1]->volume = NULL;
		}

		c_pruned++;
	}
}
Exemplo n.º 3
0
/**
 * @sa PruneNodes_r
 */
void PruneNodes (node_t *node)
{
	Verb_Printf(VERB_EXTRA, "--- PruneNodes ---\n");
	c_pruned = 0;
	PruneNodes_r(node);
	Verb_Printf(VERB_EXTRA, "%5i pruned nodes\n", c_pruned);
}
Exemplo n.º 4
0
void PruneNodes (node_t *node)
{
	qprintf ("--- PruneNodes ---\n");
	c_pruned = 0;
	PruneNodes_r (node);
	qprintf ("%5i pruned nodes\n", c_pruned);
}
Exemplo n.º 5
0
/*
   ============
   PruneNodes_r
   ============
 */
void PruneNodes_r( node_t *node ){
	bspbrush_t      *b, *next;

	if ( node->planenum == PLANENUM_LEAF ) {
		return;
	}
	PruneNodes_r( node->children[0] );
	PruneNodes_r( node->children[1] );

	if ( ( node->children[0]->contents & CONTENTS_SOLID )
		 && ( node->children[1]->contents & CONTENTS_SOLID ) ) {
		if ( node->faces ) {
			Error( "node->faces seperating CONTENTS_SOLID" );
		}
		if ( node->children[0]->faces || node->children[1]->faces ) {
			Error( "!node->faces with children" );
		}

		// FIXME: free stuff
		node->planenum = PLANENUM_LEAF;
		node->contents = CONTENTS_SOLID;
		node->detail_seperator = false;

		if ( node->brushlist ) {
			Error( "PruneNodes: node->brushlist" );
		}

		// combine brush lists
		node->brushlist = node->children[1]->brushlist;

		for ( b = node->children[0]->brushlist ; b ; b = next )
		{
			next = b->next;
			b->next = node->brushlist;
			node->brushlist = b;
		}

		c_pruned++;
	}
}
Exemplo n.º 6
0
/*
====================
WriteOutputNodes
====================
*/
static void WriteOutputNodes( node_t *node ) {
	int		numNodes;

	// prune unneeded nodes and count
	PruneNodes_r( node );
	numNodes = NumberNodes_r( node, 0 );

	// output
	procFile->WriteFloatString( "nodes { /* numNodes = */ %i\n\n", numNodes );
	procFile->WriteFloatString( "/* node format is: ( planeVector ) positiveChild negativeChild */\n" );
	procFile->WriteFloatString( "/* a child number of 0 is an opaque, solid area */\n" );
	procFile->WriteFloatString( "/* negative child numbers are areas: (-1-child) */\n" );

	WriteNode_r( node );

	procFile->WriteFloatString( "}\n\n" );
}
Exemplo n.º 7
0
void PruneNodes( node_t *node ){
	Sys_FPrintf( SYS_VRB, "--- PruneNodes ---\n" );
	c_pruned = 0;
	PruneNodes_r( node );
	Sys_FPrintf( SYS_VRB, "%5i pruned nodes\n", c_pruned );
}