Add and remove bodies¶
A world can change between any two steps. Bodies, pins, joints, muscles, loads and contact settings
added after the world has stepped take part from the next step, and world.destroy(entity)
removes one.
world.step()
block = trusty.fem.add_hex_solid(world, mesh, material, density=1000.0)
world.step() # the block falls from here on
world.destroy(block)
world.step() # and is gone
The next step after a change rebuilds the simulation from the world, so it costs about as much as the first step did. Every body that was already there continues where it was, and under BDF2 it keeps its previous step, so the trajectory is the one it would have followed with no rebuild. A body added to a running world starts moving at its initial velocity as if it had been moving that way before.
Destroying an entity also destroys everything that cannot exist without it: destroying a body
removes its pins, the pins and joints that name it from another body, the muscles and cables
attached to it, its surface loads and its contact exclusions; destroying a joint removes its limits
and drives. A handle to anything removed this way reports world.alive(handle) == False, and
destroying it again raises an error.