Пример #1
0
        public float MinDistanceToObstacle(Vector3 point)
        {
            const float R = 0;
            Vector3     c = point;

            return(AllObstacles.Aggregate(float.MaxValue, (current, obstacle) => TestOneObstacleOverlap(current, R, obstacle.Radius, c, obstacle.Center)));
        }
Пример #2
0
        public static void AddOneObstacle(float radius)
        {
            // pick a random center and radius,
            // loop until no overlap with other obstacles and the home base
            float   r;
            Vector3 c;
            float   minClearance;
            float   requiredClearance = Globals.Seeker.Radius * 4;           // 2 x diameter

            do
            {
                r            = RandomHelpers.Random(1.5f, 4);
                c            = Vector3Helpers.RandomVectorOnUnitRadiusXZDisk() * Globals.MAX_START_RADIUS * 1.1f;
                minClearance = AllObstacles.Aggregate(float.MaxValue, (current, t) => TestOneObstacleOverlap(current, r, t.Radius, c, t.Center));

                minClearance = TestOneObstacleOverlap(minClearance, r, radius - requiredClearance, c, Globals.HomeBaseCenter);
            }while (minClearance < requiredClearance);

            // add new non-overlapping obstacle to registry
            AllObstacles.Add(new SphericalObstacle(r, c));
            ObstacleCount++;
        }