User Tools

Site Tools


Sidebar



Minetest Forum
Content Database
Git Repository
Bug Tracker
Website

dev:proposals:largetracks

This is an old revision of the document!


Large track segment ideas

This is regarding a long-term idea that I had in mind, which could make railways look a lot more realistic, and would push advtrains towards being more visually aesthetic. It probably won't be implemented in the near future, if implemented at all.

The current track system is limited to the constraint that one track segment (i'm not talking about interlocking here but rather “track nodes”) spans exactly one node in any of the 16 directions. This means that all visual details regarding this single track segment must fit into the space of one meter.

This has some drawbacks:

  • Each curved rail viewed individually has a curve radius of about 4m, including switches. Even when building larger-radius curves, it is not possible to make them look “smooth”
  • Thus the overall minimum curve radius is also 4m, and cannot be constrained to be larger
  • All components of a switch must be arranged within that 1m, which makes switches look cramped. This could become a problem with monorail switches, which are rather “turnbridges” than switches and would look awful.

Proposal

A track segment should be allowed to be several nodes long, and define the exact relative positions and angles of its ends. The node position of the track segment should have no correlation with the actual position the train is positioned at, but instead the rail should define a set of points(a path) for the train to orient along.

Tracks would be defined in a “building kit”-like system, similar to how popular model railroad companies build their non-flex track assortments. Care needs to be taken that as many combinations as possible can be made with the offered track segments, and designing this is not an easy task.

Track construction would no longer work by placing nodes in the world regularily. Instead a special builder tool would allow to select unconnected track ends and allow the user to attach a fitting track segment there. The actual position of the track node should be conveniently hidden from the user.

Implications

  • The node position of the next/previous connected rail can no longer be conveniently guessed. It has to be cached in the nodedb.
  • Creating this many track models by hand is not feasible. A program to generate track meshes is required, ideally it would generate the track meshes directly from the track registration description.
  • Large parts around the path system need to be adapted to clear out the assumption that node_pos always equals advtrains.round_pos_floor_y(path_pos), and another mechanism needs to be added to determine the node position given a path item.

Compatibility consideration

It is yet to be decided whether those new tracks would be the same gauge as the current “advtrains gauge” or be changed to 1435mm standard gauge.

Using a larger gauge would allow to make trains larger in general, making them also more realistic, as current trains are pretty small in relation to Minetest players, but would also create more building work. But it would break compatibility with all existing trains and all existing tracks already built in worlds.

Keeping the same gauge would have no compatibility issues, and old and new tracks could be used similarily, requiring no migration.

Work consideration

This would be a major breaking change, and would rectify a major version increase.

Considering that I (orwell) currently have not enough time to work on such a large project, it won't be implemented in the near future. This is just a collection of ideas, open for discussion, which might eventually be implemented.

Opinions and Ideas

There will be several ideas and opinons regarding this. They are listed here, at this section:

56independent's Opinion

I think that this might work if a different mod is made. That way, server admins can choose between small or large track. This may also work as a setting, which defaults to the regular tracks, to prevent destroying infastructure on existing servers. ~56independent

Blockhead's Ideas

Sorry about this wall of text, this probably isn't going to get much visibility, but I've been doing a lot of thinking over an extended period and I felt the need to dump it all out.

Set track

This idea bears a lot of similarity to orwell's idea as explained above, but I would like to explore some areas.

Model railways are pretty comparable to advtrains in a lot of ways. They are both played with for fun, and they both still have sharper curves than most real railways. There are a variety of manufacturers of model railway track for different scales and gauges. These come in pieces that can be snapped together. We could take inspiration from the product catalogues of some of those manufacturers and build our own 'advtrains set track'.

This would be quite model-heavy, probably even more so than the current line-up. It would also let us fix the sleepers that sit under the crossings so that they do not overlap. We could also build double slip switches easily (the current space constraints make that quite hard, even if a node was mode for it, and I have a prototype…).

An an example of a poor implementation of this kind of system can be found in the Traincraft/Trains in Motion mods for Minecraft. All track blocks start and end on straight, so there are no diagonals like advtrains. The tracks in this mod are as follows:

  • Different lengths of straight track.
  • Sharp, Medium and Wide 90 degree curves.
  • Turnout to two parallel tracks which continue for a long time - can't recall if both left and right-hand turnouts are available. Yards have to be built by chaining many of these and using a lot of space. Also the frog has a huuge gap.

Note in particular no diagonals, only wibbly-wobbly - the workaround is you can use their trains on minecart tracks and those have the usual zig-zag that works to travel in a straight line on a 45 degree angle. No diamond crossings whatsoever which means no realistic junctions whatsoever - not even a two-track T-junction is possible.

All in all we can only say that the Traincraft system, as directly copied, would be a feature downgrade. A successful set track implementation must therefore include everything we already expect from advtrains or more.

The set track system would fit into the nodedb format without issue, but the adjacent track node finding code would have to change to accommodate custom adjacent directions per registered node. It still may be worth exploring if it's worth changing the nodedb format - with migration code of course. For example, if the nodedb also recorded the connections that a track node has. This may make pathfinding quicker to compute by removing adjacency calculations; on the other hand, a correct implementation needs to make sure the node's connections are always correctly encoded and updated in the nodedb to match that node's definition.

Custom curvature

I want to stress that I don't see this type of system as realistic for the Minetest engine but it's worth exploring it anyway and discussing the challenges with it.

Another route would be to take ideas from the Rails Modpack for Medieval Engineers, which has custom curvature within limitations of minimum radius and is physics-based.

I'm not sure how the medieval engineers engine and this mod work together to store the rail information, but it almost certainly wouldn't be compatible with the nodedb format.

Inside the Minetest engine the height at each end of each track segment would have to be an integer, which is quite different to Medieval Engineers' small voxel terrain. I do not think we would realistically be able to support curvature on the horizontal plane and slope at the same time in a track segment with this system.

I'm also not how we could put these segments into the Minetest engine with some combination of nodes and/or entities. Nodes can only show a static simple shape, so they would work for straight tracks and predefined slope tracks. We would probably have to use invisible nodes that manage a series of entities. Each entity would be a sleeper or a small section of track or perhaps both in one model file.

We have to be careful with entities because (1) they have a serious performance penalty with the current Minetest engine and get_objects_inside_radius (2) if we do it wrong and the entity-track doesn't show the tracks the train is travelling on, players are going to get really really confused. Well, aside from when they already are because the terrain loading often can't keep up on a loaded server so the advtrains track nodes don't show up either. We can all attest that the blocks load before the entities though, given how if you teleport to a railway station you first see the blocks then the trains load, or similarly if you teleport to an animal farm the animals come after the nodes.

Visual correctness: The custom curvature system also presents major problems to visual correctness given the features we expect from advtrains of diamond crossings, turnouts and the potential for double slip switches. If we allowed freely placing intersecting curved sections, we would end up with a jumble of sleepers and track that looks like it's going to derail any train that goes over it. I know that in real life diamond crossings almost never cross at exactly 90 degrees, with the exception of trams; the angle between tracks varies quite a lot at different crossings. Intersecting custom curves may also be tricky to check for collision - I will admit I'm not an expert on how collision is currently done in advtrains (for example, I can't answer the question: Will two trains that are too close but moving through unloaded mapblocks actually collide, or only when their Lua entities actually exist?)

To preserve visual correctness, we would realistically have to include a static set of all of these components - diamond crossings, turnouts and double slip switches - similar to what we have, also similar to the set track approach. Then at the end of custom curved track sections, the track would have to be aligned at the right angle so that it goes into the component. The track placer would enforce this of course.

dev/proposals/largetracks.1633785398.txt.gz · Last modified: 2021-10-09 15:16 by 56independent