#ifndef BRUSH_H
#define BRUSH_H

#include "tier1/utlvector.h"
#include "rendering.h"
#include "baseentity.h"
#include "physics.h"
#include "mesh.h"

//-----------------------------------------------------------------------------
// Basic triangle structure which is used in brush entities.
//-----------------------------------------------------------------------------
struct Triangle_t
{
	float location[9];
	float uv[6];
	float normal[9];
	uint32_t texture;
};

//-----------------------------------------------------------------------------
// Basic brush entity which has its own geometry defined.
// They have constant position, shape, and rotation, so it makes them 
// non-interactable with the game world in terms of ability to modify it at 
// runtime. Collisions are precise.
//-----------------------------------------------------------------------------
class CBrushEntity: public CBaseEntity
{
public:
	virtual void Precache ( void ) override;
	virtual void Spawn( void ) override;
	virtual void ReadParameter( const char *szName, const char *szValue ) override;
	virtual void Destroy( void ) override;
	virtual void Think( float fDelta ) override;
	
	CUtlVector<Triangle_t> m_mesh;
	Collider *m_collider;
	RigidBodyHandle *m_body;
};

//-----------------------------------------------------------------------------
// Client rendering for brush entitites.
//-----------------------------------------------------------------------------
class C_BrushEntity: public C_BaseEntity
{
public:
	virtual void Precache ( void ) override;
	virtual void Spawn( void ) override;
	virtual void Destroy( void ) override;
	virtual void Think( float fDelta ) override;
private:
	IVertexBuffer *vertexBuffer;
	IIndexBuffer *indexBuffer;
	IMesh *mesh;
};

#endif
