diff --git a/SubstrateCS/Source/Core/CompositeByteArray.cs b/SubstrateCS/Source/Core/CompositeByteArray.cs index 3a82b1b..1399ed3 100644 --- a/SubstrateCS/Source/Core/CompositeByteArray.cs +++ b/SubstrateCS/Source/Core/CompositeByteArray.cs @@ -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 diff --git a/SubstrateCS/Source/Core/CompositeNibbleArray.cs b/SubstrateCS/Source/Core/CompositeNibbleArray.cs index 09bc6ea..ca160bb 100644 --- a/SubstrateCS/Source/Core/CompositeNibbleArray.cs +++ b/SubstrateCS/Source/Core/CompositeNibbleArray.cs @@ -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