-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# About the pull request The codebase currently has three line-drawing algorithms: - `get_line()` - never used - `getline()` - used once - `getline2()` - used many times They are all almost identical. There is no real use-case for one over the the other. This PR removes `getline()` and `getline2()` and replaces those proc calls with `get_line()`. Furthermore, `get_line()` is replaced with a different method using linear interpolation, based on the examples here: https://www.redblobgames.com/grids/line-drawing/#optimization The pros of this new method are consistent, reversible projectile paths (if you can shoot them they can shoot you), and that it is *possibly* more performant. Bresenham's line algorithm is famously fast -- for the 1960s. This new one looks to be faster on modern computer hardware. Floats aren't scary anymore. <!-- Remove this text and explain what the purpose of your PR is. Mention if you have tested your changes. If you changed a map, make sure you used the mapmerge tool. If this is an Issue Correction, you can type "Fixes Issue #169420" to link the PR to the corresponding Issue number #169420. Remember: something that is self-evident to you might not be to others. Explain your rationale fully, even if you feel it goes without saying. --> # Explain why it's good for the game Less duplicated code. Consistent projectile paths. # Testing Photographs and Procedure <details> <summary>Screenshots & Videos</summary> The functions of interest are: - `get_line()`, `getline()`, `getline2()` - in our codebase - `getline_tgmc()` - TGMC's "Reasonably Optimized" version: https://github.com/tgstation/TerraGov-Marine-Corps/blob/2da5c237640d73e3e66ad79e34861e9682f4609c/code/__HELPERS/unsorted.dm#L816-L869 - `get_line_testA()` - the proposed replacement ![image](https://github.com/cmss13-devs/cmss13/assets/14267245/b12935c2-31ac-4b36-b2ff-fa892472ef94) The output of `get_line_testA()` is *not* identical to `getline2()`. A path starting at the center pillar and ending on a tiled floor has different results. ![image](https://github.com/cmss13-devs/cmss13/assets/14267245/923a77aa-4c6a-4dfa-8147-1001430a0529) The following examples are a comparison between `getline2()` and `get_line_testA()`. All paths start at the wall and end at the ghost. Purple tiles are where both functions picked the same turf, red is unique to `getline2()`, blue is unique to `get_line_testA()`. Note that `get_line_testA()` results in the same path taken regardless of direction. Example 1a: SW to NE ![image](https://github.com/cmss13-devs/cmss13/assets/14267245/b39dd576-0486-4524-b6ec-eeac1b7fdf52) Example 1b: NE to SW ![image](https://github.com/cmss13-devs/cmss13/assets/14267245/0994f93d-6cbb-4864-a3b8-40575881f603) Example 2a: NW to SE ![image](https://github.com/cmss13-devs/cmss13/assets/14267245/f557284b-0e19-4392-921a-adec86fea4cf) Example 2b: SE to NW ![image](https://github.com/cmss13-devs/cmss13/assets/14267245/1ee59440-d9d7-424b-b3aa-6a6883054fe1) </details> # Changelog :cl: refactor: projectile paths are the same in both directions, A->B and B->A /:cl:
- Loading branch information
Showing
22 changed files
with
61 additions
and
149 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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