A basic physics engine supporting circles and orientable non-regular convex polygons. Oh, and it has undamped springs and strings.
The demo has some basic examples, and uses SDL for rendering.
Controls:
- S to toggle stepping mode
- Space to step through frames when stepping mode is activated
Everything is in the PhysicsEngine namespace.
PhysicsManager is the class which handles everything else. Just feed it the RigidBody instances you want it to manage, and it'll do the rest for you.
-
update(float dt): Updates the physics (currently does the same thing asstep) -
step(float dt): Updates allRigidBodyandConstraintobjects tracked by the manager -
add_body(RigidBody body): Adds theRigidBodyinstance to the list of tracked objects. These will get updated every timestepis called. -
add_constraint(Constraint* constraint): Adds theConstraintpointer to the list of tracked objects. These will get updated every timestepis called. -
get_bodies(): Returns a reference to thevectorofRigidBodyinstances. Most useful for rendering the objects. This should really be read-only. Modify at your own risk. -
get_constraints(): Returns a reference to thevectorofConstraintpointers. Most useful for rendering the objects. This should really be read-only. Modify at your own risk. -
TODO set_constants
- TODO
- It needs a
Shapepointer
- TODO
- It inherits from
Shape
- TODO
- It inherits from
Shape
- TODO
- Needs pointers to two
RigidBodyinstances.