Conversation
Skylion007
suggested changes
Sep 19, 2022
Contributor
Skylion007
left a comment
There was a problem hiding this comment.
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>
Skylion007
suggested changes
Sep 19, 2022
Contributor
Skylion007
left a comment
There was a problem hiding this comment.
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>
Skylion007
approved these changes
Sep 19, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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