Skip to content
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
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

PeterNerlich
Copy link
Contributor

@PeterNerlich PeterNerlich commented Jan 17, 2022

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:

  • One layer for most applications in long, flat stretches, allowing for 3 nodes of up/down deviation, maxes out on 381 x and z deviation.
  • One smaller, but higher cuboid on top and bottom of it each, stretching 123 in every x and z direction and 67 up/down

This should be very luxurious and prove enough for almost everything most lines.

This PR builds on the changes in #15.


Screenshot: Line properly following the tracks (highlighted), defined by only 3 trainline blocks (circled).
image

@PeterNerlich PeterNerlich changed the title Trainlines: Follow tracks [WIP] Trainlines: Follow tracks Jan 17, 2022
@PeterNerlich PeterNerlich marked this pull request as draft January 17, 2022 18:55
@PeterNerlich PeterNerlich changed the title [WIP] Trainlines: Follow tracks Trainlines: Follow tracks Jan 17, 2022
@BuckarooBanzay BuckarooBanzay added the enhancement New feature or request label Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants