public CompressedVoxelVolume(Boxl bounds) { Bounds = bounds; Compressed = new CompressedList <T>(); Uncompressed = null; Fill(default(T)); }
public VertexLightingPage GetVertexLightingPage([Url] string map, [Url] int index) { var bsp = Program.GetMap(map); var info = IndexController.GetPageLayout(bsp, bsp.StaticProps.PropCount, VertexLightingPage.PropsPerPage, null).Skip(index).FirstOrDefault(); var first = info?.First ?? bsp.StaticProps.PropCount; var count = info?.Count ?? 0; var page = new VertexLightingPage(); for (var i = 0; i < count; ++i) { var propIndex = first + i; StaticPropFlags flags; bsp.StaticProps.GetPropInfo(propIndex, out flags, out bool _, out uint _); if ((flags & StaticPropFlags.NoPerVertexLighting) != 0) { page.Props.Add(null); continue; } var ldrPath = $"sp_{propIndex}.vhv"; var hdrPath = $"sp_hdr_{propIndex}.vhv"; var existingPath = bsp.PakFile.ContainsFile(hdrPath) ? hdrPath : bsp.PakFile.ContainsFile(ldrPath) ? ldrPath : null; if (existingPath == null) { page.Props.Add(null); continue; } var vhvFile = ValveVertexLightingFile.FromProvider(existingPath, bsp.PakFile); if (vhvFile == null) { page.Props.Add(null); continue; } var meshList = new List <CompressedList <uint> >(); var meshCount = vhvFile.GetMeshCount(0); for (var j = 0; j < meshCount; ++j) { var vertices = new CompressedList <uint>(); var samples = vhvFile.GetSamples(0, j); vertices.AddRange(samples.Select(x => ((uint)x.A << 24) | ((uint)x.B << 16) | ((uint)x.G << 8) | x.R)); meshList.Add(vertices); } page.Props.Add(meshList); } return(page); }