soft_body_forces_and_impulses
Forces and impulses can be applied to a soft-body as a whole
(add_force, apply_impulse),
or to one particular particle
(add_particle_force, apply_particle_impulse).
A force added to the whole body is added to each of its free particles and is persistent, i.e., it keeps being applied
at each step until the forces are reset (reset_forces), exactly like the forces of
a rigid-body. An impulse applied to the whole body is a velocity change
applied to each of its free particles, so the body is kicked as a whole without being deformed. Note that the pinned
particles ignore both.
Two additional methods are provided for the effects which magnitude depends on the distance to a point: an impulse
applied within a radius
(apply_impulse_at_point), and a
radial blast pushing the particles away from its center
(apply_radial_impulse). In both
cases the impulse is scaled linearly down to zero at the given radius. Like for the rigid-bodies,
the wake_up argument (True by default) of all these methods ensures the soft-body is
awake before the force or the impulse is applied:
soft_body = world.soft_bodies[cloth_handle]
# The soft-body is woken up, unless `wake_up=False` is given.
soft_body.reset_forces() # Reset the forces to zero.
soft_body.add_force((0.0, 1.0, 0.0)) # Spread over the particles by mass.
soft_body.add_particle_force(3, (0.0, 1.0, 0.0))
soft_body.apply_impulse((0.0, 0.1, 0.0))
soft_body.apply_particle_impulse(3, (0.0, 0.1, 0.0))
# An impulse on the particles within 0.5 of a point, scaled down with the distance.
soft_body.apply_impulse_at_point((0.0, 0.1, 0.0), (0.0, 2.0, 0.0), 0.5)
# A blast pushing the particles away from a center.
soft_body.apply_radial_impulse((0.0, 2.0, 0.0), 0.1, 1.0)