Fixed where the dynamic voxel save file browser doesn't appear In Demo

This commit is contained in:
ikpil 2024-06-11 22:23:06 +09:00
parent 65c572a4c2
commit b88b6096f6
3 changed files with 7 additions and 8 deletions

View File

@ -10,7 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Nothing - Nothing
### Fixed ### Fixed
- Nothing - Fixed bug where the dynamic voxel save file browser doesn't appear in Recast.Demo
### Changed ### Changed
- Changed to reuse samples and edges list in BuildPolyDetail() - Changed to reuse samples and edges list in BuildPolyDetail()

View File

@ -116,7 +116,8 @@ public class DynamicUpdateSampleTool : ISampleTool
if (mode == RcDynamicUpdateToolMode.BUILD) if (mode == RcDynamicUpdateToolMode.BUILD)
{ {
var loadVoxelPopupStrId = "Load Voxels Popup"; const string loadVoxelPopupStrId = "Load Voxels Popup";
bool isLoadVoxelPopup = true; bool isLoadVoxelPopup = true;
if (ImGui.Button("Load Voxels...")) if (ImGui.Button("Load Voxels..."))
{ {
@ -135,7 +136,7 @@ public class DynamicUpdateSampleTool : ISampleTool
ImGui.EndPopup(); ImGui.EndPopup();
} }
var saveVoxelPopupStrId = "Save Voxels Popup"; const string saveVoxelPopupStrId = "Save Voxels Popup";
bool isSaveVoxelPopup = true; bool isSaveVoxelPopup = true;
var dynaMesh = _tool.GetDynamicNavMesh(); var dynaMesh = _tool.GetDynamicNavMesh();
@ -144,7 +145,7 @@ public class DynamicUpdateSampleTool : ISampleTool
ImGui.Checkbox("Compression", ref compression); ImGui.Checkbox("Compression", ref compression);
if (ImGui.Button("Save Voxels...")) if (ImGui.Button("Save Voxels..."))
{ {
ImGui.BeginPopup(saveVoxelPopupStrId); ImGui.OpenPopup(saveVoxelPopupStrId);
} }
if (ImGui.BeginPopupModal(saveVoxelPopupStrId, ref isSaveVoxelPopup, ImGuiWindowFlags.NoTitleBar)) 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"); var picker = ImFilePicker.GetFilePicker(saveVoxelPopupStrId, Path.Combine(Environment.CurrentDirectory), ".voxels");
if (picker.Draw()) if (picker.Draw())
{ {
if (string.IsNullOrEmpty(picker.SelectedFile)) Save(picker.SelectedFile);
Save(picker.SelectedFile);
ImFilePicker.RemoveFilePicker(saveVoxelPopupStrId); ImFilePicker.RemoveFilePicker(saveVoxelPopupStrId);
} }

View File

@ -159,7 +159,7 @@ namespace DotRecast.Recast.Toolset.Tools
public void Save(string filename, bool compression, IRcCompressor compressor) public void Save(string filename, bool compression, IRcCompressor compressor)
{ {
DtVoxelFile voxelFile = DtVoxelFile.From(dynaMesh); 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); using var bw = new BinaryWriter(fs);
DtVoxelFileWriter writer = new DtVoxelFileWriter(compressor); DtVoxelFileWriter writer = new DtVoxelFileWriter(compressor);
writer.Write(bw, voxelFile, compression); writer.Write(bw, voxelFile, compression);