Esempio n. 1
0
/*
============
idAASBuild::LedgeSubdivFlood_r
============
*/
void idAASBuild::LedgeSubdivFlood_r( idBrushBSPNode *node, const idLedge *ledge ) {
	int s1, i;
	idBrushBSPPortal *p1;
	idWinding *w;
	idList<idBrushBSPNode *> nodeList;
	if( node->GetFlags() & NODE_VISITED ) {
		return;
	}
	// if this is not already a ledge area
	if( !( node->GetFlags() & AREA_LEDGE ) ) {
		for( p1 = node->GetPortals(); p1; p1 = p1->Next( s1 ) ) {
			s1 = ( p1->GetNode( 1 ) == node );
			if( !( p1->GetFlags() & FACE_FLOOR ) ) {
				continue;
			}
			// split the area if some part of the floor portal is inside the expanded ledge
			w = ledge->ChopWinding( p1->GetWinding() );
			if( !w ) {
				continue;
			}
			delete w;
			for( i = 0; i < ledge->numSplitPlanes; i++ ) {
				if( node->PlaneSide( ledge->planes[i], 0.1f ) != SIDE_CROSS ) {
					continue;
				}
				if( !node->Split( ledge->planes[i], -1 ) ) {
					continue;
				}
				numLedgeSubdivisions++;
				DisplayRealTimeString( "\r%6d", numLedgeSubdivisions );
				node->GetChild( 0 )->SetFlag( NODE_VISITED );
				LedgeSubdivFlood_r( node->GetChild( 1 ), ledge );
				return;
			}
			node->SetFlag( AREA_LEDGE );
			break;
		}
	}
	node->SetFlag( NODE_VISITED );
	// get all nodes we might need to flood into
	for( p1 = node->GetPortals(); p1; p1 = p1->Next( s1 ) ) {
		s1 = ( p1->GetNode( 1 ) == node );
		if( p1->GetNode( !s1 )->GetContents() & AREACONTENTS_SOLID ) {
			continue;
		}
		// flood through this portal if the portal is partly inside the expanded ledge
		w = ledge->ChopWinding( p1->GetWinding() );
		if( !w ) {
			continue;
		}
		delete w;
		// add to list, cannot flood directly cause portals might be split on the way
		nodeList.Append( p1->GetNode( !s1 ) );
	}
	// flood into other nodes
	for( i = 0; i < nodeList.Num(); i++ ) {
		LedgeSubdivLeafNodes_r( nodeList[i], ledge );
	}
}
Esempio n. 2
0
/*
============
idAASBuild::LedgeSubdivLeafNodes_r

  The node the ledge was originally part of might be split by other ledges.
  Here we recurse down the tree from the original node to find all the new leaf nodes the ledge might be part of.
============
*/
void idAASBuild::LedgeSubdivLeafNodes_r( idBrushBSPNode *node, const idLedge *ledge ) {
	if ( !node ) {
		return;
	}
	if ( !node->GetChild(0) && !node->GetChild(1) ) {
		LedgeSubdivFlood_r( node, ledge );
		return;
	}
	LedgeSubdivLeafNodes_r( node->GetChild(0), ledge );
	LedgeSubdivLeafNodes_r( node->GetChild(1), ledge );
}