Saga
Saga Game Engine
Loading...
Searching...
No Matches
Saga::Systems Namespace Reference

Namespaces

namespace  anonymous_namespace{collisionSystem.cpp}
 

Classes

struct  Collision
 Collision struct that details a collision. More...
 

Functions

void audioEmitterAwake (std::shared_ptr< GameWorld > world)
 Preprocess all audio event emitters. This loads their events's sample data if requested, and additionally play them if AudioEmitter::playOnAwake is true.
 
void audioEmitterUpdate (std::shared_ptr< GameWorld > world, float deltaTime, float time)
 Perform updates to audio emitters in the scene. Specifically, if the emitter is playing a sound and it's a 3D emitter, makes sure that the 3D positioning of the emitter is updated correctly.
 
void audioEmitterUnload (std::shared_ptr< GameWorld > world)
 Perform cleanup on the event emitters. Specifically, this stops and release event instances, as well as unload their sample data if it was previously loaded on awake.
 
void audioCameraPositioning3D (std::shared_ptr< GameWorld > world)
 Adjust the audio listener. By default, this sets it to the first camera in the scene.
 
void registerAudioSystem (std::shared_ptr< GameWorld > world)
 Register the audio system.
 
void setupAudioSystem (std::shared_ptr< GameWorld > world)
 Setup the audio set of systems, adding the appropriate systems to their own Stages.
 
void collisionSystem (std::shared_ptr< GameWorld > world, float deltaTime, float time)
 First handle cylinder-cylinder collision. Then handle all triangle-ellipsoid collisions.
 
void collisionSystem_startup (std::shared_ptr< GameWorld > world)
 Builds the bounding volume hierarchy of the scene's static triangles. Used for ellipsoid-triangle collisions.
 
void registerCollisionSystem (std::shared_ptr< GameWorld > world)
 Register all Group for this System, as well as register collisionSystem and collisionSystem as Update and Awake staged systems respectively.
 
std::optional< CollisiongetClosestCollision (std::shared_ptr< GameWorld > world, std::optional< CollisionSystemData * > systemData, Entity entity, EllipsoidCollider &ellipsoidCollider, std::optional< CylinderCollider * > cylinderCollider, glm::vec3 pos, glm::vec3 dir)
 Retrieve the closest collision to a moving object.
 
glm::vec3 doNudge (std::shared_ptr< GameWorld > world, std::optional< CollisionSystemData * > systemData, Entity entity, EllipsoidCollider &ellipsoidCollider, std::optional< CylinderCollider * > cylinderCollider, glm::vec3 pos, Collision &collision)
 Nudge the ellipsoid along the direction specified by the collision normal. This prevents the ellipsoid from sliding along a surface and thus detecting numerous collisions.
 
void rebuildUniformGrid (std::shared_ptr< GameWorld > world)
 Build a world's uniform grid from all objects with cylinder colliders.
 
std::optional< CollisiongetClosestCollisionDynamic (std::shared_ptr< GameWorld > world, std::optional< CollisionSystemData * > systemData, Entity entity, CylinderCollider &cylinderCollider, glm::vec3 pos, glm::vec3 dir)
 Retrieve the closest dynamic collision to a cylinder.
 
void runOverGridCells (CollisionSystemData &collisionSystemData, glm::vec3 pos, glm::vec3 size, std::function< void(Entity)> callback)
 Calls a function over the grid cells of a uniform grid that includes a certain bounding box.
 
void addToUniformGrid (CollisionSystemData &collisionSystemData, Entity entity, CylinderCollider &cylinderCollider, Transform &transform)
 Add an entity to the uniform grid. Here, the entity must contain a cylinder collider and transform, and we add this entity to any grid cell that the cylinder specified by the collider and transform intersects.
 
void removeFromUniformGrid (CollisionSystemData &collisionSystemData, Entity entity, CylinderCollider &cylinderCollider, Transform &transform)
 Remove an entity from the uniform grid. Here, the entity must contain a cylinder collider and transform, and we add this entity to any grid cell that the cylinder specified by the collider and transform intersects.
 
CollisionSystemDatagetSystemData (std::shared_ptr< GameWorld > world)
 Retrieve the world's CollisionSystemData. This should live as a component on an entity. If none exists, an entity with the component will be created.
 
void rebuildStaticBVH (std::shared_ptr< GameWorld > world)
 This builds the bounding volume hierarchy for all static meshes in the scene, and stores it inside of CollisionSystemData. This lives on an entity inside the world, and will create an entity to contain CollisionSystemData if one has not been created.
 
std::optional< CollisiongetClosestCollisionStatic (std::shared_ptr< GameWorld > world, std::optional< CollisionSystemData * > systemData, Entity entity, EllipsoidCollider &ellipsoidCollider, glm::vec3 pos, glm::vec3 dir)
 Retrieve the closest static collision to a moving ellipsoid.
 
void drawSystem (std::shared_ptr< Saga::GameWorld > world)
 
void drawSystem_OnResize (std::shared_ptr< GameWorld > world, int width, int height)
 System to be run on screen resize. This resize all cameras.
 
void registerDrawSystem (std::shared_ptr< GameWorld > world)
 Register Groups that the drawSystem use.
 
void drawSystem (std::shared_ptr< GameWorld > world)
 System that searches for cameras in the screen, and draw all shapes relative to those cameras on screen.
 

Variables

const glm::vec3 gridSize = glm::vec3(3,3,3)
 

Function Documentation

◆ addToUniformGrid()

void Saga::Systems::addToUniformGrid ( CollisionSystemData collisionSystemData,
Entity  entity,
CylinderCollider cylinderCollider,
Transform transform 
)
inline

Add an entity to the uniform grid. Here, the entity must contain a cylinder collider and transform, and we add this entity to any grid cell that the cylinder specified by the collider and transform intersects.

Parameters
collisionSystemDatathe collision system data where the uniform grid is stored.
entitythe entity.
cylinderColliderthe cylinder collider.
transformused to position this cylinder collider.
Here is the call graph for this function:

◆ collisionSystem_startup()

void Saga::Systems::collisionSystem_startup ( std::shared_ptr< GameWorld world)

Builds the bounding volume hierarchy of the scene's static triangles. Used for ellipsoid-triangle collisions.

System for handling collision. This should be run on startup / awake, and is responsible for constructing the datastructure neccessary for collision detection.

Parameters
world
Here is the call graph for this function:

◆ doNudge()

glm::vec3 Saga::Systems::doNudge ( std::shared_ptr< GameWorld world,
std::optional< CollisionSystemData * >  systemData,
Entity  entity,
EllipsoidCollider ellipsoidCollider,
std::optional< CylinderCollider * >  cylinderCollider,
glm::vec3  pos,
Collision collision 
)

Nudge the ellipsoid along the direction specified by the collision normal. This prevents the ellipsoid from sliding along a surface and thus detecting numerous collisions.

Parameters
posthe current position of the ellipsoid.
collisionthe collision used to nudge this ellipsoid.
Returns
glm::vec3 the position of the ellipsoid after nudging.
Here is the call graph for this function:

◆ drawSystem()

void Saga::Systems::drawSystem ( std::shared_ptr< Saga::GameWorld world)

◆ getClosestCollision()

std::optional< Collision > Saga::Systems::getClosestCollision ( std::shared_ptr< GameWorld world,
std::optional< CollisionSystemData * >  systemData,
Entity  entity,
EllipsoidCollider ellipsoidCollider,
std::optional< CylinderCollider * >  cylinderCollider,
glm::vec3  pos,
glm::vec3  dir 
)

Retrieve the closest collision to a moving object.

Parameters
world
systemDatathe data for doing collision detection. This value is optional, and if not specified, the function retrieves it from world.
entitythe moving entity. #param cylinderCollider the cylinder collider of the moving entity.
posthe starting position of the moving ellipsoid.
dirthe direction (as well as distance) the ellipsoid moves.
Returns
Collision at time t in [0,1] where position + t * dir is where the ellipsoid first collides with another object.
nothing if no collision exists.
Here is the call graph for this function:

◆ getClosestCollisionDynamic()

std::optional< Collision > Saga::Systems::getClosestCollisionDynamic ( std::shared_ptr< GameWorld world,
std::optional< CollisionSystemData * >  systemData,
Entity  entity,
CylinderCollider cylinderCollider,
glm::vec3  pos,
glm::vec3  dir 
)

Retrieve the closest dynamic collision to a cylinder.

Parameters
world
systemDatathe data for doing collision detection. This value is optional, and if not specified, the function retrieves it from world.
entitythe moving entity. #param cylinderCollider the cylinder collider of the moving entity.
posthe starting position of the moving ellipsoid.
dirthe direction (as well as distance) the ellipsoid moves.
Returns
a Collision if the moving ellipsoid collide with static terrain.
Here is the call graph for this function:

◆ getClosestCollisionStatic()

std::optional< Collision > Saga::Systems::getClosestCollisionStatic ( std::shared_ptr< GameWorld world,
std::optional< CollisionSystemData * >  systemData,
Entity  entity,
EllipsoidCollider ellipsoidCollider,
glm::vec3  pos,
glm::vec3  dir 
)

Retrieve the closest static collision to a moving ellipsoid.

Parameters
world
systemDatathe data for doing collision detection. This value is optional, and if not specified, the function retrieves it from world.
entitythe moving entity.
ellipsoidColliderthe ellipsoidCollider of the entity.
posthe starting position of the moving ellipsoid.
dirthe direction (as well as distance) the ellipsoid moves.
Returns
a Collision if the moving ellipsoid collide with static terrain.
Here is the call graph for this function:

◆ getSystemData()

CollisionSystemData & Saga::Systems::getSystemData ( std::shared_ptr< GameWorld world)

Retrieve the world's CollisionSystemData. This should live as a component on an entity. If none exists, an entity with the component will be created.

Parameters
worldthe world that the data exists on.
Returns
a reference to the CollisionSystemData that is in this world.

◆ rebuildStaticBVH()

void Saga::Systems::rebuildStaticBVH ( std::shared_ptr< GameWorld world)

This builds the bounding volume hierarchy for all static meshes in the scene, and stores it inside of CollisionSystemData. This lives on an entity inside the world, and will create an entity to contain CollisionSystemData if one has not been created.

Parameters
world
Here is the call graph for this function:

◆ rebuildUniformGrid()

void Saga::Systems::rebuildUniformGrid ( std::shared_ptr< GameWorld world)

Build a world's uniform grid from all objects with cylinder colliders.

Parameters
world
Here is the call graph for this function:

◆ registerCollisionSystem()

void Saga::Systems::registerCollisionSystem ( std::shared_ptr< GameWorld world)

Register all Group for this System, as well as register collisionSystem and collisionSystem as Update and Awake staged systems respectively.

Parameters
world
Here is the call graph for this function:

◆ registerDrawSystem()

void Saga::Systems::registerDrawSystem ( std::shared_ptr< GameWorld world)

Register Groups that the drawSystem use.

Parameters
world

◆ removeFromUniformGrid()

void Saga::Systems::removeFromUniformGrid ( CollisionSystemData collisionSystemData,
Entity  entity,
CylinderCollider cylinderCollider,
Transform transform 
)
inline

Remove an entity from the uniform grid. Here, the entity must contain a cylinder collider and transform, and we add this entity to any grid cell that the cylinder specified by the collider and transform intersects.

Parameters
collisionSystemDatathe collision system data where the uniform grid is stored.
entitythe entity.
cylinderColliderthe cylinder collider.
transformused to position this cylinder collider.
Here is the call graph for this function:

◆ runOverGridCells()

void Saga::Systems::runOverGridCells ( CollisionSystemData collisionSystemData,
glm::vec3  pos,
glm::vec3  size,
std::function< void(Entity)>  callback 
)
inline

Calls a function over the grid cells of a uniform grid that includes a certain bounding box.

Parameters
collisionSystemDatathe collision system data where the uniform grid is stored.
posthe position of the bounding box.
sizeof the bounding box.
callbackthe function to be called over all cells this bounding box intersects with.

Variable Documentation

◆ gridSize

const glm::vec3 Saga::Systems::gridSize = glm::vec3(3,3,3)