Solving constraints
In the last section, Integrating Particles, we made our particle class move using Euler Integration. The only force affecting particles was gravity. This means if you were to run the simulation, every particle would fall down without interacting with anything. In this section, we will introduce several unmovable constraints to the world. By the end of the section, particles will bounce around the screen as they hit constraints while falling under the force of gravity.
Our PhysicsSystem
currently only supports OBB constraints; however, adding additional constraint types is a trivial task. We will use raycasting to find collision features between a constraint and a particle. Because we modified the raycast for all primitives to return the same data, implementing new constraint types will use very similar code.
Solving constraints is based on Newton's third law of motion:
Every action has an equal and opposite reaction
In this section, we will explore what to do when a...