/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


#ifndef	__NBULLETDEBUG__
#define	__NBULLETDEBUG__


        #include "btBulletDynamicsCommon.h"
		#include "color/color.h"
		#include "math/vector.h"
		#include "container/narray.h"


namespace GS {
	namespace Core { class Camera; }

	namespace Render {
		class Renderer;
		class RasterFont;
	}
	namespace S3D {
		using Render::Renderer;
		using Render::RasterFont;
		using Core::Camera;

/*!
	@short	Bullet debug interface.
*/
class	BulletDebugDraw : public btIDebugDraw
{
		friend class BulletWorld;

protected:

		Renderer	&renderer;

		Camera		*camera;
		RasterFont	*raster_font;

		int			debug_mode;

		Array <Vector4> vtx_cache;
		Array <Color> col_cache;
		uint		line_count;

		bool		xray_first_pass;

public:

		float		GetXRayAlpha() const;
		void		SetXRayFirstPass(bool pass);

		void		SetDebugMode(int mode) { debug_mode = mode; }

		void 		drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color);
		void 		drawContactPoint(const btVector3 &PointOnB, const btVector3 &normalOnB, btScalar distance, int lifeTime, const btVector3 &color);
		void 		reportErrorWarning(const char *warningString);
		void 		draw3dText(const btVector3 &location, const char *textString);

		void 		setDebugMode(int mode) { debug_mode = mode; }
		int 		getDebugMode() const { return debug_mode; }

		void		Flush();

		BulletDebugDraw(Renderer &);
};

	} // S3D
} // GS


#endif	// __NBULLETDEBUG__
