public void SetBlock_GetBlock() { // Arrange var blockType1 = new Mock <IMeshBlockDetails>(); var blockType2 = new Mock <IMeshBlockDetails>(); var blockType3 = new Mock <IMeshBlockDetails>(); var blockPos1 = new BlockPosition(1, 1, 4); var blockPos2 = new BlockPosition(2, 2, 3); var blockPos3 = new BlockPosition(3, 3, 2); var blockPos4 = new BlockPosition(4, 4, 1); var chunkSize = new GridSize(3); var chunkPos = new ChunkPosition(1, 3, 6); var props = new ChunkProperties(); // Act props.Reset(chunkPos, chunkSize); props.SetBlock(blockPos1, blockType1.Object); props.SetBlock(blockPos2, blockType2.Object); props.SetBlock(blockPos3, blockType3.Object); // Assert Assert.AreEqual(blockType1.Object, props.GetBlock(blockPos1)); Assert.AreEqual(blockType2.Object, props.GetBlock(blockPos2)); Assert.AreEqual(blockType3.Object, props.GetBlock(blockPos3)); Assert.AreEqual(null, props.GetBlock(blockPos4)); }
public void TwoInputsMaterials_ThreeOutputTasks() { // Arrange ChunkProperties.SetBlock(Pos(1, 1, 1), NormalBlock); ChunkProperties.SetBlock(Pos(2, 2, 2), NormalBlock); ChunkProperties.SetBlock(Pos(3, 3, 3), NormalBlock); ChunkProperties.SetBlock(Pos(4, 4, 4), NormalBlock); ChunkProperties.SetBlock(Pos(5, 5, 5), DifferentMaterialBlock); ChunkProperties.SetBlock(Pos(6, 6, 6), DifferentMaterialBlock); ChunkProperties.SetBlock(Pos(7, 7, 7), DifferentMaterialBlock); var remeshHandler = new RemeshHandler(); remeshHandler.AddDistributor(new StandardDistributor()); // Act remeshHandler.RemeshChunk(ChunkProperties); List <RemeshTaskStack> tasks = new List <RemeshTaskStack>(); remeshHandler.FinishTasks(tasks); // Assert Assert.AreEqual(1, tasks.Count); Assert.AreEqual(3, tasks[0].TaskCount); Assert.IsInstanceOf <VisualRemeshTask>(tasks[0].GetTask(0)); Assert.IsInstanceOf <VisualRemeshTask>(tasks[0].GetTask(1)); Assert.IsInstanceOf <CollisionRemeshTask>(tasks[0].GetTask(2)); Assert.AreEqual(0, (tasks[0].GetTask(0) as VisualRemeshTask).MaterialID); Assert.AreEqual(1, (tasks[0].GetTask(1) as VisualRemeshTask).MaterialID); }
public void BlockFace_DifferentAtlas_IgnoreQuads() { // Arrange ChunkProperties.SetBlock(Pos(0, 0, 0), NormalBlock); ChunkProperties.SetBlock(Pos(1, 1, 1), DifferentMaterialBlock); // Act var task = new VisualRemeshTask(ChunkProperties, 0); var mesh = task.Finish(); // Assert Assert.AreEqual(24, mesh.Vertices.Count); Assert.AreEqual(24, mesh.Normals.Count); Assert.AreEqual(24, mesh.UVs.Count); Assert.AreEqual(36, mesh.Triangles.Count); }
public void RespectNeighborChunks() { // Arrange ChunkProperties.SetBlock(Pos(-1, 0, 0), NormalBlock); ChunkProperties.SetBlock(Pos(0, 0, 0), NormalBlock); // Act var task = new VisualRemeshTask(ChunkProperties, 0); var mesh = task.Finish(); // Assert Assert.AreEqual(20, mesh.Vertices.Count); Assert.AreEqual(20, mesh.Normals.Count); Assert.AreEqual(20, mesh.UVs.Count); Assert.AreEqual(30, mesh.Triangles.Count); }
public void TwoCubes() { // Arrange ChunkProperties.SetBlock(Pos(0, 0, 0), NormalBlock); ChunkProperties.SetBlock(Pos(0, 1, 0), NormalBlock); // Act var task = new VisualRemeshTask(ChunkProperties, 0); var mesh = task.Finish(); // Assert Assert.AreEqual(24, mesh.Vertices.Count); Assert.AreEqual(24, mesh.Normals.Count); Assert.AreEqual(24, mesh.UVs.Count); Assert.AreEqual(36, mesh.Triangles.Count); }
public void IgnoreNeighborChunks() { // Arrange ChunkProperties.SetBlock(Pos(-1, 0, 0), NormalBlock); ChunkProperties.SetBlock(Pos(0, 0, 0), NormalBlock); // Act var task = new CollisionRemeshTask(ChunkProperties); var mesh = task.Finish(); // Assert Assert.AreEqual(24, mesh.Vertices.Count); Assert.AreEqual(24, mesh.Normals.Count); Assert.AreEqual(0, mesh.UVs.Count); Assert.AreEqual(36, mesh.Triangles.Count); }
public void SetBlock_ResetChunk_GetBlock_ReturnsNull() { // Arrange var blockType = new Mock <IMeshBlockDetails>(); var blockPos = new BlockPosition(1, 1, 4); var chunkSize = new GridSize(3); var chunkPos1 = new ChunkPosition(1, 3, 6); var chunkPos2 = new ChunkPosition(17, -123, 12999); var props = new ChunkProperties(); // Act props.Reset(chunkPos1, chunkSize); props.SetBlock(blockPos, blockType.Object); props.Reset(chunkPos2, chunkSize); // Assert Assert.AreEqual(null, props.GetBlock(blockPos)); }
public void SomeSolid_NoVisible() { // Arrange ChunkProperties.SetBlock(Pos(1, 1, 5), InvisibleBlock); ChunkProperties.SetBlock(Pos(2, 2, 4), InvisibleBlock); ChunkProperties.SetBlock(Pos(3, 3, 3), InvisibleBlock); var remeshHandler = new RemeshHandler(); remeshHandler.AddDistributor(new StandardDistributor()); // Act remeshHandler.RemeshChunk(ChunkProperties); List <RemeshTaskStack> tasks = new List <RemeshTaskStack>(); remeshHandler.FinishTasks(tasks); // Assert Assert.AreEqual(1, tasks.Count); Assert.AreEqual(1, tasks[0].TaskCount); Assert.IsInstanceOf <CollisionRemeshTask>(tasks[0].GetTask(0)); }
public void StandardChunk() { // Arrange ChunkProperties.SetBlock(Pos(4, 4, 5), NormalBlock); ChunkProperties.SetBlock(Pos(4, 5, 5), NormalBlock); ChunkProperties.SetBlock(Pos(5, 5, 5), NormalBlock); var remeshHandler = new RemeshHandler(); remeshHandler.AddDistributor(new StandardDistributor()); // Act remeshHandler.RemeshChunk(ChunkProperties); List <RemeshTaskStack> tasks = new List <RemeshTaskStack>(); remeshHandler.FinishTasks(tasks); // Assert Assert.AreEqual(1, tasks.Count); Assert.AreEqual(2, tasks[0].TaskCount); Assert.IsInstanceOf <VisualRemeshTask>(tasks[0].GetTask(0)); Assert.IsInstanceOf <CollisionRemeshTask>(tasks[0].GetTask(1)); }