Level H Engine
Functions
Collision Namespace Reference

Contains Collision detection functions for use within the code. More...

Functions

bool rectRectIntersect (Vec2 posBoxA, Vec2 dimBoxA, Vec2 posBoxB, Vec2 dimBoxB)
 Checks to see if two rectangles intersect. More...
 
bool cubeCubeIntersect (Vec3 posBoxA, Vec3 dimBoxA, Vec3 posBoxB, Vec3 dimBoxB)
 Checks to see if two cubes intersect (position is the center of the cube) More...
 
bool cubeCubeIntersect (Vec3 posBoxA, Vec3 dimBoxA, Vec3 posBoxB, Vec3 dimBoxB, Vec3 &collisionSides)
 Checks to see if two cubes intersect (position is the center of the cube) More...
 
bool sphereCubeIntersect (Vec3 posBox, Vec3 dimBox, Vec3 posSphere, float radSphere)
 Checks to see if a cube and sphere intersects (position is the center of the cube) More...
 
bool sphereCubeIntersect (Vec3 posBox, Vec3 dimBox, Vec3 posSphere, float radSphere, Vec3 &collisionSides)
 Checks to see if a cube and sphere intersects (position is the center of the cube) More...
 
bool circleCircleIntersect (Vec2 circle1Pos, Vec2 circle2Pos, float circle1Rad, float circle2Rad)
 Takes in two circle positions, radius's to detect if the circles collide. More...
 
bool sphereSphereIntersect (Vec3 sphere1Pos, Vec3 sphere2Pos, float sphere1Rad, float sphere2Rad)
 Takes in two sphere positions and radius's and uses this to detect if the sphere's collide. More...
 
bool sphereSphereIntersect (Vec3 sphere1Pos, Vec3 sphere2Pos, float sphere1Rad, float sphere2Rad, Vec3 &vel1, Vec3 &vel2)
 Takes in two sphere positions and radius's and uses this to detect if the sphere's collide. More...
 
bool circleRectIntersect (Vec2 circlePos, Vec2 boxPos, float circleRad, Vec2 boxDim)
 Takes in a circle position and radius and a box position and dimensions to detect for collision. More...
 

Detailed Description

Contains Collision detection functions for use within the code.

Function Documentation

◆ circleCircleIntersect()

bool Collision::circleCircleIntersect ( Vec2  circle1Pos,
Vec2  circle2Pos,
float  circle1Rad,
float  circle2Rad 
)

Takes in two circle positions, radius's to detect if the circles collide.

Parameters
circle1PosThe first circle position's to be used in the collision check.
circle2PosThe second circle position's to be used in the collision check.
circle1RadThe first circle radius's to be used in the collision check.
circle2RadThe second circle radius's to be used in the collision check.
Returns
If the collision occurs.
Here is the call graph for this function:

◆ circleRectIntersect()

bool Collision::circleRectIntersect ( Vec2  circlePos,
Vec2  boxPos,
float  circleRad,
Vec2  boxDim 
)

Takes in a circle position and radius and a box position and dimensions to detect for collision.

Parameters
circlePosThe circle's position to be used in the collision check.
boxPosThe box's position to be used in the collision check.
circleRadThe sphere's radius to be used in the collision check.
boxDimThe box's dimension's to be used in the collision check.
Returns
If the collision occurs.

◆ cubeCubeIntersect() [1/2]

bool Collision::cubeCubeIntersect ( Vec3  posBoxA,
Vec3  dimBoxA,
Vec3  posBoxB,
Vec3  dimBoxB 
)

Checks to see if two cubes intersect (position is the center of the cube)

Parameters
posBoxAThe position of the first cube.
dimBoxAThe dimensions of the first cube.
posBoxBThe position of the second cube.
dimBoxBThe dimensions of the second cube.
Returns
If the cubes intersect.

◆ cubeCubeIntersect() [2/2]

bool Collision::cubeCubeIntersect ( Vec3  posBoxA,
Vec3  dimBoxA,
Vec3  posBoxB,
Vec3  dimBoxB,
Vec3 collisionSides 
)

Checks to see if two cubes intersect (position is the center of the cube)

Parameters
posBoxAThe position of the first cube.
dimBoxAThe dimensions of the first cube.
posBoxBThe position of the second cube.
dimBoxBThe dimensions of the second cube.
collisionSidesA reference to the sides of the cubes that collides, eg. x = -1 then left, x = 0 then none, x = 1 then right
Returns
If the cubes intersect.

◆ rectRectIntersect()

bool Collision::rectRectIntersect ( Vec2  posBoxA,
Vec2  dimBoxA,
Vec2  posBoxB,
Vec2  dimBoxB 
)

Checks to see if two rectangles intersect.

Parameters
posBoxAThe position of the first rectangle.
dimBoxAThe dimensions of the first rectangle.
posBoxBThe position of the second rectangle.
dimBoxBThe dimensions of the second rectangle.
Returns
If the rectangles intersect.

◆ sphereCubeIntersect() [1/2]

bool Collision::sphereCubeIntersect ( Vec3  posBox,
Vec3  dimBox,
Vec3  posSphere,
float  radSphere 
)

Checks to see if a cube and sphere intersects (position is the center of the cube)

Parameters
posBoxThe position of the cube.
dimBoxThe dimensions of the cube.
posSphereThe position of the sphere.
radSphereThe radius of the sphere.
Returns
If the cubes intersect.
Here is the caller graph for this function:

◆ sphereCubeIntersect() [2/2]

bool Collision::sphereCubeIntersect ( Vec3  posBox,
Vec3  dimBox,
Vec3  posSphere,
float  radSphere,
Vec3 collisionSides 
)

Checks to see if a cube and sphere intersects (position is the center of the cube)

Parameters
posBoxThe position of the cube.
dimBoxThe dimensions of the cube.
posSphereThe position of the sphere.
radSphereThe radius of the sphere.
collisionSidesA reference to the sides of the cubes that collides, eg. x = -1 then left, x = 0 then none, x = 1 then right
Returns
If the cubes intersect.

◆ sphereSphereIntersect() [1/2]

bool Collision::sphereSphereIntersect ( Vec3  sphere1Pos,
Vec3  sphere2Pos,
float  sphere1Rad,
float  sphere2Rad 
)

Takes in two sphere positions and radius's and uses this to detect if the sphere's collide.

Parameters
sphere1PosThe first sphere position's to be used in the collision check.
sphere2PosThe second sphere position's to be used in the collision check.
sphere1RadThe first sphere radius's to be used in the collision check.
sphere2RadThe second sphere radius's to be used in the collision check.
Returns
If the collision occurs.
Here is the caller graph for this function:

◆ sphereSphereIntersect() [2/2]

bool Collision::sphereSphereIntersect ( Vec3  sphere1Pos,
Vec3  sphere2Pos,
float  sphere1Rad,
float  sphere2Rad,
Vec3 vel1,
Vec3 vel2 
)

Takes in two sphere positions and radius's and uses this to detect if the sphere's collide.

Parameters
sphere1PosThe first sphere position's to be used in the collision check.
sphere2PosThe second sphere position's to be used in the collision check.
sphere1RadThe first sphere radius's to be used in the collision check.
sphere2RadThe second sphere radius's to be used in the collision check.
vel1A reference to the velocities of the 1st sphere.
vel2A reference to the velocities of the 2nd sphere.
Returns
If the collision occurs.
Here is the call graph for this function: