public void DrawBlock(BlockData data) { _genMesh.ClearAll(); var desc = StaticResources.BlocksInfo.GetBlockDescription(data.Type); var inp = new MesherBlockInput() { Block = data, Lighting = LightInfo.FullLit, Position = Byte3.Zero, Visibility = VisibilityFlags.All }; BlockModelGenerator.AddBlock(_genMesh, desc, ref Offset, ref inp); _renderer.material = VoxelsStatic.Instance.OpaqueMaterial; _genMesh.BakeMesh(); _filter.mesh = _genMesh.Mesh; }
void StartMeshing() { Profiler.BeginSample(string.Format("Chunk Meshing of {0} ", _targetChunk)); Ready = false; var stopwatch = System.Diagnostics.Stopwatch.StartNew(); stopwatch.Start(); if (_targetChunk == null) { return; } _targetChunk.PrepareAsyncMeshing(); var start = Blocks.Count - 1; for (int i = start; i >= 0; i--) { var blockItem = Blocks[i]; var rawPos = blockItem.Position; var pos = _originPos + new Vector3(rawPos.X, rawPos.Y, rawPos.Z); var desc = _library.GetBlockDescription(blockItem.Block.Type); if (desc.IsTranslucent) { BlockModelGenerator.AddBlock(_translucentPassableMesh, desc, ref pos, ref blockItem); } else if (!desc.IsPassable) { BlockModelGenerator.AddBlock(_opaqueCollidedMesh, desc, ref pos, ref blockItem); } else { BlockModelGenerator.AddBlock(_opaquePassableMesh, desc, ref pos, ref blockItem); } } Ready = true; Busy = false; stopwatch.Stop(); Profiler.EndSample(); AddTime(stopwatch.Elapsed.TotalMilliseconds); }