using System;
namespace MeshDecimator.Collections
{
///
/// A collection of UV channels.
///
/// The UV vector type.
internal sealed class UVChannels
{
#region Fields
private ResizableArray[] channels = null;
private TVec[][] channelsData = null;
#endregion
#region Properties
///
/// Gets the channel collection data.
///
public TVec[][] Data
{
get
{
for (int i = 0; i < Mesh.UVChannelCount; i++)
{
if (channels[i] != null)
{
channelsData[i] = channels[i].Data;
}
else
{
channelsData[i] = null;
}
}
return channelsData;
}
}
///
/// Gets or sets a specific channel by index.
///
/// The channel index.
public ResizableArray this[int index]
{
get { return channels[index]; }
set { channels[index] = value; }
}
#endregion
#region Constructor
///
/// Creates a new collection of UV channels.
///
public UVChannels()
{
channels = new ResizableArray[Mesh.UVChannelCount];
channelsData = new TVec[Mesh.UVChannelCount][];
}
#endregion
#region Public Methods
///
/// Resizes all channels at once.
///
/// The new capacity.
/// If exess memory should be trimmed.
public void Resize(int capacity, bool trimExess = false)
{
for (int i = 0; i < Mesh.UVChannelCount; i++)
{
if (channels[i] != null)
{
channels[i].Resize(capacity, trimExess);
}
}
}
#endregion
}
}