by

Developer Diary #2: Intersection soup

(
Jan
10
)

Since last time, I managed to make cars follow multisegment roads properly!

One interesting problem was that cars suddenly sped up and slowed down in narrow corners, since their linear progress on a lane bundle segment was measured just relative to the lane bundle center line. On the outermost lanes of roads this was particularly noticeable.

So I created all kinds of geometry code to convert between lengths and offsets on different adjacent lanes - and made sure that car progress and velocity were always measured relative to the lane they were actually on.

All of that works now.

Then, I started working on detecting lane overlaps on intersections - something that I already implemented once for the old road system.

After getting stuck on a bug that was entirely due to me forgetting about Javascript's function-only-scope, I got a first version of overlap detection going. I just displayed the starts of overlaps in red and ends of overlaps in green:

So clear what's happening!

But seriously, it looked kinda fine at that stage.

I wanted to make sure however, so I implemented a module for displaying arbitrary paths for debug purposes.

This time, connections on the intersection are drawn as white lines, merging overlaps in orange, crossing overlaps in red:

Well, still kinda a little bit broken, turns out!

And that's where I had to stop today, since it is late night now and I should get sleep :)

Let me know what you think!

Discussion on /r/Citybound
Support Citybound