Physics System Modification

In the last section of this chapter, we will build a stable Cloth class. This class contains a set of particles and three spring systems. For the cloth to actually work, we have to call its physics simulation functions every frame. In this section, we will add cloth support to the PhysicsSystem.

Getting ready

In this section, we will make several modifications to the PhysicsSystem class to add support for cloth simulation.

How to do it…

Perform the following steps to add cloth support to our physics system:

  1. Include the Cloth.h header file in PhysicsSystem.h. Add a vector of Cloth pointers to the PhysicsSystem class. Add a function to register a new cloth into the vector and a function to clear the vector:
    // Start of file ...

Get Game Physics Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.