Elektrine lite

← Feed

@jonikorpi@mastodon.gamedev.place

Post #4168454

2026-07-06 09:30 UTC

@TomF@mastodon.gamedev.place Do you happen to know any “fixed point for absolute dummies” guides? I’d like to switch to it in my hex terrain. Guessing it’s a bit more complicated than just switching my vertex attributes from floats to ints?

Replies (3)

  • @jonikorpi@mastodon.gamedev.place @TomF@mastodon.gamedev.place https://jet.ro/2006/08/07/neglected-art-of-fixed-point-arithmetic/

    Open ##4168455

  • @TomF@mastodon.gamedev.place 2026-07-06 09:42

    @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.

    Open ##4168456

  • @jonikorpi@mastodon.gamedev.place @TomF@mastodon.gamedev.place you really don't need much of a guide because it's exactly the same as regular integer math, just with an imaginary decimal point - think of "working" in meters, but with 3 fractional digits so that you actually have millimeter precision - that's fixed point math :)

    Open ##4168457