


//
// Asura_LightShaft.cpp
//
// Created by Dave Reed - 13/07/2007 
// 
// Copyright (C) 2007 Rebellion, All Rights Reserved.
//
// LightShafts 
//

#include "Core/Asura.h"

#ifdef ASURA_TARGET_SM3

#include "Core/Asura_Mempool.h"
#include "Core/Asura_Maths.h"
#include "SpecialFX/Asura_LightShaft.h"
#include "SpecialFX/Asura_LightShaft_System.h"



void Asura_LightShaft::UpdateBoundingBox(void)
{
	// We create an AABB for the cone by first creating an OBB, then converting it to an AABB.

	// Todo: Create a more optimal AABB. Needs to be fairly quick, though, as BBs will get updated
	// each frame for moving lightshafts (those attached to dynamic lights)

	Asura_Bounding_Box xOBB;

	xOBB.Reset();
	
	Asura_Vector_3 xPoint;

	float afRadii[2]	 = { m_afRadii[0] , m_afRadii[1] };
	float afDistances[2] = { m_afDistances[0] , m_afDistances[1] };

	// Need to take the corona into account in the BB
	if (afRadii[0]<m_fCoronaSize)
	{
		afRadii[0]=m_fCoronaSize;
	}

	if (afDistances[1]<m_fCoronaDepth)
	{
		afDistances[1]=m_fCoronaDepth;
	}

	for(int i=0; i<2; i++)
	{
		xPoint.x = afRadii[i];
		xPoint.y = afRadii[i];
		xPoint.z = afDistances[i];
		xOBB.Set(xPoint);
		xPoint.x = -afRadii[i];
		xPoint.y = -afRadii[i];
		xOBB.Set(xPoint);
	}	

	m_xBB.FromOBB(xOBB,m_xOrient);
	m_xBB.Displace(m_xPos);
}


#endif  //ASURA_TARGET_SM3

