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

#pragma once

#include "glmSDKAPI.h"
#include "glmPathDefinitions.h"
#include <glmVector2.h>
#include <glmVector3.h>
#include <glmTypes.h>
#include <glmConvexPolygon2.h>

namespace glm
{
	class NavigationData;

	/**
	* \brief Velocity model based on a collection of avaiable motions.
	*
	* \ingroup VelocityModel
	*
	* \author Golaem <dev@golaem.com>
	*/
	class GLM_SDK_API VelocityModel
	{
	public:

		GLM_CLASS_STAT_ID( glm::MemoryStatIds::Simulation);

		VelocityModel();
		virtual ~VelocityModel();

		bool isVelocityValid(float dt, const Vector2 & velocity, const Vector2& currentVelocity, const Vector2& orientationCosSinCached) const;
		bool adaptVelocity(float dt, Vector2 & velocity, const Vector2& currentVelocity, const Vector2& orientationCosSinCached) const;
		void adaptAngularVelocity(Angle& angularVelocity, float maxAngularSpeed) const;

		void init(float comfortSpeed, float maxAcceleration);

		// For debug purpose, compute the geometry if the limit of the velocity model
		void computeGeometry(glm::Array< glm::Vector3 >& geometry, float speed) const;
		
	private:

		//GLM_DISALLOW_COPY_AND_ASSIGN(VelocityModel);
		float _maxAcceleration;
		float _comfortSpeed;
		Time _meanUpdateTime;
		ConvexPolygon2 _validVelocitiesConvexHull;
	};
}
