// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. using FlaxEngine; namespace FlaxEditor.Progress.Handlers { /// /// Static lightmaps baking progress reporting handler. /// /// public sealed class BakeLightmapsProgress : ProgressHandler { /// /// Gets a value indicating whether GPU lightmaps baking is supported on this device. /// public static bool CanBake { get { var instance = GPUDevice.Instance; if (instance == null) return false; var limits = instance.Limits; return limits.HasCompute && limits.HasTypedUAVLoad && limits.MaximumTexture2DSize >= 8 * 1024 && instance.TotalGraphicsMemory >= 2 * 1024; } } /// /// Initializes a new instance of the class. /// public BakeLightmapsProgress() { Editor.LightmapsBakeStart += OnLightmapsBakeStart; Editor.LightmapsBakeProgress += OnLightmapsBakeProgress; Editor.LightmapsBakeEnd += OnLightmapsBakeEnd; } private void OnLightmapsBakeStart() { OnStart(); } private void OnLightmapsBakeProgress(Editor.LightmapsBakeSteps step, float stepProgress, float totalProgress) { OnUpdate(totalProgress, string.Format("Building lightmaps {0}% ...", Utils.RoundTo2DecimalPlaces(totalProgress * 100))); } private void OnLightmapsBakeEnd(bool failed) { OnEnd(); } } }