/***************************************************************************
*                                                                          *
*  Copyright (C) Golaem S.A. - All Rights Reserved.                        *
*                                                                          *
***************************************************************************/

#pragma once

#include "glmSDKAPI.h"
#include <glmAbstractGround.h>

#include <glmVector3.h>
#include <glmArray.h>
#include <glmString.h>
#include <glmCollisionFilter.h>

namespace glm
{
	class PhysicsWorld_PhysX;

	// PhysicsGround : raycast on the physics world
	class GLM_SDK_API PhysicsGround : public AbstractGround
	{
	public:
		GLM_CLASS_STAT_ID( glm::MemoryStatIds::Simulation)

		PhysicsGround();
		virtual	~PhysicsGround(); 

		//************************************************************
		/*! @name Abstract ground inheritance
		*/ //*********************************************************
		//@{	
		virtual void init() {	}
		virtual void update(Time ) {	}
		virtual void finish() {	}
		virtual bool computeProjection(const Vector3& position, const Vector3& upVector, Vector3& groundPosition, Vector3& groundNormal, float height, GroundCellId& cellId, int genericBoneIndex, const void *userPtr) const override;
		virtual void computeGeometry(glm::Array<Triangle3>&, glm::Array<Segment3>&, const Matrix4&) const {	}
		//@}

		//commmon configuration
		CollisionFilter _filter;
		int _projectionMode;
		//raycast mode
		float _raycastLength;
		int _maxTouchesCount;
		//sweep mode


		PhysicsWorld_PhysX* _internalPhysicsWorld_PhysX;

	protected:
		virtual bool computeProjection_raycast(const Vector3& position, const Vector3& upVector, Vector3& groundPosition, Vector3& groundNormal, const void *userPtr) const;
		virtual bool computeProjection_sweep(const Vector3& position, const Vector3& upVector, Vector3& groundPosition, Vector3& groundNormal, int genericBoneIndex, const void *userPtr) const;
	};
}
