public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;

            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = new ResourceDataReader(resentry, data);


            Nav = rd.ReadBlock <NavMesh>();


            if (Nav != null)
            {
                Vector3 posoffset = Nav.SectorTree?.AABBMin.XYZ() ?? Vector3.Zero;
                Vector3 aabbsize  = Nav.AABBSize;

                if (Nav.Vertices != null)
                {
                    var verts = Nav.Vertices.GetFullList();
                    Vertices = new List <Vector3>(verts.Count);
                    for (int i = 0; i < verts.Count; i++)
                    {
                        var ov = verts[i].ToVector3();
                        Vertices.Add(posoffset + ov * aabbsize);
                    }
                }
                if (Nav.Indices != null)
                {
                    Indices = Nav.Indices.GetFullList();
                }
                if (Nav.AdjPolys != null)
                {
                    AdjPolys = Nav.AdjPolys.GetFullList();
                }
                if (Nav.Polys != null)
                {
                    var polys = Nav.Polys.GetFullList();
                    Polys = new List <YnvPoly>(polys.Count);
                    for (int i = 0; i < polys.Count; i++)
                    {
                        YnvPoly poly = new YnvPoly();
                        poly.Init(this, polys[i]);
                        poly.Index = i;
                        poly.CalculatePosition(); //calc poly center for display purposes..
                        Polys.Add(poly);

                        if (poly.PortalType > 0)
                        {
                            if (poly.PortalType != 2) //seems to be what portal links need to understand..
                            {
                            }
                        }
                    }
                }
                if (Nav.Portals != null)
                {
                    var portals = Nav.Portals;
                    Portals = new List <YnvPortal>(portals.Length);
                    for (int i = 0; i < portals.Length; i++)
                    {
                        YnvPortal portal = new YnvPortal();
                        portal.Init(this, portals[i]);
                        portal.Index        = i;
                        portal.PositionFrom = posoffset + portal._RawData.PositionFrom.ToVector3() * aabbsize;
                        portal.PositionTo   = posoffset + portal._RawData.PositionTo.ToVector3() * aabbsize;
                        Portals.Add(portal);
                    }
                }


                ////### add points to the list and calculate positions...
                var treestack = new Stack <NavMeshSector>();
                var pointi    = 0;
                if (Nav.SectorTree != null)
                {
                    treestack.Push(Nav.SectorTree);
                }
                while (treestack.Count > 0)
                {
                    var sector = treestack.Pop();
                    if (sector.Data != null)
                    {
                        var points = sector.Data.Points;
                        if (points != null)
                        {
                            if (Points == null)
                            {
                                Points = new List <YnvPoint>();
                            }
                            for (int i = 0; i < points.Length; i++)
                            {
                                YnvPoint point = new YnvPoint();
                                point.Init(this, points[i]);
                                point.Index    = pointi; pointi++;
                                point.Position = posoffset + point._RawData.Position * aabbsize;
                                Points.Add(point);
                            }
                        }
                    }
                    if (sector.SubTree1 != null)
                    {
                        treestack.Push(sector.SubTree1);
                    }
                    if (sector.SubTree2 != null)
                    {
                        treestack.Push(sector.SubTree2);
                    }
                    if (sector.SubTree3 != null)
                    {
                        treestack.Push(sector.SubTree3);
                    }
                    if (sector.SubTree4 != null)
                    {
                        treestack.Push(sector.SubTree4);
                    }
                }
            }



            UpdateAllNodePositions();

            UpdateTriangleVertices();

            BuildBVH();


            Loaded     = true;
            LoadQueued = true;
        }
 public bool RemovePortal(YnvPortal portal)
 {
     return(false);
 }