Page 1 of 1

[2.0.11] Asteroid orientation snapping

Posted: Sun Oct 27, 2024 12:27 pm
by Gergely
In the attached save file, all asteroids can be observed to "snap" their orientation after unpausing.

If the snapping is caused by a timer being reset or a modulus overflowing, it can be fixed by ensuring that asteroids rotate around an integer number of times between timer resets.

Re: [2.0.11] Asteroid orientation snapping

Posted: Sun Oct 27, 2024 12:47 pm
by boskid
Thanks for the report however this is Minor issue.

In order for floating point math to not go out of hands, we only use tick value modulo 65536 to animate asteroid orientation and its done in a stateless way.

Re: [2.0.11] Asteroid orientation snapping

Posted: Sun Oct 27, 2024 12:57 pm
by Gergely
In this case you can fix the bug by rounding each randomly generated period to the nearest value with no more than 16 fractional bits.

If P is the number of times the asteroid does a 360° turn per tick then P*65536 (P << 16) should be an integer to prevent snapping. Which is the case if P has no more than 16 fractional bits.

P = round(P << 16) >> 16

Re: [2.0.11] Asteroid orientation snapping

Posted: Mon Nov 11, 2024 2:26 pm
by posila
Oh, thanks for the tip with 16 fractional bits, it never occured to me, that this would work with floats too.

Fixed for 2.0.17. I ended up turning the random rotation computation to fixed point math.

(Duplicate: 120952)