Developer Diary #2: Intersection soup
Since last time, I managed to make cars follow multisegment roads properly!
![](https://uploads-ssl.webflow.com/590b02ac96d6fe11f3fcef0c/591431868fd2a803f9505d90_Screen-Shot-2015-01-11-at-00-59-24.png)
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:
![](https://uploads-ssl.webflow.com/590b02ac96d6fe11f3fcef0c/5914319bc4fa20455e327e79_Screen-Shot-2015-01-10-at-20-08-13.png)
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:
![](https://uploads-ssl.webflow.com/590b02ac96d6fe11f3fcef0c/5911bd6edac31f78e27008a4_Screen-Shot-2015-01-11-at-00-56-15.png)
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!