//
// Tools_VIPM.h
//
// Created by KOR - 2004-11-04
//
// Copyright (C) 2004 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
	#pragma once
#endif

#ifndef __TOOLS_VIPM_H__
#define __TOOLS_VIPM_H__

#include "Core/Asura_Maths.h"

class Tools_VIPM_Collapse
{
	public:
		
		int VertexToRemove;
		int CollapseToVertex;

		int NumberOfTrisToRemove;
		int RemoveTriangles[50];

		int NumberOfAffectedVertices;
		int AffectedVertices[50];


		float Cost;

};

class Tools_VIPM_Triangle
{
	public:
		int TriangleIndex;
		int Vertex[2];

		Asura_Vector_3 Normal;
};


class Tools_VIPM_Change
{
	public:
		Tools_VIPM_Change(){Index = 0;Original=0;}
		~Tools_VIPM_Change(){delete [] Index;delete [] Original;}

		int NumberOfChanges;

		int* Original;
		int Replacement;

		unsigned short* Index;

		int NumberOfTrianglesRemoved;
		int NumberOfVerticesRemoved;

};

class Tools_VIPM
{
	public:
		Tools_VIPM();
		~Tools_VIPM();
		

		class Asura_Direct3D_CharacterVertex*	VertexList;
		unsigned short*							IndexList;

		int* m_piVertMatch;

		int TotalNumberOfVertices;
		int TotalNumberOfTriangles;
		int NumberOfCollapses;

		int CurrentNumberOfVertices;
		int CurrentNumberOfTriangles;
		int CurrentNumberOfCollapses;

		Tools_VIPM_Change* ChangeList;
	

		void Create(Asura_Direct3D_CharacterVertex* vertices, unsigned short* indices, int numberOfVertices, int numberOfIndices, int* piOutputVertexOrdering = 0, int* piOutputPolygonOrdering = 0);

		void ConstructCollapseList(int* piOutputVertexOrdering, int* piOutputPolygonOrdering);
		bool Tools_VIPM::FindNextCollapse(Tools_VIPM_Collapse& collapse);


		bool UpOneLevel(void);
		bool DownOneLevel(void);

};

#endif//__TOOLS_VIPM_H__
