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

#pragma once

#include "glmSDKAPI.h"
#include <glmVector3.h>
#include <glmVector3.h>
#include <glmPathDefinitions.h>

namespace glm
{
	class NavigationMesh3;

	class GLM_SDK_API NavigationMeshLocation
	{
		friend class NavigationMesh3;

	public:
		NavigationMeshLocation();

		void setFromLocal(const Vector3& position, const NavigationMeshCellId& cellId);
		void setFromWorld(const NavigationMesh3& navMesh, const Vector3& position, const NavigationMeshCellId& cellId);
		
		bool operator==(const NavigationMeshLocation & other) const;
		bool operator!=(const NavigationMeshLocation & other) const;

		// utilities for backward compat
		bool setLocationFromWorld(const NavigationMesh3* navMesh, const Vector3& position, const Vector3& up, NavigationMeshCellId cellId = -1);
		
		bool isValid() const { return _cellId != -1; }
		void clear() { _cellId = -1; }

		/**
		* \name Accessors
		*/
		//@{
		const Vector3 & getNavigationPositionLocal() const;
		Vector3 getNavigationPositionWorld(const NavigationMesh3& navMesh) const;
		
		inline const NavigationMeshCellId& getCellId() const;

		//inline const NavigationMesh3& getNavigationMesh() const;
		//@}

	private:

		Vector3 _navigationPosition;
		NavigationMeshCellId _cellId;
	};

	//*****************************************************************************
	// NavigationMeshLocation inline definitions
	//*****************************************************************************

	//-----------------------------------------------------------------------------
	inline const Vector3& NavigationMeshLocation::getNavigationPositionLocal() const
	{
		return _navigationPosition;
	}

	//-----------------------------------------------------------------------------
	inline const NavigationMeshCellId& NavigationMeshLocation::getCellId() const
	{
		return _cellId;
	}

	//-----------------------------------------------------------------------------
	inline void NavigationMeshLocation::setFromLocal(const Vector3& position, const NavigationMeshCellId& cellId) 
	{
		_navigationPosition = position;
		_cellId = cellId; 
	}
}
