public void DoWork() { // Can't Load A Null Region if (region == null) { return; } // TODO: Load A Region // TODO: Generate A Region Correctly Random r = new Random(); // Surface Blocks Vector3I v = Vector3I.Zero; for (v.Z = 0; v.Z < Region.DEPTH; v.Z++) { for (v.X = 0; v.X < Region.WIDTH; v.X++) { for (v.Y = 0; v.Y < Region.HEIGHT / 2; v.Y++) { region.SetVoxel(v.X, v.Y, v.Z, 1); } } } // Place It In The World Now region.LoadComplete(); if (!region.World.PlaceRegion(region)) { return; } // Faces Need To Be Calculated region.NotifyFacesChanged(); // Check For Neighboring Regions int rx = region.loc.X; int rz = region.loc.Y; if (region.rNX != null) { region.rNX.NotifyFacesChanged(); } //else region.World.state.AddEvent(new VEWorldMod(rx - 1, rz, VEWMType.RegionAdd)); if (region.rPX != null) { region.rPX.NotifyFacesChanged(); } //else region.World.state.AddEvent(new VEWorldMod(rx + 1, rz, VEWMType.RegionAdd)); if (region.rNZ != null) { region.rNZ.NotifyFacesChanged(); } //else region.World.state.AddEvent(new VEWorldMod(rx, rz - 1, VEWMType.RegionAdd)); if (region.rPZ != null) { region.rPZ.NotifyFacesChanged(); } //else region.World.state.AddEvent(new VEWorldMod(rx, rz + 1, VEWMType.RegionAdd)); }
public void AddVoxel(int x, int y, int z, ushort id) { // Check If A Voxel Exists There int i = ToIndex(x, y, z); if (voxels[i].ID == id) { return; } // Set The Voxel To Be Empty bool change = Flags.HasSomeFlags(voxels[i].Flags, Voxel.FACE_MASK); voxels[i].ID = id; voxels[i].Flags = 0x00; // TODO: Check Surrounding Faces if (x < WIDTH - 1) { change |= RecalculateSeams(i + 1, i, Voxel.FACE_NX); } if (x > 0) { change |= RecalculateSeams(i - 1, i, Voxel.FACE_PX); } if (z < DEPTH - 1) { change |= RecalculateSeams(i + WIDTH, i, Voxel.FACE_NZ); } if (z > 0) { change |= RecalculateSeams(i - WIDTH, i, Voxel.FACE_PZ); } if (y < HEIGHT - 1) { change |= RecalculateSeams(i + PLANE_SIZE, i, Voxel.FACE_NY); } if (y > 0) { change |= RecalculateSeams(i - PLANE_SIZE, i, Voxel.FACE_PY); } // TODO: Send Update To Neighboring Regions if (x == 0 && rNX != null) { rNX.NotifyFacesChanged(); } else if (x == Region.WIDTH - 1 && rPX != null) { rPX.NotifyFacesChanged(); } if (z == 0 && rNZ != null) { rNZ.NotifyFacesChanged(); } else if (z == Region.DEPTH - 1 && rPZ != null) { rPZ.NotifyFacesChanged(); } // TODO: Use The Change NotifyFacesChanged(); }