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

#pragma once

#include "glmSDKAPI.h"
#include "glmPathDefinitions.h"

#include <glmMemoryPool.h>
#include <glmMatrix4.h>

namespace glm
{
	class NavigationMesh3;
	class Roadmap;
	class Vector3;

	/** 
	* \brief Defines a spatial environment. 
	*
	* \ingroup SpatialEnvironment
	*
	* \author Golaem <dev@golaem.com>
	*/
	class GLM_SDK_API SpatialEnvironment
	{
	public:

		GLM_CLASS_STAT_ID( glm::MemoryStatIds::Simulation)

		SpatialEnvironment() ;
		~SpatialEnvironment() ;

		/**
		* \brief Check if the spatial environment is empty.
		* \see ISpatialisEmpty
		*/
		bool isEmpty() const;

		/**
		* \brief Computes and returns this spatial environment axis aligned bounding box.
		* \see ISpatialcomputeBoundingBox
		*/
		void computeBoundingBox(Vector3& min, Vector3& max) const;

		/**
		* \brief Erases a cell from the spatial environment
		*/
#if GLM_ROADMAP_ERASE_SUPPORT_ENABLE
		void eraseCell(const NavigationMeshCellId& cellId);
#endif

		/**
		* \brief reserve a temporary buffer to be used while doing a topological query
		* \return A vector where explored node will be marked while parsing topology.
		*/
		glm::PODArray<bool>* reserveBufferForTopologicalQuery() const;

		void releaseBufferForTopologicalQuery(glm::PODArray<bool>*& queryBuffer) const;

		// set a navmesh worldMatrix. the navmesh should have been created with a frozen transform on a single mesh to use this. (Make several ground if needed)
		void setWorldMatrix(const Matrix4& worldMatrix);

		/**
		* \brief The navigation mesh
		*/
		NavigationMesh3* _navigationMesh;

		/**
		* \brief The roadmap
		*/
		Roadmap* _roadmap;

	private:
		GLM_DISALLOW_COPY_AND_ASSIGN(SpatialEnvironment);

		friend class AbstractSpatialEnvironmentCreator;
	} ;
}
