-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add islands to NavMesh API #1866
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some code suggestions to address some performance concerns with std::unordered_map (which is admittingly complex to use properly pre-C++17 with try_emplace).
Mainly:
- Calling reserve() to prevent tons of reallocations / rehashing of the hashmap as the container grows
- Emplacing the std::vector directly into the map during construction
- Emplacing the value directly if it makes sense (non-primitive type).
Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplify a bit. I don't think explicitly default initializing the unordered_map is even necessary at all. (For default constructible values at least).
Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
Motivation and Context
Though the underlying C++ nav module has been computing islands on the back-end, we hadn't yet exposed island filtered queries for NavMesh operations.
This PR introduces new island operations:
get_island(point)
- get the island index closest to a pointisland_area(index)
- get the area of a specific island by indexisland_radius(point)
andisland_radius(index)
- get the radius heuristic for island sizenum_islands
- property for number of islands on a NavMeshand adds optional island specification to other operations:
get_random_navigable_point()
andget_random_navigable_point_near()
- now can query a specific island by indexsnap_point()
- now can snap to a specified islandbuild_navmesh_vertices()
- can get vertex buffer for a specific islandbuild_navmesh_vertex_indices()
- can get index buffer for a specific islandAlso adds and updates docstrings for the full Nav module in both C++ and Python.
How Has This Been Tested
Added new pytests for island functionality.
Types of changes
Checklist