PhysicsEngine
A basic physics engine supporting circles and orientable non-regular convex polygons. Oh, and it has undamped springs and strings.
Demo
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
Interface
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.
PhysicsManager
:
-
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
RigidBody
:
- TODO
- It needs a
Shape
pointer
Circle
:
- TODO
- It inherits from
Shape
Polygon
:
- TODO
- It inherits from
Shape
Constraint
:
- TODO
- Needs pointers to two
RigidBody
instances.