From 0f701ec08e94f41718af188aefad3407b989946b Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 4 Nov 2025 13:30:18 +0100 Subject: [PATCH] Add force Mesh SDF rebuild when holiding `F` key and using Build All Meshes SDF optino in Editor menu --- Source/Editor/Editor.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Source/Editor/Editor.cs b/Source/Editor/Editor.cs index 66328926d..58466e35d 100644 --- a/Source/Editor/Editor.cs +++ b/Source/Editor/Editor.cs @@ -1390,6 +1390,7 @@ namespace FlaxEditor public void BuildAllMeshesSDF() { var models = new List(); + var forceRebuild = Input.GetKey(KeyboardKeys.F); Scene.ExecuteOnGraph(node => { if (node is StaticModelNode staticModelNode && staticModelNode.Actor is StaticModel staticModel) @@ -1399,7 +1400,7 @@ namespace FlaxEditor model != null && !models.Contains(model) && !model.IsVirtual && - model.SDF.Texture == null) + (forceRebuild || model.SDF.Texture == null)) { models.Add(model); } @@ -1412,7 +1413,17 @@ namespace FlaxEditor { var model = models[i]; Log($"[{i}/{models.Count}] Generating SDF for {model}"); - if (!model.GenerateSDF()) + float resolutionScale = 1.0f, backfacesThreshold = 0.6f; + int lodIndex = 6; + bool useGPU = true; + var sdf = model.SDF; + if (sdf.Texture != null) + { + // Preserve options set on this model + resolutionScale = sdf.ResolutionScale; + lodIndex = sdf.LOD; + } + if (!model.GenerateSDF(resolutionScale, lodIndex, true, backfacesThreshold, useGPU)) model.Save(); } });