public void Rebuild(GraphicsDevice g) { if (g == null || g.IsDisposed) { return; } GeometricPrimitive primitive = null; if (Debugger.Switches.UseNewVoxelGeoGen) { primitive = Voxels.GeometryBuilder.CreateFromChunk(this, Manager.World); } else { primitive = new VoxelListPrimitive(); (primitive as VoxelListPrimitive).InitializeFromChunk(this, Manager.World); } PrimitiveMutex.WaitOne(); if (Primitive != null) { Primitive.Dispose(); } Primitive = primitive; PrimitiveMutex.ReleaseMutex(); }
public void RecieveNewPrimitive(DwarfTime t) { PrimitiveMutex.WaitOne(); if (NewPrimitiveReceived) { Primitive = NewPrimitive; NewPrimitive = null; NewPrimitiveReceived = false; } PrimitiveMutex.ReleaseMutex(); }
public VoxelChunk(ChunkManager manager, Vector3 origin, GlobalChunkCoordinate id) { ID = id; Origin = origin; Data = VoxelData.Allocate(); Primitive = new VoxelListPrimitive(); Manager = manager; InitializeStatics(); PrimitiveMutex = new Mutex(); DynamicLights = new List <DynamicLight>(); Liquids = new Dictionary <LiquidType, LiquidPrimitive>(); Liquids[LiquidType.Water] = new LiquidPrimitive(LiquidType.Water); Liquids[LiquidType.Lava] = new LiquidPrimitive(LiquidType.Lava); }
public void DiscardPrimitive() { PrimitiveMutex.WaitOne(); if (Primitive != null) { Primitive.Dispose(); } Primitive = null; for (var y = 0; y < VoxelConstants.ChunkSizeY; ++y) { Data.SliceCache[y] = null; MoteRecords[y] = null; } PrimitiveMutex.ReleaseMutex(); }
public void Rebuild(GraphicsDevice g) { if (g == null || g.IsDisposed) { return; } VoxelListPrimitive primitive = new VoxelListPrimitive(); primitive.InitializeFromChunk(this, Manager.World.PlayerFaction.Designations, Manager.World.DesignationDrawer, Manager.World); // TODO: Move to main thread! var changedMessage = new Message(Message.MessageType.OnChunkModified, "Chunk Modified"); foreach (var c in Manager.World.EnumerateIntersectingObjects(GetBoundingBox(), CollisionType.Both)) { c.ReceiveMessageRecursive(changedMessage); } }
public void Rebuild(GraphicsDevice g) { if (g == null || g.IsDisposed) { return; } VoxelListPrimitive primitive = new VoxelListPrimitive(); primitive.InitializeFromChunk(this); var changedMessage = new Message(Message.MessageType.OnChunkModified, "Chunk Modified"); foreach (var c in Manager.World.CollisionManager.EnumerateIntersectingObjects(GetBoundingBox(), CollisionManager.CollisionType.Both).OfType <GameComponent>()) { c.ReceiveMessageRecursive(changedMessage); } }
public void Rebuild(GraphicsDevice g) { if (g == null || g.IsDisposed) { return; } var primitive = new VoxelListPrimitive(); primitive.InitializeFromChunk(this, Manager.World.PersistentData.Designations, Manager.World); PrimitiveMutex.WaitOne(); if (Primitive != null) { Primitive.Dispose(); } Primitive = primitive; PrimitiveMutex.ReleaseMutex(); }
public VoxelChunk(ChunkManager manager, Vector3 origin, int tileSize, Point3 id, int sizeX, int sizeY, int sizeZ) { FirstWaterIter = true; this.sizeX = sizeX; this.sizeY = sizeY; this.sizeZ = sizeZ; ID = id; Origin = origin; Data = AllocateData(sizeX, sizeY, sizeZ); IsVisible = true; ShouldRebuild = true; this.tileSize = tileSize; HalfLength = new Vector3((float) this.tileSize / 2.0f, (float) this.tileSize / 2.0f, (float) this.tileSize / 2.0f); Primitive = new VoxelListPrimitive(); RenderWireframe = false; Manager = manager; IsActive = true; InitializeStatics(); PrimitiveMutex = new Mutex(); ShouldRecalculateLighting = true; Neighbors = new ConcurrentDictionary<Point3, VoxelChunk>(); DynamicLights = new List<DynamicLight>(); Liquids = new Dictionary<LiquidType, LiquidPrimitive>(); Liquids[LiquidType.Water] = new LiquidPrimitive(LiquidType.Water); Liquids[LiquidType.Lava] = new LiquidPrimitive(LiquidType.Lava); ShouldRebuildWater = true; Springs = new ConcurrentDictionary<Voxel, byte>(); IsRebuilding = false; LightingCalculated = false; RebuildPending = false; RebuildLiquidPending = false; ReconstructRamps = true; }
public void BuildPrimitive(GraphicsDevice g) { //Primitive.InitializeFromChunk(this, g); VoxelListPrimitive primitive = new VoxelListPrimitive(); primitive.InitializeFromChunk(this, g); }
public void Update(DwarfTime t) { //PrimitiveMutex.WaitOne(); if(NewPrimitiveReceived) { Primitive = NewPrimitive; NewPrimitive = null; NewPrimitiveReceived = false; } //PrimitiveMutex.ReleaseMutex(); }