Log In  

I'm working on a top-down space game, which has an option to toggle on planetary orbit indicator lines (mostly for checking things are where they're meant to be but I might include it in the actual game, don't know yet).

This results in circles being generated using the circ() function, sometimes with some large values for the circle radius (some planets can be orbiting thousands of pixels out)

Anyway, this worked fine before I upgraded to the newest Pico-8 version - I'm not sure what version I was on before but I've tested it with 0.2.0i and it works correctly and the orbit lines are drawn in full and in the correct place, even for planets that are thousands of pixels out from 0,0 where the star system is centred.

On the Pico-8 0.2.1b though, something is going quite wrong - any circles that are more than a few hundred pixels in radius are becoming very corrupted - circles have gaps in the area around y=0, and the top and bottom of the circles are very strange and... not circular...

I tested in 0.2.1 as well and that seems to be the point where this issue started. So I'm trying to figure out if it's a bug or if it's due to something that's changed there?

In this screenshot, the yellow line should be part of a circle and it's... not. The planet's orbital radius is 2226, so the raw circle will be circ(0,0,2226,9).

To clarify further I've made a test cart. This shows that circle radius values above 900 seem to be where the problems start, and the distortion that appears when the radius is increased beyond this.

Use the arrow buttons to pan the view around, and X and O buttons to increase and decrease the radius of the circle.

Cart #circletest-0 | 2020-07-14 | Code ▽ | Embed ▽ | No License
5

So I guess, I'm just wondering if this is intended behaviour in line with changes to Pico-8 limitations in 0.2.1 onwards, or is it a bug? (I'm hoping it's just a bug as my entire game is built around big circles...)

P#79324 2020-07-14 19:08 ( Edited 2020-07-14 19:15)

2

I'm guessing this is related to the new oval functions, which might have introduced some precision errors in the circ functions if they share code now. Can I just say, this is a really cool idea for visuals, and I love how the pico8 community finds bugs like this so quickly because of all the cool ideas people use in their projects.

P#79328 2020-07-14 19:21

I thought the new oval stuff might have something to do with it. I tried replacing the circfill in that test cart with an ovalfill instead (still making a circle with it though), and it has the same result - if the radius is over 900, weird stuff happens. That would seem to confirm that some of the maths is shared between the circ and oval functions.

Here's the test with ovalfill instead of circfill - Use the arrow buttons to pan the view around, and X and O buttons to increase and decrease the radius of the circle.

Cart #ovaltest-0 | 2020-07-14 | Code ▽ | Embed ▽ | No License

P#79330 2020-07-14 19:46 ( Edited 2020-07-14 20:47)
4

Hey @Psychometric

Thanks for the handy test cart, and apologies for leaving this bug blocking your cart for so long. I've fixed it for 0.2.2b (out soon), and you can assume that any circle/oval size is ok. This was an interesting bug -- it was only showing up on some (32-bit) platforms because of multiply overflows having undefined behaviour according to the C spec, and was only working by chance otherwise. Fixing this bug also allowed some host speed improvement, as I found a pure 32-bit int implementation can run faster for smaller circles even on 64-bit machines 👍

P#88357 2021-03-01 07:33

Hey @zep

That looks like it's fixed it for filled circles, but I'm still seeing the issue with non-filled circles using the circ() or oval() functions, the radius of above 900 still seems to be the point when things go weird.

It definitely does seem to be fixed now for circfill() and ovalfill() though, I've not been able to break those even with radii in the tens of thousands.

This was tested on 0.2.2c

P#93962 2021-06-24 13:36 ( Edited 2021-06-24 13:39)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 23:25:42 | 0.022s | Q:26