Home
Resume
About Me
Youtube Channel
LinkedIn
Project Archive
Game Documentation
Creative Writing

Mass Aggregate Simulation


Project Info

Project Title: Mass Aggregate Simulation

Development: C++ / OpenGL

My Role: Graphics / Physics Programmer

Mass Aggregate Start
Mass Aggregate Cube

Overview

Simultaneously designing the physics architecture, as well as learning about collisions and contacts, served as the primary challenge for the duration of this project. Overall, implementing many of the physics features was relatively straight forward, but enabling the foundation for easily extending and adding new forces and contacts took a bit of additional time. Another issue that arose related to the potential performance limitations, which sparked some investigation and resolution into many areas of possible inefficiency.

The Architecture

The actual contents of the simulation are located within a level structure, which is responsible for creating the collectibles, player, and ground components for gameplay. However, the actual force and contact registers are given to the Physics system. From here, the Physics System handles the force registers, and a Collision System accounts for the potential contacts and resolutions. By default, all collision objects undergo collisions with the ground and walls. However, specific contact registers enable checks for springs, bungees, rods, and cables.

This ensures that all simulation input is extracted from the force and collision procedures, allowing for debugging of the Physics and Collision Systems without requiring external information. The Collision System presented a number of issues, primarily due to the fact that it initially had a tendency to drop the framerate by quite a bit with only a few collision additions.

Mass Aggregate Blob
Mass Aggregate Wide Cube

Fixing the Frame Rate

Evidently, the low frame rate was of some concern, since it limited the amount of objects that could readily be displayed in the simulation. Overall, there are likely many instances that may require additional passes to optimize, but I did end up locating some areas that provided immediate cases of improvements.

First, I discovered that the way I may have been handling elapsed time could occasionally become distorted due to its dependency on certain frame calculations. In these scenarios, this meant that the elapsed time could exceed expected values, causing all physics objects to basically increment in large time steps, ultimately bypassing through contacts. As a result, I redesign the frame system, and it should now reliably output the current frame amount without exceeding duration values.

While this stabilized the physics system, it did not resolve some of the performance issues. These wound up being tied to the collision checking process, which ultimately would occur more often than need be, simply due to the way I sought to recheck contacts. By providing a restriction to the process, this would prevent any individual frame from remaining on contact resolution for too long, and most instances could be continued within the next frame anyhow.

Mass Aggregate Shapes

With the overall simulation running smoothly, this would then allow me create several shapes based on the rod connections. Building the cube, tetrahedron, and diamond shapes provided several testing cases to ensuring that dropping these objects would respond reliably against the ground and walls. Initially, there were some issues with some shapes not properly interacting with the ground collisions, but this just related to the requirement for elapsed time during interpenetration resolution, otherwise the velocity force of a contact could overpower the position adjustments.

Force and Contact Generators

The system also has support for bungee and spring forces, along with rod and cable contacts. I added a bungee connection between the camera and player character, allowing for the camera to effectively center and follow the player around the small area. Rods have been specifically introduced to the mass aggregate shapes, allowing for sturdy creations that maintain form under stress.

Mass Aggregate Shapes
Mass Aggregate Tetrahedron

Player and Collection

The Player moves around the area based on the WASD keys, while also using the Spacebar to jump. If the player approaches any of the Collectible pieces, that piece will attach as a rod to the player, and the entire mass aggregate body will follow. This ultimately weighs down the player, but the force creation process still allows the player to continue moving around the scene. A small UI area conveys the player's velocity, collection total, and current world collision counter.

Conclusion

Going forward, it'll be important to spend some time continuing to improve the performance of the system, allowing for more objects and collisions to be allotted during gameplay. However, given the various hurdles gone through, this simulation shows various area of progress from the initial origins of learning about the forces and contact pieces required within the system, to the actual implementation and development of the mass aggregate physics world.

Physics Demo - Mass Aggregate Simulation