Expand description
2D soft body physics engine based on point masses.
Bodies are rings of point masses joined by force-based springs; ropes are chains of
point masses joined by position-based distance constraints (Rope).
Structs§
- Aabb
- Axis-aligned bounding box.
- Body
- A soft body: a closed ring of consecutive points in
World::pointsplus its derived state. - BodyId
- Stable handle of a
BodyinWorld::bodies. It stays valid when other bodies are removed. - Body
Joint - A spring tying a chassis point to a body’s center.
- Contact
- A point of one body found inside another body, with the data needed to push it out.
- Grab
- State (
World::grab) of the point currently held by the mouse (or touch). - Material
- How two materials behave when bodies made of them touch.
- Point
Mass - Everything in JellyPhysics is made of point masses: a position, a velocity, a force and a mass. No rotation, no shape. Forces are summed each step.
- Rope
- A chain of point masses joined by position-based distance constraints.
- Rope
Anchor - Ties a rope node to an existing point in
World::points, usually a point of aBody. - RopeId
- Stable handle of a
RopeinWorld::ropes. It stays valid when other ropes are removed. - Settings
- Simulation parameters and settings
- Spring
- A soft body is
PointMassvalues joined bySprings. Each spring wants to stay at its rest length: stretch it and it pulls the ends together, squash it and it pushes them apart. A damper slows the ends’ relative motion along the spring so it doesn’t wobble forever. - World
- The simulation world: points, springs, bodies, contacts, joints and settings.
Functions§
- closest_
edge - Finds the ring edge closest to
pointand returns it as aContact(withpointleft unset).firstis the index of the ring’s first point inWorld::points. - make_
rectangle - Builds an axis-aligned rectangle (4 vertices) centered at
centerwith sizewxh. - make_
regular_ polygon - Builds a regular polygon approximating a circle centered at
centerwith radiusr.nis clamped to at least 3 so the result is always a valid polygon. - make_
rounded_ rectangle - Builds a rectangle whose corners are beveled (cropped) at 45 degrees, i.e. an octagon,
centered at
centerwith sizewxh. The cut size scales with the shorter side. - mean_
velocity - Returns the mean
PointMass::velocityof the points. - nearest_
point - Returns the index of the nearest
World::pointsentry toatwithinmax_dist, orNoneif none is close enough. - point_
in_ polygon - Returns
trueifpointis inside the polygon formed by theringofPointMassvalues (ray casting). - polygon_
area - Signed area of the polygon (shoelace formula); positive for counter-clockwise order.
- spring_
force - Returns the force on
a.