Attachments
Particles held to points on rigid bodies: a rope tied to a crate, a blob glued to a wheel. Each one pulls its particle and the point of its body together, the XPBD way, as softly as its compliance says, so the particle is dragged along by the body and the body is tugged by the particle, moving and turning it. 0 is a firm hold. Each is an Attachment handle; a removed one's slot is reused, and removing its particle or body removes the attachment.
toString gives how many there are, for example Attachments(size=2).
Samples
val world = PhysicsWorld()
val crate = world.rigidBody(Shape.box(20f, 20f), x = 100f, y = 0f)
val rope = world.rope(fromX = 0f, fromY = 0f, toX = 90f, toY = 0f, segments = 9)
// Ties the rope's free end to the crate's left face: the crate swings on the rope.
val knot = world.attach(rope.last, crate)
repeat(60) { world.step(1.seconds / 60) }
assertPrints(world.attachments.bodyOf(knot) == crate, "true")
assertTrue(world.rigidBodies.yOf(crate) > 20f)Functions
Holds particle to body at the point where the particle is now, as softly as compliance, and returns the attachment's handle.
Returns the rigid body attachment ties its particle to.
Returns true if attachment is still there.
Returns the particle attachment holds.
Returns where attachment holds its particle, the point on its body, in the world now, across.
Returns where attachment holds its particle in the world now, down.
Lets go: attachment no longer holds its particle. Removing one that is gone does nothing.