private static void MeasureIntersectionPerformance(HeightField heightfield, Vector3 start, Vector3 end, int iterations) { Vector3 direction = end - start; MyIntersector intersector = new MyIntersector(heightfield); FootprintDebugInfo debugInfo = new FootprintDebugInfo(); Intersection isec = intersector.Intersect(start, end, ref debugInfo); int visitedPixels = debugInfo.VisitedPixels.Count; Stopwatch sw = Stopwatch.StartNew(); for (int i = 0; i < iterations; i++) { Intersection intersection = intersector.Intersect(start, end); } sw.Stop(); Console.WriteLine("Intersection?: {0}", isec != null); Console.WriteLine("Ray length: {0:0.0}", direction.Length); Console.WriteLine("Visited pixels: {0}", visitedPixels); Console.WriteLine("Iterations: {0}", iterations); Console.WriteLine("Total time: {0} ms", sw.ElapsedMilliseconds); Console.WriteLine("Average time: {0:0.000} ms", sw.ElapsedMilliseconds / (double)iterations); double throughput = iterations / ((double)sw.ElapsedMilliseconds * 0.001); Console.WriteLine("Throughput: {0:0.000} traversals/s", throughput); Console.WriteLine("Throughput of visited pixels: {0:0.000} Mpx/s", throughput * visitedPixels * 1e-6); }
private void ComputeIntersection(bool withDebugInfo) { rayStartPoint = new Point((int)rayStart.X, (int)rayStart.Y); rayEndPoint = new Point((int)rayEnd.X, (int)rayEnd.Y); if (withDebugInfo) { footprintDebugInfo = new FootprintDebugInfo(); } else { footprintDebugInfo = null; } intersection = selectedIntersector.Intersect(rayStart, rayEnd, ref footprintDebugInfo); intersectionLabel.Text = (intersection != null) ? intersection.Position.ToString() : "none"; isecLayerLabel.Text = (footprintDebugInfo != null) && (intersection != null) ? footprintDebugInfo.LayerOfIntersection.ToString() : ""; heightFieldPanel.Invalidate(); footprintTraversalPanel.Invalidate(); }