void SpreadMaxByVec(ref bool[] testedIndex, Vector3UInt StartPos, ref Vector3UInt Size, Vector3UInt direction) { bool CanSpread = true; Size += direction; while (CanSpread) { for (uint x = StartPos.X; x <= Size.X && CanSpread; x++) { for (uint y = StartPos.Y; y <= Size.Y && CanSpread; y++) { for (uint z = StartPos.Z; z <= Size.Z && CanSpread; z++) { CanSpread = TestIndexSpread(x, y, z, testedIndex); } } } if (CanSpread) { StartPos += direction; Size += direction; } } Size -= direction; }
Vector3UInt SpreadRectangular(Vector3UInt StartPos, ref bool[] testedIndex) { Vector3UInt Size = new Vector3UInt(StartPos.X, StartPos.Y, StartPos.Z); SpreadMaxByVec(ref testedIndex, StartPos, ref Size, new Vector3UInt(1, 0, 0)); SpreadMaxByVec(ref testedIndex, StartPos, ref Size, new Vector3UInt(0, 1, 0)); SpreadMaxByVec(ref testedIndex, StartPos, ref Size, new Vector3UInt(0, 0, 1)); CheckBool(ref testedIndex, StartPos, Size); Size += new Vector3UInt(1, 1, 1); return(Size - StartPos); }
void CheckBool(ref bool[] testedIndex, Vector3UInt StartPos, Vector3UInt EndPOs) { for (uint x = StartPos.X; x <= EndPOs.X; x++) { for (uint y = StartPos.Y; y <= EndPOs.Y; y++) { for (uint z = StartPos.Z; z <= EndPOs.Z; z++) { testedIndex[x | y << Data.YOffset | z << Data.ZOffset] = true; } } } }