this post was submitted on 26 Feb 2024
757 points (95.8% liked)
Programmer Humor
19522 readers
189 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
IMO, floats model real observations.
And since there is no precision in nature, there shouldn't be precision in floats either.
So their odd behavior is actually entirely justified. This is why I can accept them.
I just gave up fighting. There is no system that is going to both fast and infinitely precision.
So long ago I worked in a game middleware company. One of the most common problems was skinning in local space vs global space. We kept having customers try and have global skinning and massive worlds, then upset by geometry distortion when miles away from the origin.
How do y'all solve that, out of curiosity?
I'm a hobbyist game dev and when I was playing with large map generation I ended up breaking the world into a hierarchy of map sections. Tiles in a chunk were locally mapped using floats within comfortable boundaries. But when addressing portions of the map, my global coordinates included the chunk coords as an extra pair.
So an object's location in the 2D world map might be ((122, 45), (12.522, 66.992)), where the first elements are the map chunk location and the last two are the precise "offset" coordinates within that chunk.
It wasn't the most elegant to work with, but I was still able to generate an essentially limitless map without floating point errors poking holes in my tiling.
I've always been curious how that gets done in real game dev though. if you don't mind sharing, I'd love to learn!
That's pretty neat. Game streaming isn't that different. It basically loads the adjacent scene blocks ready for you to wonder in that direction. Some load in LOD (Level Of Detail) versions of the scene blocks so you can see into the distance. The further away, the lower the LOD of course. Also, you shouldn't really keep the same origin, or you will hit the distort geometry issue. Have the origin as the centre of tha current block.