Sand Simulator / 2D Fun

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
FirepathAgain
Posts: 11
Joined: March 20th, 2021, 3:01 am

Sand Simulator / 2D Fun

Post by FirepathAgain » May 21st, 2021, 11:51 pm

Hey again everyone

I've been working on a sand simulator / game and want to show what it does so far.

https://www.youtube.com/watch?v=ycENPoeEUG4

I'll be back with more info later, I need to go to a meeting.


Basically a lot more is needed, but it's on the list lol. At the moment it has a basic sound, that used to work pretty well, but with the latest changes for efficiency is a bit more janky.

I've been working on making it more efficient by separating different zones of material. Basically there are dynamic particles that update every frame, a dynamic body, and a static body.

The bodies have an edge and a bulk.

The edges are used with dynamic particles for collisions.

The static bulk does nothing.

The dynamic bulk next to its edge may transition to being an edge each frame.

The dynamic edge may transition to a dynamic particle each frame.


Actually that's about it lol. Video shows various debug colours and pausing, stepping through, and zooming, scrolling, changing brush size.

FirepathAgain
Posts: 11
Joined: March 20th, 2021, 3:01 am

Re: Sand Simulator / 2D Fun

Post by FirepathAgain » May 23rd, 2021, 5:59 am

I updated to use vector gravity physics. I still need to advance it to make the vectors work in directions other than down, but this is a big step towards that. It wasn't hard either, a couple of hours, mostly debugging silly mistakes. I must have designed it pretty well lol.

Looks better now, the sand falls through the air more realistically and just looks better.

EDIT: Also now the magenta debug border section is a lot more sparkly and magical looking. Not sure why it changed, obviously to do with particles falling faster now and not hitting the edge all at once or something like that.

https://youtu.be/9hv6zD6CW58

FirepathAgain
Posts: 11
Joined: March 20th, 2021, 3:01 am

Re: Sand Simulator / 2D Fun

Post by FirepathAgain » May 30th, 2021, 2:37 am

A third installment in the ever-exciting world of sand simulation.

I tackled the last (I think) remaining spot not being calculated as vector simulation and made it vector / physics based. This is the piling / collision deflection section where it was doing a simple logic of if blocked down try left or right, and if blocked, try the other side, and if blocked, blocked.

It now deflects based on the particle's trajectory. It attempts to go to one side or the other. It has less of a chance of trying the second side if the first side fails too, which improves / resolves some edge case behaviour.

I also added two more different modes to the brush. It now pours (as normal), slings, and hoses. All three modes are pouring but allow giving each particle an initial velocity in different ways.


https://youtu.be/YXC_TQeV98g

FirepathAgain
Posts: 11
Joined: March 20th, 2021, 3:01 am

Re: Sand Simulator / 2D Fun

Post by FirepathAgain » August 8th, 2021, 4:54 am

I made another video on this thing.

Progress has been slow. Mostly I half-rewrote it to be able to multi-thread it. Weeks of work and the threading took about 1.5 hours after that.

Made the material colours able to vary.

Added another material to test interaction with existing material. At the moment this is just testing two solid materials that behave the same way. I did adjust density to check how that worked and no problems but reverted to the same as the sand as that's what it should be anyway, roughly.

I want to work on improving the viewport for smoother zooming and scrolling.

Lots of stuff I want to do but it's starting to get to the stage of expansion and adding fun stuff.

https://youtu.be/HGHvWSwwXdU

albinopapa
Posts: 4317
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Sand Simulator / 2D Fun

Post by albinopapa » August 12th, 2021, 9:22 pm

Interesting stuff.

Have you determined how many particles you're creating and rendering? Seems to be quite a few and still pretty smooth.

Are you planning on releasing the source code? or as a library? or just for personal use?
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply