Ejemplo n.º 1
0
        private static void Hashtest()
        {
            float worldSize = 100f;
            AABB hpbbox = new AABB(new Point(-worldSize), new Point(worldSize));
            int pointsCount = 1000000;

            var rnd = new FastRandom();
            HashMap map = new HashMap();
            List<Photon> pt = new List<Photon>();
            for (int i = 0; i < pointsCount; i++)
            {
                var hitPoint = new Point(worldSize * rnd.NextFloatNeg(), worldSize * rnd.NextFloatNeg(),
                                         worldSize * rnd.NextFloatNeg());
                if (!hpbbox.Inside(hitPoint))
                {
                    Console.WriteLine("Generated invalid point");
                    continue;
                }

                Vector dir = new Vector(worldSize * rnd.NextFloatNeg(), worldSize * rnd.NextFloatNeg(), worldSize * rnd.NextFloatNeg());
                RgbSpectrum spec = new RgbSpectrum(rnd.NextFloat(), rnd.NextFloat(), rnd.NextFloat());

                pt.Add(new Photon(ref hitPoint, ref dir, ref spec));
            }

            map.Construct(pt.ToArray());

            var qp = new Point(1f);

            var query = map.Query(ref qp, 2f);
            foreach (var photon in query)
            {
                Console.WriteLine(photon);
            }

            Console.WriteLine("Bounding box size {0}, Points {1}", worldSize, pointsCount);

            return;
        }