Collection of collision detection routines. More...
#include <decDCollisionDetection.h>
Public Types | |
| enum | eIntersectionResult { eirInside, eirPartial, eirOutside } |
Intersection test results. More... | |
Static Public Member Functions | |
| static bool | AABoxHitsAABox (const decDVector &minExtend1, const decDVector &maxExtend1, const decDVector &minExtend2, const decDVector &maxExtend2) |
| Determines if two axis aligned boxes defined by their extends intersect. | |
| static int | AABoxIntersectsAABox (const decDVector &minExtend1, const decDVector &maxExtend1, const decDVector &minExtend2, const decDVector &maxExtend2) |
| Determines how the first axis aligned box intersects the second one. | |
| static bool | RayHitsBox (const decDVector &rayOrigin, const decDVector &rayDirection, const decDVector &boxCenter, const decDVector &boxHalfExtends, double &hitDistance) |
| Determines if a ray hits an axis aligned box. | |
| static bool | RayHitsCapsule (const decDVector &rayOrigin, const decDVector &rayDirection, const decDVector &capsuleCenter, double capsuleHalfHeight, double capsuleRadius, double &hitDistance) |
| Determines if a ray hits a capsule with uniform radius oriented along the Y-Axis. | |
| static bool | RayHitsCylinder (const decDVector &rayOrigin, const decDVector &rayDirection, const decDVector &cylinderCenter, double cylinderHalfHeight, double cylinderRadius, double &hitDistance) |
| Determines if a ray hits a cylinder with uniform radius oriented along the Y-Axis. | |
| static bool | RayHitsTaperedCapsule (const decDVector &rayOrigin, const decDVector &rayDirection, const decDVector &capsuleCenter, double capsuleHalfHeight, double capsuleTopRadius, double capsuleBottomRadius, double &hitDistance) |
| Determines if a ray hits a tapered capsule oriented along the Y-Axis. | |
| static bool | RayHitsTaperedCylinder (const decDVector &rayOrigin, const decDVector &rayDirection, const decDVector &cylinderCenter, double cylinderHalfHeight, double cylinderTopRadius, double cylinderBottomRadius, double &hitDistance) |
| Determines if a ray hits a tapered cylinder oriented along the Y-Axis. | |
| static bool | RayHitsTriangle (const decDVector &rayOrigin, const decDVector &rayDirection, const decDVector &tri1, const decDVector &tri2, const decDVector &tri3) |
| Determines if a ray hits a triangle. | |
| static bool | RayHitsTriangle (const decDVector &rayOrigin, const decDVector &rayDirection, const decDVector &tri1, const decDVector &tri2, const decDVector &tri3, const decDVector &trinormal) |
| Determines if a ray hits a triangle using a precalculated triangle normal. | |
| static double | SphereMoveHitsSphere (const decDVector &sphere1Center, double sphere1Radius, const decDVector &sphere2Center, double sphere2Radius, const decDVector &displacement, decDVector *normal) |
| Determines if a sphere collides with another sphere while moving. | |
Closest Point Routines | |
| static decDVector | ClosestPointOnLine (const decDVector &la, const decDVector &lb, const decDVector &p) |
| Retrieves the closest point on a line to another point. | |
| static decDVector | ClosestPointOnTriangle (const decDVector &tp1, const decDVector &tp2, const decDVector &tp3, const decDVector &p) |
| Retrieves the closest point on a triangle to a given point. | |
| static decDVector | ClosestPointOnQuad (const decDVector &tp1, const decDVector &tp2, const decDVector &tp3, const decDVector &tp4, const decDVector &p) |
| Retrieves the closest point on a quad to a given point. | |
Intersection Routines | |
| static double | RayPlane (const decDVector &pp, const decDVector &pn, const decDVector &rp, const decDVector &rd) |
| Intersections a ray with a plane. | |
| static double | RaySphere (const decDVector &rp, const decDVector &rd, const decDVector &sc, double sr) |
| Intersections a ray with a sphere. | |
Distance Routines | |
| static double | SegmentSegmentDistance (const decDVector &as, const decDVector &ae, const decDVector &bs, const decDVector &be) |
| Retrieves the smallest distance of a line segment to another line segment. | |
Collision Tests | |
| static bool | PointInTriangle (const decDVector &tp1, const decDVector &tp2, const decDVector &tp3, const decDVector &p) |
| Determines if a point is inside a triangle. | |
| static bool | PointInTriangle (const decDVector &tp1, const decDVector &tp2, const decDVector &tp3, const decDVector &tnormal, const decDVector &p) |
| Determines if a point is inside a triangle. | |
| static bool | PointInQuad (const decDVector &tp1, const decDVector &tp2, const decDVector &tp3, const decDVector &tp4, const decDVector &p) |
| Determines if a point is inside a quad. | |
| static bool | RayHitsSphere (const decDVector &rayOrigin, const decDVector &rayDirection, const decDVector &sphereCenter, double sphereRadius, double &hitDistance) |
| Determines if a ray hits a sphere. | |
| static bool | SphereHitsSphere (const decDVector &sphere1Center, double sphere1Radius, const decDVector &sphere2Center, double sphere2Radius) |
| Determines if a sphere collides with another sphere. | |
Side Test Routines | |
| static int | PointOnPlaneSide (const decDVector &pp, const decDVector &pn, const decDVector &p) |
| Determines on which side of a plane the given point lies in respect to the plane normal. | |
Collection of collision detection routines.
Contains a set of collision detection routines used often in a game engine or similar 3D project. Some collision routines from collision volumes have been moved over here as they can be used then also by scripting modules which do not want to create collision volume objects for doing collision detection.
| static bool decDCollisionDetection::AABoxHitsAABox | ( | const decDVector & | minExtend1, |
| const decDVector & | maxExtend1, | ||
| const decDVector & | minExtend2, | ||
| const decDVector & | maxExtend2 | ||
| ) | [inline, static] |
Determines if two axis aligned boxes defined by their extends intersect.
| minExtend1 | Minimum extend of the first box. |
| maxExtend1 | Maximum extend of the first box. |
| minExtend2 | Minimum extend of the second box. |
| maxExtend2 | Maximum extend of the second box. |
| static int decDCollisionDetection::AABoxIntersectsAABox | ( | const decDVector & | minExtend1, |
| const decDVector & | maxExtend1, | ||
| const decDVector & | minExtend2, | ||
| const decDVector & | maxExtend2 | ||
| ) | [static] |
Determines how the first axis aligned box intersects the second one.
| minExtend1 | Minimum extend of the first box. |
| maxExtend1 | Maximum extend of the first box. |
| minExtend2 | Minimum extend of the second box. |
| maxExtend2 | Maximum extend of the second box. |
| static decDVector decDCollisionDetection::ClosestPointOnLine | ( | const decDVector & | la, |
| const decDVector & | lb, | ||
| const decDVector & | p | ||
| ) | [static] |
Retrieves the closest point on a line to another point.
| la | Begin of line. |
| lb | End of line. |
| p | Point to check. |
| static decDVector decDCollisionDetection::ClosestPointOnQuad | ( | const decDVector & | tp1, |
| const decDVector & | tp2, | ||
| const decDVector & | tp3, | ||
| const decDVector & | tp4, | ||
| const decDVector & | p | ||
| ) | [static] |
Retrieves the closest point on a quad to a given point.
The corners of the quad have to be coplanar or the result is is falsified.
| tp1 | First quad point. |
| tp2 | Second quad point. |
| tp3 | Third quad point. |
| tp4 | Fourth quad point. |
| p | Point to check. |
| static decDVector decDCollisionDetection::ClosestPointOnTriangle | ( | const decDVector & | tp1, |
| const decDVector & | tp2, | ||
| const decDVector & | tp3, | ||
| const decDVector & | p | ||
| ) | [static] |
Retrieves the closest point on a triangle to a given point.
| tp1 | First triangle point. |
| tp2 | Second triangle point. |
| tp3 | Third triangle point. |
| p | Point to check. |
| static bool decDCollisionDetection::PointInQuad | ( | const decDVector & | tp1, |
| const decDVector & | tp2, | ||
| const decDVector & | tp3, | ||
| const decDVector & | tp4, | ||
| const decDVector & | p | ||
| ) | [static] |
Determines if a point is inside a quad.
The point and the all corners of the quad have to be coplanar for this test to work.
| tp1 | First quad point. |
| tp2 | Second quad point. |
| tp3 | Third quad point. |
| tp4 | Fourth quad point. |
| p | Point to check. |
| static bool decDCollisionDetection::PointInTriangle | ( | const decDVector & | tp1, |
| const decDVector & | tp2, | ||
| const decDVector & | tp3, | ||
| const decDVector & | tnormal, | ||
| const decDVector & | p | ||
| ) | [static] |
Determines if a point is inside a triangle.
The point has to be coplanar with the triangle for this test to work.
| tp1 | First triangle point. |
| tp2 | Second triangle point. |
| tp3 | Third triangle point. |
| tnormal | Triangle normal. |
| p | Point to check. |
| static bool decDCollisionDetection::PointInTriangle | ( | const decDVector & | tp1, |
| const decDVector & | tp2, | ||
| const decDVector & | tp3, | ||
| const decDVector & | p | ||
| ) | [static] |
Determines if a point is inside a triangle.
The point has to be coplanar with the triangle for this test to work.
| tp1 | First triangle point. |
| tp2 | Second triangle point. |
| tp3 | Third triangle point. |
| p | Point to check. |
| static int decDCollisionDetection::PointOnPlaneSide | ( | const decDVector & | pp, |
| const decDVector & | pn, | ||
| const decDVector & | p | ||
| ) | [inline, static] |
Determines on which side of a plane the given point lies in respect to the plane normal.
| pp | Plane point. |
| pn | Plane normal. |
| p | Point to test. |
| static bool decDCollisionDetection::RayHitsBox | ( | const decDVector & | rayOrigin, |
| const decDVector & | rayDirection, | ||
| const decDVector & | boxCenter, | ||
| const decDVector & | boxHalfExtends, | ||
| double & | hitDistance | ||
| ) | [static] |
Determines if a ray hits an axis aligned box.
| rayOrigin | Origin of the ray. |
| rayDirection | Normalized direction of the ray. |
| boxCenter | Center of the box. |
| boxHalfExtends | Half extends of the spherbox. All components have to be greater than 0. |
| hitDistance | If the ray hits this will be set to the distance from the ray origin to the collision point. |
| static bool decDCollisionDetection::RayHitsCapsule | ( | const decDVector & | rayOrigin, |
| const decDVector & | rayDirection, | ||
| const decDVector & | capsuleCenter, | ||
| double | capsuleHalfHeight, | ||
| double | capsuleRadius, | ||
| double & | hitDistance | ||
| ) | [static] |
Determines if a ray hits a capsule with uniform radius oriented along the Y-Axis.
| rayOrigin | Origin of the ray. |
| rayDirection | Normalized direction of the ray. |
| capsuleCenter | Center of the capsule. |
| capsuleHalfHeight | Half height of capsule. Has to be greater than 0. |
| capsuleRadius | Radius of the capsule. Has to be greater than 0. |
| hitDistance | If the ray hits this will be set to the distance from the ray origin to the collision point. |
| static bool decDCollisionDetection::RayHitsCylinder | ( | const decDVector & | rayOrigin, |
| const decDVector & | rayDirection, | ||
| const decDVector & | cylinderCenter, | ||
| double | cylinderHalfHeight, | ||
| double | cylinderRadius, | ||
| double & | hitDistance | ||
| ) | [static] |
Determines if a ray hits a cylinder with uniform radius oriented along the Y-Axis.
| rayOrigin | Origin of the ray. |
| rayDirection | Normalized direction of the ray. |
| cylinderCenter | Center of the cylinder. |
| cylinderHalfHeight | Half height of cylinder. Has to be greater than 0. |
| cylinderRadius | Radius of the cylinder. Has to be greater than 0. |
| hitDistance | If the ray hits this will be set to the distance from the ray origin to the collision point. |
| static bool decDCollisionDetection::RayHitsSphere | ( | const decDVector & | rayOrigin, |
| const decDVector & | rayDirection, | ||
| const decDVector & | sphereCenter, | ||
| double | sphereRadius, | ||
| double & | hitDistance | ||
| ) | [static] |
Determines if a ray hits a sphere.
| rayOrigin | Origin of the ray. |
| rayDirection | Normalized direction of the ray. |
| sphereCenter | Center of the sphere. |
| sphereRadius | Radius of the sphere. Has to be greater than 0. |
| hitDistance | If the ray hits this will be set to the distance from the ray origin to the collision point. |
| static bool decDCollisionDetection::RayHitsTaperedCapsule | ( | const decDVector & | rayOrigin, |
| const decDVector & | rayDirection, | ||
| const decDVector & | capsuleCenter, | ||
| double | capsuleHalfHeight, | ||
| double | capsuleTopRadius, | ||
| double | capsuleBottomRadius, | ||
| double & | hitDistance | ||
| ) | [static] |
Determines if a ray hits a tapered capsule oriented along the Y-Axis.
| rayOrigin | Origin of the ray. |
| rayDirection | Normalized direction of the ray. |
| capsuleCenter | Center of the capsule. |
| capsuleHalfHeight | Half height of capsule. Has to be greater than 0. |
| capsuleTopRadius | Radius of the top cap of the capsule. Has to be greater than 0. |
| capsuleBottomRadius | Radius of the bottom cap of the capsule. Has to be greater than 0. |
| hitDistance | If the ray hits this will be set to the distance from the ray origin to the collision point. |
| static bool decDCollisionDetection::RayHitsTaperedCylinder | ( | const decDVector & | rayOrigin, |
| const decDVector & | rayDirection, | ||
| const decDVector & | cylinderCenter, | ||
| double | cylinderHalfHeight, | ||
| double | cylinderTopRadius, | ||
| double | cylinderBottomRadius, | ||
| double & | hitDistance | ||
| ) | [static] |
Determines if a ray hits a tapered cylinder oriented along the Y-Axis.
| rayOrigin | Origin of the ray. |
| rayDirection | Normalized direction of the ray. |
| cylinderCenter | Center of the cylinder. |
| cylinderHalfHeight | Half height of cylinder. Has to be greater than 0. |
| cylinderTopRadius | Radius of the top cap of the cylinder. Has to be greater than 0. |
| cylinderBottomRadius | Radius of the bottom cap of the cylinder. Has to be greater than 0. |
| hitDistance | If the ray hits this will be set to the distance from the ray origin to the collision point. |
| static bool decDCollisionDetection::RayHitsTriangle | ( | const decDVector & | rayOrigin, |
| const decDVector & | rayDirection, | ||
| const decDVector & | tri1, | ||
| const decDVector & | tri2, | ||
| const decDVector & | tri3 | ||
| ) | [static] |
Determines if a ray hits a triangle.
| rayOrigin | Origin of the ray. |
| rayDirection | Normalized direction of the ray. |
| tri1 | First point of the triangle. |
| tri2 | Second point of the triangle. |
| tri3 | Third point of the triangle. |
| static bool decDCollisionDetection::RayHitsTriangle | ( | const decDVector & | rayOrigin, |
| const decDVector & | rayDirection, | ||
| const decDVector & | tri1, | ||
| const decDVector & | tri2, | ||
| const decDVector & | tri3, | ||
| const decDVector & | trinormal | ||
| ) | [static] |
Determines if a ray hits a triangle using a precalculated triangle normal.
| rayOrigin | Origin of the ray. |
| rayDirection | Normalized direction of the ray. |
| tri1 | First point of the triangle. |
| tri2 | Second point of the triangle. |
| tri3 | Third point of the triangle. |
| trinormal | Normal of the triangle. |
| static double decDCollisionDetection::RayPlane | ( | const decDVector & | pp, |
| const decDVector & | pn, | ||
| const decDVector & | rp, | ||
| const decDVector & | rd | ||
| ) | [static] |
Intersections a ray with a plane.
| pp | Plane position. |
| pn | Plane normal. |
| rp | Ray position. |
| rd | Ray direction. |
| static double decDCollisionDetection::RaySphere | ( | const decDVector & | rp, |
| const decDVector & | rd, | ||
| const decDVector & | sc, | ||
| double | sr | ||
| ) | [static] |
Intersections a ray with a sphere.
| rp | Ray position. |
| rd | Ray direction. |
| sc | Sphere center. |
| sr | Sphere radius. |
| static double decDCollisionDetection::SegmentSegmentDistance | ( | const decDVector & | as, |
| const decDVector & | ae, | ||
| const decDVector & | bs, | ||
| const decDVector & | be | ||
| ) | [static] |
Retrieves the smallest distance of a line segment to another line segment.
| as | Segment a start position. |
| ae | Segment a end position. |
| bs | Segment b start position. |
| be | Segment b end position. |
| static bool decDCollisionDetection::SphereHitsSphere | ( | const decDVector & | sphere1Center, |
| double | sphere1Radius, | ||
| const decDVector & | sphere2Center, | ||
| double | sphere2Radius | ||
| ) | [static] |
Determines if a sphere collides with another sphere.
| sphere1Center | Center of the first sphere. |
| sphere1Radius | Radius of the first sphere. Has to be greater than 0. |
| sphere2Center | Center of the second sphere. |
| sphere2Radius | Radius of the second sphere. Has to be greater than 0. |
| static double decDCollisionDetection::SphereMoveHitsSphere | ( | const decDVector & | sphere1Center, |
| double | sphere1Radius, | ||
| const decDVector & | sphere2Center, | ||
| double | sphere2Radius, | ||
| const decDVector & | displacement, | ||
| decDVector * | normal | ||
| ) | [static] |
Determines if a sphere collides with another sphere while moving.
| sphere1Center | Center of the first sphere. |
| sphere1Radius | Radius of the first sphere. Has to be greater than 0. |
| sphere2Center | Center of the second sphere. |
| sphere2Radius | Radius of the second sphere. Has to be greater than 0. |
| displacement | Displacement of the first sphere. |
| normal | Stores the collision normal into. Set to NULL if you do not require the normal. |
1.7.2