示例#1
0
 private PlanetariaArcCollider(PlanetariaSphereCollider circle_boundary,
                               PlanetariaSphereCollider arc_boundary, PlanetariaSphereCollider circle_boundary_complement)
 {
     circle_boundary_variable            = circle_boundary;
     arc_boundary_variable               = arc_boundary;
     circle_boundary_complement_variable = circle_boundary_complement;
 }
示例#2
0
 public bool collides_with(PlanetariaSphereCollider other, Quaternion shift_from_self_to_other) // TODO: implement as Unity Job (multithreaded)
 {
     for (int self_index = 0; self_index < 3; ++self_index)
     {
         if (!this[self_index].collides_with(other, shift_from_self_to_other))
         {
             return(false);
         }
     }
     return(true);
 }
示例#3
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]));
        }
示例#4
0
        /// <summary>
        /// Inspector (pseudo-mutator) - Setup and caches all arcs based on curve_list at load-time
        /// </summary>
        private void initialize()
        {
            arc_list   = new Arc[0];
            block_list = new PlanetariaArcCollider[0];
            field_list = new PlanetariaSphereCollider[0];

            List <Arc> result = generate_edges();

            result   = add_corners_between_edges(result);
            arc_list = result.ToArray();
            generate_colliders();
        }
示例#5
0
 internal static PlanetariaSphereCollider[] elevation_collider(SphericalCap cap)
 {
     if (cap.offset > 1f - Precision.threshold)
     {
         return(new PlanetariaSphereCollider[2] {
             ideal_collider(cap), PlanetariaSphereCollider.always
         });
     }
     PlanetariaSphereCollider[] colliders = new PlanetariaSphereCollider[2];
     colliders[0] = uniform_collider(cap);
     colliders[1] = uniform_collider(cap.complement());
     return(colliders);
 }
 public static void draw_sphere(PlanetariaSphereCollider self, Quaternion orientation)
 {
     if (!EditorGlobal.self.hide_graphics)
     {
         Vector3 center = self.center;
         if (orientation != Quaternion.identity)
         {
             center = orientation * center;
         }
         Gizmos.color = new Color(0, 1, 0, 0.5f); // translucent green
         Gizmos.DrawSphere(center, self.radius);  // consider drawing a higher precision mesh
         Gizmos.color = Color.green;
         Gizmos.DrawWireSphere(center, self.radius);
     }
 }
        private void cache(PlanetariaShape shape)
        {
            PlanetariaCache.uncache(this);
            shape_variable = shape;
            if (shape != null)
            {
                PlanetariaCache.cache(this);
                PlanetariaSphereCollider sphere = shape.bounding_sphere;

                internal_collider.center = sphere.center;
                internal_collider.radius = sphere.radius;
            }
            else
            {
                internal_collider.radius = float.NegativeInfinity; // FIXME: HACK: ensure there are no collisions
            }
            internal_collider.isTrigger = true;                    // Rigidbody must be added for collisions to be detected.
        }
示例#8
0
        public bool collides_with(PlanetariaSphereCollider other, Quaternion shift_from_self_to_other)
        {
            if (float.IsInfinity(this.radius) || float.IsInfinity(other.radius)) // optimization for always_collide()/never_collide()
            {
                bool never_collide = float.IsNegativeInfinity(this.radius) || float.IsNegativeInfinity(other.radius);
                return(never_collide == false);
            }
            Vector3 this_center  = this.center;
            Vector3 other_center = other.center;

            if (shift_from_self_to_other != Quaternion.identity)
            {
                this_center = shift_from_self_to_other * this_center;
            }
            float magnitude_squared = (this_center - other_center).sqrMagnitude;
            float sum_of_radii      = this.radius + other.radius;

            return(magnitude_squared < sum_of_radii * sum_of_radii);
        }