コード例 #1
0
 public ColliderManager(AABox area, int depth = 5)
 {
     root = new Node(area);
     for (int i = 0; i < depth; i++)
     {
         root.Subdivide();
     }
 }
コード例 #2
0
 public void Subdivide()
 {
     if (children.Count == 0)
     {
         AABox[] subBoxes = new AABox[8];
         AABox.Subdivide(volume, subBoxes);
         for (int i = 0; i < 8; i++)
         {
             Node subNode = new Node(subBoxes[i]);
             children.Add(subNode);
         }
     }
     else
     {
         for (int i = 0; i < children.Count; i++)
         {
             children[i].Subdivide();
         }
     }
 }
コード例 #3
0
            public bool Intersect(LineTestData intersectData, out EntityID entity)
            {
                entity = this.entity;

                //First test if the bounds intersect
                if (!AABox.Intersect(box, intersectData.TestBounds))
                {
                    return(false);
                }

                //Then test if the ray intersects
                float rayTime;

                if (!AABox.Intersect(box, intersectData.TestRay, out rayTime))
                {
                    return(false);
                }

                //Then test if that ray was still within the line
                return(intersectData.TestLine.SqrMagnitude >= (rayTime * rayTime));
            }
コード例 #4
0
            public bool Intersect(AABox box, out EntityID entity)
            {
                if (AABox.Intersect(volume, box))
                {
                    for (int i = 0; i < children.Count; i++)
                    {
                        if (children[i].Intersect(box, out entity))
                        {
                            return(true);
                        }
                    }

                    for (int i = 0; i < entries.Count; i++)
                    {
                        if (entries[i].Intersect(box, out entity))
                        {
                            return(true);
                        }
                    }
                }
                entity = 0;
                return(false);
            }
コード例 #5
0
            public bool Intersect(LineTestData intersectData, out EntityID entity)
            {
                if (AABox.Intersect(volume, intersectData.TestBounds))
                {
                    for (int i = 0; i < children.Count; i++)
                    {
                        if (children[i].Intersect(intersectData, out entity))
                        {
                            return(true);
                        }
                    }

                    for (int i = 0; i < entries.Count; i++)
                    {
                        if (entries[i].Intersect(intersectData, out entity))
                        {
                            return(true);
                        }
                    }
                }
                entity = 0;
                return(false);
            }
コード例 #6
0
 public bool Intersect(AABox box, out EntityID entity)
 {
     return(root.Intersect(box, out entity));
 }
コード例 #7
0
 public void Add(AABox box, EntityID entity)
 {
     root.Add(new Entry(box, entity));
 }
コード例 #8
0
 public bool Intersect(AABox box, out EntityID entity)
 {
     entity = this.entity;
     return(AABox.Intersect(this.box, box));
 }
コード例 #9
0
 public bool Intersect(AABox box) => AABox.Intersect(this.box, box);
コード例 #10
0
 public Entry(AABox box, EntityID entity)
 {
     this.box    = box;
     this.entity = entity;
 }
コード例 #11
0
 public LineTestData(Line testLine)
 {
     TestLine   = testLine;
     TestBounds = testLine.GetBounds();
     TestRay    = testLine.GetRay();
 }
コード例 #12
0
 public static bool Intersect(AABox a, AABox b)
 => a.Min.x <b.Max.x && a.Max.x> b.Min.x &&
 a.Min.y <b.Max.y && a.Max.y> b.Min.y &&
 a.Min.z <b.Max.z && a.Max.z> b.Min.z;
コード例 #13
0
 public static bool Contains(AABox box, Vector3 point)
 => point.x > box.Min.x && point.x <box.Max.x &&
                                    point.y> box.Min.y && point.y <box.Max.y &&
                                                                   point.z> box.Min.z && point.z < box.Max.z;