Skip to content

Polyline item

skzk edited this page Jul 18, 2024 · 12 revisions

Roads and various other items in the game are procedurally generated by drawing a spline through the nodes of the items and creating geometry along that path. (I've yet to figure out which spline function is actually used in the game.)

To my great annoyance, the rotation of a node and the length of the path between the two nodes of an item are cached in the map files. If you don't get them right, the game will initially create the items with your inaccurate values, and to fix them, you need to open the properties dialog of each node and click Cancel, after which it will recalculate the node and its attached items and reset them to the actual values.

Length

I have absolutely no idea how the length calculation actually works – I decompiled it and now I just plug my numbers in and the right number comes out, but all this SIMD math is a black box to me.

Rotation

The rotation value of the two nodes of a polyline item are the tangents of the spline. This rotation value can either be set manually using the Free Rotation option, or the game can calculate it automatically:

For a node with only one "neighbor" in either direction, the rotation of both nodes is simply the direction of that segment.

For a node p1 with a "neighbor" in both directions: Take the yaw of (p1-p0), add the yaw of (p2-p1), divide by 2. Or something like that. I haven't actually checked what do to with the other two angles yet.

Clone this wiki locally