openomf icon indicating copy to clipboard operation
openomf copied to clipboard

Use fixed point math for position, endurance, health

Open Nopey opened this issue 1 year ago • 4 comments

This PR hopes to improve netplay and rec compatibility & determinism across platforms.

Positions and velocities (vec2f) are now stored as 24.8 fixed point numbers, which means there are 24 bits for the whole part and 8 for the fractional part.

This PR has the annoying quirk of taking an existing name and appending 'f' to mark it as fixedpoint, some of these should be un-renamed before merging-- this was done to ensure non-updated code would compiler error while writing the PR.

Nopey avatar Mar 26 '25 20:03 Nopey

This is more precise, but it's also probably less accurate. The original game retains values as integers, where positions are pixel coords multiplied by 256. That is probably what openomf also needs to do to remain as close to omf2097 as possible.

katajakasa avatar Mar 26 '25 20:03 katajakasa

This is more precise, but it's also probably less accurate. The original game retains values as integers, where positions are pixel coords multiplied by 256. That is probably what openomf also needs to do to remain as close to omf2097 as possible.

I believe you have the exact same misconception I had at first glance, that is precisely what is being described with the fixed point type, it's just not the name we had for it

LegendaryBlueShirt avatar Mar 26 '25 22:03 LegendaryBlueShirt

This is more precise, but it's also probably less accurate. The original game retains values as integers, where positions are pixel coords multiplied by 256. That is probably what openomf also needs to do to remain as close to omf2097 as possible.

I believe you have the exact same misconception I had at first glance, that is precisely what is being described with the fixed point type, it's just not the name we had for it

Ah. I see. I assumed a standard fixed point library.

katajakasa avatar Mar 26 '25 22:03 katajakasa

~~Will rebase onto latest master once #1054 is merged.~~ EDIT: rebased.

Nopey avatar Mar 27 '25 21:03 Nopey