Mailing list archives : pcb-rnd

ID:6282
From:rn...@igor2.repo.hu
Date:Wed, 10 Jan 2024 12:11:03 +0100 (CET)
Subject:[pcb-rnd] librnd opengl rendering fix: how I found the bug
Hi all,
 
 
I share this because I find it funny.
 
I've found this bug while working on osm-rnd because librnd coordinates 
there are always large: I managed to fit the whole globe into 32 bit 
coords and get a ~centimeter resolution, but the cost is that editing 
around Budapest yields librnd coords as large as 604060000 decimal.
 
The other day I was testing osm-rnd with opengl (and lesstif too, just to 
make sure it really works with all our HIDs).
 
As I was looking at buildings, I saw a lot of them not having orthogonal 
walls - which is common when a novice user draws them free-hand and 
doesn't know about the tools to orthogonalize the result. So for a 
while I didn't care. Then I saw the same distortion on buildings I 
remember drawing a decade ago and I know I did use tools to make sure 
walls were orthogonal. First I thought someone tried to move or align 
things and that introduced the distortion... But then I figured too many 
of those old buildings of mine looked bad. So I restarted osm-rnd with the 
gdk render and saw the same building all rendering properly!
 
The error this bug caused was much more visible in osm-rnd because, in 
pcb-rnd terms, I was editing 604mm away from 0;0 and was zoomed in so much 
to have only a few dozen nanometers per pixels. (In osm-rnd terms this 
really means editing near Budapest with zoom set to a fraction of a meter 
per pixel which is normal if you are tracing buildings)
 
The other hint was that osm-rnd draws a little square for nodes (points); 
these looks perfect squares in gdk rendering but looked like narrow 
rectangles with random aspect ratio with the opengl rendering. That was 
the same bug: these squares are a few 10 "nanometers" in size when I zoom 
in, and with the original code using 32 bit floats on GPU side to 
represent numbers in the range of 604060000, it's trivial you get huge 
rounding errors.
 
Best regards,
 
Igor2
 
 

Reply subtree:
6282 [pcb-rnd] librnd opengl rendering fix: how I found the bug from rn...@igor2.repo.hu