Profile the rectpacking

This commit is contained in:
Jarrod Doyle 2024-08-26 14:26:45 +01:00
parent 20a0796410
commit 42cc08363e
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 6 additions and 1 deletions

View File

@ -277,7 +277,12 @@ public partial class Mission : Node3D
private static Texture BuildLightmapTexture(WorldRep.Cell[] cells, PackingRectangle[] packingRects, Dictionary<int, LightmapRectData> rectDataMap, Dictionary<int, MeshSurfaceData> surfaceDataMap) private static Texture BuildLightmapTexture(WorldRep.Cell[] cells, PackingRectangle[] packingRects, Dictionary<int, LightmapRectData> rectDataMap, Dictionary<int, MeshSurfaceData> surfaceDataMap)
{ {
RectanglePacker.Pack(packingRects, out var bounds); var bounds = Timing.TimeStage("RectPack", () =>
{
RectanglePacker.Pack(packingRects, out var bounds);
return bounds;
});
GD.Print($"Creating lightmap with bounds: ({bounds.Width}, {bounds.Height})");
var image = Image.CreateEmpty((int)bounds.Width, (int)bounds.Height, false, Image.Format.Rgba8); var image = Image.CreateEmpty((int)bounds.Width, (int)bounds.Height, false, Image.Format.Rgba8);
foreach (var rect in packingRects) foreach (var rect in packingRects)
{ {