internal void TryChangeToDemo(int demoIndex) { if (demoIndex >= 0 && demoIndex < demoSet.Count) { demo.Dispose(); demo = demoSet.Build(demoIndex, content, camera); //Forcing a full blocking collection makes it a little easier to distinguish some memory issues. GC.Collect(int.MaxValue, GCCollectionMode.Forced, true, true); } }
public DemoHarness(GameLoop loop, ContentArchive content, Controls?controls = null, DemoSet customDemoSet = null) { this.window = loop.Window; this.input = loop.Input; this.camera = loop.Camera; this.content = content; timeSamples = new SimulationTimeSamples(512, loop.Pool); if (controls == null) { this.controls = Controls.Default; } var fontContent = content.Load <FontContent>(@"Content\Carlito-Regular.ttf"); font = new Font(loop.Surface.Device, loop.Surface.Context, fontContent); timingGraph = new Graph(new GraphDescription { BodyLineColor = new Vector3(1, 1, 1), AxisLabelHeight = 16, AxisLineRadius = 0.5f, HorizontalAxisLabel = "Frames", VerticalAxisLabel = "Time (ms)", VerticalIntervalValueScale = 1e3f, VerticalIntervalLabelRounding = 2, BackgroundLineRadius = 0.125f, IntervalTextHeight = 12, IntervalTickRadius = 0.25f, IntervalTickLength = 6f, TargetHorizontalTickCount = 5, HorizontalTickTextPadding = 0, VerticalTickTextPadding = 3, LegendMinimum = new Vector2(20, 200), LegendNameHeight = 12, LegendLineLength = 7, TextColor = new Vector3(1, 1, 1), Font = font, LineSpacingMultiplier = 1f, ForceVerticalAxisMinimumToZero = true }); timingGraph.AddSeries("Total", new Vector3(1, 1, 1), 0.75f, timeSamples.Simulation); timingGraph.AddSeries("Pose Integrator", new Vector3(0, 0, 1), 0.25f, timeSamples.PoseIntegrator); timingGraph.AddSeries("Sleeper", new Vector3(0.5f, 0, 1), 0.25f, timeSamples.Sleeper); timingGraph.AddSeries("Broad Update", new Vector3(1, 1, 0), 0.25f, timeSamples.BroadPhaseUpdate); timingGraph.AddSeries("Collision Test", new Vector3(0, 1, 0), 0.25f, timeSamples.CollisionTesting); timingGraph.AddSeries("Narrow Flush", new Vector3(1, 0, 1), 0.25f, timeSamples.NarrowPhaseFlush); timingGraph.AddSeries("Solver", new Vector3(1, 0, 0), 0.5f, timeSamples.Solver); timingGraph.AddSeries("Body Opt", new Vector3(1, 0.5f, 0), 0.125f, timeSamples.BodyOptimizer); timingGraph.AddSeries("Constraint Opt", new Vector3(0, 0.5f, 1), 0.125f, timeSamples.ConstraintOptimizer); timingGraph.AddSeries("Batch Compress", new Vector3(0, 0.5f, 0), 0.125f, timeSamples.BatchCompressor); demoSet = customDemoSet ?? new DemoSet().AddDefaultOptions(); demo = demoSet.Build(0, content, camera); OnResize(window.Resolution); }