DavidMcLaughlin208 / FallingSandJava

Falling Sand Simulation implemented in Java. Every pixel is simulated every frame and has its own state and intrinsic motivations.
151 stars 17 forks source link

A bug about this project. #2

Closed PandaDecSt closed 3 years ago

PandaDecSt commented 3 years ago

Hello, when I zoomed the camera in the game to be smaller, I stumbled upon a bug.

The green area on this picture is the matrix by fallingsand simulation. (I changed the color of emptycell to this color.) Screenshot_2020-10-13-20-04-54-35

Then these are abnormal pictures: Screenshot_2020-10-13-20-05-43-58 Screenshot_2020-10-13-20-05-26-76

When generating new element pixels, this problem appeared on the right side of the original green matrix. I haven't found the root cause of the problem, so I submit this question in the hope that you can solve it.

(Maybe my English is a bit strange, because I am not very good at English. If there is any language inappropriate, I hope you can forgive me)

DavidMcLaughlin208 commented 3 years ago

You changed the color of EmptyCell to the Green color? And you did this in the code not at runtime? And then what did you do to get the pictures with the errors? Did you spawn elements?

This looks like a bug with LIBGDX drawing. Sometimes when using ShapeRenderer it will stretch the small square it draws halfway across the screen. I still haven't quite figured exactly when this happens but by putting the drawing of elements in Scene2D actors it has solved the issue mostly.

Also since EmptyCell is a singleton there may be some weird behavior here.

DavidMcLaughlin208 commented 3 years ago

When generating new element pixels, this problem appeared on the right side of the original green matrix.

Just noticed you said this. In that case indeed this has to do with LIBGDX drawing. I will try to reproduce and see if I can figure out why this is happening.

PandaDecSt commented 3 years ago

I changed the color of emptycell to green to make the error more obvious. When its color is black, it is more difficult to find the error.

When you have completed the construction of the analog matrix and zoomed the camera to a smaller size, you can find this problem by generating elements at this time.