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 FinishTasks() { var handler = new RemeshHandler(); var distributor = new Mock <IRemeshDistributor>(); var chunkProperties = new Mock <ChunkProperties>(); var task0 = new Mock <IRemeshTask>(); var task1 = new Mock <IRemeshTask>(); var task2 = new Mock <IRemeshTask>(); distributor.Setup(dis => dis.CreateTasks(chunkProperties.Object, It.IsAny <RemeshTaskStack>())) .Callback <ChunkProperties, RemeshTaskStack>((properties, taskStack) => { taskStack.AddTask(task0.Object); taskStack.AddTask(task1.Object); taskStack.AddTask(task2.Object); }); handler.AddDistributor(distributor.Object); handler.RemeshChunk(chunkProperties.Object); List <RemeshTaskStack> taskStacks = new List <RemeshTaskStack>(); handler.FinishTasks(taskStacks); task0.Verify(t => t.Finish(), Times.Once); task1.Verify(t => t.Finish(), Times.Once); task2.Verify(t => t.Finish(), Times.Once); Assert.AreEqual(1, taskStacks.Count); }
public void Add_Distributor() { var handler = new RemeshHandler(); var distributor = new Mock <IRemeshDistributor>(); var chunkProperties = new Mock <ChunkProperties>(); handler.AddDistributor(distributor.Object); handler.RemeshChunk(chunkProperties.Object); distributor.Verify(dis => dis.CreateTasks(chunkProperties.Object, It.IsAny <RemeshTaskStack>()), Times.Once); }
/// <summary> /// Creates a new block type preview object. /// </summary> /// <param name="blockTypes">The block type list to reference when rendering.</param> public BlockTypesPreview(BlockTypeList blockTypes) { this.blockTypes = blockTypes; EditorUtility.SetCameraAnimateMaterials(previewUtility.camera, true); remeshHandler = new RemeshHandler(); remeshHandler.AddDistributor(new StandardDistributor()); remeshHandler.OnRemeshFinish += OnRemeshFinish; }
/// <summary> /// Called when the BlockWorld behaviour is enabled. /// </summary> private void OnEnable() { var chunkSize = new GridSize(4); var world = new World(chunkSize); var blockList = new BlockTypeList(); var remesh = new RemeshHandler(); var database = new WorldDatabase("/home/thedudefromci/Bones3/TestWorld"); remesh.AddDistributor(new StandardDistributor()); WorldContainer = new WorldContainer(world, remesh, blockList, database); WorldContainer.BlockContainerProvider.OnBlockContainerCreated += OnChunkCreated; WorldContainer.BlockContainerProvider.OnBlockContainerDestroyed += OnChunkDestroyed; WorldContainer.RemeshHandler.OnRemeshFinish += OnRemeshFinished; }
public void ChunkAllAir_GeneratesNoTasks() { // Arrange 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(0, tasks[0].TaskCount); }
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)); }