/*********************************************************************//**
*		Definice objektu BSPLeaf
*	Tento objekt je list BSP stromu a nebo take Cluster. Vsechny clustery
*	modelu cislo nula, coz jsou staticke steny, maji mezi sebou definovanou
*	viditelnost, takze kazdy vi, jaky uzel muze byt z neho viden cameru.
*                                                                        
*
*	author: Michal Jirous
*	date: 4.2.2009
*	file: level_face.cpp
**********************************************************************/  

#include "level_structs.h"

/** @param bspleaf Uzel bsp stromu definovany bsp souborem, jeho nektere informace se zkopiruji do tohoto BSPLeaf objektu. */
void BSPLeaf::create( const dleaf_t &bspleaf )
{
	contents = bspleaf.contents;

	//proc je v bsp filu bounding box jako integer
	bounds.m_fBounds[MIN_X] = (float)bspleaf.mins[0];
	bounds.m_fBounds[MIN_Y] = (float)bspleaf.mins[1];
	bounds.m_fBounds[MIN_Z] = (float)bspleaf.mins[2];
	bounds.m_fBounds[MAX_X] = (float)bspleaf.maxs[0];
	bounds.m_fBounds[MAX_Y] = (float)bspleaf.maxs[1];
	bounds.m_fBounds[MAX_Z] = (float)bspleaf.maxs[2];

	first_mark_surface = bspleaf.firstmarksurface;
	mark_surfaces_count = bspleaf.nummarksurfaces;
	memcpy( ambient_level, bspleaf.ambient_level, sizeof(ambient_level) );
}

void BSPLeaf::destroy()
{
	if( visible_leafs )
	{
		delete [] visible_leafs;
		visible_leafs = NULL;
		visible_leafs_count = 0;
	}
}

