Beispiel #1
0
        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);
        }
Beispiel #2
0
 private static void IntersectAndReport(HeightField heightfield, Vector3 start, Vector3 end)
 {
     MyIntersector intersector = new MyIntersector(heightfield);
     Intersection intersection = intersector.Intersect(start, end);
     Console.WriteLine((intersection != null) ? intersection.Position.ToString() : "no intersection");
 }