Skip to content

Conversation

@Nopey
Copy link
Member

@Nopey Nopey commented Mar 26, 2025

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.

@katajakasa
Copy link
Member

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.

@LegendaryBlueShirt
Copy link
Contributor

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

@katajakasa
Copy link
Member

katajakasa commented Mar 26, 2025

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.

@Nopey
Copy link
Member Author

Nopey commented Mar 27, 2025

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

@Nopey Nopey force-pushed the fixed-point branch 2 times, most recently from 8d15229 to d8c7b6d Compare March 29, 2025 03:38
Nopey and others added 6 commits March 28, 2025 20:52
)

* Try to improve the fixedpt_str function and add unit tests for it

* Fix overflow in fixedpt_fracpart macro

* Futher clarify the function

* Clarify fixed point string printing test suite name

* Clearer handling of negative numbers

* Apply suggestions from code review

---------

Co-authored-by: Magnus Larsen <[email protected]>
@Nopey Nopey marked this pull request as ready for review March 29, 2025 03:56
@Nopey Nopey added this to the 0.8.1 milestone Mar 29, 2025
NOTICE Outdated
@@ -0,0 +1,25 @@
This software contains fixedptc, whose license follows:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should be combined with the LICENSE file?

#define ARENA_RIGHT_WALL 300
#define ARENA_FLOOR 190

// fixed point versions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably we should remove the non fixed point versions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ARENA_FLOOR is important for object rendering, and we render in pixels-- not fixedpt fractions of pixels.
The arena walls can be fixedpt only, sure.

}
fixedpt rand_fixedpt(fixedpt max) {
return random_fixedpt(&rand_state, max);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a newline at end of this file

printf("%d\n", af->health);
break;
case 5:
printf("%f\n", af->forward_speed);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably we could print these as fixedpt_strs

if(info) { // Only Power Plant has the electric overlay effect
object *obj2 = omf_calloc(1, sizeof(object));
object_create(obj2, scene->gs, vec2i_create(o_har->pos.x, o_har->pos.y), vec2f_create(0, 0));
object_create(obj2, scene->gs, vec2f_to_i(o_har->pos), vec2f_createf(0, 0));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we should create objects in the fixed point space?

@Nopey Nopey marked this pull request as draft September 14, 2025 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants