예제 #1
0
 public bool Insert(ICollidableGameObject obj)
 {
     if (!Boundary.IntersectsWith(obj.Collider))
     {
         return(false);
     }
     if (objectsInQuad.Count < maxCapacity)
     {
         objectsInQuad.Add(obj);
         return(true);
     }
     if (!divided)
     {
         Subdivide();
     }
     if (northWest.Insert(obj))
     {
         return(true);
     }
     if (northEast.Insert(obj))
     {
         return(true);
     }
     if (southWest.Insert(obj))
     {
         return(true);
     }
     if (southEast.Insert(obj))
     {
         return(true);
     }
     return(false);
 }
예제 #2
0
 private void UpdateCollisionTree()
 {
     QuadTree.Reset();
     foreach (var obj in collidableGameObjects)
     {
         obj.Transform = obj.Model.TransformToAncestor(PlayArea);
         obj.Collider  = new BoxCollider(obj, obj.Transform);
         QuadTree.Insert(obj);
     }
 }