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 allRigidBody
andConstraint
objects tracked by the manager -
add_body(RigidBody body)
: Adds theRigidBody
instance to the list of tracked objects. These will get updated every timestep
is called. -
add_constraint(Constraint* constraint)
: Adds theConstraint
pointer to the list of tracked objects. These will get updated every timestep
is called. -
get_bodies()
: Returns a reference to thevector
ofRigidBody
instances. Most useful for rendering the objects. This should really be read-only. Modify at your own risk. -
get_constraints()
: Returns a reference to thevector
ofConstraint
pointers. Most useful for rendering the objects. This should really be read-only. Modify at your own risk. -
TODO set_constants
- TODO
- It needs a
Shape
pointer
- TODO
- It inherits from
Shape
- TODO
- It inherits from
Shape
- TODO
- Needs pointers to two
RigidBody
instances.