package classes.away3d.graphs.bsp.builder
{
	import classes.away3d.graphs.bsp.builder.BSPCollisionPlaneBuilder;
	import classes.away3d.graphs.bsp.builder.BSPGeometryBuilder;
	import classes.away3d.graphs.bsp.builder.BSPPVSBuilder;
	import classes.away3d.graphs.bsp.builder.BSPPortalBuilder;
	import classes.away3d.graphs.bsp.builder.BSPTJunctionFixer;
	import classes.away3d.graphs.bsp.builder.IBSPBuilder;
	import classes.away3d.graphs.bsp.builder.IBSPPortalProvider;

	public class BSPBuilder
	{
		public static function generateBuilder(fixTJunctions : Boolean = false, buildCollisionPlanes : Boolean = false, buildPVS : Boolean = false) : IBSPBuilder
		{
			var builder : IBSPBuilder = new BSPGeometryBuilder();

			// wrap with builder decorators as necessary
			if (fixTJunctions || buildCollisionPlanes || buildPVS)
				builder = new BSPPortalBuilder(builder);

			if (fixTJunctions)
				builder = new BSPTJunctionFixer(IBSPPortalProvider(builder));

			if (buildCollisionPlanes)
				builder = new BSPCollisionPlaneBuilder(IBSPPortalProvider(builder));

			if (buildPVS)
				builder = new BSPPVSBuilder(IBSPPortalProvider(builder));

			return builder;
		}
	}
}