Fixed index calculation bug in Anvil composite arrays.

This commit is contained in:
Justin Aquadro 2012-09-09 14:36:38 -04:00
parent aed388dd80
commit 81920ef73d
2 changed files with 4 additions and 2 deletions

View file

@ -63,7 +63,7 @@ namespace Substrate.Core
{
int ydiv = y / _sections[0].YDim;
int yrem = y - (ydiv * _sections[0].YDim);
return ydiv * _sections[ydiv].GetIndex(x, yrem, z);
return (ydiv * _sections[0].Length) + _sections[ydiv].GetIndex(x, yrem, z);
}
public void GetMultiIndex (int index, out int x, out int y, out int z)
@ -71,6 +71,7 @@ namespace Substrate.Core
int idiv = index / _sections[0].Length;
int irem = index - (idiv * _sections[0].Length);
_sections[idiv].GetMultiIndex(irem, out x, out y, out z);
y += idiv * _sections[0].YDim;
}
#endregion

View file

@ -63,7 +63,7 @@ namespace Substrate.Core
{
int ydiv = y / _sections[0].YDim;
int yrem = y - (ydiv * _sections[0].YDim);
return ydiv * _sections[ydiv].GetIndex(x, yrem, z);
return (ydiv * _sections[0].Length) + _sections[ydiv].GetIndex(x, yrem, z);
}
public void GetMultiIndex (int index, out int x, out int y, out int z)
@ -71,6 +71,7 @@ namespace Substrate.Core
int idiv = index / _sections[0].Length;
int irem = index - (idiv * _sections[0].Length);
_sections[idiv].GetMultiIndex(irem, out x, out y, out z);
y += idiv * _sections[0].YDim;
}
#endregion