-
Notifications
You must be signed in to change notification settings - Fork 14
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
Trainlines: Follow tracks #19
Draft
PeterNerlich
wants to merge
12
commits into
minetest-mapserver:master
Choose a base branch
from
PeterNerlich:follow_tracks
base: master
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
Trainlines: Follow tracks #19
PeterNerlich
wants to merge
12
commits into
minetest-mapserver:master
from
PeterNerlich:follow_tracks
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
PeterNerlich
changed the title
Trainlines: Follow tracks
[WIP] Trainlines: Follow tracks
Jan 17, 2022
PeterNerlich
changed the title
[WIP] Trainlines: Follow tracks
Trainlines: Follow tracks
Jan 17, 2022
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 uses advtrains functions to find the exact path along the tracks between two trainline blocks.
In order to achieve this, a rail node can be associated with a block, similar to how advtrains TCBs or influence points are set. When placing or saving on a block, we search for the blocks belonging to the same line in the surrounding area and figure out the immediately previous and next block using the index. If this block and one of its neighbours have a rail node associated with it, we use advtrains functions to march from one rail towards the position of the other until we find it (or 1000 nodes were traversed). Every time the heading changes, the current position is added to the list eventually saved to the
linepath_from_prv
metadata attribute so it can be read by the mapserver.Searching an area for nodes is expensive. Minetest limits the amount to 4,096,000 nodes. Because there is not a good way to form one cuboid to fit all major long-distance usecases and this will not be frequently executed on a server (only every time a player manually sets or updates a train map block), we take all we can with 3 separate ranges:
This should
be very luxurious andprove enough foralmost everythingmost lines.This PR builds on the changes in #15.
Screenshot: Line properly following the tracks (highlighted), defined by only 3 trainline blocks (circled).