//
// Asura_Mesh_CollMeshGenData.h
//
// Created by Richard Rice - 18/03/2004
// 
// Copyright (C) 2004 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef __ASURA_MESH__COLLMESHGENDATA_H__
#define __ASURA_MESH__COLLMESHGENDATA_H__

#include "Core/Asura_Maths.h"


class Asura_Mesh;
struct Asura_Mesh_CollPolyInfo;
struct Asura_Mesh_CollBoxInfo;




//Extra Asura_Mesh data giving instructions on how the collision mesh should be generated
struct Asura_Mesh_CollMeshGenData
{
	Asura_Mesh_CollMeshGenData();
	~Asura_Mesh_CollMeshGenData();

	//allocate polygon flags array , and initialises them (if not done already)
	void InitialisePolygonArray(const Asura_Mesh* pxMesh);

	//allocates and initialises a collision box , assigning a free group ID
	Asura_Mesh_CollBoxInfo* CreateBox();

	void RemoveUnusedGroups();

	//deal with polygon deletion/craetion/merging etc
	void HandlePolygonConversion(const Asura_Mesh* pxMesh,const int* piPolyConv1=0,const int* piPolyConv2=0);


	////
	int m_iNumberOfPolygons;//has to be the same as in the associated Asura_Mesh...
	Asura_Mesh_CollPolyInfo* m_pxPolygons;

	u_int m_uNumberOfBoxes;
	Asura_Mesh_CollBoxInfo* m_pxBoxes;
};

struct Asura_Mesh_CollPolyInfo
{
	union
	{
		u_short m_usFlags;

		struct
		{
			u_short m_usSpare:15;
			u_short m_bReplaceByBox:1;
		};
	};
	u_short m_usGroupID;//ID of group of polygons this is associated with for replacement by a box etc
};

struct Asura_Mesh_CollBoxInfo
{
	u_int m_uGroupID;
	Asura_Matrix_3x3 m_xOrient;
};


#endif //__ASURA_MESH_COLLMESHGENDATA_H__

