Post #4168456
2026-07-06 09:42 UTC
@jonikorpi@mastodon.gamedev.place Uuuuu... it's pretty close to that simple. You need to pick a scale that "1" means - millimeters or whatever. Stick it in a constant and you can change it later.
Any time you read the fixed-point position of an object, subtract the fixed-point position of the camera. Do the subtraction also in integer.
Then convert the int to float and multiply by the scale. That's the camera-relative position (e.g. in meters). The rest is just like normal.
Replies (2)
-
@TomF@mastodon.gamedev.place 2026-07-06 09:43
@jonikorpi@mastodon.gamedev.place Same for testing collision between objects. Subtract one fixed-point position from another as integers, convert to float, multiply by scale, and now just use as normal float32. Because it's *offset* from one to the other, it's totally fine to use a float, because that only loses precision when they're far away - in which case they didn't collide any :-)
-
@mmby@mastodon.social 2026-07-06 09:59
@TomF@mastodon.gamedev.place @jonikorpi@mastodon.gamedev.place I've been thinking abou that wrt. b-splines - but I'd need an entire fp arithmetic and probably get lots of overhead costs for it ...