22 #ifndef G3D_CollisionDetection_h
23 #define G3D_CollisionDetection_h
133 const int separatingAxisIndex,
154 const double epsilon,
180 const int separatingAxisIndex,
279 const int lastSeparatingAxis = -1);
343 const int lastSeparatingAxis = -1);
362 const class Sphere& sphereA,
421 const class Plane& planeB,
466 const class Plane& plane,
524 location = orig + dir * t;
558 location = orig + dir * t;
594 location = orig + dir * t;
613 const class AABox& box,
615 bool& inside = ignoreBool,
637 const class AABox& box,
639 bool& inside = ignoreBool,
661 float boundingRadiusSquared,
685 const class Sphere& sphere,
708 const class Box& box,
777 const class Sphere& sphere,
779 const class Plane& plane,
799 const class Sphere& sphere,
803 float b[3] = (
float*)&ignore);
823 const class Sphere& sphere,
850 const class Sphere& sphere,
852 const class Box& box,
876 const Sphere& fixedSphere,
898 const class Sphere& sphere,
920 const class Sphere& sphere,
922 const float collisionTime,
923 const Vector3& collisionLocation,
924 const Vector3& collisionNormal);
943 const class Sphere& sphere,
945 const float collisionTime,
946 const Vector3& collisionLocation);
1020 const Vector3 edgeDirection[3],
1021 const float edgeLength[3],
1082 double timeLimit =
inf());
1102 const Sphere& fixedSphere,
1103 double timeLimit =
inf());
1205 #endif // G3D_COLLISIONDETECTION_H
float finf()
Definition: g3dmath.cpp:71
static float collisionTimeForMovingPointFixedRectangle(const Vector3 &point, const Vector3 &velocity, const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, Vector3 &outLocation, Vector3 &outNormal=ignore)
Definition: CollisionDetection.cpp:1308
static float penetrationDepthForFixedSphereFixedPlane(const Sphere &sphereA, const class Plane &planeB, Array< Vector3 > &contactPoints, Array< Vector3 > &contactNormals=ignoreArray)
Definition: CollisionDetection.cpp:788
virtual ~CollisionDetection()
Definition: CollisionDetection.h:117
static float collisionTimeForMovingSphereFixedRectangle(const class Sphere &sphere, const Vector3 &velocity, const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, Vector3 &outLocation, Vector3 &outNormal=ignore)
Definition: CollisionDetection.cpp:1750
static float penetrationDepthForFixedSphereFixedBox(const Sphere &sphere, const Box &box, Array< Vector3 > &contactPoints, Array< Vector3 > &contactNormals=ignoreArray)
Definition: CollisionDetection.cpp:554
Dynamic 1D array tuned for performance.
Definition: Array.h:95
static Vector3 slideDirection(const class Sphere &sphere, const Vector3 &velocity, const float collisionTime, const Vector3 &collisionLocation)
Definition: CollisionDetection.cpp:1874
static bool __fastcall rayAABox(const Ray &ray, const Vector3 &invDir, const AABox &box, const Vector3 &boxCenter, float boundingRadiusSquared, Vector3 &location, bool &inside)
Calculates intersection of a ray and a static Axis-Aligned Box (AABox).
Definition: CollisionDetection.cpp:886
static bool fixedSolidBoxIntersectsFixedTriangle(const AABox &box, const Triangle &triangle)
Definition: CollisionDetection.cpp:2367
Axis
Definition: Vector3.h:122
Vector3 direction() const
Definition: Vector3.h:756
static float collisionTimeForMovingSphereFixedTriangle(const class Sphere &sphere, const Vector3 &velocity, const Triangle &triangle, Vector3 &outLocation, float b[3]=(float *)&ignore)
Definition: CollisionDetection.cpp:1636
static Vector3 ignore
Definition: CollisionDetection.h:101
static void closestPointsBetweenLineAndLine(const Line &line1, const Line &line2, Vector3 &closest1, Vector3 &closest2)
Definition: CollisionDetection.cpp:309
Definition: CollisionDetection.h:94
An arbitrary (oriented) 3D box, useful as a bounding box.
Definition: Box.h:35
static bool isPointInsideTriangle(const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &normal, const Vector3 &point, float b[3], Vector3::Axis primaryAxis=Vector3::DETECT_AXIS)
Definition: CollisionDetection.cpp:2009
static bool isPointInsideRectangle(const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, const Vector3 &normal, const Vector3 &point)
Definition: CollisionDetection.cpp:2086
static float penetrationDepthForFixedSphereFixedSphere(const class Sphere &sphereA, const Sphere &sphereB, Array< Vector3 > &contactPoints, Array< Vector3 > &contactNormals=ignoreArray)
Definition: CollisionDetection.cpp:764
static bool fixedSolidSphereIntersectsFixedSolidSphere(const Sphere &sphere1, const Sphere &sphere2)
Definition: CollisionDetection.cpp:2172
Definition: Vector3.h:122
static bool ignoreBool
Definition: CollisionDetection.h:107
double inf()
Definition: g3dmath.cpp:40
static bool fixedSolidBoxIntersectsFixedSolidBox(const Box &box1, const Box &box2, const int lastSeparatingAxis=-1)
Definition: CollisionDetection.cpp:251
static float collisionTimeForMovingPointFixedTriangle(const Vector3 &orig, const Vector3 &dir, const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, Vector3 &location, Vector3 &normal)
Definition: CollisionDetection.h:584
static float collisionTimeForMovingPointFixedAABox(const Vector3 &point, const Vector3 &velocity, const class AABox &box, Vector3 &outLocation, bool &inside=ignoreBool, Vector3 &outNormal=ignore)
Definition: CollisionDetection.cpp:1210
static void fillSolidBoxSolidBoxInfo(const Box &box1, const Box &box2, Vector3 &a, Vector3 &b, Vector3 &D, double *c, double *ca, double *ad, double *bd)
Definition: CollisionDetection.cpp:202
static float collisionTimeForMovingPointFixedTriangle(const Vector3 &orig, const Vector3 &dir, const Vector3 &v0, const Vector3 &v1, const Vector3 &v2)
Definition: CollisionDetection.h:487
static Vector3 closestPointToRectanglePerimeter(const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, const Vector3 &point)
Definition: CollisionDetection.cpp:2099
static bool collisionLocationForMovingPointFixedAABox(const Vector3 &point, const Vector3 &velocity, const class AABox &box, Vector3 &outLocation, bool &inside=ignoreBool, Vector3 &normal=ignore)
Definition: CollisionDetection.cpp:1226
static Vector3 closestPointOnTrianglePerimeter(const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &point)
Definition: CollisionDetection.cpp:1935
static Ray fromOriginAndDirection(const Point3 &point, const Vector3 &direction)
Definition: Ray.h:87
static float collisionTimeForMovingPointFixedCapsule(const Vector3 &point, const Vector3 &velocity, const class Capsule &capsule, Vector3 &outLocation, Vector3 &outNormal=ignore)
Definition: CollisionDetection.cpp:1542
static bool movingSpherePassesThroughFixedSphere(const Sphere &sphere, const Vector3 &velocity, const Sphere &fixedSphere, double timeLimit=inf())
Definition: CollisionDetection.cpp:2225
static bool fixedSolidSphereIntersectsFixedSolidBox(const Sphere &sphere, const Box &box)
Definition: CollisionDetection.cpp:2180
static Array< Vector3 > ignoreArray
Definition: CollisionDetection.h:113
static Vector3 closestPointOnLineSegment(const Vector3 &v0, const Vector3 &v1, const Vector3 &point)
Definition: CollisionDetection.cpp:1889
static float penetrationDepthForFixedBoxFixedPlane(const Box &box, const Plane &plane, Array< Vector3 > &contactPoints, Array< Vector3 > &contactNormals=ignoreArray)
Definition: CollisionDetection.cpp:813
static bool parallelAxisForSolidBoxSolidBox(const double *ca, const double epsilon, int &axis1, int &axis2)
Definition: CollisionDetection.cpp:183
static float collisionTimeForMovingSphereFixedBox(const class Sphere &sphere, const Vector3 &velocity, const class Box &box, Vector3 &outLocation, Vector3 &outNormal=ignore)
Definition: CollisionDetection.cpp:1790
static float collisionTimeForMovingPointFixedSphere(const Vector3 &point, const Vector3 &velocity, const class Sphere &sphere, Vector3 &outLocation, Vector3 &outNormal=ignore, bool solid=false)
Definition: CollisionDetection.cpp:977
static float collisionTimeForMovingSphereFixedPlane(const class Sphere &sphere, const Vector3 &velocity, const class Plane &plane, Vector3 &outLocation, Vector3 &outNormal=ignore)
Definition: CollisionDetection.cpp:1589
Vector3 cross(const Vector3 &v1, const Vector3 &v2)
Definition: vectorMath.h:144
const Vector3 & normal() const
Definition: Triangle.cpp:93
static float collisionTimeForMovingSphereFixedCapsule(const class Sphere &sphere, const Vector3 &velocity, const class Capsule &capsule, Vector3 &outLocation, Vector3 &outNormal=ignore)
Definition: CollisionDetection.cpp:1826
static float penetrationDepthForFixedBoxFixedBox(const Box &box1, const Box &box2, Array< Vector3 > &contactPoints, Array< Vector3 > &contactNormals, const int lastSeparatingAxis=-1)
Definition: CollisionDetection.cpp:347
static Vector3 bounceDirection(const class Sphere &sphere, const Vector3 &velocity, const float collisionTime, const Vector3 &collisionLocation, const Vector3 &collisionNormal)
Definition: CollisionDetection.cpp:1850
static bool movingSpherePassesThroughFixedBox(const Sphere &sphere, const Vector3 &velocity, const Box &box, double timeLimit=inf())
Definition: CollisionDetection.cpp:2207
static float collisionTimeForMovingPointFixedTriangle(const Vector3 &orig, const Vector3 &dir, const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, Vector3 &location)
Definition: CollisionDetection.h:515
static Vector3 separatingAxisForSolidBoxSolidBox(const int separatingAxisIndex, const Box &box1, const Box &box2)
Definition: CollisionDetection.cpp:45
static float collisionTimeForMovingPointFixedPlane(const Vector3 &point, const Vector3 &velocity, const class Plane &plane, Vector3 &outLocation, Vector3 &outNormal=ignore)
Definition: CollisionDetection.cpp:847
static bool isPointInsideTriangle(const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &normal, const Vector3 &point, Vector3::Axis primaryAxis=Vector3::DETECT_AXIS)
Definition: CollisionDetection.h:1050
static float collisionTimeForMovingPointFixedTriangle(const Vector3 &orig, const Vector3 &dir, const Triangle &tri, Vector3 &location=ignore, Vector3 &normal=ignore)
Definition: CollisionDetection.h:547
const Point3 & vertex(int n) const
Definition: Triangle.h:70
static Vector3 closestPointToRectangle(const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, const Vector3 &point)
Definition: CollisionDetection.cpp:2148
static float collisionTimeForMovingSphereFixedSphere(const Sphere &sphere, const Vector3 &velocity, const Sphere &fixedSphere, Vector3 &outLocation, Vector3 &outNormal=ignore)
Definition: CollisionDetection.cpp:1032
static float collisionTimeForMovingPointFixedBox(const Vector3 &point, const Vector3 &velocity, const class Box &box, Vector3 &outLocation, Vector3 &outNormal=ignore)
Definition: CollisionDetection.cpp:1176
Definition: Triangle.h:34
float intersectionTime(const class Sphere &sphere, bool solid=false) const
Definition: Ray.cpp:179
CollisionDetection()
Definition: CollisionDetection.h:116
static bool conservativeBoxBoxTest(const Vector3 &a, const Vector3 &b, const Vector3 &D)
Definition: CollisionDetection.cpp:239
static float projectedDistanceForSolidBoxSolidBox(const int separatingAxisIndex, const Vector3 &a, const Vector3 &b, const Vector3 &D, const double *c, const double *ca, const double *ad, const double *bd)
Definition: CollisionDetection.cpp:69
static bool fixedSolidSphereIntersectsFixedTriangle(const Sphere &sphere, const Triangle &triangle)
Definition: CollisionDetection.cpp:2245