Following this 1997 Siggraph course and 1999 paper, I implemented realistic physics simulation over two weeks in C++ and OpenGL utilizing the Finite Element Method.

The simulation takes in an input tetrahedral mesh from an obj file, and performs calculations for forces such as gravity, stress, strain, and internal viscous damping.

The program uses the RK4-5 iterative method to simulate each timestep and runs in realtime. Collisions are discrete and involves pushing the tetrahedron away from the other object along the collision’s normal vector.

When objects are not being deformed, we don’t need to simulate them too precisely. I implemented adaptive stepsizing to adjust my timestep to ensure that the simulation uses the largest possible timestep while staying under an error threshold.

5000 fps vs average 60fps simulation