ikpil / DotRecast

DotRecast - a port of Recast & Detour, Industry-standard navigation mesh toolset for .NET, C#, Unity3D, games, servers
zlib License
563 stars 72 forks source link

Issue with DynamicNavMesh Generation at Tile Boundaries #77

Open OhJeongrok opened 2 months ago

OhJeongrok commented 2 months ago

Hello,

I’m encountering an issue with generating a DtDynamicNavMesh in DotRecast, particularly when placing colliders at the boundaries between tiles. I’ve been testing this using the RcDynamicUpdateTool.cs from the Recast.Demo project, specifically with the box collider generation function. Below is the code I’m using for the collider creation:

        public RcGizmo BoxCollider(RcVec3f p, float walkableClimb)
        {
            RcVec3f extent = new RcVec3f(
                25.0f * 2,
                25.0f * 2,
                25.0f * 2
            );
            RcVec3f forward = RcVec3f.UnitX;
            RcVec3f up = RcVec3f.UnitY;
            RcVec3f[] halfEdges = Detour.Dynamic.Colliders.DtBoxCollider.GetHalfEdges(up, forward, extent);
            var collider = new DtBoxCollider(p, halfEdges, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, walkableClimb);
            var gizmo = RcGizmoFactory.Box(p, halfEdges);
            return new RcGizmo(collider, gizmo);
        }

I’m using the following settings:

    public class RcNavMeshBuildSettings
    {
        public float cellSize = 19.0f;
        public float cellHeight = 25.0f;

        public float agentHeight = 144.0f;
        public float agentRadius = 35.0f;
        public float agentMaxClimb = 49.0f;
        public float agentMaxSlope = 60.0f;

        public float agentMaxAcceleration = 800.0f;
        public float agentMaxSpeed = 600.0f;

        public int minRegionSize = 0;
        public int mergedRegionSize = 20;

        public int partitioning = RcPartitionType.WATERSHED.Value;

        public bool filterLowHangingObstacles = true;
        public bool filterLedgeSpans = true;
        public bool filterWalkableLowHeightSpans = true;

        public float edgeMaxLen = 12.0f;
        public float edgeMaxError = 1.3f;
        public int vertsPerPoly = 6;

        public float detailSampleDist = 6.0f;
        public float detailSampleMaxError = 1.0f;

        public bool tiled = true;
        public int tileSize = 150;
    }

When using these settings, the NavMesh fails to generate correctly at the tile boundaries where the box colliders are placed. The colliders on these boundaries are either not being processed correctly, resulting in gaps or incomplete navigation data at the borders. I’ve tried adjusting various parameters like tile size and collider extents, but the problem persists.

Could you provide guidance on how to resolve this issue so that colliders at tile boundaries are correctly integrated into the DtDynamicNavMesh generation?

Thank you for your help!

image image

ikpil commented 2 months ago

Hello, I’ve been busy with work recently, so my response is delayed. I’m sorry about that.

I will check into this.

ikpil commented 1 month ago

image

ikpil commented 1 month ago

First, I apologize. I've been busy and couldn't pay attention to this. @ppiastucki from recast4j has made the correction, and I've ported it as is. Thank you once again for reporting this!