Example #1
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();
        }
Example #2
0
 public static void draw_arc(PlanetariaArcCollider self, Quaternion orientation, bool[] mask)
 {
     if (!EditorGlobal.self.hide_graphics)
     {
         for (int index = 0; index < 3; ++index)
         {
             if (!mask[index])
             {
                 PlanetariaSphereColliderEditor.draw_sphere(self[index], orientation);
             }
         }
     }
 }
Example #3
0
 public bool collides_with(PlanetariaArcCollider other, Quaternion shift_from_self_to_other) // TODO: implement as Unity Job (multithreaded)
 {
     for (int self_index = 0; self_index < 3; ++self_index)
     {
         for (int other_index = 0; other_index < 3; ++other_index)
         {
             if (!this[self_index].collides_with(other[other_index], shift_from_self_to_other))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Example #4
0
        /// <summary>
        /// Inspector (pseudo-mutator) - Caches each PlanetariaArcCollider associated with each Arc.
        /// </summary>
        private void generate_colliders()
        {
            block_list = new PlanetariaArcCollider[arc_list.Length];
            for (int collider = 0; collider < arc_list.Length; ++collider)
            {
                block_list[collider] = PlanetariaArcCollider.block(arc_list[collider]);
            }

            /*
             * field_list = new PlanetariaSphereCollider[has_corners ? arc_list.Length/2 : arc_list.Length];
             * for (int collider = 0; collider < arc_list.Length; collider += (has_corners ? 2 : 1))
             * {
             *  field_list[has_corners ? collider/2 : collider] = PlanetariaArcCollider.field(arc_list[collider]);
             * }*/
        }
Example #5
0
        public List <Arc> block_collision(PlanetariaShape other, Quaternion shift_from_self_to_other) // TODO: AABB-equivalent would be nice here
        {
            List <Arc> union = new List <Arc>();

            for (int other_index = 0; other_index < other.block_list.Length; ++other_index)
            {
                PlanetariaArcCollider other_collider = other.block_list[other_index];
                foreach (PlanetariaArcCollider this_collider in this.block_list)
                {
                    if (other_collider.collides_with(this_collider, shift_from_self_to_other))
                    {
                        union.Add(other.arc_list[other_index]);
                        break; // try to see if the next arc collides (because we know this one does)
                    }
                }
            }
            return(union);
        }