Skip to content

A 2D Physics Engine written in C++, supporting circles and orientable, non-regular convex polygons.

License

Notifications You must be signed in to change notification settings

ThePythonator/PhysicsEngine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 as step)

  • step(float dt) : Updates all RigidBody and Constraint objects tracked by the manager

  • add_body(RigidBody body) : Adds the RigidBody instance to the list of tracked objects. These will get updated every time step is called.

  • add_constraint(Constraint* constraint) : Adds the Constraint pointer to the list of tracked objects. These will get updated every time step is called.

  • get_bodies() : Returns a reference to the vector of RigidBody instances. Most useful for rendering the objects. This should really be read-only. Modify at your own risk.

  • get_constraints() : Returns a reference to the vector of Constraint 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.

About

A 2D Physics Engine written in C++, supporting circles and orientable, non-regular convex polygons.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published