by

Developer Diary #3: The Struggle

(
Jan
12
)

Last time, I thought that there was not much missing until lane overlaps would work properly.

Boy was I wrong!

I have a collection of screenshots on my desktop, telling the story of my efforts today and yesterday. Let me share it with you.

Having almost lost hope of finding a solution to my problems the day before, I decided to tell Michael about it, as the first thing to do today.

First I showed him all the lanes that exist on an intersection - it is their overlap intervals that I wanted to find:

For debug purposes, I decided to show the detected overlap intervals on top of that, orange being merging overlaps, red being head-on overlaps:

As can be seen, some overlaps that should have been detected are completely missing (see white sections where there should be merging overlaps). Also the red, head-on overlaps were much too long. They started at the right point, but went on for too long.

Also in many places, overlaps could ...well... overlap - basically an overlap with one lane started inside an overlap with another lane. But because they had the same color, it looked like it was just one continous overlap.

(I'm not sure if you can follow me here...)

Michael had the great idea of vertically distributing the colored lines for each overlap, so you could see their actual lengths, even if they were on top of each other.

He also suggested to make the lane shapes that are tested for overlaps thinner than the lanes visually were, resulting in hopefully smaller and more understandable overlap intervals.

I did that and first just gave each unique overlap on the intersection its own height, resulting in this extremely unhelpful image:

Then, after giving only overlaps of the same lane different heights, it became more understandable:

If you look closely at the red overlaps, you can see that they start at the right place, but go on until the end of the intersection.

Simplyfing things further, I disabled overlap tests for all lanes but the innermost ones, making everything even clearer:

After nearly going mad for the first time, I discovered that the overlap intervals were actually completely fine, but there was a bug in the code that drew their colored lines!

Much better! (the perspective warps everything  bit)

So I decided to make everything flat and try a full intersection with all lanes again:

There was still some weird stuff going on with merging overlaps - some were just missing, others mutated into these strange red circle-arcs.

The latter was easily fixed, the first, however almost drove me mad a second time, over the course of some additional hours.

In the end it turned out to be due to a beginner-level programming error that I made somewhere, as is the case so often :)

Beautiful. Everything is there. To celebrate that some more, here is a slightly higher-res picture of a normal intersection next to one with a one-way road:

I hope you enjoyed this, see you soon! :)

Edit: after looking at these pictures some more, I noticed that there are in fact still some missing merging overlaps. Back to work...

Edit 2: turned out to just be a display bug again. Now really everything is there!

Discussion on /r/Citybound
Support Citybound