public long ParseSurfaces(BSP bsp, BinaryReader reader, int count)
        {
            bsp.Surfaces = new List <BSP.Surface>();
            var originalPos = reader.BaseStream.Position;

            for (uint i = 0; i < count; ++i)
            {
                reader.BaseStream.Position = originalPos + (i * SURFACE_SIZE);
                var plane_idx         = BitConverter.ToInt32(reader.ReadBytes(4).Reverse().ToArray(), 0);
                var first_edge        = BitConverter.ToInt32(reader.ReadBytes(4).Reverse().ToArray(), 0);
                var flags             = reader.ReadByte();
                var breakable_surface = reader.ReadByte();
                var material          = BitConverter.ToInt16(reader.ReadBytes(2).Reverse().ToArray(), 0);

                var surface = new BSP.Surface();

                //sign-compress the plane index
                var uplane_idx = (plane_idx & 0x7fff);
                if (plane_idx < 0)
                {
                    uplane_idx |= 0x8000;
                }

                surface.Plane = (short)uplane_idx;

                surface.FirstEdge        = (short)first_edge;
                surface.Material         = material;
                surface.BreakableSurface = breakable_surface;
                surface.Unknown2         = flags;

                bsp.Surfaces.Add(surface);
            }
            return(originalPos + (count * SURFACE_SIZE));
        }
        public long ParseSurfaces(BSP bsp, BinaryReader reader, int count)
        {
            bsp.Surfaces = new List<BSP.Surface>();
            var originalPos = reader.BaseStream.Position;

            for (uint i = 0; i < count; ++i)
            {
                reader.BaseStream.Position = originalPos + (i * SURFACE_SIZE);
                var plane_idx = BitConverter.ToInt32(reader.ReadBytes(4).Reverse().ToArray(), 0);
                var first_edge = BitConverter.ToInt32(reader.ReadBytes(4).Reverse().ToArray(), 0);
                var flags = reader.ReadByte();
                var breakable_surface = reader.ReadByte();
                var material = BitConverter.ToInt16(reader.ReadBytes(2).Reverse().ToArray(), 0);

                var surface = new BSP.Surface();

                //sign-compress the plane index
                var uplane_idx = (plane_idx & 0x7fff);
                if (plane_idx < 0)
                    uplane_idx |= 0x8000;

                surface.Plane = (short)uplane_idx;

                surface.FirstEdge = (short)first_edge;
                surface.Material = material;
                surface.BreakableSurface = breakable_surface;
                surface.Unknown2 = flags;

                bsp.Surfaces.Add(surface);
            }
            return originalPos + (count * SURFACE_SIZE);
        }