Implement CellLandblock geometry cache. #639
Merged
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 for the 2 Trello tasks:
https://trello.com/c/4ErxP7lc/90-implement-celllandblock-geometry-cache
https://trello.com/c/TxnqEnBH/85-celllandblockgetz-needs-rework
I'm still learning my way around the ACE project, so it's possible this code is not integrated in the correct location yet...
A LoadMesh() method has been added to Landblock.cs, which uses the Region file to determine the correct heights for the vertices. It loads the landblock grid as a triangle mesh, using a snippet of code from AC2D to ensure the cells are split between the correct vertices. I have verified in a few different locations that these splitters are being generated correctly, but I have no automated way of ensuring 100% accuracy across the entire map yet.
The GetZ() method has been implemented in Landblock.cs, which returns the correct Z-height information for any X/Y position on the map.
There are no unit tests yet, but here is a video of the landblock grid mesh visualization:
https://youtu.be/5yTTcMY-1Pw
The video quality was unfortunately degraded when uploaded to Youtube, but in the right corner is a 'current landblock height' stat that is updated every time the camera moves. This shows the information returned by GetZ().
Since this mesh data is to eventually be consumed by other classes, it can be tailored to provide whatever public API would be most useful to these other classes. For now it just has some of the basics, but more can be added as needed.