
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_CalculateSurfaceReorientationNormal_SphereCache.h
// Author : Will Plano
// Date   : 10/11/2008
//
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
	#pragma once
#endif   // ifdef ASURA_USE_PRAGMA_ONCE

#ifndef __AVP_CALCULATESURFACEREORIENTATIONNORMAL_SPHERECACHE_H__
#define __AVP_CALCULATESURFACEREORIENTATIONNORMAL_SPHERECACHE_H__

////////////////////////////////////////////////////////////////////////////////
// Include files...
////////////////////////////////////////////////////////////////////////////////

#include "Physics/Asura_Physics_EnvironmentCache.h"

#include "Physics/AVP_CalculateSurfaceReorientationNormal.h"

////////////////////////////////////////////////////////////////////////////////
// Forward class declarations...
////////////////////////////////////////////////////////////////////////////////

class Asura_Physics_Tri;

////////////////////////////////////////////////////////////////////////////////
// Class declaration...
////////////////////////////////////////////////////////////////////////////////

class AVP_CalculateSurfaceReorientationNormal_SphereCache : public AVP_CalculateSurfaceReorientationNormal
{
public:
	// Public functions...
	AVP_CalculateSurfaceReorientationNormal_SphereCache(const float fCosLimit, const u_short usPolyFlagsToIgnore);
	//virtual ~AVP_CalculateSurfaceReorientationNormal_SphereCache();

	// Overridden functions...
	virtual void	Update(Asura_Physics_Object& xPhysicsObject, Asura_AVector3_InParam xInputVelocity, Asura_AVector3_InParam xInputNormal);

protected:
	// Protected variables...
	Asura_Physics_EnvironmentCache	m_xEnvironmentCache;	// The environment-cache to use for surface re-orientation.

	float			m_fQueryRadius;			// The radius of the sphere used for the querying of collision polygons.
	float			m_fClosestDistance;
	float			m_fClosestDistanceOfBadNormal;
	Asura_AVector3	m_xQueryCentre;
	Asura_AVector3	m_xClosestNormal;
	Asura_AVector3  m_xPrevNormal;

	// Protected functions...
	void	UpdateNormalForEnvironment( const Asura_Physics_Object& xPhysicsObject, Asura_AVector3_InParam xInputVelocity );
	void	UpdateNormalForObject( const Asura_Physics_Object& xPhysicsObject, Asura_AVector3_InParam xInputVelocity );

	void	UpdateNormalForTriangle( const Asura_Physics_Tri& xTriangle, Asura_AVector3_InParam xInputVelocity );

private:
	// Private typedefs...
	typedef AVP_CalculateSurfaceReorientationNormal PARENT;

	// Private variables...

	// Private functions...
	AVP_CalculateSurfaceReorientationNormal_SphereCache(void);
	AVP_CalculateSurfaceReorientationNormal_SphereCache(const AVP_CalculateSurfaceReorientationNormal_SphereCache& xOther);

	AVP_CalculateSurfaceReorientationNormal_SphereCache&	operator=(const AVP_CalculateSurfaceReorientationNormal_SphereCache& xOther);
};   // End of class 'AVP_CalculateSurfaceReorientationNormal_SphereCache'.


#endif   // ifndef __AVP_CALCULATESURFACEREORIENTATIONNORMAL_SPHERECACHE_H__


/// End of file. ///
