#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef __TOOLS_MULTIPLE_NODES_H
#define __TOOLS_MULTIPLE_NODES_H

#include "Misc/list_tem.hpp"
#include "Core/Asura_Maths.h"

struct TexturingNode;
struct TexturingNodeVertex;
class Tools_UV_Editor;

////////////////////////////////////////////////////////////////////////////////////////
//For working out the connectivity of all the vertices in the selected polygons

class Texturing_Multiple_Nodes
{
	public :
		static void Initialise();
		static void Shutdown();

		static bool DetermineNodesForSelection(Tools_UV_Editor* pxTextureEdit);//calculates all the nodes for the current poly selection
		static void ClearupNodes(Tools_UV_Editor* pxTextureEdit);
		static void ApplyUVCoordinates(Tools_UV_Editor* pxTextureEdit);
		static int GetConnectedNode(int NodeIndex,int ConnectionIndex);//returns -1 if ConnectionIndex is too high
	private :
		static List<TexturingNode*> NodeList;

		static TexturingNode* FindNodeAtLocation(const Asura_Vector_3& pos);
		static TexturingNode* FindNodeForVertex(int module,int poly,int vertex);
		static bool SortOutNodeTiling(Tools_UV_Editor* pxTextureEdit);
};

////////////////////////////////////////////////////////////////////////////////////////

//details of one node 
struct TexturingNode
{
	TexturingNode(const Asura_Vector_3& pos,int index);
	~TexturingNode();

	void AddVertex(int m_index,int p_index,int v_index);
	void AddConnection(TexturingNode* node);
	void ApplyUVCoordinates(const Asura_Vector_2& uv);

	Asura_Vector_3 Position;//position of associated vertex in world coordinates
	int	Index; //index of this node in the NodeList
	List<TexturingNodeVertex*> VertexList; //list of vertices that use this node
	List<TexturingNode*> ConnectionList; //list of connected nodes
};


////////////////////////////////////////////////////////////////////////////////////////

//details of one vertex associated with a node
struct TexturingNodeVertex
{
	TexturingNodeVertex(int m_index,int p_index,int v_index);

	int ModuleIndex;
	int PolyIndex;
	int VertIndex;//index of vertex in polyogon (0 to 3)
};













#endif// __TOOLS_MULTIPLE_NODES_H
