Saga
Saga Game Engine
|
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< Collision > | 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. | |
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< Collision > | 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. | |
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. | |
CollisionSystemData & | 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. | |
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< Collision > | 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. | |
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) |
|
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.
collisionSystemData | the collision system data where the uniform grid is stored. |
entity | the entity. |
cylinderCollider | the cylinder collider. |
transform | used to position this cylinder collider. |
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.
world |
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.
pos | the current position of the ellipsoid. |
collision | the collision used to nudge this ellipsoid. |
void Saga::Systems::drawSystem | ( | std::shared_ptr< Saga::GameWorld > | world | ) |
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.
world | |
systemData | the data for doing collision detection. This value is optional, and if not specified, the function retrieves it from world. |
entity | the moving entity. #param cylinderCollider the cylinder collider of the moving entity. |
pos | the starting position of the moving ellipsoid. |
dir | the direction (as well as distance) the ellipsoid moves. |
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.
world | |
systemData | the data for doing collision detection. This value is optional, and if not specified, the function retrieves it from world. |
entity | the moving entity. #param cylinderCollider the cylinder collider of the moving entity. |
pos | the starting position of the moving ellipsoid. |
dir | the direction (as well as distance) the ellipsoid moves. |
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.
world | |
systemData | the data for doing collision detection. This value is optional, and if not specified, the function retrieves it from world. |
entity | the moving entity. |
ellipsoidCollider | the ellipsoidCollider of the entity. |
pos | the starting position of the moving ellipsoid. |
dir | the direction (as well as distance) the ellipsoid moves. |
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.
world | the world that the data exists on. |
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.
world |
void Saga::Systems::rebuildUniformGrid | ( | std::shared_ptr< GameWorld > | world | ) |
Build a world's uniform grid from all objects with cylinder colliders.
world |
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.
world |
void Saga::Systems::registerDrawSystem | ( | std::shared_ptr< GameWorld > | world | ) |
Register Groups that the drawSystem use.
world |
|
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.
collisionSystemData | the collision system data where the uniform grid is stored. |
entity | the entity. |
cylinderCollider | the cylinder collider. |
transform | used to position this cylinder collider. |
|
inline |
Calls a function over the grid cells of a uniform grid that includes a certain bounding box.
collisionSystemData | the collision system data where the uniform grid is stored. |
pos | the position of the bounding box. |
size | of the bounding box. |
callback | the function to be called over all cells this bounding box intersects with. |
const glm::vec3 Saga::Systems::gridSize = glm::vec3(3,3,3) |