r/Simulated • • 4d ago

Interactive Coupled Box2D rigid bodies with real-time thermodynamics in my falling-sand engine (C++ / OpenGL)

Hey everyone,

I'm making my own cellular automata engine in C++. I recently added support for thermodynamics and rigid body physics (implemented using the Box2D library).

The video shows an engine test; occasionally I toggle the heat map to demonstrate how temperature changes across different areas. If you drop an iron cube into lava, it heats up heavily and turns red. If you drop it into water, it cools down and heats up the water. If you place a red-hot cube into liquid nitrogen, it cools down much faster.

Box2D rigid bodies can also interact with particles and exchange heat with them: wood floats in water, iron sinks, and other materials can be easily added with individually tuned densities.

It's a data-driven approach: all physics, reactions, and phase transitions (like water turning into steam or lava into obsidian) are defined in JSON configs, with no hardcoding in C++.

I tried to optimize the engine as much as possible; watching so many interactions happen on screen at once is really satisfying.

Would love to hear your feedback or thoughts!

37 Upvotes

6 comments sorted by

4

u/Fembottom7274 4d ago

Ooooh noita engine! Sounds neat!

Are you going to follow the noita methods for making the water splash?

5

u/Mindless_Insurance79 4d ago

As far as I know, there’s no temperature in Noita. Could you tell me more about the water splashes? I watched some videos about the game, but I didn’t find anything that was significantly different from what I have.

2

u/Fembottom7274 4d ago

They move the water pixels into a separate physics sim to make them behave like particles instead of sand, then when they collide with something they return to sand

And I don't know about temperature in noita

3

u/Mindless_Insurance79 4d ago

I forgot to clarify. Each physical body (a cube made of steel, wood, or another material) is destructible; you can shoot it to split it into 2 parts or 10 parts, and each part will retain its temperature when split.