Search Unity

NavMeshBuilder.CollectSources async?

Discussion in 'Navigation' started by Sebioff, Jul 11, 2017.

  1. Sebioff

    Sebioff

    Joined:
    Dec 22, 2013
    Posts:
    218
    The new runtime NavMesh baking is really cool :) Pretty easy to use, works well and performance is great too.
    One improvement suggestion I have: would it be possible to add an async version of NavMeshBuilder.CollectSources?
    There's already some async building with NavMeshBuilder.UpdateNavMeshDataAsync, but at least in my case UpdateNavMeshData is quite fast while NavMeshBuilder.CollectSources can easily take 60-100ms in fairly small scenes with small bounds.
     
  2. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    This is by deliberately not implemented as an async operation - as we want to provide a snapshot of the geometry in the bounds/world/root - if this was an async operation, and the scene changes while executing - it'd be hard to reason about which sources are gathered.
    We can have a look at performance - are you collecting physics or render meshes ?
     
  3. Sebioff

    Sebioff

    Joined:
    Dec 22, 2013
    Posts:
    218
    Ah, yeah. For my case though it wouldn't matter - I'm only collecting non-moving geometry, and if a potentially blocking object is placed/removed within the range of the navmesh I need to re-collect the sources and regenerate the navmesh anyways.

    I'm collecting both physics (< 5) and render meshes (anywhere between hundreds to thousands).
     
  4. DwinTeimlon

    DwinTeimlon

    Joined:
    Feb 25, 2016
    Posts:
    300
    Have you looked at the examples especially NavMeshSourceTag.cs and LocalNavMeshBuilder.cs? Afaik it's a faster way of collecting and you can still change LocalNavMeshBuilder so that it is only updating when you changed something on your terrain.