Kigs Framework
Doc version 0.8
Open source multi purpose Rapid Application Development framework
|
#include <Collision.h>
Static Public Member Functions | |
static bool | CollideSphereSphere (const Point3D &Sphere1Center, const Vector3D &Sphere1Velocity, const kfloat Sphere1Radius, const Point3D &Sphere2Center, const Vector3D &Sphere2Velocity, const kfloat Sphere2Radius, kfloat &IntersectionTime) |
compute collision time between two moving spheres given 2 spheres radius, position, and velocity, return true if the sphere collide or false if not. If the sphere collide, return the intersection time More... | |
static bool | CollideSphereTriangle (const Point3D &SphereOrigin, const Vector3D &SphereVelocity, const kfloat SphereRadius, const Point3D &P1, const Point3D &P2, const Point3D &P3, kdouble &IntersectionDistance, Vector3D &InteresectionNormal, Point3D &IntersectionPoint) |
compute collision between a moving sphere and a single triangle given the sphere origin, radius and velocity, and 3 points, return if there is a collision, and if yes, give the intersection distance (time?), the intersecting point and normal More... | |
static bool | CollideSphereAABBTreeNode (const Point3D &SphereOrigin, const Vector3D &SphereVelocity, const kfloat &SphereRadius, AABBTreeNode &pAABB, Mesh *pMesh, kdouble &IntersectionDistance, Vector3D &InteresectionNormal, Point3D &IntersectionPoint) |
compute collision between a moving sphere and a mesh using an already existing AABBTree given the sphere origin, radius and velocity, the mesh and its AABBtree, return if there is a collision, and if yes, give the intersection distance (time?), the intersecting point and normal More... | |
static bool | CollideRaySphere (const Point3D &RayStartingPoint, const Vector3D &Raydirection, const kfloat &SphereRadius, kdouble &IntersectionDistance, Vector3D &IntersectionNormal) |
compute collision between a ray and a sphere given the ray origin, ray direction in sphere local coords, and sphere radius return if there is a collision, and if yes, give the intersection distance (time?), the intersecting point and normal | |
Static Protected Member Functions | |
static bool | CheckPointInTriangle (const Point3D &point, const Point3D &A, const Point3D &B, const Point3D &C) |
return true if point is in triangle given by A,B and C More... | |
static Point3D | closestPointOnLine (const Point3D &A, const Point3D &B, const Point3D &P) |
return the closest point to P on the line (A,B) | |
static Point3D | closestPointOnTriangle (const Point3D &A, const Point3D &B, const Point3D &C, const Point3D &P) |
return the closest point to P on the triangle (A,B,C) | |
static bool | CollideSphereAABBTreeNode (const Point3D &SphereOrigin, const Vector3D &SphereVelocity, const kfloat &SphereRadius, AABBTreeNode &pAABB, Mesh *pMesh, const BBox &MovingSphereBBox, kdouble &IntersectionDistance, Vector3D &InteresectionNormal, Point3D &IntersectionPoint) |
internal collide computation used by the public CollideSphereAABBTreeNode method More... | |
Encapsulate useful collision calculation methods.
|
staticprotected |
return true if point is in triangle given by A,B and C
check if a point (Point, P) is inside a triangle defined by points (A,B,C) the given point is in the triangle plane. Use the angles sum : APB + BPC + CPA. If sum is near 2*PI then the point is in the triangle else it is out. This method use 3 vector normalize, 3 acos, 3 dot product and one abs, perhaps other faster method is possible
|
staticprotected |
internal collide computation used by the public CollideSphereAABBTreeNode method
check collision between a moving sphere (position, radius, movement vector, bbox along trajectory) and mesh given its AABBTree. this method is recursive
first test current node bounding box against moving sphere bounding box
if the bounding box are intersecting
if this node is a leaf then check each triangles and return
if this node is not a leaf then recurse to sons
|
static |
compute collision between a moving sphere and a mesh using an already existing AABBTree given the sphere origin, radius and velocity, the mesh and its AABBtree, return if there is a collision, and if yes, give the intersection distance (time?), the intersecting point and normal
check collision between a moving sphere (position, radius, movement vector) and mesh given its AABBTree.
first compute the bounding box for the sphere along its trajectory
then call the same method but with the moving sphere BBOx param
|
static |
compute collision time between two moving spheres given 2 spheres radius, position, and velocity, return true if the sphere collide or false if not. If the sphere collide, return the intersection time
check if a collision occurs between two moving spheres Two usages are possibles :
first compute sphere1 to sphere 2 vector
then compute sphere2 relative velocity to sphere1
distance equation between sphere1 and sphere2
return true if collision occur in the next second (or between start and end position)
|
static |
compute collision between a moving sphere and a single triangle given the sphere origin, radius and velocity, and 3 points, return if there is a collision, and if yes, give the intersection distance (time?), the intersecting point and normal
check collision between a moving sphere (position, radius, movement vector) and a triangle (P1,P2,P3). the method return false if the sphere is already intersecting the triangle
compute the "normal velocity", ie the velocity of the sphere on the plane's normal axis
first return false if sphere is moving far away from the triangle (nv>KFLOAT_CONST(0.0))
compute distance from sphere origin to plane
compute intersection start/end times
if collision has already occured or there's no collision between sphere start/end pos then return false
compute projected intersection point on plane
and return true if it is inside the triangle
if intersection occured with the plane but outside the triangle, compute intersection with nearest of P1, P2 or P3
then compute intersection with nearest edge (P1,P2), (P2,P3), (P3,P1)
finally keep the nearest intersection with point or edge if any, and return