Flafla2 / Vive-Teleporter

A framework for Unity3D that automatically generates teleporter boundaries and facilitates the teleporter mechanic, similarly to Valve's "The Lab"
MIT License
394 stars 94 forks source link

Optimize Navmesh Polling #9

Closed Flafla2 closed 8 years ago

Flafla2 commented 8 years ago

The API currently slows to a crawl when dealing with large Navmeshes. The most intensive step currently (at runtime) is raycasting against the Navmesh, an O(T) calculation (T=number of triangles). This performance is dismal in comparison to Unity's own navmesh, which does some sort of preprocessing beforehand. Clearly this can be improved, however I want to retain the non-invasive aspects of the current system (ie the user can currently use the Unity navmesh for AI or other things and doesn't have to limit the bake settings just because of Vive teleportation).

The easiest solution is to roll with an existing pathfinding system. Detour (a part of the Recast navigation system) seems like an excellent candidate in this regard. It shouldn't be too difficult to port Detour to C# (using C#'s native DLL binding system).

Flafla2 commented 8 years ago

Addressed in version 2.0.0 (we now use Unity's physics raycasting for the initial raycast and Unity's Navmesh for sampling if a point is on the navmesh), but I may decide to reopen this if more robust control is called for.