Compare commits
No commits in common. "261d5fe399bf0c52458a1e36f38df06edde183ad" and "e213b3ea262d9950dd6636d5597ea11fe639c645" have entirely different histories.
261d5fe399
...
e213b3ea26
|
@ -221,11 +221,7 @@ public partial class Mission : Node3D
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var lightmapTexture = Timing.TimeStage("Build Lightmap", () =>
|
var lightmapTexture = BuildLightmapTexture(cells, packingRects.ToArray(), rectDataMap, surfaceDataMap);
|
||||||
{
|
|
||||||
return BuildLightmapTexture(cells, packingRects.ToArray(), rectDataMap, surfaceDataMap);
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (var (textureId, surface) in surfaceDataMap)
|
foreach (var (textureId, surface) in surfaceDataMap)
|
||||||
{
|
{
|
||||||
if (surface.Empty)
|
if (surface.Empty)
|
||||||
|
@ -277,12 +273,7 @@ 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)
|
||||||
{
|
{
|
||||||
var bounds = Timing.TimeStage("RectPack", () =>
|
RectanglePacker.Pack(packingRects, out var bounds);
|
||||||
{
|
|
||||||
RectanglePacker.Pack(packingRects, out var bounds, PackingHints.FindBest, 0);
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,13 +12,4 @@ public static class Timing
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
Godot.GD.Print($"[{stagename}]: {watch.Elapsed:g}");
|
Godot.GD.Print($"[{stagename}]: {watch.Elapsed:g}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T TimeStage<T>(string stagename, Func<T> action)
|
|
||||||
{
|
|
||||||
var watch = Stopwatch.StartNew();
|
|
||||||
var value = action();
|
|
||||||
watch.Stop();
|
|
||||||
Godot.GD.Print($"[{stagename}]: {watch.Elapsed:g}");
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue