rename Recast.Recast -> RcUtils

This commit is contained in:
ikpil 2023-07-30 11:17:10 +09:00
parent 5b16338447
commit 8044b85ec5
16 changed files with 62 additions and 24 deletions

View File

@ -84,7 +84,7 @@ public class NavMeshRenderer
int gw = 0, gh = 0;
RcVec3f bmin = geom.GetMeshBoundsMin();
RcVec3f bmax = geom.GetMeshBoundsMax();
Recast.CalcGridSize(bmin, bmax, settings.cellSize, out gw, out gh);
RcUtils.CalcGridSize(bmin, bmax, settings.cellSize, out gw, out gh);
int tw = (gw + settings.tileSize - 1) / settings.tileSize;
int th = (gh + settings.tileSize - 1) / settings.tileSize;
float s = settings.tileSize * settings.cellSize;

View File

@ -451,7 +451,7 @@ public class RecastDemo : IRecastDemoChannel
var settings = _sample.GetSettings();
RcVec3f bmin = _sample.GetInputGeom().GetMeshBoundsMin();
RcVec3f bmax = _sample.GetInputGeom().GetMeshBoundsMax();
Recast.CalcGridSize(bmin, bmax, settings.cellSize, out var gw, out var gh);
RcUtils.CalcGridSize(bmin, bmax, settings.cellSize, out var gw, out var gh);
settingsView.SetVoxels(gw, gh);
settingsView.SetTiles(tileNavMeshBuilder.GetTiles(_sample.GetInputGeom(), settings.cellSize, settings.tileSize));
settingsView.SetMaxTiles(tileNavMeshBuilder.GetMaxTiles(_sample.GetInputGeom(), settings.cellSize, settings.tileSize));

View File

@ -11,6 +11,8 @@ public class ObstacleTool : IRcTool
{
private static readonly ILogger Logger = Log.ForContext<ObstacleTool>();
private readonly ObstacleToolImpl _impl;
private bool _hitPosSet;
private RcVec3f _hitPos;
public ObstacleTool()
{
@ -32,7 +34,7 @@ public class ObstacleTool : IRcTool
{
//m_sample->clearAllTempObstacles();
}
ImGui.Separator();
ImGui.Text("Click LMB to create an obstacle.");
@ -41,6 +43,17 @@ public class ObstacleTool : IRcTool
public void HandleClick(RcVec3f s, RcVec3f p, bool shift)
{
_hitPosSet = true;
_hitPos = p;
if (shift)
{
_impl.RemoveTempObstacle(s, p);
}
else
{
_impl.AddTempObstacle(_hitPos);
}
}
public void HandleRender(NavMeshRenderer renderer)

View File

@ -128,7 +128,7 @@ namespace DotRecast.Recast.DemoTool.Builder
private int GetTileBits(DemoInputGeomProvider geom, float cellSize, int tileSize)
{
Recast.CalcGridSize(geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), cellSize, out var gw, out var gh);
RcUtils.CalcGridSize(geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), cellSize, out var gw, out var gh);
int tw = (gw + tileSize - 1) / tileSize;
int th = (gh + tileSize - 1) / tileSize;
int tileBits = Math.Min(DetourCommon.Ilog2(DetourCommon.NextPow2(tw * th)), 14);
@ -137,7 +137,7 @@ namespace DotRecast.Recast.DemoTool.Builder
public int[] GetTiles(DemoInputGeomProvider geom, float cellSize, int tileSize)
{
Recast.CalcGridSize(geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), cellSize, out var gw, out var gh);
RcUtils.CalcGridSize(geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), cellSize, out var gw, out var gh);
int tw = (gw + tileSize - 1) / tileSize;
int th = (gh + tileSize - 1) / tileSize;
return new int[] { tw, th };

View File

@ -1,4 +1,7 @@
namespace DotRecast.Recast.DemoTool.Tools
using DotRecast.Core;
using DotRecast.Detour.TileCache;
namespace DotRecast.Recast.DemoTool.Tools
{
public class ObstacleToolImpl : ISampleTool
{
@ -18,5 +21,16 @@
{
return _sample;
}
public void RemoveTempObstacle(RcVec3f sp, RcVec3f sq)
{
// ..
}
public void AddTempObstacle(RcVec3f pos)
{
//p[1] -= 0.5f;
//m_tileCache->addObstacle(p, 1.0f, 2.0f, 0);
}
}
}

View File

@ -36,7 +36,7 @@ namespace DotRecast.Recast.DemoTool.Tools
var bmin = geom.GetMeshBoundsMin();
var bmax = geom.GetMeshBoundsMax();
int gw = 0, gh = 0;
Recast.CalcGridSize(bmin, bmax, settings.cellSize, out gw, out gh);
RcUtils.CalcGridSize(bmin, bmax, settings.cellSize, out gw, out gh);
int ts = settings.tileSize;
int tw = (gw + ts - 1) / ts;
@ -64,7 +64,7 @@ namespace DotRecast.Recast.DemoTool.Tools
var bmin = geom.GetMeshBoundsMin();
var bmax = geom.GetMeshBoundsMax();
int gw = 0, gh = 0;
Recast.CalcGridSize(bmin, bmax, settings.cellSize, out gw, out gh);
RcUtils.CalcGridSize(bmin, bmax, settings.cellSize, out gw, out gh);
int ts = settings.tileSize;
int tw = (gw + ts - 1) / ts;

View File

@ -22,9 +22,20 @@ namespace DotRecast.Recast
{
public static class RcConstants
{
/// Represents the null area.
/// When a data element is given this value it is considered to no longer be
/// assigned to a usable area. (E.g. It is un-walkable.)
public const int RC_NULL_AREA = 0;
public const int RC_NOT_CONNECTED = 0x3f;
/// The default area id used to indicate a walkable polygon.
/// This is also the maximum allowed area id, and the only non-null area id
/// recognized by some steps in the build process.
public const int RC_WALKABLE_AREA = 63;
/// The value returned by #rcGetCon if the specified direction is not connected
/// to another span. (Has no neighbor.)
public const int RC_NOT_CONNECTED = 0x3f;
/// Defines the number of bits allocated to rcSpan::smin and rcSpan::smax.
public const int SPAN_HEIGHT_BITS = 20;

View File

@ -23,9 +23,9 @@ using DotRecast.Core;
namespace DotRecast.Recast
{
using static RcConstants;
public static class Recast
using static DotRecast.Recast.RcConstants;
public static class RcUtils
{
public static void CalcBounds(float[] verts, int nv, float[] bmin, float[] bmax)
{

View File

@ -45,7 +45,7 @@ namespace DotRecast.Recast
{
RcVec3f bmin = geom.GetMeshBoundsMin();
RcVec3f bmax = geom.GetMeshBoundsMax();
Recast.CalcTileCount(bmin, bmax, cfg.Cs, cfg.TileSizeX, cfg.TileSizeZ, out var tw, out var th);
RcUtils.CalcTileCount(bmin, bmax, cfg.Cs, cfg.TileSizeX, cfg.TileSizeZ, out var tw, out var th);
List<RecastBuilderResult> results = new List<RecastBuilderResult>();
if (null != taskFactory)
{
@ -64,7 +64,7 @@ namespace DotRecast.Recast
{
RcVec3f bmin = geom.GetMeshBoundsMin();
RcVec3f bmax = geom.GetMeshBoundsMax();
Recast.CalcTileCount(bmin, bmax, cfg.Cs, cfg.TileSizeX, cfg.TileSizeZ, out var tw, out var th);
RcUtils.CalcTileCount(bmin, bmax, cfg.Cs, cfg.TileSizeX, cfg.TileSizeZ, out var tw, out var th);
Task task;
if (1 < threads)
{

View File

@ -92,7 +92,7 @@ namespace DotRecast.Recast
}
else
{
Recast.CalcGridSize(this.bmin, this.bmax, cfg.Cs, out width, out height);
RcUtils.CalcGridSize(this.bmin, this.bmax, cfg.Cs, out width, out height);
}
}
}

View File

@ -57,7 +57,7 @@ namespace DotRecast.Recast
{
int[] tris = node.tris;
int ntris = tris.Length / 3;
int[] m_triareas = Recast.MarkWalkableTriangles(ctx, cfg.WalkableSlopeAngle, verts, tris, ntris, cfg.WalkableAreaMod);
int[] m_triareas = RcUtils.MarkWalkableTriangles(ctx, cfg.WalkableSlopeAngle, verts, tris, ntris, cfg.WalkableAreaMod);
RecastRasterization.RasterizeTriangles(solid, verts, tris, m_triareas, ntris, cfg.WalkableClimb, ctx);
}
}
@ -65,7 +65,7 @@ namespace DotRecast.Recast
{
int[] tris = geom.GetTris();
int ntris = tris.Length / 3;
int[] m_triareas = Recast.MarkWalkableTriangles(ctx, cfg.WalkableSlopeAngle, verts, tris, ntris, cfg.WalkableAreaMod);
int[] m_triareas = RcUtils.MarkWalkableTriangles(ctx, cfg.WalkableSlopeAngle, verts, tris, ntris, cfg.WalkableAreaMod);
RecastRasterization.RasterizeTriangles(solid, verts, tris, m_triareas, ntris, cfg.WalkableClimb, ctx);
}
}

View File

@ -69,7 +69,7 @@ public class MeshSetReaderWriterTest
RcVec3f bmin = geom.GetMeshBoundsMin();
RcVec3f bmax = geom.GetMeshBoundsMax();
Recast.Recast.CalcTileCount(bmin, bmax, m_cellSize, m_tileSize, m_tileSize, out var tw, out var th);
Recast.RcUtils.CalcTileCount(bmin, bmax, m_cellSize, m_tileSize, m_tileSize, out var tw, out var th);
for (int y = 0; y < th; ++y)
{
for (int x = 0; x < tw; ++x)

View File

@ -53,7 +53,7 @@ public class AbstractTileCacheTest
public DtTileCache GetTileCache(IInputGeomProvider geom, RcByteOrder order, bool cCompatibility)
{
DtTileCacheParams option = new DtTileCacheParams();
Recast.Recast.CalcTileCount(geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), m_cellSize, m_tileSize, m_tileSize, out var tw, out var th);
Recast.RcUtils.CalcTileCount(geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), m_cellSize, m_tileSize, m_tileSize, out var tw, out var th);
option.ch = m_cellHeight;
option.cs = m_cellSize;
option.orig = geom.GetMeshBoundsMin();

View File

@ -57,7 +57,7 @@ public class TestTileLayerBuilder : AbstractTileLayersBuilder
true, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);
RcVec3f bmin = geom.GetMeshBoundsMin();
RcVec3f bmax = geom.GetMeshBoundsMax();
Recast.Recast.CalcTileCount(bmin, bmax, m_cellSize, m_tileSize, m_tileSize, out tw, out th);
Recast.RcUtils.CalcTileCount(bmin, bmax, m_cellSize, m_tileSize, m_tileSize, out tw, out th);
}
public List<byte[]> Build(RcByteOrder order, bool cCompatibility, int threads)

View File

@ -131,7 +131,7 @@ public class RecastSoloMeshTest
// Find triangles which are walkable based on their slope and rasterize them.
// If your input data is multiple meshes, you can transform them here, calculate
// the are type for each of the meshes and rasterize them.
int[] m_triareas = Recast.MarkWalkableTriangles(m_ctx, cfg.WalkableSlopeAngle, verts, tris, ntris, cfg.WalkableAreaMod);
int[] m_triareas = RcUtils.MarkWalkableTriangles(m_ctx, cfg.WalkableSlopeAngle, verts, tris, ntris, cfg.WalkableAreaMod);
RecastRasterization.RasterizeTriangles(m_solid, verts, tris, m_triareas, ntris, cfg.WalkableClimb, m_ctx);
}

View File

@ -39,18 +39,18 @@ public class RecastTest
RcTelemetry ctx = new RcTelemetry();
{
int[] areas = { 42 };
Recast.ClearUnwalkableTriangles(ctx, walkableSlopeAngle, verts, nv, unwalkable_tri, nt, areas);
RcUtils.ClearUnwalkableTriangles(ctx, walkableSlopeAngle, verts, nv, unwalkable_tri, nt, areas);
Assert.That(areas[0], Is.EqualTo(RC_NULL_AREA), "Sets area ID of unwalkable triangle to RC_NULL_AREA");
}
{
int[] areas = { 42 };
Recast.ClearUnwalkableTriangles(ctx, walkableSlopeAngle, verts, nv, walkable_tri, nt, areas);
RcUtils.ClearUnwalkableTriangles(ctx, walkableSlopeAngle, verts, nv, walkable_tri, nt, areas);
Assert.That(areas[0], Is.EqualTo(42), "Does not modify walkable triangle aread ID's");
}
{
int[] areas = { 42 };
walkableSlopeAngle = 0;
Recast.ClearUnwalkableTriangles(ctx, walkableSlopeAngle, verts, nv, walkable_tri, nt, areas);
RcUtils.ClearUnwalkableTriangles(ctx, walkableSlopeAngle, verts, nv, walkable_tri, nt, areas);
Assert.That(areas[0], Is.EqualTo(RC_NULL_AREA), "Slopes equal to the max slope are considered unwalkable.");
}
}