Compare commits

..

4 Commits

Author SHA1 Message Date
ikpil 97777511a7 Added the keepInterResults option to RcBuilder.Build()
- https://github.com/ikpil/DotRecast/issues/66
2024-04-25 01:18:04 +09:00
ikpil f22ec94038 support C# 10, 11 in DotRecast.Recast.Demo 2024-04-25 00:59:02 +09:00
ikpil 4a80473e2f fix workflow 2024-04-25 00:02:27 +09:00
ikpil bf6ee495d2 upgrade Silk.NET 2.20.0 -> 2.21.0 2024-04-24 23:40:11 +09:00
13 changed files with 47 additions and 56 deletions

View File

@ -49,7 +49,7 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up .NET 8.0 - name: Set up .NET 8.0
uses: actions/setup-dotnet@v3 uses: actions/setup-dotnet@v4
with: with:
dotnet-version: 8.x dotnet-version: 8.x

View File

@ -37,7 +37,7 @@ jobs:
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
- name: Setup .NET - name: Setup .NET
uses: actions/setup-dotnet@v3 uses: actions/setup-dotnet@v4
with: with:
dotnet-version: ${{ matrix.dotnet-version }}.x dotnet-version: ${{ matrix.dotnet-version }}.x

View File

@ -33,7 +33,7 @@ jobs:
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
- name: Setup Dotnet - name: Setup Dotnet
uses: actions/setup-dotnet@v3 uses: actions/setup-dotnet@v4
with: with:
dotnet-version: '8.x' dotnet-version: '8.x'

View File

@ -15,7 +15,7 @@ jobs:
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
- name: Setup Dotnet - name: Setup Dotnet
uses: actions/setup-dotnet@v3 uses: actions/setup-dotnet@v4
with: with:
dotnet-version: '8.x' dotnet-version: '8.x'

View File

@ -100,7 +100,7 @@ namespace DotRecast.Detour.Dynamic
Math.Min(DtDynamicNavMesh.MAX_VERTS_PER_POLY, config.vertsPerPoly), Math.Min(DtDynamicNavMesh.MAX_VERTS_PER_POLY, config.vertsPerPoly),
config.detailSampleDistance, config.detailSampleMaxError, config.detailSampleDistance, config.detailSampleMaxError,
true, true, true, default, true); true, true, true, default, true);
RcBuilderResult r = builder.Build(context, vt.tileX, vt.tileZ, null, rcConfig, heightfield); RcBuilderResult r = builder.Build(context, vt.tileX, vt.tileZ, null, rcConfig, heightfield, false);
if (config.keepIntermediateResults) if (config.keepIntermediateResults)
{ {
recastResult = r; recastResult = r;

View File

@ -27,8 +27,8 @@
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" /> <PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0"/> <PackageReference Include="Serilog.Sinks.File" Version="5.0.0"/>
<PackageReference Include="K4os.Compression.LZ4" Version="1.3.8" /> <PackageReference Include="K4os.Compression.LZ4" Version="1.3.8" />
<PackageReference Include="Silk.NET" Version="2.20.0" /> <PackageReference Include="Silk.NET" Version="2.21.0" />
<PackageReference Include="Silk.NET.OpenGL.Extensions.ImGui" Version="2.20.0" /> <PackageReference Include="Silk.NET.OpenGL.Extensions.ImGui" Version="2.21.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -32,15 +32,18 @@ public class GLCheckerTexture
_gl = gl; _gl = gl;
} }
public void Release() public unsafe void Release()
{ {
if (m_texId != 0) if (m_texId != 0)
{ {
_gl.DeleteTextures(1, m_texId); fixed (uint* p = &m_texId)
{
_gl.DeleteTextures(1, p);
}
} }
} }
public void Bind() public unsafe void Bind()
{ {
if (m_texId == 0) if (m_texId == 0)
{ {
@ -50,7 +53,11 @@ public class GLCheckerTexture
uint TSIZE = 64; uint TSIZE = 64;
int[] data = new int[TSIZE * TSIZE]; int[] data = new int[TSIZE * TSIZE];
_gl.GenTextures(1, out m_texId); fixed (uint* p = &m_texId)
{
_gl.GenTextures(1, p);
}
_gl.BindTexture(GLEnum.Texture2D, m_texId); _gl.BindTexture(GLEnum.Texture2D, m_texId);
int level = 0; int level = 0;
@ -70,8 +77,10 @@ public class GLCheckerTexture
level++; level++;
} }
_gl.TexParameterI(GLEnum.Texture2D, GLEnum.TextureMinFilter, (uint)GLEnum.LinearMipmapNearest); uint linearMipmapNearest = (uint)GLEnum.LinearMipmapNearest;
_gl.TexParameterI(GLEnum.Texture2D, GLEnum.TextureMagFilter, (uint)GLEnum.Linear); uint linear = (uint)GLEnum.Linear;
_gl.TexParameterI(GLEnum.Texture2D, GLEnum.TextureMinFilter, &linearMipmapNearest);
_gl.TexParameterI(GLEnum.Texture2D, GLEnum.TextureMagFilter, &linear);
} }
else else
{ {

View File

@ -80,22 +80,7 @@ namespace DotRecast.Recast.Toolset.Builder
{ {
RcBuilderConfig bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax()); RcBuilderConfig bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax());
RcBuilder rcBuilder = new RcBuilder(); RcBuilder rcBuilder = new RcBuilder();
var result = rcBuilder.Build(geom, bcfg); return rcBuilder.Build(geom, bcfg, keepInterResults);
if (!keepInterResults)
{
return new RcBuilderResult(
result.TileX,
result.TileZ,
null,
null,
null,
result.Mesh,
result.MeshDetail,
result.Context
);
}
return result;
} }
public DtMeshData BuildMeshData(DemoInputGeomProvider geom, public DtMeshData BuildMeshData(DemoInputGeomProvider geom,

View File

@ -132,30 +132,17 @@ namespace DotRecast.Recast
public RcBuilderResult BuildTile(IInputGeomProvider geom, RcConfig cfg, RcVec3f bmin, RcVec3f bmax, int tx, int ty, RcAtomicInteger progress, int total, bool keepInterResults) public RcBuilderResult BuildTile(IInputGeomProvider geom, RcConfig cfg, RcVec3f bmin, RcVec3f bmax, int tx, int ty, RcAtomicInteger progress, int total, bool keepInterResults)
{ {
var bcfg = new RcBuilderConfig(cfg, bmin, bmax, tx, ty); var bcfg = new RcBuilderConfig(cfg, bmin, bmax, tx, ty);
RcBuilderResult result = Build(geom, bcfg); RcBuilderResult result = Build(geom, bcfg, keepInterResults);
if (_progressListener != null) if (_progressListener != null)
{ {
_progressListener.OnProgress(progress.IncrementAndGet(), total); _progressListener.OnProgress(progress.IncrementAndGet(), total);
} }
if (!keepInterResults)
{
return new RcBuilderResult(
result.TileX,
result.TileZ,
null,
null,
null,
result.Mesh,
result.MeshDetail,
result.Context
);
}
return result; return result;
} }
public RcBuilderResult Build(IInputGeomProvider geom, RcBuilderConfig bcfg) public RcBuilderResult Build(IInputGeomProvider geom, RcBuilderConfig bcfg, bool keepInterResults)
{ {
RcConfig cfg = bcfg.cfg; RcConfig cfg = bcfg.cfg;
RcContext ctx = new RcContext(); RcContext ctx = new RcContext();
@ -163,10 +150,10 @@ namespace DotRecast.Recast
// Step 1. Rasterize input polygon soup. // Step 1. Rasterize input polygon soup.
// //
RcHeightfield solid = RcVoxelizations.BuildSolidHeightfield(ctx, geom, bcfg); RcHeightfield solid = RcVoxelizations.BuildSolidHeightfield(ctx, geom, bcfg);
return Build(ctx, bcfg.tileX, bcfg.tileZ, geom, cfg, solid); return Build(ctx, bcfg.tileX, bcfg.tileZ, geom, cfg, solid, keepInterResults);
} }
public RcBuilderResult Build(RcContext ctx, int tileX, int tileZ, IInputGeomProvider geom, RcConfig cfg, RcHeightfield solid) public RcBuilderResult Build(RcContext ctx, int tileX, int tileZ, IInputGeomProvider geom, RcConfig cfg, RcHeightfield solid, bool keepInterResults)
{ {
FilterHeightfield(ctx, solid, cfg); FilterHeightfield(ctx, solid, cfg);
RcCompactHeightfield chf = BuildCompactHeightfield(ctx, geom, cfg, solid); RcCompactHeightfield chf = BuildCompactHeightfield(ctx, geom, cfg, solid);
@ -237,7 +224,17 @@ namespace DotRecast.Recast
RcPolyMeshDetail dmesh = cfg.BuildMeshDetail RcPolyMeshDetail dmesh = cfg.BuildMeshDetail
? RcMeshDetails.BuildPolyMeshDetail(ctx, pmesh, chf, cfg.DetailSampleDist, cfg.DetailSampleMaxError) ? RcMeshDetails.BuildPolyMeshDetail(ctx, pmesh, chf, cfg.DetailSampleDist, cfg.DetailSampleMaxError)
: null; : null;
return new RcBuilderResult(tileX, tileZ, solid, chf, cset, pmesh, dmesh, ctx);
return new RcBuilderResult(
tileX,
tileZ,
keepInterResults ? solid : null,
keepInterResults ? chf : null,
keepInterResults ? cset : null,
pmesh,
dmesh,
ctx
);
} }
/* /*

View File

@ -72,7 +72,7 @@ public class RecastTestMeshBuilder
SampleAreaModifications.SAMPLE_AREAMOD_GROUND, true); SampleAreaModifications.SAMPLE_AREAMOD_GROUND, true);
RcBuilderConfig bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax()); RcBuilderConfig bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax());
RcBuilder rcBuilder = new RcBuilder(); RcBuilder rcBuilder = new RcBuilder();
RcBuilderResult rcResult = rcBuilder.Build(geom, bcfg); RcBuilderResult rcResult = rcBuilder.Build(geom, bcfg, false);
RcPolyMesh m_pmesh = rcResult.Mesh; RcPolyMesh m_pmesh = rcResult.Mesh;
for (int i = 0; i < m_pmesh.npolys; ++i) for (int i = 0; i < m_pmesh.npolys; ++i)
{ {

View File

@ -72,7 +72,7 @@ public class RecastTestMeshBuilder
SampleAreaModifications.SAMPLE_AREAMOD_GROUND, true); SampleAreaModifications.SAMPLE_AREAMOD_GROUND, true);
RcBuilderConfig bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax()); RcBuilderConfig bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax());
RcBuilder rcBuilder = new RcBuilder(); RcBuilder rcBuilder = new RcBuilder();
RcBuilderResult rcResult = rcBuilder.Build(geom, bcfg); RcBuilderResult rcResult = rcBuilder.Build(geom, bcfg, false);
RcPolyMesh m_pmesh = rcResult.Mesh; RcPolyMesh m_pmesh = rcResult.Mesh;
for (int i = 0; i < m_pmesh.npolys; ++i) for (int i = 0; i < m_pmesh.npolys; ++i)
{ {

View File

@ -27,7 +27,7 @@ public class TestDetourBuilder : DetourBuilder
float agentMaxClimb, int x, int y, bool applyRecastDemoFlags) float agentMaxClimb, int x, int y, bool applyRecastDemoFlags)
{ {
RcBuilder rcBuilder = new RcBuilder(); RcBuilder rcBuilder = new RcBuilder();
RcBuilderResult rcResult = rcBuilder.Build(geom, rcConfig); RcBuilderResult rcResult = rcBuilder.Build(geom, rcConfig, false);
RcPolyMesh pmesh = rcResult.Mesh; RcPolyMesh pmesh = rcResult.Mesh;
if (applyRecastDemoFlags) if (applyRecastDemoFlags)

View File

@ -69,27 +69,27 @@ public class RecastTileMeshTest
true, true, true, true, true, true,
SampleAreaModifications.SAMPLE_AREAMOD_GROUND, true); SampleAreaModifications.SAMPLE_AREAMOD_GROUND, true);
RcBuilderConfig bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 7, 8); RcBuilderConfig bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 7, 8);
RcBuilderResult rcResult = builder.Build(geom, bcfg); RcBuilderResult rcResult = builder.Build(geom, bcfg, false);
Assert.That(rcResult.Mesh.npolys, Is.EqualTo(1)); Assert.That(rcResult.Mesh.npolys, Is.EqualTo(1));
Assert.That(rcResult.Mesh.nverts, Is.EqualTo(5)); Assert.That(rcResult.Mesh.nverts, Is.EqualTo(5));
bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 6, 9); bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 6, 9);
rcResult = builder.Build(geom, bcfg); rcResult = builder.Build(geom, bcfg, false);
Assert.That(rcResult.Mesh.npolys, Is.EqualTo(2)); Assert.That(rcResult.Mesh.npolys, Is.EqualTo(2));
Assert.That(rcResult.Mesh.nverts, Is.EqualTo(7)); Assert.That(rcResult.Mesh.nverts, Is.EqualTo(7));
bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 2, 9); bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 2, 9);
rcResult = builder.Build(geom, bcfg); rcResult = builder.Build(geom, bcfg, false);
Assert.That(rcResult.Mesh.npolys, Is.EqualTo(2)); Assert.That(rcResult.Mesh.npolys, Is.EqualTo(2));
Assert.That(rcResult.Mesh.nverts, Is.EqualTo(9)); Assert.That(rcResult.Mesh.nverts, Is.EqualTo(9));
bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 4, 3); bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 4, 3);
rcResult = builder.Build(geom, bcfg); rcResult = builder.Build(geom, bcfg, false);
Assert.That(rcResult.Mesh.npolys, Is.EqualTo(3)); Assert.That(rcResult.Mesh.npolys, Is.EqualTo(3));
Assert.That(rcResult.Mesh.nverts, Is.EqualTo(6)); Assert.That(rcResult.Mesh.nverts, Is.EqualTo(6));
bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 2, 8); bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 2, 8);
rcResult = builder.Build(geom, bcfg); rcResult = builder.Build(geom, bcfg, false);
Assert.That(rcResult.Mesh.npolys, Is.EqualTo(5)); Assert.That(rcResult.Mesh.npolys, Is.EqualTo(5));
Assert.That(rcResult.Mesh.nverts, Is.EqualTo(17)); Assert.That(rcResult.Mesh.nverts, Is.EqualTo(17));
bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 0, 8); bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 0, 8);
rcResult = builder.Build(geom, bcfg); rcResult = builder.Build(geom, bcfg, false);
Assert.That(rcResult.Mesh.npolys, Is.EqualTo(6)); Assert.That(rcResult.Mesh.npolys, Is.EqualTo(6));
Assert.That(rcResult.Mesh.nverts, Is.EqualTo(15)); Assert.That(rcResult.Mesh.nverts, Is.EqualTo(15));
} }