-
Notifications
You must be signed in to change notification settings - Fork 20
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
Replace Pathfinding (Incomplete) #330
Draft
TheNexusAvenger
wants to merge
22
commits into
dev
Choose a base branch
from
enhancement/navmeshes
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains 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.
This pull request is incomplete and covers a feature I have abandoned due to a lack of motivation.
This pull request attempts to replace the current AI movement system. At the moment, the system applies the A* algorithm on a grid of points generated from the heightmap, which results in a huge grid with tens of thousands to hundreds of thousands of nodes. Using a system simpler to navigation meshes is the obvious replacement for the existing solution.
Theory
The theory of the solution proposed in the pull request uses the idea of generating bounding shapes from the heightmap for the walkable areas and determining paths from there. Since the LEGO Universe maps are relatively flat for where NPCs can traverse, the math for the paths is 2D and the heightmap can be referenced for the height component when needed. Even if this doesn't completely match what the game uses due to objects, this is still a decent replacement for the existing system.
Shape Parsing
This is assumed to be completely implemented at this point. Issues may exist.
Parsing of the bounding shapes of the walkable area is done in several steps and uses the heightmap as the only source of truth. Caching is done of the shape parsing since results can take a very long time to generate. For releases, we would want to pre-calculate them and bundle them with the releases.
Determine Walkable Heightmap Graph
The first step follows the primary step of the existing solution: taking the heightmap and creating a graph of the positions that can be walked to from each other. To do this, a 2D grid is made of the heightmap points and each point is connected if the distance between them is a certain amount. This makes it so points that are considered too steep to traverse aren't connected. For lack of a better picture, this is an example of Avant Gardens rendered in Roblox that I took before:
Create Bounding Shapes
From this graph of connected nodes, the bounding shapes are created. After several attempts, the solution that was found to is to convert the graph into a set of small shapes (triangles and squares) and merge them. The process for this is very slow and requires being run in parallel. Otherwise, parsing can take 10s of minutes. To get around this, a merging technic similar to "merge sort" is done in parallel. Below is a small example illustrated in Roblox with the initial graph step.
Optimize Bounding Shapes
To optimize the bounding shapes, all that needs to be done is to merge lines that are collinear. This reduces the total lines each shape has without changing the geometry, making any computations faster.
Store The Shapes By Containment
The last step that is done is to store the shapes in order by how they are contained. In order to reduce computations for pathfinding, the only relevant shapes for a given point to path find around is the inner-most shape that contains the point and the shapes that are directly contained by that shape. Creating the hierarchy, or spanning tree, makes that easier.
Pathfinding
This has not been implemented.
Once the bounding shapes are generated or cached for a zone, the assumed process for an NPC is to find the inner-most bounding shape for them and then path find to targets using 1 of 3 options:
This gives the X and Z positions to use. The Y position is then reversed from the heightmap given the X and Z positions.
Remaining Work
It is believed that a majority of the work is done and not a lot is required to finish it. However, there are still several tasks left: