public override void Execute() { var version = chunk.version; var min = chunk.position.min; var max = chunk.position.max; for (int z = min.z; z <= max.z; z++) { for (int x = min.x; x <= max.x; x++) { for (int y = min.y; y <= max.y; y++) { pos.Set(x, y, z); if (chunk.GetBlockData(pos).IsEmpty()) { render.data[pos.GetIndex()] = false; if ((x & 0xF) == 0) { render.visibleFacing |= 1 << (int)Facing.West; } else if ((x & 0xF) == 0xF) { render.visibleFacing |= 1 << (int)Facing.East; } if ((y & 0xF) == 0) { render.visibleFacing |= 1 << (int)Facing.Down; } else if ((y & 0xF) == 0xF) { render.visibleFacing |= 1 << (int)Facing.Up; } if ((z & 0xF) == 0) { render.visibleFacing |= 1 << (int)Facing.South; } else if ((z & 0xF) == 0xF) { render.visibleFacing |= 1 << (int)Facing.North; } } else { render.data[pos.GetIndex()] = true; render.empty--; } } } } render.visibilityVersion = version; render.calculating = false; }
public override void Execute() { vertices.Clear(); triangles.Clear(); uv.Clear(); var min = chunk.position.min; var max = chunk.position.max; for (int z = min.z; z <= max.z; z++) { for (int x = min.x; x <= max.x; x++) { for (int y = min.y; y <= max.y; y++) { pos.Set(x, y, z); var index = pos.GetIndex(); if (render.data[index]) { byte set = 0; for (Facing facing = Facing.First; facing <= Facing.Last; facing++) { if (facing == Facing.North) { continue; } offset.Set(pos); offset.Add(facing.GetVector()); if (offset.x < min.x || offset.x > max.x || offset.y < min.y || offset.y > max.y || offset.z < min.z || offset.z > max.z) { if (offset.z < 0) { set |= (byte)(1 << (int)facing); } else { if (world.GetBlockData(offset).IsEmpty()) { set |= (byte)(1 << (int)facing); } } } else { if (!render.data[index + DF[(int)facing]]) { set |= (byte)(1 << (int)facing); } } } AddBlock(pos, set); } } } } var e = render.calcMeshProvider.Create(); e.render = render; var v = e.vertices; e.vertices = vertices; vertices = v; var t = e.triangles; e.triangles = triangles; triangles = t; var u = e.uv; e.uv = uv; uv = u; e.Publish(); }