internal void ApplySpatter(BlockMeshSet blockMeshSet, int block_z) { if (HasSpatter(block_z)) { blockMeshSet.SetSpatterMap(spatterLayers[block_z]); } }
internal void ApplyGrass(BlockMeshSet blockMeshSet, int block_z) { if (HasGrass(block_z)) { blockMeshSet.SetGrassMap(grassSplatLayers[block_z], grassTintLayers[block_z]); } }
internal void ApplyTerrain(BlockMeshSet blockMeshSet, int block_z) { if (!HasTerrain(block_z)) { CreateBlankTerrainTextures(block_z); } blockMeshSet.SetTerrainMap(terrainSplatLayers[block_z], terrainTintLayers[block_z]); }
// Get new meshes from the mesher void FetchNewMeshes() { UnityEngine.Profiling.Profiler.BeginSample("FetchNewMeshes", this); if (mesher.HasNewMeshes) { var newMeshes = mesher.Dequeue().Value; int block_x = newMeshes.location.x / blockSize; int block_y = newMeshes.location.y / blockSize; int block_z = newMeshes.location.z; if (mapMeshes[block_x, block_y, block_z] == null) mapMeshes[block_x, block_y, block_z] = new BlockMeshSet(); var meshSet = mapMeshes[block_x, block_y, block_z]; meshSet.LoadMeshes(newMeshes, string.Format("{0}_{1}_{2}", block_x, block_y, block_z)); if (newMeshes.collisionMesh != null) { if (meshSet.collisionBlocks == null) { meshSet.collisionBlocks = Instantiate(collisionTemplate); meshSet.collisionBlocks.name = string.Format("collisionBlock_{0}_{1}_{2}", block_x, block_y, block_z); meshSet.collisionBlocks.transform.position = DFtoUnityCoord(block_x * blockSize, block_y * blockSize, block_z); meshSet.collisionBlocks.transform.parent = transform; } Mesh collisionMesh = new Mesh(); collisionMesh.name = string.Format("block_collision_{0}_{1}_{2}", block_x, block_y, block_z); newMeshes.collisionMesh.CopyToMesh(collisionMesh); meshSet.collisionBlocks.sharedMesh = collisionMesh; } } UnityEngine.Profiling.Profiler.EndSample(); }