CG-Project2
Loading...
Searching...
No Matches
PhysicWorld Class Reference

The PhysicWorld is a Layer that simulates physic objects in the scene. More...

#include <PhysicWorld.hpp>

Inheritance diagram for PhysicWorld:
Collaboration diagram for PhysicWorld:

Public Member Functions

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.
Public Member Functions inherited from ogl::Layer
 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

Additional Inherited Members

Protected Attributes inherited from ogl::Layer
std::string m_name {"Layer"}
bool m_attached = false

Detailed Description

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

Constructor & Destructor Documentation

◆ PhysicWorld()

PhysicWorld::PhysicWorld ( const std::string & name = "Physic World")
inline

Construct a simulated world.

Parameters
namethe name of the layer
See also
ogl::Layer

Member Function Documentation

◆ addEntity()

void PhysicWorld::addEntity ( const unsigned int & id)

Adds the given entity to the simulation.

Parameters
identity id

◆ addSolver()

template<typename T, typename... Args>
void PhysicWorld::addSolver ( Args &&... args)
inline

This method add a Solver to physics simulation.

Template Parameters
TSolver solver's class to instance
Argslist 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

Reimplemented from ogl::Layer.

◆ onUpdate()

void PhysicWorld::onUpdate ( )
overridevirtual

Reimplemented from ogl::Layer.

◆ removeEntity()

bool PhysicWorld::removeEntity ( const unsigned int & id)

Removes the given entity from the simulation.

Parameters
identity id
Returns
true if the entity is removed

The documentation for this class was generated from the following files: