Exemplo n.º 1
0
 /// <summary>
 /// Constructor (Named) - The intersection of two spheres is a circle, and adding a third sphere generates a set of colliders that define an arc
 /// </summary>
 /// <param name="arc">The arc for which the field will be generated.</param>
 /// <returns>A sphere representing a field collision at a single edge.</returns>
 public static PlanetariaSphereCollider field(Arc arc)
 {
     if (arc.type >= ArcType.ConvexCorner) // FIXME: (?) lazy
     {
         return(PlanetariaSphereCollider.always);
     }
     return(PlanetariaArcColliderUtility.uniform_collider(arc.floor()));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor (Named) - The intersection of two spheres is a circle, and adding a third sphere generates a set of colliders that define an arc
        /// </summary>
        /// <param name="arc">The arc for which the colliders will be generated.</param>
        /// <returns>A set of three Spheres that define an arc collision.</returns>
        public static PlanetariaArcCollider block(Arc arc)
        {
            if (arc.type == ArcType.ConcaveCorner)
            {
                return(new PlanetariaArcCollider(PlanetariaSphereCollider.never, PlanetariaSphereCollider.never,
                                                 PlanetariaSphereCollider.never));
            }
            PlanetariaSphereCollider boundary_collider = PlanetariaArcColliderUtility.boundary_collider(arc);

            PlanetariaSphereCollider[] elevation_colliders = PlanetariaArcColliderUtility.elevation_collider(arc.floor());
            return(new PlanetariaArcCollider(elevation_colliders[0], boundary_collider, elevation_colliders[1]));
        }
Exemplo n.º 3
0
        internal static PlanetariaSphereCollider boundary_collider(Vector3 center_axis, Vector3 point)
        {
            PlanetariaSphereCollider result;
            SphericalCap             cap = SphericalCap.cap(center_axis, point); // create a SphericalCap centered at "center" that captures both corners (2nd implicitly)

            float real_angle = Vector3.Angle(center_axis, point) * Mathf.Deg2Rad;

            if (real_angle < Precision.max_sphere_radius) // use a r<=1 sphere
            {
                result = PlanetariaArcColliderUtility.ideal_collider(cap);
            }
            else // use r=2 sphere
            {
                result = PlanetariaArcColliderUtility.uniform_collider(cap);
            }

            if (result.radius < Precision.threshold)
            {
                return(new PlanetariaSphereCollider(center_axis, 0));
            }
            return(result);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Constructor (Named) - Finds a Sphere that include "point" at the boundary and has a center along "center_axis"
 /// </summary>
 /// <param name="center_axis">The axis of the center point. The resulting center point (in return value) may vary.</param>
 /// <param name="point">The furthest point to include.</param>
 /// <returns>A sphere centered along "center_axis" and including "point" at its boundary.</returns>
 public static PlanetariaSphereCollider boundary(Vector3 center_axis, Vector3 point)
 {
     return(PlanetariaArcColliderUtility.boundary_collider(center_axis, point));
 }