-
Notifications
You must be signed in to change notification settings - Fork 277
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
[DDA Port] Type safe coords and more point-related refactors #941
Merged
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
(cherry picked from commit 4db4b25129740866577e7ee0d0ed2b370d142686)
The current simple_pathfinding implementation only works for point. We want it to word for the various type-safe point types also. Make the point type a template parameter to that end. Because point and coord_point require their members to be accessed in different ways (p. vs p.x()) this entails introducing a point_traits helper to dispatch to the correct access type. Also added a simple pathfinding test. (cherry picked from commit f97a8476a88f965f024e8f0c4b335595a519776f)
Previously point serialization used free functions and tripoint serialization used member functions. For coord_point serialization to work the way we probably want, points and tripoints need to be serialized the same way. So, switch points to member functions. Because point and label are implicitly convertible to one another, they also need to use the same serialization technique to avoid ambiguity. So, also transition label to use member functions for serialization. (cherry picked from commit 89a8084bcb423eb59eb5501e8c200a126ff05192)
Previously we had separate functions closest_points_first and closest_tripoints_first. We'd like to extend this functionality to coord_point, but it's easier to do if both the raw underlying functions have the same name (so the generic wrapper can be the same). To that end, rename closest_tripoints_first to closest_points_first (they are chosen between based on overload resolution), and add a wrapper to allow coord_point to be used similarly. (cherry picked from commit 4f597dc72a631f31835163f383d83b500d06f8b5)
Make the point type of tripoint_range be a template parameter, so that it can work for coord_point types as well as simple tripoint. Provide that template parameter wherever needed, and add a test. (cherry picked from commit 84afc8ef7852f82628af5192ed71aaf5502ca52b)
We don't want to force people to always construct a coord_point from a point. Suppress the check in these cases. (cherry picked from commit b3a7b7863532306c5a885d37240d3e9a3ec157ca)
It was never clear how project_remain should work for tripoints. Should the z coordinate be included in the quotient, the remainder, or both? This implementation allows the client code to choose which of the two will contain it (you must pick exactly one). Add project_combine, which is the opposite operation, and a test that one operation reverses the other. (cherry picked from commit c1719b1ab3e40170b1258678782ecfa57cb8900b)
Things we want to be able to call on these new point types: * square_dist * trig_dist * rl_dist * manhattan_dist * direction_from * line_to * midpoint And tests for all the above. (cherry picked from commit b66068ac0cfaee189527e9b3ea372ab9fbd8c8cd)
To help people understand the game's coordinate systems and how to use the new point types, add some documentation Move the description of coordinate systems out of coordinate_conversions.h into a markdown file, and reference that new file from coordinate_conversions.h and coordinates.h. (cherry picked from commit c1cabb8fa26c5cf4c1e1a65422ab85be3d9cafc7)
olanti-p
force-pushed
the
typesafe-coords
branch
from
September 28, 2021 21:13
a17136f
to
b61fb5f
Compare
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.
Purpose of change
Continuation of #900
Describe the solution
Cherry-picked from DDA:
CleverRaven/Cataclysm-DDA#32017
CleverRaven/Cataclysm-DDA#41946
CleverRaven/Cataclysm-DDA#41951
CleverRaven/Cataclysm-DDA#41962
CleverRaven/Cataclysm-DDA#42048
CleverRaven/Cataclysm-DDA#42069
CleverRaven/Cataclysm-DDA#42078
CleverRaven/Cataclysm-DDA#42141
CleverRaven/Cataclysm-DDA#42303
Testing
Compiles, tests pass.