Rigidbody Modifications
We will create a new Rigidbody
subclass that has volume. This class will either be a sphere or a box. Before we make this subclass, we need to slightly modify the Rigidbody
class so that we can identify the type of rigidbody we are dealing with.
As we will create a new subclass of Rigidbody
, we need a way to differentiate this new class from a particle. We will introduce the HasVolume
helper function that will let us know if a rigid body has volume or not.
Getting ready
This class will be a rigidbody that has a shape and some volume. We will also add a type identifier to the Rigidbody
class. With this identifier, we will be able to tell if a rigidbody is a particle or if it has some volume.
How to do it…
Follow the mentioned steps to add type information to the Rigidbody
class:
- Add the following type definitions to
Rigidbody.h
. These constants will let us know what type of rigidbody each rigidbody subclass is:#define RIGIDBODY_TYPE_BASE 0 #define RIGIDBODY_TYPE_PARTICLE...