The PhysicWorld is a Layer that simulates physic objects in the scene.
More...
#include <PhysicWorld.hpp>
|
virtual void | onAttach () override |
virtual void | onUpdate () override |
template<typename T, typename... Args> |
void | addSolver (Args &&...args) |
| This method add a Solver to physics simulation.
|
void | addEntity (const unsigned int &id) |
| Adds the given entity to the simulation.
|
bool | removeEntity (const unsigned int &id) |
| Removes the given entity from the simulation.
|
float | getWorldDeltaTime () const |
| Removes the given entity from the simulation.
|
std::vector< unsigned int > | getEntities () const |
| PhysicWorld (const std::string &name="Physic World") |
| Construct a simulated world.
|
| Layer (const std::string &name) |
| Layer (const Layer &other)=delete |
virtual void | onDetach () |
virtual void | onRender () |
virtual void | begin () |
virtual void | end () |
std::string | getName () const |
bool | isAttached () const |
|
std::string | m_name {"Layer"} |
bool | m_attached = false |
The PhysicWorld is a Layer that simulates physic objects in the scene.
- Warning
- It needs to be attached, detached, and at every loop iteration should be called PhysicWorld::onUpdate().
- Note
- By default it contains some Solver to simulate gravity and collision response.
- See also
- Solver
-
ogl::Layer
◆ PhysicWorld()
PhysicWorld::PhysicWorld |
( |
const std::string & | name = "Physic World" | ) |
|
|
inline |
Construct a simulated world.
- Parameters
-
name | the name of the layer |
- See also
- ogl::Layer
◆ addEntity()
void PhysicWorld::addEntity |
( |
const unsigned int & | id | ) |
|
Adds the given entity to the simulation.
- Parameters
-
◆ addSolver()
template<typename T, typename... Args>
void PhysicWorld::addSolver |
( |
Args &&... | args | ) |
|
|
inline |
This method add a Solver to physics simulation.
- Template Parameters
-
T | Solver solver's class to instance |
Args | list of parameters for Solver constructor |
- Note
- Everytime a Solver is added to the simulation it will create a shared pointer of type T
◆ getEntities()
std::vector< unsigned int > PhysicWorld::getEntities |
( |
| ) |
const |
|
inline |
Retrieves all the entity that are simulated.
- Returns
- a std::vector<unsigned int> containing the entities in the simulation
◆ getWorldDeltaTime()
float PhysicWorld::getWorldDeltaTime |
( |
| ) |
const |
|
inline |
Removes the given entity from the simulation.
- Returns
- world's delta time
◆ onAttach()
void PhysicWorld::onAttach |
( |
| ) |
|
|
overridevirtual |
◆ onUpdate()
void PhysicWorld::onUpdate |
( |
| ) |
|
|
overridevirtual |
◆ removeEntity()
bool PhysicWorld::removeEntity |
( |
const unsigned int & | id | ) |
|
Removes the given entity from the simulation.
- Parameters
-
- Returns
- true if the entity is removed
The documentation for this class was generated from the following files: