Search Unity

NavMesh.CalculateTriangulation not returning all of the geometry

Discussion in 'Navigation' started by cpuRunningHot, Jul 22, 2022.

  1. cpuRunningHot

    cpuRunningHot

    Joined:
    May 5, 2018
    Posts:
    94
    i am attempting to create an in-game visualization of the NavMesh so QA can quickly identify issues related to pathfinding. For the example I'm about to show, we are using a larger than usual step height, which is a deliberate choice at this time for reasons I won't bore you with. Anyway, here is the situation...

    Code (CSharp):
    1.  
    2. var triangulation = NavMesh.CalculateTriangulation();
    3. var vertices = triangulation.vertices;
    4. var indices = triangulation.indices;
    5.  
    6. var mesh = new Mesh();
    7. mesh.vertices = vertices;
    8. mesh.SetIndices(indices, MeshTopology.Triangles, 0);
    9.  
    10. AssetDatabase.CreateAsset( mesh, assetFileName);
    11. AssetDatabase.SaveAssets();
    upload_2022-7-22_14-21-20.png
    NavMesh as it appears in the editor

    First red flag here is that there are no black dots being rendered on some of the vertices...
    upload_2022-7-22_14-22-54.png


    Then when I export the data using the results from NavMesh.CalculateTriangulation(), those bits that are not rendering black vertex dots seem to be omitted completely...

    upload_2022-7-22_15-28-35.png
    In Blender

    upload_2022-7-22_15-29-54.png
    In Unity

    This is in Unity 2021.2.17f1.4580


    The NavMesh data obviously exists as per the first screen shot. Does anyone know what the solution for this issue may be?

    Thx in advance :D

     
  2. cpuRunningHot

    cpuRunningHot

    Joined:
    May 5, 2018
    Posts:
    94
    I would still be interested in a solution to the above problem if one is available ( suspect that it's simply not possible ), but in the interest of sharing, here is a simple solution to prevent the above case from happening. Simply mark those objects as a different NavMesh area, and the resulting NavMesh will be much cleaner ( even if a separate cost is not required )

    upload_2022-7-23_10-47-19.png
     

    Attached Files: