Last time, I outlined two different approaches to modelling multi-lane highways. To recap, option one was to handle every lane as its own special bit of geometry, with manually-defined start & end points and beginning & ending tangents. Option two, on the other hand, economised on the geometry a bit – only the “spine” of a multi-lane road would have a start and end point and tangent, and lanes would just be offset to one side or the other of that spine. This is an earth-shattering decision. Ramifications will be far-reaching. Nations will rise and fall, etc.
I chose the second approach; I thought that the extra up-front work would pay off in the long run because it’d be easier to make the spine-based approach editable. Plus, “spine” and “spline” are dangerously (although not actually hilariously) similar sounding, and I’m a sucker for a pun. Maybe I can drop in a SimCity reference by using the phrase “reticulating spines” on a loading screen.
I’m skipping over the maths for now, unless one of you comes back interested; I took an embarrassingly fudge-y approach rather than coming up with a nice way of deriving a “parallel” hermite based on a spine and an offset – I’m not even sure that concept’s coherent. I am sure that I wouldn’t know how to even approach the problem without spending a few nights reading.
So instead, here’s a pretty video that looks a bit like a blue velcro rainbow in space with smurfs running across it:
Features added since last time
What’s working well
- I’m very happy with the way the offset curves turned out. It’s nice that a beautiful abstraction (hermites) could give beautiful results even after I’ve tried to hide its light under a bushel of ugly hack-maths.
What’s not working well
I’m not actually unhappy about this point; it’s just somewhere I’m saying “that’s good enough for now” and moving on:
My approach treats all lanes on the same “spine” as having the same length. The main consequence is that a car in lane 0 in the video above travelling at the same speed as a car in lane 9 would take exactly the same amount of time to cross the road, which to me is clearly (a) bollocks and (b) just fine, thanks. This leads to some subtle weirdness (like, cars in the outside lane become more widely spaced while they’re on the curve, and cars in the innermost lane become more tightly packed) as a side-effect of the way I subdivide the spine into sections based on length, and then assign that length (which is a poor approximation, it turns out) to the corresponding length of each lane that is marked off by the same beginning and ending radial.
Upcoming decisions
- Nothing on my radar that’s earth-shattering right now.
To do (short term)
- Still to do to achieve multi-lanedness:
- Demonstrate connected-ness for lanes that are defined relative to a spine.
- Support “reverse” lanes, along which traffic flows in the opposite direction to the spine. Nothing rocket science-y here, just a lot of subtracting other numbers from 1.
- Cars look “sideways” as well as forwards, so that they merge cautiously and safely.
- Model vehicle arrivals using a Poisson distribution vehicles so my mouse button doesn’t wear out
To do (long term)
- Cars slow down according to the tightness of a curve
- Make the network interactively editable
- Cross-overs (either a 2d-fudge or genuine 3d)
- Cosmetic
- Render an “underlay” for lanes hanging off the same spine so that they look more like a shared width of bitumen.
- 3d display engine rewrite (i.e. make it beautiful)