forked from mirror/DotRecast
typo
This commit is contained in:
parent
21a6b1c5e8
commit
e6e17d83a2
|
@ -20,33 +20,28 @@ freely, subject to the following restrictions:
|
|||
|
||||
namespace DotRecast.Detour
|
||||
{
|
||||
/**
|
||||
* Defines an navigation mesh off-mesh connection within a dtMeshTile object. An off-mesh connection is a user defined
|
||||
* traversable connection made up to two vertices.
|
||||
*/
|
||||
/// Defines an navigation mesh off-mesh connection within a dtMeshTile object.
|
||||
/// An off-mesh connection is a user defined traversable connection made up to two vertices.
|
||||
public class DtOffMeshConnection
|
||||
{
|
||||
/** The endpoints of the connection. [(ax, ay, az, bx, by, bz)] */
|
||||
/// The endpoints of the connection. [(ax, ay, az, bx, by, bz)]
|
||||
public float[] pos = new float[6];
|
||||
|
||||
/** The radius of the endpoints. [Limit: >= 0] */
|
||||
/// The radius of the endpoints. [Limit: >= 0]
|
||||
public float rad;
|
||||
|
||||
/** The polygon reference of the connection within the tile. */
|
||||
/// The polygon reference of the connection within the tile.
|
||||
public int poly;
|
||||
|
||||
/**
|
||||
* Link flags.
|
||||
*
|
||||
* @note These are not the connection's user defined flags. Those are assigned via the connection's Poly definition.
|
||||
* These are link flags used for internal purposes.
|
||||
*/
|
||||
/// Link flags.
|
||||
/// @note These are not the connection's user defined flags. Those are assigned via the
|
||||
/// connection's dtPoly definition. These are link flags used for internal purposes.
|
||||
public int flags;
|
||||
|
||||
/** End point side. */
|
||||
/// End point side.
|
||||
public int side;
|
||||
|
||||
/** The id of the offmesh connection. (User assigned when the navigation mesh is built.) */
|
||||
/// The id of the offmesh connection. (User assigned when the navigation mesh is built.)
|
||||
public int userId;
|
||||
}
|
||||
}
|
|
@ -228,7 +228,7 @@ public class NavMeshRenderer
|
|||
_debugDraw.DepthMask(false);
|
||||
|
||||
_debugDraw.Begin(DebugDrawPrimitives.LINES, 2.0f);
|
||||
foreach (DemoOffMeshConnection con in geom.GetOffMeshConnections())
|
||||
foreach (var con in geom.GetOffMeshConnections())
|
||||
{
|
||||
float[] v = con.verts;
|
||||
_debugDraw.Vertex(v[0], v[1], v[2], baseColor);
|
||||
|
|
|
@ -1,48 +1,49 @@
|
|||
using DotRecast.Detour;
|
||||
using DotRecast.Recast.DemoTool.Geom;
|
||||
using DotRecast.Recast.Geom;
|
||||
|
||||
namespace DotRecast.Recast.DemoTool.Builder
|
||||
{
|
||||
public abstract class AbstractNavMeshBuilder
|
||||
public static class DemoNavMeshBuilder
|
||||
{
|
||||
protected DtNavMeshCreateParams GetNavMeshCreateParams(DemoInputGeomProvider m_geom, float m_cellSize,
|
||||
float m_cellHeight, float m_agentHeight, float m_agentRadius, float m_agentMaxClimb,
|
||||
public static DtNavMeshCreateParams GetNavMeshCreateParams(DemoInputGeomProvider geom, float cellSize,
|
||||
float cellHeight, float agentHeight, float agentRadius, float agentMaxClimb,
|
||||
RecastBuilderResult rcResult)
|
||||
{
|
||||
RcPolyMesh m_pmesh = rcResult.GetMesh();
|
||||
RcPolyMeshDetail m_dmesh = rcResult.GetMeshDetail();
|
||||
RcPolyMesh pmesh = rcResult.GetMesh();
|
||||
RcPolyMeshDetail dmesh = rcResult.GetMeshDetail();
|
||||
DtNavMeshCreateParams option = new DtNavMeshCreateParams();
|
||||
for (int i = 0; i < m_pmesh.npolys; ++i)
|
||||
for (int i = 0; i < pmesh.npolys; ++i)
|
||||
{
|
||||
m_pmesh.flags[i] = 1;
|
||||
pmesh.flags[i] = 1;
|
||||
}
|
||||
|
||||
option.verts = m_pmesh.verts;
|
||||
option.vertCount = m_pmesh.nverts;
|
||||
option.polys = m_pmesh.polys;
|
||||
option.polyAreas = m_pmesh.areas;
|
||||
option.polyFlags = m_pmesh.flags;
|
||||
option.polyCount = m_pmesh.npolys;
|
||||
option.nvp = m_pmesh.nvp;
|
||||
if (m_dmesh != null)
|
||||
option.verts = pmesh.verts;
|
||||
option.vertCount = pmesh.nverts;
|
||||
option.polys = pmesh.polys;
|
||||
option.polyAreas = pmesh.areas;
|
||||
option.polyFlags = pmesh.flags;
|
||||
option.polyCount = pmesh.npolys;
|
||||
option.nvp = pmesh.nvp;
|
||||
if (dmesh != null)
|
||||
{
|
||||
option.detailMeshes = m_dmesh.meshes;
|
||||
option.detailVerts = m_dmesh.verts;
|
||||
option.detailVertsCount = m_dmesh.nverts;
|
||||
option.detailTris = m_dmesh.tris;
|
||||
option.detailTriCount = m_dmesh.ntris;
|
||||
option.detailMeshes = dmesh.meshes;
|
||||
option.detailVerts = dmesh.verts;
|
||||
option.detailVertsCount = dmesh.nverts;
|
||||
option.detailTris = dmesh.tris;
|
||||
option.detailTriCount = dmesh.ntris;
|
||||
}
|
||||
|
||||
option.walkableHeight = m_agentHeight;
|
||||
option.walkableRadius = m_agentRadius;
|
||||
option.walkableClimb = m_agentMaxClimb;
|
||||
option.bmin = m_pmesh.bmin;
|
||||
option.bmax = m_pmesh.bmax;
|
||||
option.cs = m_cellSize;
|
||||
option.ch = m_cellHeight;
|
||||
option.walkableHeight = agentHeight;
|
||||
option.walkableRadius = agentRadius;
|
||||
option.walkableClimb = agentMaxClimb;
|
||||
option.bmin = pmesh.bmin;
|
||||
option.bmax = pmesh.bmax;
|
||||
option.cs = cellSize;
|
||||
option.ch = cellHeight;
|
||||
option.buildBvTree = true;
|
||||
|
||||
option.offMeshConCount = m_geom.GetOffMeshConnections().Count;
|
||||
option.offMeshConCount = geom.GetOffMeshConnections().Count;
|
||||
option.offMeshConVerts = new float[option.offMeshConCount * 6];
|
||||
option.offMeshConRad = new float[option.offMeshConCount];
|
||||
option.offMeshConDir = new int[option.offMeshConCount];
|
||||
|
@ -51,7 +52,7 @@ namespace DotRecast.Recast.DemoTool.Builder
|
|||
option.offMeshConUserID = new int[option.offMeshConCount];
|
||||
for (int i = 0; i < option.offMeshConCount; i++)
|
||||
{
|
||||
DemoOffMeshConnection offMeshCon = m_geom.GetOffMeshConnections()[i];
|
||||
DemoOffMeshConnection offMeshCon = geom.GetOffMeshConnections()[i];
|
||||
for (int j = 0; j < 6; j++)
|
||||
{
|
||||
option.offMeshConVerts[6 * i + j] = offMeshCon.verts[j];
|
||||
|
@ -66,7 +67,7 @@ namespace DotRecast.Recast.DemoTool.Builder
|
|||
return option;
|
||||
}
|
||||
|
||||
protected DtMeshData UpdateAreaAndFlags(DtMeshData meshData)
|
||||
public static DtMeshData UpdateAreaAndFlags(DtMeshData meshData)
|
||||
{
|
||||
// Update poly flags from areas.
|
||||
for (int i = 0; i < meshData.polys.Length; ++i)
|
|
@ -23,7 +23,6 @@ using System.Linq;
|
|||
|
||||
namespace DotRecast.Recast.DemoTool.Builder
|
||||
{
|
||||
|
||||
public class SampleAreaModifications
|
||||
{
|
||||
public const int SAMPLE_POLYAREA_TYPE_GROUND = 0x0;
|
||||
|
@ -35,6 +34,13 @@ namespace DotRecast.Recast.DemoTool.Builder
|
|||
public const int SAMPLE_POLYAREA_TYPE_JUMP_AUTO = 0x6;
|
||||
public const int SAMPLE_POLYAREA_TYPE_WALKABLE = 0x3f;
|
||||
|
||||
public static readonly int SAMPLE_POLYFLAGS_WALK = 0x01; // Ability to walk (ground, grass, road)
|
||||
public static readonly int SAMPLE_POLYFLAGS_SWIM = 0x02; // Ability to swim (water).
|
||||
public static readonly int SAMPLE_POLYFLAGS_DOOR = 0x04; // Ability to move through doors.
|
||||
public static readonly int SAMPLE_POLYFLAGS_JUMP = 0x08; // Ability to jump.
|
||||
public static readonly int SAMPLE_POLYFLAGS_DISABLED = 0x10; // Disabled polygon
|
||||
public static readonly int SAMPLE_POLYFLAGS_ALL = 0xffff; // All abilities.
|
||||
|
||||
public static readonly RcAreaModification SAMPLE_AREAMOD_WALKABLE = new RcAreaModification(SAMPLE_POLYAREA_TYPE_WALKABLE);
|
||||
public static readonly RcAreaModification SAMPLE_AREAMOD_GROUND = new RcAreaModification(SAMPLE_POLYAREA_TYPE_GROUND);
|
||||
public static readonly RcAreaModification SAMPLE_AREAMOD_WATER = new RcAreaModification(SAMPLE_POLYAREA_TYPE_WATER);
|
||||
|
@ -57,12 +63,5 @@ namespace DotRecast.Recast.DemoTool.Builder
|
|||
{
|
||||
return Values.FirstOrDefault(x => x.Value == value) ?? SAMPLE_AREAMOD_GRASS;
|
||||
}
|
||||
|
||||
public static readonly int SAMPLE_POLYFLAGS_WALK = 0x01; // Ability to walk (ground, grass, road)
|
||||
public static readonly int SAMPLE_POLYFLAGS_SWIM = 0x02; // Ability to swim (water).
|
||||
public static readonly int SAMPLE_POLYFLAGS_DOOR = 0x04; // Ability to move through doors.
|
||||
public static readonly int SAMPLE_POLYFLAGS_JUMP = 0x08; // Ability to jump.
|
||||
public static readonly int SAMPLE_POLYFLAGS_DISABLED = 0x10; // Disabled polygon
|
||||
public static readonly int SAMPLE_POLYFLAGS_ALL = 0xffff; // All abilities.
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ using DotRecast.Recast.DemoTool.Geom;
|
|||
|
||||
namespace DotRecast.Recast.DemoTool.Builder
|
||||
{
|
||||
public class SoloNavMeshBuilder : AbstractNavMeshBuilder
|
||||
public class SoloNavMeshBuilder
|
||||
{
|
||||
public NavMeshBuildResult Build(DemoInputGeomProvider geom, PartitionType partitionType,
|
||||
float cellSize, float cellHeight, float agentHeight, float agentRadius, float agentMaxClimb,
|
||||
|
@ -62,12 +62,13 @@ namespace DotRecast.Recast.DemoTool.Builder
|
|||
return rcBuilder.Build(geom, bcfg);
|
||||
}
|
||||
|
||||
private DtMeshData BuildMeshData(DemoInputGeomProvider geom, float cellSize, float cellHeight, float agentHeight,
|
||||
public DtMeshData BuildMeshData(DemoInputGeomProvider geom, float cellSize, float cellHeight, float agentHeight,
|
||||
float agentRadius, float agentMaxClimb, RecastBuilderResult result)
|
||||
{
|
||||
DtNavMeshCreateParams option = GetNavMeshCreateParams(geom, cellSize, cellHeight, agentHeight, agentRadius,
|
||||
agentMaxClimb, result);
|
||||
return UpdateAreaAndFlags(NavMeshBuilder.CreateNavMeshData(option));
|
||||
DtNavMeshCreateParams option = DemoNavMeshBuilder
|
||||
.GetNavMeshCreateParams(geom, cellSize, cellHeight, agentHeight, agentRadius, agentMaxClimb, result);
|
||||
var meshData = NavMeshBuilder.CreateNavMeshData(option);
|
||||
return DemoNavMeshBuilder.UpdateAreaAndFlags(meshData);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,14 +19,12 @@ freely, subject to the following restrictions:
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using DotRecast.Core;
|
||||
using DotRecast.Detour;
|
||||
using DotRecast.Recast.DemoTool.Geom;
|
||||
using static DotRecast.Core.RcMath;
|
||||
|
||||
namespace DotRecast.Recast.DemoTool.Builder
|
||||
{
|
||||
public class TileNavMeshBuilder : AbstractNavMeshBuilder
|
||||
public class TileNavMeshBuilder
|
||||
{
|
||||
public TileNavMeshBuilder()
|
||||
{
|
||||
|
@ -47,7 +45,7 @@ namespace DotRecast.Recast.DemoTool.Builder
|
|||
return new NavMeshBuildResult(results, tileNavMesh);
|
||||
}
|
||||
|
||||
private List<RecastBuilderResult> BuildRecastResult(DemoInputGeomProvider geom, PartitionType partitionType,
|
||||
public List<RecastBuilderResult> BuildRecastResult(DemoInputGeomProvider geom, PartitionType partitionType,
|
||||
float cellSize, float cellHeight, float agentHeight, float agentRadius, float agentMaxClimb,
|
||||
float agentMaxSlope, int regionMinSize, int regionMergeSize, float edgeMaxLen, float edgeMaxError,
|
||||
int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, bool filterLowHangingObstacles,
|
||||
|
@ -63,7 +61,7 @@ namespace DotRecast.Recast.DemoTool.Builder
|
|||
return rcBuilder.BuildTiles(geom, cfg, Task.Factory);
|
||||
}
|
||||
|
||||
private DtNavMesh BuildNavMesh(DemoInputGeomProvider geom, List<DtMeshData> meshData, float cellSize, int tileSize, int vertsPerPoly)
|
||||
public DtNavMesh BuildNavMesh(DemoInputGeomProvider geom, List<DtMeshData> meshData, float cellSize, int tileSize, int vertsPerPoly)
|
||||
{
|
||||
DtNavMeshParams navMeshParams = new DtNavMeshParams();
|
||||
navMeshParams.orig = geom.GetMeshBoundsMin();
|
||||
|
@ -79,6 +77,31 @@ namespace DotRecast.Recast.DemoTool.Builder
|
|||
return navMesh;
|
||||
}
|
||||
|
||||
private List<DtMeshData> BuildMeshData(DemoInputGeomProvider geom, float cellSize, float cellHeight, float agentHeight,
|
||||
float agentRadius, float agentMaxClimb, List<RecastBuilderResult> results)
|
||||
{
|
||||
// Add tiles to nav mesh
|
||||
List<DtMeshData> meshData = new List<DtMeshData>();
|
||||
foreach (RecastBuilderResult result in results)
|
||||
{
|
||||
int x = result.tileX;
|
||||
int z = result.tileZ;
|
||||
DtNavMeshCreateParams option = DemoNavMeshBuilder
|
||||
.GetNavMeshCreateParams(geom, cellSize, cellHeight, agentHeight, agentRadius, agentMaxClimb, result);
|
||||
|
||||
option.tileX = x;
|
||||
option.tileZ = z;
|
||||
DtMeshData md = NavMeshBuilder.CreateNavMeshData(option);
|
||||
if (md != null)
|
||||
{
|
||||
meshData.Add(DemoNavMeshBuilder.UpdateAreaAndFlags(md));
|
||||
}
|
||||
}
|
||||
|
||||
return meshData;
|
||||
}
|
||||
|
||||
|
||||
public int GetMaxTiles(DemoInputGeomProvider geom, float cellSize, int tileSize)
|
||||
{
|
||||
int tileBits = GetTileBits(geom, cellSize, tileSize);
|
||||
|
@ -107,28 +130,5 @@ namespace DotRecast.Recast.DemoTool.Builder
|
|||
int th = (gh + tileSize - 1) / tileSize;
|
||||
return new int[] { tw, th };
|
||||
}
|
||||
|
||||
private List<DtMeshData> BuildMeshData(DemoInputGeomProvider geom, float cellSize, float cellHeight, float agentHeight,
|
||||
float agentRadius, float agentMaxClimb, List<RecastBuilderResult> results)
|
||||
{
|
||||
// Add tiles to nav mesh
|
||||
List<DtMeshData> meshData = new List<DtMeshData>();
|
||||
foreach (RecastBuilderResult result in results)
|
||||
{
|
||||
int x = result.tileX;
|
||||
int z = result.tileZ;
|
||||
DtNavMeshCreateParams option = GetNavMeshCreateParams(geom, cellSize, cellHeight, agentHeight,
|
||||
agentRadius, agentMaxClimb, result);
|
||||
option.tileX = x;
|
||||
option.tileZ = z;
|
||||
DtMeshData md = NavMeshBuilder.CreateNavMeshData(option);
|
||||
if (md != null)
|
||||
{
|
||||
meshData.Add(UpdateAreaAndFlags(md));
|
||||
}
|
||||
}
|
||||
|
||||
return meshData;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ namespace DotRecast.Recast.DemoTool.Geom
|
|||
private readonly RcVec3f bmin;
|
||||
private readonly RcVec3f bmax;
|
||||
private readonly List<RcConvexVolume> _convexVolumes = new List<RcConvexVolume>();
|
||||
private readonly List<DemoOffMeshConnection> offMeshConnections = new List<DemoOffMeshConnection>();
|
||||
private readonly List<DemoOffMeshConnection> _offMeshConnections = new List<DemoOffMeshConnection>();
|
||||
private readonly RcTriMesh _mesh;
|
||||
|
||||
public DemoInputGeomProvider(List<float> vertexPositions, List<int> meshFaces) :
|
||||
|
@ -134,18 +134,18 @@ namespace DotRecast.Recast.DemoTool.Geom
|
|||
|
||||
public List<DemoOffMeshConnection> GetOffMeshConnections()
|
||||
{
|
||||
return offMeshConnections;
|
||||
return _offMeshConnections;
|
||||
}
|
||||
|
||||
public void AddOffMeshConnection(RcVec3f start, RcVec3f end, float radius, bool bidir, int area, int flags)
|
||||
{
|
||||
offMeshConnections.Add(new DemoOffMeshConnection(start, end, radius, bidir, area, flags));
|
||||
_offMeshConnections.Add(new DemoOffMeshConnection(start, end, radius, bidir, area, flags));
|
||||
}
|
||||
|
||||
public void RemoveOffMeshConnections(Predicate<DemoOffMeshConnection> filter)
|
||||
{
|
||||
//offMeshConnections.RetainAll(offMeshConnections.Stream().Filter(c -> !filter.Test(c)).Collect(ToList()));
|
||||
offMeshConnections.RemoveAll(filter); // TODO : 확인 필요
|
||||
_offMeshConnections.RemoveAll(filter); // TODO : 확인 필요
|
||||
}
|
||||
|
||||
public float? RaycastMesh(RcVec3f src, RcVec3f dst)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using DotRecast.Core;
|
||||
using DotRecast.Recast.DemoTool.Builder;
|
||||
using DotRecast.Recast.DemoTool.Geom;
|
||||
using DotRecast.Recast.Geom;
|
||||
|
||||
namespace DotRecast.Recast.DemoTool.Tools
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using DotRecast.Core;
|
||||
using DotRecast.Detour.TileCache;
|
||||
|
||||
namespace DotRecast.Recast.DemoTool.Tools
|
||||
{
|
||||
|
@ -36,9 +37,9 @@ namespace DotRecast.Recast.DemoTool.Tools
|
|||
|
||||
int tx = (int)((pos.x - bmin[0]) / ts);
|
||||
int ty = (int)((pos.z - bmin[2]) / ts);
|
||||
|
||||
|
||||
var tileRef = navMesh.GetTileRefAt(tx, ty, 0);
|
||||
navMesh.RemoveTile(tileRef);
|
||||
// navMesh.RemoveTile(tileRef);
|
||||
}
|
||||
|
||||
public void RemoveTile(RcVec3f pos)
|
||||
|
|
|
@ -93,10 +93,12 @@ public class TestDetourBuilder : DetourBuilder
|
|||
option.ch = rcConfig.ch;
|
||||
option.buildBvTree = true;
|
||||
/*
|
||||
* option.offMeshConVerts = m_geom->GetOffMeshConnectionVerts(); option.offMeshConRad =
|
||||
* m_geom->GetOffMeshConnectionRads(); option.offMeshConDir = m_geom->GetOffMeshConnectionDirs();
|
||||
* option.offMeshConAreas = m_geom->GetOffMeshConnectionAreas(); option.offMeshConFlags =
|
||||
* m_geom->GetOffMeshConnectionFlags(); option.offMeshConUserID = m_geom->GetOffMeshConnectionId();
|
||||
* option.offMeshConVerts = m_geom->GetOffMeshConnectionVerts();
|
||||
* option.offMeshConRad = m_geom->GetOffMeshConnectionRads();
|
||||
* option.offMeshConDir = m_geom->GetOffMeshConnectionDirs();
|
||||
* option.offMeshConAreas = m_geom->GetOffMeshConnectionAreas();
|
||||
* option.offMeshConFlags = m_geom->GetOffMeshConnectionFlags();
|
||||
* option.offMeshConUserID = m_geom->GetOffMeshConnectionId();
|
||||
* option.offMeshConCount = m_geom->GetOffMeshConnectionCount();
|
||||
*/
|
||||
return option;
|
||||
|
|
Loading…
Reference in New Issue