Emergency 2017 Dokumentation  v3.0.1
qsf::CollisionHelper Class Reference

QSF collision helper class. More...

#include <CollisionHelper.h>

Public Member Functions

 CollisionHelper (Map &map)
 Constructor. More...
 
 ~CollisionHelper ()
 Destructor. More...
 
bool doesEntityCollideWithAnyOf (const Entity &source, const std::vector< Entity * > &targets) const
 Returns whether the source entity is colliding with the target or any of the list of target objects. More...
 
bool doesEntityCollideWith (const Entity &source, const Entity &target) const
 
bool canBeAddedWithoutCollision (const Entity &source) const
 Checks whether the entity can be added at its current position without creating a collision. More...
 
bool canBeAddedWithoutCollision (const Transform &transform, BulletCollisionComponent &collisionComponent) const
 Checks whether an entity with the given transform and collision setup can be added without creating a collision. More...
 
bool findFreePosition (const Entity &sourceEntity, const Transform &transform, float radius, float safety, uint16 collisionFlags, glm::vec3 &outPosition) const
 Tries to find a free position where to place the given entity. More...
 
bool findPhysicsFreePosition (const qsf::Entity &sourceEntity, const qsf::Transform &transform, float radius, uint16 collisionFlags, glm::vec3 &outPosition) const
 
bool getCollisionsAt (const Transform &transform, btCollisionShape &collisionShape, std::vector< BulletCollisionComponent * > &outCollisions) const
 Check for colliding components when inserting a collision shape. More...
 
bool getCollisionsAt (btCollisionObject &collisionObject, std::vector< Entity * > &outCollisions, uint16 filterGroup=0xffff, uint16 filterMask=0xffff) const
 Check for colliding components for an existing collision object. More...
 
bool getCollisionsAt (btCollisionObject &collisionObject, std::vector< PhysicsWorldComponent::HitResult > &outCollisions, uint16 filterGroup=0xffff, uint16 filterMask=0xffff) const
 

Protected Attributes

MapmMap
 

Detailed Description

QSF collision helper class.

Definition at line 48 of file CollisionHelper.h.

Constructor & Destructor Documentation

qsf::CollisionHelper::CollisionHelper ( Map map)
inlineexplicit

Constructor.

Definition at line 14 of file CollisionHelper-inl.h.

qsf::CollisionHelper::~CollisionHelper ( )
inline

Destructor.

Definition at line 20 of file CollisionHelper-inl.h.

Member Function Documentation

bool qsf::CollisionHelper::canBeAddedWithoutCollision ( const Entity source) const

Checks whether the entity can be added at its current position without creating a collision.

Note
Make sure that the relevant information for the bullet collision component like transform and collision mask & filter flags are correct before calling this function.
bool qsf::CollisionHelper::canBeAddedWithoutCollision ( const Transform transform,
BulletCollisionComponent collisionComponent 
) const

Checks whether an entity with the given transform and collision setup can be added without creating a collision.

Note
Make sure that the relevant information for the bullet collision component like transform and collision mask & filter flags are correct before calling this function. Variant of the above function which allows for would be test without changing the current data.
bool qsf::CollisionHelper::doesEntityCollideWith ( const Entity source,
const Entity target 
) const
bool qsf::CollisionHelper::doesEntityCollideWithAnyOf ( const Entity source,
const std::vector< Entity * > &  targets 
) const

Returns whether the source entity is colliding with the target or any of the list of target objects.

Uses the bullet collision information to determine this relation.

bool qsf::CollisionHelper::findFreePosition ( const Entity sourceEntity,
const Transform transform,
float  radius,
float  safety,
uint16  collisionFlags,
glm::vec3 &  outPosition 
) const

Tries to find a free position where to place the given entity.

Parameters
[in]sourceEntityThe entity to find a collision-free position for
[in]transformThe preferred transformation for the entity, around which a valid position should be found
[in]radiusRadius of the area to search for a free position
[in]safetyAdditional space required around the entity at the target position, so that it will be accepted as valid free position
[in]collisionFlagsCollision bitmask
[out]outPositionThe resulting position; not touched if result is "false"
Returns
"true" if a position was found, "false" if not
Todo:
  • TODO(co) Review those both methods, are those the same?
bool qsf::CollisionHelper::findPhysicsFreePosition ( const qsf::Entity sourceEntity,
const qsf::Transform transform,
float  radius,
uint16  collisionFlags,
glm::vec3 &  outPosition 
) const
bool qsf::CollisionHelper::getCollisionsAt ( const Transform transform,
btCollisionShape &  collisionShape,
std::vector< BulletCollisionComponent * > &  outCollisions 
) const

Check for colliding components when inserting a collision shape.

Parameters
[in]transformThe transformation where to test for collisions
[in]collisionShapeThe shape to test
[out]outCollisionsThe resulting list of colliding components
Returns
"true" if at least one collision was found, "false" if not
bool qsf::CollisionHelper::getCollisionsAt ( btCollisionObject &  collisionObject,
std::vector< Entity * > &  outCollisions,
uint16  filterGroup = 0xffff,
uint16  filterMask = 0xffff 
) const

Check for colliding components for an existing collision object.

Parameters
[in]collisionObjectThe collision object to check the collisions for
[out]outCollisionsThe resulting list of colliding entities
[out]filterGroupThe filter group to use
[out]filterMaskThe filter mask to use
Returns
"true" if at least one collision was found, "false" if not
bool qsf::CollisionHelper::getCollisionsAt ( btCollisionObject &  collisionObject,
std::vector< PhysicsWorldComponent::HitResult > &  outCollisions,
uint16  filterGroup = 0xffff,
uint16  filterMask = 0xffff 
) const

Member Data Documentation

Map& qsf::CollisionHelper::mMap
protected

Definition at line 162 of file CollisionHelper.h.


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