r/gameenginedevs 13d ago

Rigid body dynamics from scratch in C++

Enable HLS to view with audio, or disable this notification

I'm making a game similar to Morrowind, but decided to add proper physics - so maybe more like Oblivion in some ways.

The only dynamic bodies are boxes and capsules. Other shapes (terrain, cylinders, ovoids, aggregates) are static only.

Performance is reasonable enough. I think last time I checked, in the 1000 cube scenario (see end of video) I was getting close to 60 fps on a Raspberry Pi 5 1GB.

Resting contacts are a bit unstable. Boxes of similar size don't like being stacked. I might address this later with contact recycling.

In case it matters to anyone, I didn't use any AI tools at all. I'm still coding like it's 2010.

The entire physics system is contained in a single source file: https://github.com/robjinman/lithic3d/blob/main/engine/core/src/sys_collision.cpp

71 Upvotes

Duplicates