vleue / vleue_navigator

https://vleue.github.io/vleue_navigator/
Apache License 2.0
173 stars 13 forks source link

Possible to add obstacles to existing NavMeshes? #42

Open 66OJ66 opened 1 month ago

66OJ66 commented 1 month ago

Hi, is it currently possible to take an existing NavMesh and add obstacles to it?

In my game, I have multiple overlapping navmeshes being used simultaneously (each with their own set of obstacles), so I don't think I can use the NavmeshUpdaterPlugin approach. (e.g. an obstacle at x: 5.0 and y: 10.5 might only be valid for 1 navmesh but not the others).

If there is a way to convert an existing NavMesh to edges, then I could just use this method

mockersf commented 1 month ago

In my game, I have multiple overlapping navmeshes being used simultaneously (each with their own set of obstacles), so I don't think I can use the NavmeshUpdaterPlugin approach.

It should still be possible to use NavmeshUpdaterPlugin in that case, at least I planned it so but I just realised there's a hole in the API. The plugin takes an optional second type parameter that can control which obstacle to use and which to ignore, but it still update all the navmeshes. I'll look into adding something to also limit which navmeshes are updated.

If there is a way to convert an existing NavMesh to edges

Not yet, but it's "easy" to add. Do you want the edges so you can call from_edge_and_obstacles? Or would returning a Triangulation be ok for you?

66OJ66 commented 1 month ago

Or would returning a Triangulation be ok for you?

Ah okay, I think this would be more ergonomic because Triangulation has the methods for caching obstacles (and all my obstacles are currently static).

In terms of generating the most performant NavMeshes with obstacles, would you say this sequence of operations is correct?

  1. Start with NavMesh (generated from gLTF etc)
  2. Convert to Triangulation
  3. Add obstacles
  4. Prebuild
  5. Convert back to NavMesh
  6. Merge polygons
  7. Bake

The plugin takes an optional second type parameter that can control which obstacle to use and which to ignore, but it still update all the navmeshes. I'll look into adding something to also limit which navmeshes are updated.

That makes sense - as I'm just using static obstacles I think the approach above would be easier for me, but being able to have dynamic obstacles per navmesh might be beneficial for others :)