Пример #1
0
 public void Insert(Plane3D p)
 {
     if (node == null)
     {
         node = new BSPTreeNode(p);
     }
     else
     {
         node.Insert(p);
     }
 }
Пример #2
0
 // split both child spaces
 public void Insert(Plane3D p)
 {
     if (this.plane.normal == p.normal)
     {
         Vector3D point           = p.normal * -p.distance;
         double   distanceToPoint = this.plane.GetDistanceToPoint(point);
         if (distanceToPoint > 0)
         {
             if (left == null)
             {
                 left = new BSPTreeNode(p);
             }
             else
             {
                 left.Insert(p);
             }
         }
         else if (distanceToPoint < 0)
         {
             if (right == null)
             {
                 right = new BSPTreeNode(p);
             }
             else
             {
                 right.Insert(p);
             }
         }
         else
         {
             Debug.LogError("Splitting plane already defined");
         }
     }
     else
     {
         if (left == null)
         {
             left = new BSPTreeNode(p);
         }
         else
         {
             left.Insert(p);
         }
         if (right == null)
         {
             right = new BSPTreeNode(p);
         }
         else
         {
             right.Insert(p);
         }
     }
 }