CheeseEngine
A 2D Game Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
phys2d::PhysicsSystem Class Reference

#include <types.hpp>

Collaboration diagram for phys2d::PhysicsSystem:
[legend]

Public Member Functions

 PhysicsSystem (entt::registry &registry)
 constructor for PhysicsSystem
 
void update (float dt)
 updates the physics simulation for the current frame
 
void setGravity (const glm::vec2 &g)
 sets the global gravity vector for the physics world
 
glm::vec2 getGravity () const
 gets the current global gravity vector
 
void setRegistry (entt::registry *registry)
 updates the pointer to the entt registry
 
void setEventBus (EventBus *eventBus)
 sets the event bus for dispatching physics-related events (e.g., collisions)
 

Private Member Functions

void integrateForcesAndVelocities (float dt)
 
void checkCollisions ()
 
void processImpulseAndPushback (entt::entity eA, entt::entity eB, const glm::vec2 &normal, float penetration, bool isTriggerA, bool isTriggerB)
 
bool collideCircleVsCircle (entt::entity e1, const TransformComponent &tc1, const CircleGeometry &geometry1, entt::entity e2, const TransformComponent &tc2, const CircleGeometry &geometry2)
 
bool collideCircleVsPolygon (entt::entity e1, const TransformComponent &tc1, const CircleGeometry &geometry1, entt::entity e2, const TransformComponent &tc2, const PolygonGeometry &geometry2, bool flipNormal)
 
bool collidePolygonVsPolygon (entt::entity e1, const TransformComponent &tc1, const PolygonGeometry &geometry1, entt::entity e2, const TransformComponent &tc2, const PolygonGeometry &geometry2)
 

Private Attributes

glm::vec2 gravity {0.0f, 0.0f}
 global gravity vector applied to dynamic bodies
 
entt::registry * registry
 pointer to the registry for fetching entities
 
EventBuseventBus
 pointer to the system event bus
 

Constructor & Destructor Documentation

◆ PhysicsSystem()

phys2d::PhysicsSystem::PhysicsSystem ( entt::registry &  registry)

constructor for PhysicsSystem

Parameters
registryreference to the entt registry to manage entities and components

Member Function Documentation

◆ checkCollisions()

void phys2d::PhysicsSystem::checkCollisions ( )
private

◆ collideCircleVsCircle()

bool phys2d::PhysicsSystem::collideCircleVsCircle ( entt::entity  e1,
const TransformComponent tc1,
const CircleGeometry geometry1,
entt::entity  e2,
const TransformComponent tc2,
const CircleGeometry geometry2 
)
private

◆ collideCircleVsPolygon()

bool phys2d::PhysicsSystem::collideCircleVsPolygon ( entt::entity  e1,
const TransformComponent tc1,
const CircleGeometry geometry1,
entt::entity  e2,
const TransformComponent tc2,
const PolygonGeometry geometry2,
bool  flipNormal 
)
private

◆ collidePolygonVsPolygon()

bool phys2d::PhysicsSystem::collidePolygonVsPolygon ( entt::entity  e1,
const TransformComponent tc1,
const PolygonGeometry geometry1,
entt::entity  e2,
const TransformComponent tc2,
const PolygonGeometry geometry2 
)
private

◆ getGravity()

glm::vec2 phys2d::PhysicsSystem::getGravity ( ) const

gets the current global gravity vector

Parameters
None
Return values
currentgravity vector

◆ integrateForcesAndVelocities()

void phys2d::PhysicsSystem::integrateForcesAndVelocities ( float  dt)
private

◆ processImpulseAndPushback()

void phys2d::PhysicsSystem::processImpulseAndPushback ( entt::entity  eA,
entt::entity  eB,
const glm::vec2 &  normal,
float  penetration,
bool  isTriggerA,
bool  isTriggerB 
)
private

◆ setEventBus()

void phys2d::PhysicsSystem::setEventBus ( EventBus eventBus)

sets the event bus for dispatching physics-related events (e.g., collisions)

Parameters
eventBuspointer to the EventBus instance
Return values
None

◆ setGravity()

void phys2d::PhysicsSystem::setGravity ( const glm::vec2 &  g)

sets the global gravity vector for the physics world

Parameters
gnew two-dimensional gravity vector
Return values
None

◆ setRegistry()

void phys2d::PhysicsSystem::setRegistry ( entt::registry *  registry)

updates the pointer to the entt registry

Parameters
registrypointer to the new entt registry
Return values
None

◆ update()

void phys2d::PhysicsSystem::update ( float  dt)

updates the physics simulation for the current frame

Parameters
dtdelta time since the last frame
Return values
None

Member Data Documentation

◆ eventBus

EventBus* phys2d::PhysicsSystem::eventBus
private

pointer to the system event bus

◆ gravity

glm::vec2 phys2d::PhysicsSystem::gravity {0.0f, 0.0f}
private

global gravity vector applied to dynamic bodies

◆ registry

entt::registry* phys2d::PhysicsSystem::registry
private

pointer to the registry for fetching entities


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