diff --git a/CHANGELOG.md b/CHANGELOG.md index a6e3d40..9cd5c25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Nothing ### Fixed -- Nothing +- Fixed bug where the dynamic voxel save file browser doesn't appear in Recast.Demo ### Changed - Changed to reuse samples and edges list in BuildPolyDetail() diff --git a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateSampleTool.cs b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateSampleTool.cs index fd54f71..54dfd25 100644 --- a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateSampleTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateSampleTool.cs @@ -116,7 +116,8 @@ public class DynamicUpdateSampleTool : ISampleTool if (mode == RcDynamicUpdateToolMode.BUILD) { - var loadVoxelPopupStrId = "Load Voxels Popup"; + const string loadVoxelPopupStrId = "Load Voxels Popup"; + bool isLoadVoxelPopup = true; if (ImGui.Button("Load Voxels...")) { @@ -135,7 +136,7 @@ public class DynamicUpdateSampleTool : ISampleTool ImGui.EndPopup(); } - var saveVoxelPopupStrId = "Save Voxels Popup"; + const string saveVoxelPopupStrId = "Save Voxels Popup"; bool isSaveVoxelPopup = true; var dynaMesh = _tool.GetDynamicNavMesh(); @@ -144,7 +145,7 @@ public class DynamicUpdateSampleTool : ISampleTool ImGui.Checkbox("Compression", ref compression); if (ImGui.Button("Save Voxels...")) { - ImGui.BeginPopup(saveVoxelPopupStrId); + ImGui.OpenPopup(saveVoxelPopupStrId); } if (ImGui.BeginPopupModal(saveVoxelPopupStrId, ref isSaveVoxelPopup, ImGuiWindowFlags.NoTitleBar)) @@ -152,9 +153,7 @@ public class DynamicUpdateSampleTool : ISampleTool var picker = ImFilePicker.GetFilePicker(saveVoxelPopupStrId, Path.Combine(Environment.CurrentDirectory), ".voxels"); if (picker.Draw()) { - if (string.IsNullOrEmpty(picker.SelectedFile)) - Save(picker.SelectedFile); - + Save(picker.SelectedFile); ImFilePicker.RemoveFilePicker(saveVoxelPopupStrId); } diff --git a/src/DotRecast.Recast.Toolset/Tools/RcDynamicUpdateTool.cs b/src/DotRecast.Recast.Toolset/Tools/RcDynamicUpdateTool.cs index 83cc474..f5e2ac5 100644 --- a/src/DotRecast.Recast.Toolset/Tools/RcDynamicUpdateTool.cs +++ b/src/DotRecast.Recast.Toolset/Tools/RcDynamicUpdateTool.cs @@ -159,7 +159,7 @@ namespace DotRecast.Recast.Toolset.Tools public void Save(string filename, bool compression, IRcCompressor compressor) { DtVoxelFile voxelFile = DtVoxelFile.From(dynaMesh); - using var fs = new FileStream(filename, FileMode.CreateNew, FileAccess.Write); + using var fs = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite); using var bw = new BinaryWriter(fs); DtVoxelFileWriter writer = new DtVoxelFileWriter(compressor); writer.Write(bw, voxelFile, compression);