Physics Simulations

Overview

As part of the Game Physics course during my studies, I worked on a series of physics simulation exercises covering mass-spring systems, rigid bodies, and smoothed particle hydrodynamics (SPH). The project focused on implementing core simulation methods from the lecture in order to strengthen both conceptual understanding and practical experience with numerical simulation in C++.

The work was completed in a team of three, with responsibilities divided across the individual simulation tasks:

James LiAlgorithms & Performance Evaluation
Mengdi WangAlgorithms & Testing
Alexander EppleLead Algorithm Development, Rendering, SPH Simulation

Implemented Simulations

Mass Spring System

The first task was the implementation of a mass-spring system, a common model for effects such as cloth and hair simulation. We simulated a grid of mass points with randomly fixed constraints and added interactive mouse input for direct manipulation. To make the behavior easier to interpret, the springs were color-coded to visualize the magnitude of the applied forces.

The mass spring system in action

Rigid Body Simulation and Collision

The second exercise focused on rigid body dynamics and collision handling, which form a central part of most physics engines. This was the most technically demanding part of the project, as stable results depended on the correct ordering of several tightly coupled computations. The final implementation produced a working simulation, although collision detection and response remained approximate due to time constraints. Despite these limitations, the exercise provided valuable insight into the practical challenges of physically based simulation.

Collision detection and response for rigid bodies

Efficient Collision Detection

This exercise explored the implementation of efficient collision detection for sphere-based scenes. We compared a naive all-pairs approach with a grid-based method and an experimental k-d tree implementation. The project highlighted the practical importance of spatial acceleration structures: in larger test scenes, the optimized approaches achieved speed-ups of up to 100× while preserving the visual behavior of the simulation.

Performance comparison without rendering, showing speed-ups of up to 100×
Grid-based collision detection

Smoothed Particle Hydrodynamics (SPH)

The final task extended the previous work toward a smoothed particle hydrodynamics (SPH) simulation for fluid-like behavior. Building on the previously developed acceleration structures, I implemented an improved version of the SPH system in the SPH_New branch. The revised implementation was designed to be more stable and accurate than the baseline version and more closely reflected the requirements of a practical simulation pipeline.

The improved SPH system

Conclusion

This project provided hands-on experience with several core methods used in real-time physics simulation and numerical modeling. In addition to reinforcing the underlying theory, it offered practical training in C++ implementation, performance-oriented development, and the trade-offs involved in building stable simulation systems under limited time constraints.

The project is available on GitHub. It was developed with Visual Studio 2019 and may require minor adjustments depending on the target environment.

Leave a Reply