public void PartitionChunk_MiscTiles() { // Arrange var chunk = ChunkFactory(4, _testMiscTiles); IList <Box2> rects = new List <Box2>(8); // Act GridChunkPartition.PartitionChunk(chunk, ref rects, out var bounds); // Assert Assert.That(rects.Count, Is.EqualTo(5)); // box origin is top left // algorithm goes down columns of array, starting on left side, then moves right, expanding rectangles to the right /* * 0 2 . . * . 2 3 . * . 2 3 4 * 1 2 . . */ Assert.That(rects[0], Is.EqualTo(new Box2(0, 0, 1, 1))); Assert.That(rects[1], Is.EqualTo(new Box2(0, 3, 1, 4))); Assert.That(rects[2], Is.EqualTo(new Box2(1, 0, 2, 4))); Assert.That(rects[3], Is.EqualTo(new Box2(2, 1, 3, 3))); Assert.That(rects[4], Is.EqualTo(new Box2(3, 2, 4, 3))); Assert.That(bounds, Is.EqualTo(new Box2i(0, 0, 4, 4))); }
public void PartitionChunk_JoinTiles() { // Arrange var chunk = ChunkFactory(4, _testJoinTiles); // Act GridChunkPartition.PartitionChunk(chunk, out var bounds); Assert.That(bounds, Is.EqualTo(new Box2i(1, 0, 3, 3))); }
public void PartitionChunk_JoinTiles() { // Arrange var chunk = ChunkFactory(4, _testJoinTiles); IList <Box2> rects = new List <Box2>(16); // Act GridChunkPartition.PartitionChunk(chunk, ref rects, out var bounds); // Assert Assert.That(rects.Count, Is.EqualTo(1)); // box origin is bottom left Assert.That(rects[0], Is.EqualTo(new Box2(1, 0, 3, 3))); Assert.That(bounds, Is.EqualTo(new Box2i(1, 0, 3, 3))); }
public void PartitionChunk_MiscTiles() { // Arrange var chunk = ChunkFactory(4, _testMiscTiles); // Act GridChunkPartition.PartitionChunk(chunk, out var bounds); // box origin is top left // algorithm goes down columns of array, starting on left side, then moves right, expanding rectangles to the right /* * 0 2 . . * . 2 3 . * . 2 3 4 * 1 2 . . */ Assert.That(bounds, Is.EqualTo(new Box2i(0, 0, 4, 4))); }