Skip to content

ilya-sotnikov/demos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

demos

3D rigid body (spheres, convex hulls) physics simulator with friction with a vulkan renderer.

Graphics features:

  • debug renderer (Vulkan 1.3)
  • DrawIndexedIndirect rendering for 3d shapes
  • stable cascaded shadow maps (CSM)
  • soft shadows (PCF with adaptive sampling)

Physics features:

  • rigid body dynamics simulation between arbitrary convex polyhedra
  • sequential impulses solver (PGS), essentially, this is a port of box2d-lite to 3D
  • stable stacking (one-shot manifolds with contact reduction and feature identification, warm starting)
  • friction
  • broad-phase (hierarchical grid)

WARNING for Windows users: totally untested on windows and MSVC, expect issues.

WARNING: the code is not production ready, it may be buggy, non-robust and unoptimized, it's definetely non-deterministic.

Preview

Rigid body dynamics simulation between arbitrary convex polyhedra

Fun stuff when solver fails to converge quickly enough and significant interpenetration occurs

Debug UI (settings and statistics)

Build and run

Dependencies (bundled):

  • volk
  • SDL3
  • Dear ImGui

You also need Vulkan SDK (not bundled).

Building SDL3 may require additional dependencies depending on your OS.

cmake -B build -DCMAKE_BUILD_TYPE=Release -G Ninja
cmake --build build
cd build
./demo

Controls

  • WASD/ZX -- position control, Z/X are down/up, you can choose a body from the menu to control it instead
  • Shift -- accelerate
  • Escape -- close
  • . -- toggle fullscreen
  • u -- toggle UI
  • m -- toggle mouse
  • r -- restart simulation (Shift+R to restart and reduce time step for more accurate simulation in slow motion)
  • p -- step 1 tick if physics stepping is enabled

Resources

Physics

General

Sequential Impulses

Contact manifold creation

Graphics