/* 
-------------------------------------------------------------------------------
Author: Mihail Lupu
Description: Overlap uv clusters by centers.
-------------------------------------------------------------------------------
 */
(
	local mainArr = #()
	uvMod = modPanel.getCurrentObject() 
	getSubMode = subobjectLevel
	if getSubMode == 2 then	(
		uvMod.edgeToVertSelect() 
		subobjectLevel = 1
	)
	if getSubMode == 3 then	(
		uvMod.faceToVertSelect() 
		subobjectLevel = 1
	)
	UVsel = uvMod.getSelectedVertices() as array
	filterUV_Verts = #()
	for aa = 1 to UVsel.count do (
		uvMod.selectVerticesByNode #{UVsel[aa]} $
		uvMod.selectElement() 
		element_Verts = uvMod.getSelectedVertices() as array
		appendIfUnique filterUV_Verts (element_Verts[1])
	)		
	for aa = 1 to filterUV_Verts.count do (
		tempArr = #()
		uvMod.selectVerticesByNode #{filterUV_Verts[aa]} $
		uvMod.selectElement() 
		selElement = uvMod.getSelectedVertices() as array

		sumUVpos = 0
		for bb = 1 to selElement.count do (
			vert = selElement[bb]
			selVerts = (uvMod.getVertexPosition 0 vert)
			sumUVpos = sumUVpos + selVerts	
		)
		append tempArr (sumUVpos/selElement.count)
		append tempArr (selElement)
		append mainArr (tempArr )
	)

	UVdestination = 0
	if mainArr.count != 0 then (
		for item in mainArr do ( UVdestination += (item[1]))
		UVdestination = (UVdestination/mainArr.count)
	)

	for item in mainArr do (
		uvMod.selectVerticesByNode #{item[2][1]} $
		uvMod.selectElement() 
		uvMod.MoveSelected (UVdestination - item[1])
	)
	subobjectLevel = getSubMode
)