forked from bit/DotRecastNetSim
refactor: vcelfile save and load
This commit is contained in:
parent
9788fd536f
commit
6e8867ec94
|
@ -692,10 +692,7 @@ public class DynamicUpdateSampleTool : ISampleTool
|
|||
{
|
||||
try
|
||||
{
|
||||
using var fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
|
||||
using var br = new BinaryReader(fs);
|
||||
VoxelFileReader reader = new VoxelFileReader(DtVoxelTileLZ4DemoCompressor.Shared);
|
||||
VoxelFile voxelFile = reader.Read(br);
|
||||
var voxelFile = _tool.Load(filename, DtVoxelTileLZ4DemoCompressor.Shared);
|
||||
dynaMesh = new DynamicNavMesh(voxelFile);
|
||||
dynaMesh.config.keepIntermediateResults = true;
|
||||
|
||||
|
@ -714,11 +711,8 @@ public class DynamicUpdateSampleTool : ISampleTool
|
|||
|
||||
private void Save(string filename)
|
||||
{
|
||||
using var fs = new FileStream(filename, FileMode.CreateNew, FileAccess.Write);
|
||||
using var bw = new BinaryWriter(fs);
|
||||
VoxelFile voxelFile = VoxelFile.From(dynaMesh);
|
||||
VoxelFileWriter writer = new VoxelFileWriter(DtVoxelTileLZ4DemoCompressor.Shared);
|
||||
writer.Write(bw, voxelFile, compression);
|
||||
_tool.Save(filename, voxelFile, compression, DtVoxelTileLZ4DemoCompressor.Shared);
|
||||
}
|
||||
|
||||
private void BuildDynaMesh()
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
namespace DotRecast.Recast.Toolset.Tools
|
||||
using System.IO;
|
||||
using DotRecast.Core;
|
||||
using DotRecast.Detour.Dynamic.Io;
|
||||
|
||||
namespace DotRecast.Recast.Toolset.Tools
|
||||
{
|
||||
public class RcDynamicUpdateTool : IRcToolable
|
||||
{
|
||||
|
@ -6,5 +10,23 @@
|
|||
{
|
||||
return "Dynamic Updates";
|
||||
}
|
||||
|
||||
public VoxelFile Load(string filename, IRcCompressor compressor)
|
||||
{
|
||||
using var fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
|
||||
using var br = new BinaryReader(fs);
|
||||
VoxelFileReader reader = new VoxelFileReader(compressor);
|
||||
VoxelFile voxelFile = reader.Read(br);
|
||||
|
||||
return voxelFile;
|
||||
}
|
||||
|
||||
public void Save(string filename, VoxelFile voxelFile, bool compression, IRcCompressor compressor)
|
||||
{
|
||||
using var fs = new FileStream(filename, FileMode.CreateNew, FileAccess.Write);
|
||||
using var bw = new BinaryWriter(fs);
|
||||
VoxelFileWriter writer = new VoxelFileWriter(compressor);
|
||||
writer.Write(bw, voxelFile, compression);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue