Developer Diary #1: Where do you think you're going?
Finally a little progress that is literally visible! Cars now kinda started working on the new roads. (As you can see, not completely, more soon!)
To give you an idea why it took so long to get here, here is a short description of the deep underlying differences between the old and the new road system:
smallest entity: lane piece (just one straight or curved segment)
- adjacent pieces were treated like completely separate ones
cars were managed on a per-lane-piece-level!
roads were collections of a lot of lane pieces
intersections consisted of even more lane pieces!!
the code for multilane and intersection traffic had no chance but to be horrible, for each car you needed to constantly consider at a lot of cars on other lane pieces
- forking and merging lanes were something fundamentally different from intersections
- resulted lots of "special cases" that are actually just duplicates of each other, but couldn't be simplified as such
connections between lane pieces were given implicitly
- relation descriptions between lane pieces, like "left", "right", "next", "previous
- hard to create
- hard to update
finding conflicts between lane pieces for intersection behaviour was hard, ignoring false positives was even harder!
- on intersections, a car basically saw every other car as a stationary, crossing obstacle, even the one in front of it on the same lane, in the worst cases even itself!
- avoiding this was impossibly hard to implement, one of the main inspirations for a redesign of the system
smallest entity: lane bundle
- represents multiple lanes next to each other
- can have a complicated multisegment shape, but still functions as the continous stretch of road that it actually is
cars are managed on a per-lane-bundle-level
this means it is a lot easier to do multilane traffic: all the relevant cars are probably on the same lane bundle
roads consist of just one or two lane bundles (one, or two-way road)
intersections still consist of many lane bundles
- but because each can have a complex shape (which is often required for properly connecting the roads that enter an intersection) and still be one functional unit, it is much easier to avoid these false positive self-collisions I described earlier
shape information needs to be stored only once per lane bundle, the graphics card takes care of rendering cars in the correct position according to car's progress on the lane bundle and its lane offset
- especially wide multilane roads, or long roads with a complicated shape benefit from this
connections between lane bundles are given explicitly by so called "connection points"
- easy to create, easy to update, easy to manage
- easy to visualize and make usable for the player (more on this soon)
I'm already tired and I probably forgot a lot of stuff, or wrote it in an incohesive way, but I hope this first developer diary was interesting.
Let me know what you think!