Contains different types of collision detection and resolve functions.
More...
Go to the source code of this file.
|
template<class BoxVertexContainer , class NormalContainer > |
bool | satBoxTest (const BoxVertexContainer &vertices1, const BoxVertexContainer &vertices2, const NormalContainer &normals, CollisionManifold &manifold) |
| Returns the normal and depth of two polygons defined by the vertices vertices1 and vertices2 by using normals inside of the manifold .
|
|
template<typename Container , typename Integer > |
void | findClosestPoint (vec2 &cp1, vec2 &cp2, Integer &count, Float &distance1, const Container &points1, const Container &points2) |
| Finds the closest point between points1 and the faces defined by points2.
|
|
template<typename Container > |
void | computeBoxManifold (const Container &points1, const Container &points2, CollisionManifold &manifold) |
| Finds the closest point between points1 and the faces defined by points2.
|
|
template<class TileData > |
bool | detectNarrowCollision (const TileBody< TileData > &body1, const glm::i32vec2 &tilePos1, const vec2 &body1Offset, const TileBody< TileData > &body2, const glm::i32vec2 &tilePos2, const vec2 &body2Offset, CollisionManifold &manifold) |
| Detects the collision between the tile in tilePos1 of body1 and the tile tilePos2 of body2.
|
|
template<class TileData > |
void | detectTileBodyCollision (const TileBody< TileData > &body1, const TileBody< TileData > &body2, TileBodyCollisionCache< TileData > &cache, std::vector< CollisionManifold > &manifolds, vec2 &body1Offset, vec2 &body2Offset) |
| Detects the collision between the tiles bodies, body1 and body2.
|
|
Contains different types of collision detection and resolve functions.
◆ computeBoxManifold()
template<typename Container >
void computeBoxManifold |
( |
const Container & | points1, |
|
|
const Container & | points2, |
|
|
CollisionManifold & | manifold ) |
|
inline |
Finds the closest point between points1 and the faces defined by points2.
The size of vertices1 and vertices2 must be 4. The size of normals must be 2.
- Parameters
-
[in] | points1 | The set of points used to find the closest point in the faces defined by points2 |
[in] | points2 | The set of points that define faces that points1 will check against |
[in,out] | manifold | The normal and depth must be already calculated within manifold. The contact points betweeen the shapes defined by points1 and points2 will be written inside of manifold |
◆ detectNarrowCollision()
template<class TileData >
bool detectNarrowCollision |
( |
const TileBody< TileData > & | body1, |
|
|
const glm::i32vec2 & | tilePos1, |
|
|
const vec2 & | body1Offset, |
|
|
const TileBody< TileData > & | body2, |
|
|
const glm::i32vec2 & | tilePos2, |
|
|
const vec2 & | body2Offset, |
|
|
CollisionManifold & | manifold ) |
Detects the collision between the tile in tilePos1
of body1
and the tile tilePos2
of body2.
In order to not modify body1 and body2, detectTileBodyCollision() uses offsets that are applied to body1 and body2 that would correctly resolve the collision between the two bodies. The offsets after each call to detectNarrowCollision() will have "normal * depth" added to them.
- Parameters
-
[in] | body1 | The first body to grab the tile data defined by tilePos1 |
[in] | tilePos1 | The tile position of body1 to check against tilePos2 |
[in] | body1Offset | A world offset to apply to the OBB of the tile defined by tilePos1 of body1 |
[in] | body2 | The second body to grab the tile data defined by tilePos2 |
[in] | tilePos2 | The tile position of body2 to check against tilePos1 |
[in] | body2Offset | A world offset to apply to the OBB of the tile defined by tilePos2 of body2 |
[out] | manifold | If detectNarrowCollision() returns true, Will contain a set of contact points and the normal and depth that may be applied to body1 and body2 to resolve the collision of the tiles defined by tilePos1 and tilePos2 |
- Returns
- If true, the collision between the tile of tilePos1 of body1 and the tile of tilePos2 of body2 is occuring.
◆ detectTileBodyCollision()
template<class TileData >
Detects the collision between the tiles bodies, body1 and body2.
Uses chunking as a broad phase to speed up the collision of extremely large tile bodies
- Parameters
-
[in] | body1 | The first tile body |
[in] | body2 | The second tile body |
[in,out] | cache | In order to speed up collisions, a cache is used to lessen calls to malloc() and free() |
[out] | manifolds | the contact manifolds between the tiles of body1 and body2 |
[out] | body1Offset | A world offset to apply to body1 to resolve the collision |
[out] | body2Offset | A world offset to apply to body2 to resolve the collision |
◆ findClosestPoint()
template<typename Container , typename Integer >
void findClosestPoint |
( |
vec2 & | cp1, |
|
|
vec2 & | cp2, |
|
|
Integer & | count, |
|
|
Float & | distance1, |
|
|
const Container & | points1, |
|
|
const Container & | points2 ) |
|
inline |
Finds the closest point between points1 and the faces defined by points2.
The size of vertices1 and vertices2 must be 4. The size of normals must be 2.
- Parameters
-
[in,out] | cp1 | The first closest point between points1 and points2 |
[in,out] | cp2 | The second closest point between points1 and points2, may not exist |
[in,out] | count | The count of closest points between points1 and points2 |
[in,out] | distance1 | Contains the minimum distance between points1 and faces defined by points2 |
[in] | points1 | The set of points used to find the closest point in the faces defined by points2 |
[in] | points2 | The set of points that define faces that points1 will check against |
◆ satBoxTest()
template<class BoxVertexContainer , class NormalContainer >
bool satBoxTest |
( |
const BoxVertexContainer & | vertices1, |
|
|
const BoxVertexContainer & | vertices2, |
|
|
const NormalContainer & | normals, |
|
|
CollisionManifold & | manifold ) |
Returns the normal and depth of two polygons defined by the vertices vertices1
and vertices2
by using normals
inside of the manifold
.
The size of vertices1 and vertices2 must be 4. The size of normals must be 2.
- Parameters
-
[in] | vertices1 | The first set of vertices that define a convex polygon |
[in] | vertices2 | The second set of vertices that define a convex polygon |
[out] | manifold | If satBoxTest() returns true, it will contain the normal and depth of penetration between vertices1 and vertices2 inside of its members, 'normal' and 'depth' |
- Returns
- Will return true if there was a collision detected, false otherwise