public void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera) // Todo: Camera redundant { PerformanceMonitor.PushFrame("Component Update"); PerformanceMonitor.SetMetric("COMPONENTS", NumComponents()); var playerPoint = World.Renderer.Camera.Position; // Todo: Make this a sphere? var distanceVec = new Vector3(GameSettings.Default.EntityUpdateDistance, GameSettings.Default.EntityUpdateDistance, GameSettings.Default.EntityUpdateDistance); var updateBox = new BoundingBox(playerPoint - distanceVec, playerPoint + distanceVec); var componentsToUpdate = World.EnumerateIntersectingObjectsLoose(updateBox); PerformanceMonitor.SetMetric("COMPONENTS UPDATED", componentsToUpdate.Count); foreach (var body in componentsToUpdate) { body.Update(gameTime, chunks, camera); body.ProcessTransformChange(); } if (Debugger.Switches.DrawUpdateBox) { foreach (var chunk in World.EnumerateChunksInBounds(updateBox)) { Drawer3D.DrawBox(chunk.GetBoundingBox(), Color.Red, 0.4f, false); } } PerformanceMonitor.PopFrame(); AddRemove(); ReceiveMessage(); }
public void DisplaySpeciesCountsInMetrics() { foreach (var species in PersistentData.SpeciesCounts) { PerformanceMonitor.SetMetric(species.Key, species.Value); } }
public void Flush( GraphicsDevice Device, Shader Effect, Camera Camera, InstanceRenderMode Mode) { foreach (var group in InstanceTypes) { group.Value.Flush(Device, Effect, Camera, Mode); } PerformanceMonitor.SetMetric("INSTANCES DRAWN", _instanceCounter); _instanceCounter = 0; }
public void RebuildVoxelsThread() { Console.Out.WriteLine("Starting chunk regeneration thread."); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; var liveChunks = new List <VoxelChunk>(); #if !DEBUG try #endif { while (!DwarfGame.ExitGame && !ExitThreads) { try { RebuildEvent.WaitOne(); } catch (ThreadAbortException exception) { continue; } VoxelChunk chunk = null; do { chunk = PopInvalidChunk(); if (chunk != null) { if (!chunk.Visible) { continue; // Don't bother rebuilding chunks that won't be rendered. } chunk.Rebuild(GameState.Game.GraphicsDevice); liveChunks.Add(chunk); if (liveChunks.Count() > GameSettings.Current.MaxLiveChunks) { liveChunks.Sort((a, b) => a.RenderCycleWhenLastVisible - b.RenderCycleWhenLastVisible); while (liveChunks.Count() > GameSettings.Current.MaxLiveChunks) { if (liveChunks[0].Visible) { break; } liveChunks[0].DiscardPrimitive(); liveChunks.RemoveAt(0); } } NeedsMinimapUpdate = true; // Soon to be redundant. } }while (chunk != null); PerformanceMonitor.SetMetric("VISIBLE CHUNKS", liveChunks.Count); } } #if !DEBUG catch (Exception exception) { Console.Out.WriteLine("Chunk regeneration thread encountered an exception."); ProgramData.WriteExceptionLog(exception); //throw; } #endif Console.Out.WriteLine(String.Format("Chunk regeneration thread exited cleanly Exit Game: {0} Exit Thread: {1}.", DwarfGame.ExitGame, ExitThreads)); }