User Tools

Site Tools


Sidebar



Minetest Forum
Content Database
Git Repository
Bug Tracker
Website

dev:core:path

This is an old revision of the document!


Table of Contents

Path

The Path is a mapping of whole (positive or negative) numbers to a world position, describing a continuous section of track.

Every path node corresponds to a piece of track in the world. The path is a property of every ''train'' Table and is used in various ways:

  1. The wagons of a train use the path and their position in the train to determine their absolute position, rotation and movement direction in the world
  2. The train-to-train collision system relies on nodes in the path being occupied or free. This includes coupling.
  3. Nodes in the path are used as base positions for checking collisions with the environment and player damage (a cube centered around the nearest path node is scanned)
  4. Node callbacks are run per path node

Index

The index is a positive, fractional number that describes a certain position in a path.

index =  5   -> The position described is the path item 5
index =  3.5 -> The point halfway between path items 3 and 4
index =  2.75-> The point between path items 2 and 3, 3/4 of the distance towards item 3
index = -4   -> path item -4
index = -3.5 -> the point halfway between path items -4 and -3

A whole index always maps to a path item. In many places where the exact position between items doesn't matter, the index is rounded to map to the nearest path item directly, instead of interpolating between path items.

Every train has an 'index' property which tells the exact index on the train's path where the front of the train is. The 'end_index' is calculated every step and tells the exact index where the back of the train is.

A train is moved by advancing its index. It is important to note that the train's 'index' is always incremented, never decremented. See also “reversion” in ''train'' Table.

Path generation

dev/core/path.1586861302.txt.gz · Last modified: 2020-04-14 12:48 by orwell