public static void FindFacesAndGroups(Map map, out List <LMFace> faces, out List <LightmapGroup> lmGroups) { faces = new List <LMFace>(); lmGroups = new List <LightmapGroup>(); foreach (Solid solid in map.WorldSpawn.Find(x => x is Solid).OfType <Solid>()) { foreach (Face tface in solid.Faces) { tface.Vertices.ForEach(v => { v.LMU = -500.0f; v.LMV = -500.0f; }); tface.UpdateBoundingBox(); if (tface.Texture?.Texture == null) { continue; } if (tface.Texture.Name.ToLowerInvariant() == "tooltextures/invisible_collision") { continue; } if (tface.Texture.Name.ToLowerInvariant() == "tooltextures/remove_face") { continue; } if (tface.Texture.Name.ToLowerInvariant() == "tooltextures/block_light") { continue; } if (tface.Texture.Texture.HasTransparency()) { continue; } LMFace face = new LMFace(tface, solid); LightmapGroup group = LightmapGroup.FindCoplanar(lmGroups, face); BoxF faceBox = new BoxF(face.BoundingBox.Start - new CoordinateF(3.0f, 3.0f, 3.0f), face.BoundingBox.End + new CoordinateF(3.0f, 3.0f, 3.0f)); if (group == null) { group = new LightmapGroup(); group.BoundingBox = faceBox; group.Faces = new List <LMFace>(); group.Plane = new PlaneF(face.Plane.Normal, face.Vertices[0].Location); lmGroups.Add(group); } #if DEBUG if (face.Texture.ToLowerInvariant() == "tooltextures/debug_breakpoint") { group.DebugBreakpoint = true; } #endif group.Faces.Add(face); group.Plane = new PlaneF(group.Plane.Normal, (face.Vertices[0].Location + group.Plane.PointOnPlane) / 2); group.BoundingBox = new BoxF(new BoxF[] { group.BoundingBox, faceBox }); } } }
public static void FindFacesAndGroups(Map map, out List <LMFace> faces, out List <LightmapGroup> lmGroups) { faces = new List <LMFace>(); lmGroups = new List <LightmapGroup>(); foreach (Solid solid in map.WorldSpawn.Find(x => x is Solid).OfType <Solid>()) { foreach (Face tface in solid.Faces) { tface.Vertices.ForEach(v => { v.LMU = -500.0f; v.LMV = -500.0f; }); tface.UpdateBoundingBox(); if (tface.Texture?.Texture == null) { continue; } if (tface.Texture.IsToolTexture) { continue; } if (tface.Texture.Texture.HasTransparency()) { continue; } LMFace face = new LMFace(tface, solid); LightmapGroup group = LightmapGroup.FindCoplanar(lmGroups, face); BoxF faceBox = new BoxF(face.BoundingBox.Start - new CoordinateF(3.0f, 3.0f, 3.0f), face.BoundingBox.End + new CoordinateF(3.0f, 3.0f, 3.0f)); if (group == null) { group = new LightmapGroup(); group.BoundingBox = faceBox; group.Faces = new List <LMFace>(); group.Plane = new PlaneF(face.Plane.Normal, face.Vertices[0].Location); lmGroups.Add(group); } group.Faces.Add(face); group.Plane = new PlaneF(group.Plane.Normal, (face.Vertices[0].Location + group.Plane.PointOnPlane) / 2); group.BoundingBox = new BoxF(new BoxF[] { group.BoundingBox, faceBox }); } } }