The World class represents the physical world being simulated. More...
#include <world.h>
Public Member Functions | |
~World () | |
void | addObject (PhysicalObject *object) |
Adds an object to the simulation. More... | |
void | removeObject (PhysicalObject *object) |
Removes an object from the simulation. More... | |
void | step (float dt) |
Steps the simulation once, then calls the step method of all the objects in the simulation. More... | |
void | stepGraphics () |
Called by SimulatorView to synchronize the graphical view (positions and rotations) with the physical simulation of each object. More... | |
b2World * | world () |
Getter for the Box2D world object. More... | |
Static Public Member Functions | |
static World * | fromJsonDocument (const QJsonDocument &doc) |
Named constructor creating a world with many PhysicalObject based on a JSON-document. More... | |
static World * | instance () |
Static getter method to get the singleton instance of the class. More... | |
Private Member Functions | |
World () | |
Private Attributes | |
b2World * | _world |
QList< PhysicalObject * > | _physicalObjects |
Static Private Attributes | |
static World * | _instance = NULL |
The World class represents the physical world being simulated.
It has methods for adding and removing objects from the simulation. The step function will call the step-method on all PhysicalObject stored in the simulation.
The world can be created from a JSON-file, which will delete the old world and create a new one based on the objects of the JSON-file.
|
explicitprivate |
References _world.
Referenced by fromJsonDocument(), and instance().
void World::addObject | ( | PhysicalObject * | object) |
Adds an object to the simulation.
object | PhysicalObject that will be added to the simulation. |
References _physicalObjects, and PhysicalObject::item().
Referenced by fromJsonDocument().
|
static |
Named constructor creating a world with many PhysicalObject based on a JSON-document.
doc | The JSON-document containing the objects in the world. |
References _instance, addObject(), PhysicalObjectFactory::getFactory(), PhysicalObjectFactory::instance(), and World().
Referenced by MainWindow::on_actionLoad_World_triggered().
|
static |
Static getter method to get the singleton instance of the class.
References _instance, and World().
Referenced by SimulatorView::SimulatorView().
void World::removeObject | ( | PhysicalObject * | object) |
Removes an object from the simulation.
object | PhysicalObject that will be removed from the simulation. |
References _physicalObjects, _world, PhysicalObject::body(), and PhysicalObject::item().
void World::step | ( | float | dt) |
Steps the simulation once, then calls the step method of all the objects in the simulation.
dt | Time in seconds since last step. |
References _physicalObjects, and _world.
Referenced by SimulatorView::step().
void World::stepGraphics | ( | ) |
Called by SimulatorView to synchronize the graphical view (positions and rotations) with the physical simulation of each object.
References _physicalObjects.
Referenced by SimulatorView::step().
b2World * World::world | ( | ) |
Getter for the Box2D world object.
References _world.
Referenced by arenaFactory(), chirpFactory(), pushableObjectFactory(), and wallFactory().
|
staticprivate |
Referenced by fromJsonDocument(), instance(), and ~World().
|
private |
Referenced by addObject(), removeObject(), step(), and stepGraphics().
|
private |
Referenced by removeObject(), step(), world(), World(), and ~World().