Exemple #1
0
        public bool box_intersects_cell_bsp_inner(BSPNode node, List <Vector3> corners)
        {
            foreach (var corner in corners)
            {
                if (node.SplittingPlane.GetSide(corner) != Side.Behind)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #2
0
        public List <BSPPortal> PurgePortals()
        {
            var portals = new List <BSPPortal>();

            if (PosNode != null)
            {
                portals.AddRange(PosNode.PurgePortals());
                PosNode = null;
            }

            if (NegNode != null)
            {
                portals.AddRange(NegNode.PurgePortals());
                NegNode = null;
            }
            return(portals);
        }
Exemple #3
0
 public BSPNode(DatLoader.Entity.BSPNode node, Dictionary <ushort, DatLoader.Entity.Polygon> polys, DatLoader.Entity.CVertexArray vertexArray)
 {
     if (node.Sphere != null)
     {
         Sphere = new Sphere(node.Sphere);
     }
     if (node.SplittingPlane != null)
     {
         SplittingPlane = node.SplittingPlane.ToNumerics();
     }
     Type = (BSPTreeType)node.Type;
     //Typename
     if (node.InPolys != null)
     {
         NumPolys = node.InPolys.Count;
         PolyIDs  = node.InPolys;
         Polygons = new List <Polygon>();
         foreach (var poly in node.InPolys)
         {
             Polygons.Add(new Polygon(polys[poly], vertexArray));
         }
     }
     if (node.PosNode != null)
     {
         if (!(node.PosNode is DatLoader.Entity.BSPLeaf))
         {
             PosNode = new BSPNode(node.PosNode, polys, vertexArray);
         }
         else // portal?
         {
             PosNode = new BSPLeaf((DatLoader.Entity.BSPLeaf)node.PosNode, polys, vertexArray);
         }
     }
     if (node.NegNode != null)
     {
         if (!(node.NegNode is DatLoader.Entity.BSPLeaf))
         {
             NegNode = new BSPNode(node.NegNode, polys, vertexArray);
         }
         else // portal?
         {
             NegNode = new BSPLeaf((DatLoader.Entity.BSPLeaf)node.NegNode, polys, vertexArray);
         }
     }
 }
Exemple #4
0
 public BSPTree(DatLoader.Entity.BSPTree bsp, Dictionary <ushort, DatLoader.Entity.Polygon> polys, DatLoader.Entity.CVertexArray vertexArray)
 {
     RootNode = new BSPNode(bsp.RootNode, polys, vertexArray);
 }
Exemple #5
0
 public BSPTree(BSPNode rootNode)
 {
     RootNode = rootNode;
 }