diff --git a/Source/Editor/Editor.cs b/Source/Editor/Editor.cs index d0076068e..2a768099d 100644 --- a/Source/Editor/Editor.cs +++ b/Source/Editor/Editor.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.InteropServices.Marshalling; +using System.Threading.Tasks; using FlaxEditor.Content; using FlaxEditor.Content.Settings; using FlaxEditor.Content.Thumbnails; @@ -1338,20 +1339,33 @@ namespace FlaxEditor /// public void BuildAllMeshesSDF() { - // TODO: async maybe with progress reporting? + var models = new List(); Scene.ExecuteOnGraph(node => { if (node is StaticModelNode staticModelNode && staticModelNode.Actor is StaticModel staticModel) { - if (staticModel.DrawModes.HasFlag(DrawPass.GlobalSDF) && staticModel.Model != null && !staticModel.Model.IsVirtual && staticModel.Model.SDF.Texture == null) + var model = staticModel.Model; + if (staticModel.DrawModes.HasFlag(DrawPass.GlobalSDF) && + model != null && + !models.Contains(model) && + !model.IsVirtual && + model.SDF.Texture == null) { - Log("Generating SDF for " + staticModel.Model); - if (!staticModel.Model.GenerateSDF()) - staticModel.Model.Save(); + models.Add(model); } } return true; }); + Task.Run(() => + { + for (int i = 0; i < models.Count; i++) + { + var model = models[i]; + Log($"[{i}/{models.Count}] Generating SDF for {model}"); + if (!model.GenerateSDF()) + model.Save(); + } + }); } #endregion