update comments

This commit is contained in:
ikpil 2024-01-07 12:53:28 +09:00
parent ae0f21c808
commit 648d7bd703
7 changed files with 93 additions and 160 deletions

View File

@ -154,22 +154,17 @@ namespace DotRecast.Detour
return DtStatus.DT_SUCCESS; return DtStatus.DT_SUCCESS;
} }
/** /// Returns random location on navmesh within the reach of specified location.
* Returns random location on navmesh within the reach of specified location. Polygons are chosen weighted by area. /// Polygons are chosen weighted by area. The search runs in linear related to number of polygon.
* The search runs in linear related to number of polygon. The location is not exactly constrained by the circle, /// The location is not exactly constrained by the circle, but it limits the visited polygons.
* but it limits the visited polygons. /// @param[in] startRef The reference id of the polygon where the search starts.
* /// @param[in] centerPos The center of the search circle. [(x, y, z)]
* @param startRef /// @param[in] maxRadius The radius of the search circle. [Units: wu]
* The reference id of the polygon where the search starts. /// @param[in] filter The polygon filter to apply to the query.
* @param centerPos /// @param[in] frand Function returning a random number [0..1).
* The center of the search circle. [(x, y, z)] /// @param[out] randomRef The reference id of the random location.
* @param maxRadius /// @param[out] randomPt The random location. [(x, y, z)]
* @param filter /// @returns The status flags for the query.
* The polygon filter to apply to the query.
* @param frand
* Function returning a random number [0..1).
* @return Random location
*/
public DtStatus FindRandomPointAroundCircle(long startRef, RcVec3f centerPos, float maxRadius, public DtStatus FindRandomPointAroundCircle(long startRef, RcVec3f centerPos, float maxRadius,
IDtQueryFilter filter, IRcRand frand, out long randomRef, out RcVec3f randomPt) IDtQueryFilter filter, IRcRand frand, out long randomRef, out RcVec3f randomPt)
{ {
@ -197,6 +192,18 @@ namespace DotRecast.Detour
return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, DtStrictDtPolygonByCircleConstraint.Shared, out randomRef, out randomPt); return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, DtStrictDtPolygonByCircleConstraint.Shared, out randomRef, out randomPt);
} }
/// Returns random location on navmesh within the reach of specified location.
/// Polygons are chosen weighted by area. The search runs in linear related to number of polygon.
/// The location is not exactly constrained by the circle, but it limits the visited polygons.
/// @param[in] startRef The reference id of the polygon where the search starts.
/// @param[in] centerPos The center of the search circle. [(x, y, z)]
/// @param[in] maxRadius The radius of the search circle. [Units: wu]
/// @param[in] filter The polygon filter to apply to the query.
/// @param[in] frand Function returning a random number [0..1).
/// @param[in] constraint
/// @param[out] randomRef The reference id of the random location.
/// @param[out] randomPt The random location. [(x, y, z)]
/// @returns The status flags for the query.
public DtStatus FindRandomPointAroundCircle(long startRef, RcVec3f centerPos, float maxRadius, public DtStatus FindRandomPointAroundCircle(long startRef, RcVec3f centerPos, float maxRadius,
IDtQueryFilter filter, IRcRand frand, IDtPolygonByCircleConstraint constraint, IDtQueryFilter filter, IRcRand frand, IDtPolygonByCircleConstraint constraint,
out long randomRef, out RcVec3f randomPt) out long randomRef, out RcVec3f randomPt)
@ -393,13 +400,13 @@ namespace DotRecast.Detour
/// ///
/// @p pos does not have to be within the bounds of the polygon or navigation mesh. /// @p pos does not have to be within the bounds of the polygon or navigation mesh.
/// ///
/// See ClosestPointOnPolyBoundary() for a limited but faster option. /// See closestPointOnPolyBoundary() for a limited but faster option.
/// ///
/// Finds the closest point on the specified polygon. /// Finds the closest point on the specified polygon.
/// @param[in] ref The reference id of the polygon. /// @param[in] ref The reference id of the polygon.
/// @param[in] pos The position to check. [(x, y, z)] /// @param[in] pos The position to check. [(x, y, z)]
/// @param[out] closest /// @param[out] closest The closest point on the polygon. [(x, y, z)]
/// @param[out] posOverPoly /// @param[out] posOverPoly True of the position is over the polygon.
/// @returns The status flags for the query. /// @returns The status flags for the query.
public DtStatus ClosestPointOnPoly(long refs, RcVec3f pos, out RcVec3f closest, out bool posOverPoly) public DtStatus ClosestPointOnPoly(long refs, RcVec3f pos, out RcVec3f closest, out bool posOverPoly)
{ {

View File

@ -6,48 +6,20 @@ namespace DotRecast.Recast
/// @see rcHeightfieldLayerSet /// @see rcHeightfieldLayerSet
public class RcHeightfieldLayer public class RcHeightfieldLayer
{ {
public RcVec3f bmin = new RcVec3f(); public RcVec3f bmin = new RcVec3f(); // < The minimum bounds in world space. [(x, y, z)]
public RcVec3f bmax = new RcVec3f(); // < The maximum bounds in world space. [(x, y, z)]
/// < The minimum bounds in world space. [(x, y, z)] public float cs; // < The size of each cell. (On the xz-plane.)
public RcVec3f bmax = new RcVec3f(); public float ch; // < The height of each cell. (The minimum increment along the y-axis.)
public int width; // < The width of the heightfield. (Along the x-axis in cell units.)
/// < The maximum bounds in world space. [(x, y, z)] public int height; // < The height of the heightfield. (Along the z-axis in cell units.)
public float cs; public int minx; // < The minimum x-bounds of usable data.
public int maxx; // < The maximum x-bounds of usable data.
/// < The size of each cell. (On the xz-plane.) public int miny; // < The minimum y-bounds of usable data. (Along the z-axis.)
public float ch; public int maxy; // < The maximum y-bounds of usable data. (Along the z-axis.)
public int hmin; // < The minimum height bounds of usable data. (Along the y-axis.)
/// < The height of each cell. (The minimum increment along the y-axis.) public int hmax; // < The maximum height bounds of usable data. (Along the y-axis.)
public int width; public int[] heights; // < The heightfield. [Size: width * height]
public int[] areas; // < Area ids. [Size: Same as #heights]
/// < The width of the heightfield. (Along the x-axis in cell units.) public int[] cons; // < Packed neighbor connection information. [Size: Same as #heights]
public int height;
/// < The height of the heightfield. (Along the z-axis in cell units.)
public int minx;
/// < The minimum x-bounds of usable data.
public int maxx;
/// < The maximum x-bounds of usable data.
public int miny;
/// < The minimum y-bounds of usable data. (Along the z-axis.)
public int maxy;
/// < The maximum y-bounds of usable data. (Along the z-axis.)
public int hmin;
/// < The minimum height bounds of usable data. (Along the y-axis.)
public int hmax;
/// < The maximum height bounds of usable data. (Along the y-axis.)
public int[] heights;
/// < The heightfield. [Size: width * height]
public int[] areas;
/// < Area ids. [Size: Same as #heights]
public int[] cons; /// < Packed neighbor connection information. [Size: Same as #heights]
} }
} }

View File

@ -18,7 +18,6 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
using DotRecast.Core.Numerics;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {

View File

@ -869,9 +869,7 @@ namespace DotRecast.Recast
{ {
if (@in[vj + 2] > @in[vi + 2]) if (@in[vj + 2] > @in[vi + 2])
{ {
int temp = vi; (vi, vj) = (vj, vi);
vi = vj;
vj = temp;
swapped = true; swapped = true;
} }
} }
@ -879,9 +877,7 @@ namespace DotRecast.Recast
{ {
if (@in[vj + 0] > @in[vi + 0]) if (@in[vj + 0] > @in[vi + 0])
{ {
int temp = vi; (vi, vj) = (vj, vi);
vi = vj;
vj = temp;
swapped = true; swapped = true;
} }
} }

View File

@ -22,52 +22,26 @@ using DotRecast.Core.Numerics;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
/** Represents a polygon mesh suitable for use in building a navigation mesh. */ /// Represents a polygon mesh suitable for use in building a navigation mesh.
/// @ingroup recast
public class RcPolyMesh public class RcPolyMesh
{ {
/** The mesh vertices. [Form: (x, y, z) coordinates * #nverts] */ public int[] verts; // The mesh vertices. [Form: (x, y, z) coordinates * #nverts]
public int[] verts; public int[] polys; // Polygon and neighbor data. [Length: #maxpolys * 2 * #nvp]
public int[] regs; // The region id assigned to each polygon. [Length: #maxpolys]
public int[] areas; // The area id assigned to each polygon. [Length: #maxpolys]
public int nverts; // The number of vertices.
public int npolys; // The number of polygons.
public int nvp; // The maximum number of vertices per polygon.
public int maxpolys; // The number of allocated polygons.
public int[] flags; // The user defined flags for each polygon. [Length: #maxpolys]
public RcVec3f bmin = new RcVec3f(); // The minimum bounds in world space. [(x, y, z)]
public RcVec3f bmax = new RcVec3f(); // The maximum bounds in world space. [(x, y, z)]
/** Polygon and neighbor data. [Length: #maxpolys * 2 * #nvp] */ public float cs; // The size of each cell. (On the xz-plane.)
public int[] polys; public float ch; // The height of each cell. (The minimum increment along the y-axis.)
/** The region id assigned to each polygon. [Length: #maxpolys] */ public int borderSize; // The AABB border size used to generate the source data from which the mesh was derived.
public int[] regs; public float maxEdgeError; // The max error of the polygon edges in the mesh.
/** The area id assigned to each polygon. [Length: #maxpolys] */
public int[] areas;
/** The number of vertices. */
public int nverts;
/** The number of polygons. */
public int npolys;
/** The maximum number of vertices per polygon. */
public int nvp;
/** The number of allocated polygons. */
public int maxpolys;
/** The user defined flags for each polygon. [Length: #maxpolys] */
public int[] flags;
/** The minimum bounds in world space. [(x, y, z)] */
public RcVec3f bmin = new RcVec3f();
/** The maximum bounds in world space. [(x, y, z)] */
public RcVec3f bmax = new RcVec3f();
/** The size of each cell. (On the xz-plane.) */
public float cs;
/** The height of each cell. (The minimum increment along the y-axis.) */
public float ch;
/** The AABB border size used to generate the source data from which the mesh was derived. */
public int borderSize;
/** The max error of the polygon edges in the mesh. */
public float maxEdgeError;
} }
} }

View File

@ -20,28 +20,16 @@ freely, subject to the following restrictions:
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
/** /// Contains triangle meshes that represent detailed height data associated
* Contains triangle meshes that represent detailed height data associated with the polygons in its associated polygon /// with the polygons in its associated polygon mesh object.
* mesh object. /// @ingroup recast
*/
public class RcPolyMeshDetail public class RcPolyMeshDetail
{ {
/** The sub-mesh data. [Size: 4*#nmeshes] */ public int[] meshes; //< The sub-mesh data. [Size: 4*#nmeshes]
public int[] meshes; public float[] verts; //< The mesh vertices. [Size: 3*#nverts]
public int[] tris; //< The mesh triangles. [Size: 4*#ntris]
/** The mesh vertices. [Size: 3*#nverts] */ public int nmeshes; //< The number of sub-meshes defined by #meshes.
public float[] verts; public int nverts; //< The number of vertices in #verts.
public int ntris; //< The number of triangles in #tris.
/** The mesh triangles. [Size: 4*#ntris] */
public int[] tris;
/** The number of sub-meshes defined by #meshes. */
public int nmeshes;
/** The number of vertices in #verts. */
public int nverts;
/** The number of triangles in #tris. */
public int ntris;
} }
} }

View File

@ -421,10 +421,10 @@ namespace DotRecast.Recast
/// @param[in] flagMergeThreshold The distance where the walkable flag is favored over the non-walkable flag. /// @param[in] flagMergeThreshold The distance where the walkable flag is favored over the non-walkable flag.
/// [Limit: >= 0] [Units: vx] /// [Limit: >= 0] [Units: vx]
/// @returns True if the operation completed successfully. /// @returns True if the operation completed successfully.
public static void RasterizeTriangles(RcTelemetry ctx, float[] verts, int[] tris, int[] triAreaIDs, int numTris, public static void RasterizeTriangles(RcTelemetry context, float[] verts, int[] tris, int[] triAreaIDs, int numTris,
RcHeightfield heightfield, int flagMergeThreshold) RcHeightfield heightfield, int flagMergeThreshold)
{ {
using var timer = ctx.ScopedTimer(RcTimerLabel.RC_TIMER_RASTERIZE_TRIANGLES); using var timer = context.ScopedTimer(RcTimerLabel.RC_TIMER_RASTERIZE_TRIANGLES);
float inverseCellSize = 1.0f / heightfield.cs; float inverseCellSize = 1.0f / heightfield.cs;
float inverseCellHeight = 1.0f / heightfield.ch; float inverseCellHeight = 1.0f / heightfield.ch;
@ -438,28 +438,25 @@ namespace DotRecast.Recast
} }
} }
/** /// Rasterizes a triangle list into the specified heightfield.
* Rasterizes a triangle list into the specified heightfield. Expects each triangle to be specified as three ///
* sequential vertices of 3 floats. Spans will only be added for triangles that overlap the heightfield grid. /// Expects each triangle to be specified as three sequential vertices of 3 floats.
* ///
* @param heightfield /// Spans will only be added for triangles that overlap the heightfield grid.
* An initialized heightfield. ///
* @param verts /// @see rcHeightfield
* The vertices. [(x, y, z) * numVerts] /// @ingroup recast
* @param areaIds /// @param[in,out] context The build context to use during the operation.
* The area id's of the triangles. [Limit: <= WALKABLE_AREA] [Size: numTris] /// @param[in] verts The triangle vertices. [(ax, ay, az, bx, by, bz, cx, by, cx) * @p nt]
* @param tris /// @param[in] triAreaIDs The area id's of the triangles. [Limit: <= #RC_WALKABLE_AREA] [Size: @p nt]
* The triangle indices. [(vertA, vertB, vertC) * nt] /// @param[in] numTris The number of triangles.
* @param numTris /// @param[in,out] heightfield An initialized heightfield.
* The number of triangles. /// @param[in] flagMergeThreshold The distance where the walkable flag is favored over the non-walkable flag.
* @param flagMergeThreshold /// [Limit: >= 0] [Units: vx]
* The distance where the walkable flag is favored over the non-walkable flag. [Limit: >= 0] [Units: vx] /// @returns True if the operation completed successfully.
* @see Heightfield public static void RasterizeTriangles(RcTelemetry context, float[] verts, int[] triAreaIDs, int numTris, RcHeightfield heightfield, int flagMergeThreshold)
*/
public static void RasterizeTriangles(RcHeightfield heightfield, float[] verts, int[] areaIds, int numTris,
int flagMergeThreshold, RcTelemetry ctx)
{ {
using var timer = ctx.ScopedTimer(RcTimerLabel.RC_TIMER_RASTERIZE_TRIANGLES); using var timer = context.ScopedTimer(RcTimerLabel.RC_TIMER_RASTERIZE_TRIANGLES);
float inverseCellSize = 1.0f / heightfield.cs; float inverseCellSize = 1.0f / heightfield.cs;
float inverseCellHeight = 1.0f / heightfield.ch; float inverseCellHeight = 1.0f / heightfield.ch;
@ -468,7 +465,7 @@ namespace DotRecast.Recast
int v0 = (triIndex * 3 + 0); int v0 = (triIndex * 3 + 0);
int v1 = (triIndex * 3 + 1); int v1 = (triIndex * 3 + 1);
int v2 = (triIndex * 3 + 2); int v2 = (triIndex * 3 + 2);
RasterizeTri(verts, v0, v1, v2, areaIds[triIndex], heightfield, heightfield.bmin, heightfield.bmax, heightfield.cs, RasterizeTri(verts, v0, v1, v2, triAreaIDs[triIndex], heightfield, heightfield.bmin, heightfield.bmax, heightfield.cs,
inverseCellSize, inverseCellHeight, flagMergeThreshold); inverseCellSize, inverseCellHeight, flagMergeThreshold);
} }
} }