Game Development Reference
initialized so that it can generate proper collision detection for the world's soft bod-
ies. Diving into the guts of soft bodies could take forever; there are entire volumes of
scientific papers on the subject, so we will only be giving concepts such as SDFs a
very cursory examination.
The SDF is a data structure that generates a more simplified (sparse) version of the
soft body for collision detection in order to improve processing time, and is used to
detect the distances between the soft body and other objects. After initialization, it
will actively communicate with the dispatcher and the broad phase to generate colli-
sion responses for soft bodies (hence it needed the pointers to them).
Creating soft bodies
To create a soft body, we will utilize btSoftBodyHelpers , which contains many
useful functions to simplify the act of generating these complex objects. We will use
CreateEllipsoid() to build a sphere of triangles (an ellipsoid with equal dimen-
sions is just a sphere), and then configure it with some additional commands. We
won't be using GameObject for this object, because CreateEllipsoid() already
generates the entire object for us.
btSoftBody* pSoftBody =
As with rigid bodies and constraints, we need to specifically add a soft body to the
scene before it shows up. This is accomplished by calling the addSoftBody() func-
tion on our world object. But, before we attach it, we need to perform some additional
A soft body is (obviously) not a very rigid structure. It deforms as it collides with other
objects. But, the question is how does it deform? What is this object's resistance to
being crushed? What is it's ability to maintain its own shape when sitting stationary?
How heavy is the entire volume? How much friction does it suffer when morphing
and rolling over surfaces? These are all the variables that can be tweaked in any
given soft body, making them the most complex type of collision shape that can be
found in a Bullet.