forked from mirror/DotRecast
Compare commits
No commits in common. "e67dbfa60431eac7dbaad3207ef4d5b5eccaed87" and "0ed414f08c6d51fc9eb08e2189b6307200114c30" have entirely different histories.
e67dbfa604
...
0ed414f08c
|
@ -49,7 +49,7 @@ jobs:
|
|||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up .NET 8.0
|
||||
uses: actions/setup-dotnet@v4
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: 8.x
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ jobs:
|
|||
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: ${{ matrix.dotnet-version }}.x
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ jobs:
|
|||
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
|
||||
|
||||
- name: Setup Dotnet
|
||||
uses: actions/setup-dotnet@v4
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '8.x'
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ jobs:
|
|||
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
|
||||
|
||||
- name: Setup Dotnet
|
||||
uses: actions/setup-dotnet@v4
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '8.x'
|
||||
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace DotRecast.Core
|
||||
{
|
||||
public static class RcSpans
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Copy<T>(Span<T> source, Span<T> destination)
|
||||
{
|
||||
Copy(source, 0, destination, 0, source.Length);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Copy<T>(Span<T> source, int sourceIdx, Span<T> destination, int destinationIdx, int length)
|
||||
{
|
||||
var src = source.Slice(sourceIdx, length);
|
||||
var dst = destination.Slice(destinationIdx);
|
||||
src.CopyTo(dst);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -100,7 +100,7 @@ namespace DotRecast.Detour.Dynamic
|
|||
Math.Min(DtDynamicNavMesh.MAX_VERTS_PER_POLY, config.vertsPerPoly),
|
||||
config.detailSampleDistance, config.detailSampleMaxError,
|
||||
true, true, true, default, true);
|
||||
RcBuilderResult r = builder.Build(context, vt.tileX, vt.tileZ, null, rcConfig, heightfield, false);
|
||||
RcBuilderResult r = builder.Build(context, vt.tileX, vt.tileZ, null, rcConfig, heightfield);
|
||||
if (config.keepIntermediateResults)
|
||||
{
|
||||
recastResult = r;
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0"/>
|
||||
<PackageReference Include="K4os.Compression.LZ4" Version="1.3.8" />
|
||||
<PackageReference Include="Silk.NET" Version="2.21.0" />
|
||||
<PackageReference Include="Silk.NET.OpenGL.Extensions.ImGui" Version="2.21.0" />
|
||||
<PackageReference Include="Silk.NET" Version="2.20.0" />
|
||||
<PackageReference Include="Silk.NET.OpenGL.Extensions.ImGui" Version="2.20.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -32,18 +32,15 @@ public class GLCheckerTexture
|
|||
_gl = gl;
|
||||
}
|
||||
|
||||
public unsafe void Release()
|
||||
public void Release()
|
||||
{
|
||||
if (m_texId != 0)
|
||||
{
|
||||
fixed (uint* p = &m_texId)
|
||||
{
|
||||
_gl.DeleteTextures(1, p);
|
||||
}
|
||||
_gl.DeleteTextures(1, m_texId);
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe void Bind()
|
||||
public void Bind()
|
||||
{
|
||||
if (m_texId == 0)
|
||||
{
|
||||
|
@ -53,11 +50,7 @@ public class GLCheckerTexture
|
|||
uint TSIZE = 64;
|
||||
int[] data = new int[TSIZE * TSIZE];
|
||||
|
||||
fixed (uint* p = &m_texId)
|
||||
{
|
||||
_gl.GenTextures(1, p);
|
||||
}
|
||||
|
||||
_gl.GenTextures(1, out m_texId);
|
||||
_gl.BindTexture(GLEnum.Texture2D, m_texId);
|
||||
|
||||
int level = 0;
|
||||
|
@ -77,10 +70,8 @@ public class GLCheckerTexture
|
|||
level++;
|
||||
}
|
||||
|
||||
uint linearMipmapNearest = (uint)GLEnum.LinearMipmapNearest;
|
||||
uint linear = (uint)GLEnum.Linear;
|
||||
_gl.TexParameterI(GLEnum.Texture2D, GLEnum.TextureMinFilter, &linearMipmapNearest);
|
||||
_gl.TexParameterI(GLEnum.Texture2D, GLEnum.TextureMagFilter, &linear);
|
||||
_gl.TexParameterI(GLEnum.Texture2D, GLEnum.TextureMinFilter, (uint)GLEnum.LinearMipmapNearest);
|
||||
_gl.TexParameterI(GLEnum.Texture2D, GLEnum.TextureMagFilter, (uint)GLEnum.Linear);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -80,7 +80,22 @@ namespace DotRecast.Recast.Toolset.Builder
|
|||
{
|
||||
RcBuilderConfig bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax());
|
||||
RcBuilder rcBuilder = new RcBuilder();
|
||||
return rcBuilder.Build(geom, bcfg, keepInterResults);
|
||||
var result = rcBuilder.Build(geom, bcfg);
|
||||
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,
|
||||
|
|
|
@ -132,17 +132,30 @@ namespace DotRecast.Recast
|
|||
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);
|
||||
RcBuilderResult result = Build(geom, bcfg, keepInterResults);
|
||||
RcBuilderResult result = Build(geom, bcfg);
|
||||
if (_progressListener != null)
|
||||
{
|
||||
_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;
|
||||
}
|
||||
|
||||
public RcBuilderResult Build(IInputGeomProvider geom, RcBuilderConfig bcfg, bool keepInterResults)
|
||||
public RcBuilderResult Build(IInputGeomProvider geom, RcBuilderConfig bcfg)
|
||||
{
|
||||
RcConfig cfg = bcfg.cfg;
|
||||
RcContext ctx = new RcContext();
|
||||
|
@ -150,10 +163,10 @@ namespace DotRecast.Recast
|
|||
// Step 1. Rasterize input polygon soup.
|
||||
//
|
||||
RcHeightfield solid = RcVoxelizations.BuildSolidHeightfield(ctx, geom, bcfg);
|
||||
return Build(ctx, bcfg.tileX, bcfg.tileZ, geom, cfg, solid, keepInterResults);
|
||||
return Build(ctx, bcfg.tileX, bcfg.tileZ, geom, cfg, solid);
|
||||
}
|
||||
|
||||
public RcBuilderResult Build(RcContext ctx, int tileX, int tileZ, IInputGeomProvider geom, RcConfig cfg, RcHeightfield solid, bool keepInterResults)
|
||||
public RcBuilderResult Build(RcContext ctx, int tileX, int tileZ, IInputGeomProvider geom, RcConfig cfg, RcHeightfield solid)
|
||||
{
|
||||
FilterHeightfield(ctx, solid, cfg);
|
||||
RcCompactHeightfield chf = BuildCompactHeightfield(ctx, geom, cfg, solid);
|
||||
|
@ -224,17 +237,7 @@ namespace DotRecast.Recast
|
|||
RcPolyMeshDetail dmesh = cfg.BuildMeshDetail
|
||||
? RcMeshDetails.BuildPolyMeshDetail(ctx, pmesh, chf, cfg.DetailSampleDist, cfg.DetailSampleMaxError)
|
||||
: null;
|
||||
|
||||
return new RcBuilderResult(
|
||||
tileX,
|
||||
tileZ,
|
||||
keepInterResults ? solid : null,
|
||||
keepInterResults ? chf : null,
|
||||
keepInterResults ? cset : null,
|
||||
pmesh,
|
||||
dmesh,
|
||||
ctx
|
||||
);
|
||||
return new RcBuilderResult(tileX, tileZ, solid, chf, cset, pmesh, dmesh, ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<PackageReference Include="Moq" Version="4.20.70" />
|
||||
<PackageReference Include="NUnit" Version="4.1.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Sockets;
|
||||
using DotRecast.Core.Buffers;
|
||||
using DotRecast.Core.Collections;
|
||||
using NUnit.Framework;
|
||||
|
@ -85,73 +84,18 @@ public class RcArrayBenchmarkTests
|
|||
[Test]
|
||||
public void TestBenchmarkArrays()
|
||||
{
|
||||
var results = new List<(string title, long ticks)>();
|
||||
results.Add(Bench("new int[len]", RoundForArray));
|
||||
results.Add(Bench("ArrayPool<int>.Shared.Rent(len)", RoundForPureRentArray));
|
||||
results.Add(Bench("RcRentedArray.Rent<int>(len)", RoundForRcRentedArray));
|
||||
results.Add(Bench("new RcStackArray512<int>()", RoundForRcStackArray));
|
||||
results.Add(Bench("stackalloc int[len]", RoundForStackalloc));
|
||||
var list = new List<(string title, long ticks)>();
|
||||
list.Add(Bench("new int[len]", RoundForArray));
|
||||
list.Add(Bench("ArrayPool<int>.Shared.Rent(len)", RoundForPureRentArray));
|
||||
list.Add(Bench("RcRentedArray.Rent<int>(len)", RoundForRcRentedArray));
|
||||
list.Add(Bench("new RcStackArray512<int>()", RoundForRcStackArray));
|
||||
list.Add(Bench("stackalloc int[len]", RoundForStackalloc));
|
||||
|
||||
results.Sort((x, y) => x.ticks.CompareTo(y.ticks));
|
||||
list.Sort((x, y) => x.ticks.CompareTo(y.ticks));
|
||||
|
||||
foreach (var t in results)
|
||||
foreach (var t in list)
|
||||
{
|
||||
Console.WriteLine($"{t.title} {t.ticks / (double)TimeSpan.TicksPerMillisecond} ms");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSpanVsArray()
|
||||
{
|
||||
var r = new RcRand();
|
||||
var list = new List<(long[] src, long[] dest)>();
|
||||
for (int i = 0; i < 14; ++i)
|
||||
{
|
||||
var s = new long[(int)Math.Pow(2, i + 1)];
|
||||
var d = new long[(int)Math.Pow(2, i + 1)];
|
||||
for (int ii = 0; ii < s.Length; ++ii)
|
||||
{
|
||||
s[ii] = r.NextInt32();
|
||||
}
|
||||
|
||||
list.Add((s, d));
|
||||
}
|
||||
|
||||
var results = new List<(string title, long ticks)>();
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
{
|
||||
var seq = i;
|
||||
|
||||
Array.Fill(list[seq].dest, 0);
|
||||
var resultLong = Bench($"long[{list[seq].src.Length}]", _ =>
|
||||
{
|
||||
var v = list[seq];
|
||||
RcArrays.Copy(v.src, 0, v.dest, 0, v.src.Length);
|
||||
});
|
||||
|
||||
|
||||
Array.Fill(list[seq].dest, 0);
|
||||
var resultSpan = Bench($"Span<long[], {list[seq].src.Length}>", _ =>
|
||||
{
|
||||
var v = list[seq];
|
||||
RcSpans.Copy<long>(v.src, 0, v.dest, 0, v.src.Length);
|
||||
});
|
||||
|
||||
|
||||
results.Add(resultLong);
|
||||
results.Add(resultSpan);
|
||||
}
|
||||
|
||||
|
||||
int newLine = 0;
|
||||
foreach (var t in results)
|
||||
{
|
||||
Console.WriteLine($"{t.title}: {t.ticks / (double)TimeSpan.TicksPerMillisecond} ms");
|
||||
newLine += 1;
|
||||
if (0 == (newLine % 2))
|
||||
{
|
||||
Console.WriteLine("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
<PackageReference Include="Moq" Version="4.20.70" />
|
||||
<PackageReference Include="NUnit" Version="4.1.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -72,7 +72,7 @@ public class RecastTestMeshBuilder
|
|||
SampleAreaModifications.SAMPLE_AREAMOD_GROUND, true);
|
||||
RcBuilderConfig bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax());
|
||||
RcBuilder rcBuilder = new RcBuilder();
|
||||
RcBuilderResult rcResult = rcBuilder.Build(geom, bcfg, false);
|
||||
RcBuilderResult rcResult = rcBuilder.Build(geom, bcfg);
|
||||
RcPolyMesh m_pmesh = rcResult.Mesh;
|
||||
for (int i = 0; i < m_pmesh.npolys; ++i)
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<PackageReference Include="Moq" Version="4.20.70" />
|
||||
<PackageReference Include="NUnit" Version="4.1.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<PackageReference Include="Moq" Version="4.20.70" />
|
||||
<PackageReference Include="NUnit" Version="4.1.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<PackageReference Include="Moq" Version="4.20.70" />
|
||||
<PackageReference Include="NUnit" Version="4.1.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -72,7 +72,7 @@ public class RecastTestMeshBuilder
|
|||
SampleAreaModifications.SAMPLE_AREAMOD_GROUND, true);
|
||||
RcBuilderConfig bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax());
|
||||
RcBuilder rcBuilder = new RcBuilder();
|
||||
RcBuilderResult rcResult = rcBuilder.Build(geom, bcfg, false);
|
||||
RcBuilderResult rcResult = rcBuilder.Build(geom, bcfg);
|
||||
RcPolyMesh m_pmesh = rcResult.Mesh;
|
||||
for (int i = 0; i < m_pmesh.npolys; ++i)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ public class TestDetourBuilder : DetourBuilder
|
|||
float agentMaxClimb, int x, int y, bool applyRecastDemoFlags)
|
||||
{
|
||||
RcBuilder rcBuilder = new RcBuilder();
|
||||
RcBuilderResult rcResult = rcBuilder.Build(geom, rcConfig, false);
|
||||
RcBuilderResult rcResult = rcBuilder.Build(geom, rcConfig);
|
||||
RcPolyMesh pmesh = rcResult.Mesh;
|
||||
|
||||
if (applyRecastDemoFlags)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<PackageReference Include="Moq" Version="4.20.70" />
|
||||
<PackageReference Include="NUnit" Version="4.1.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<PackageReference Include="Moq" Version="4.20.70" />
|
||||
<PackageReference Include="NUnit" Version="4.1.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -69,27 +69,27 @@ public class RecastTileMeshTest
|
|||
true, true, true,
|
||||
SampleAreaModifications.SAMPLE_AREAMOD_GROUND, true);
|
||||
RcBuilderConfig bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 7, 8);
|
||||
RcBuilderResult rcResult = builder.Build(geom, bcfg, false);
|
||||
RcBuilderResult rcResult = builder.Build(geom, bcfg);
|
||||
Assert.That(rcResult.Mesh.npolys, Is.EqualTo(1));
|
||||
Assert.That(rcResult.Mesh.nverts, Is.EqualTo(5));
|
||||
bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 6, 9);
|
||||
rcResult = builder.Build(geom, bcfg, false);
|
||||
rcResult = builder.Build(geom, bcfg);
|
||||
Assert.That(rcResult.Mesh.npolys, Is.EqualTo(2));
|
||||
Assert.That(rcResult.Mesh.nverts, Is.EqualTo(7));
|
||||
bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 2, 9);
|
||||
rcResult = builder.Build(geom, bcfg, false);
|
||||
rcResult = builder.Build(geom, bcfg);
|
||||
Assert.That(rcResult.Mesh.npolys, Is.EqualTo(2));
|
||||
Assert.That(rcResult.Mesh.nverts, Is.EqualTo(9));
|
||||
bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 4, 3);
|
||||
rcResult = builder.Build(geom, bcfg, false);
|
||||
rcResult = builder.Build(geom, bcfg);
|
||||
Assert.That(rcResult.Mesh.npolys, Is.EqualTo(3));
|
||||
Assert.That(rcResult.Mesh.nverts, Is.EqualTo(6));
|
||||
bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 2, 8);
|
||||
rcResult = builder.Build(geom, bcfg, false);
|
||||
rcResult = builder.Build(geom, bcfg);
|
||||
Assert.That(rcResult.Mesh.npolys, Is.EqualTo(5));
|
||||
Assert.That(rcResult.Mesh.nverts, Is.EqualTo(17));
|
||||
bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 0, 8);
|
||||
rcResult = builder.Build(geom, bcfg, false);
|
||||
rcResult = builder.Build(geom, bcfg);
|
||||
Assert.That(rcResult.Mesh.npolys, Is.EqualTo(6));
|
||||
Assert.That(rcResult.Mesh.nverts, Is.EqualTo(15));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue