TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CollisionDetection.cpp File Reference
#include "G3D/CoordinateFrame.h"
#include "G3D/platform.h"
#include "G3D/CollisionDetection.h"
#include "G3D/debugAssert.h"
#include "G3D/vectorMath.h"
#include "G3D/Capsule.h"
#include "G3D/Plane.h"
#include "G3D/Line.h"
#include "G3D/LineSegment.h"
#include "G3D/Sphere.h"
#include "G3D/Box.h"
#include "G3D/Triangle.h"
#include "G3D/Vector3.h"
#include "G3D/AABox.h"
+ Include dependency graph for CollisionDetection.cpp:

Namespaces

 G3D
 

Macros

#define IR(x)   ((uint32&)x)
 
#define AREA2(d, e, f)   (((e)[i] - (d)[i]) * ((f)[j] - (d)[j]) - ((f)[i] - (d)[i]) * ((e)[j] - (d)[j]))
 
#define X   0
 
#define Y   1
 
#define Z   2
 
#define FINDMINMAX(x0, x1, x2, min, max)
 
#define AXISTEST_X01(a, b, fa, fb)
 
#define AXISTEST_X2(a, b, fa, fb)
 
#define AXISTEST_Y02(a, b, fa, fb)
 
#define AXISTEST_Y1(a, b, fa, fb)
 
#define AXISTEST_Z12(a, b, fa, fb)
 
#define AXISTEST_Z0(a, b, fa, fb)
 

Functions

static int G3D::findRayCapsuleIntersectionAux (const Vector3 &rkOrigin, const Vector3 &rkDirection, const Capsule &rkCapsule, double afT[2])
 
static bool G3D::findRayCapsuleIntersection (const Ray &rkRay, const Capsule &rkCapsule, int &riQuantity, Vector3 akPoint[2])
 
static bool G3D::planeBoxOverlap (const Vector3 &normal, const Vector3 &vert, const Vector3 &maxbox)
 

Detailed Description

Morgan McGuire, http://graphics.cs.williams.edu

[Bounce] direction based on Paul Nettle's ftp://ftp.3dmaileffects.com/pub/FluidStudios/CollisionDetection/Fluid_Studios_Generic_Collision_Detection_for_Games_Using_Ellipsoids.pdf and comments by Max McGuire. Ray-sphere code by Eric Haines.

2001-11-24 2008-12-29

Macro Definition Documentation

#define AREA2 (   d,
  e,
 
)    (((e)[i] - (d)[i]) * ((f)[j] - (d)[j]) - ((f)[i] - (d)[i]) * ((e)[j] - (d)[j]))
#define AXISTEST_X01 (   a,
  b,
  fa,
  fb 
)
Value:
p0 = a*v0[Y] - b*v0[Z]; \
p2 = a*v2[Y] - b*v2[Z]; \
if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} \
rad = fa * boxhalfsize[Y] + fb * boxhalfsize[Z]; \
if(min>rad || max<-rad) return false;
#define Z
Definition: CollisionDetection.cpp:2283
#define false
Definition: CascPort.h:18
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
#define Y
Definition: CollisionDetection.cpp:2282
#define AXISTEST_X2 (   a,
  b,
  fa,
  fb 
)
Value:
p0 = a*v0[Y] - b*v0[Z]; \
p1 = a*v1[Y] - b*v1[Z]; \
if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} \
rad = fa * boxhalfsize[Y] + fb * boxhalfsize[Z]; \
if(min>rad || max<-rad) return false;
#define Z
Definition: CollisionDetection.cpp:2283
#define false
Definition: CascPort.h:18
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
#define Y
Definition: CollisionDetection.cpp:2282
#define AXISTEST_Y02 (   a,
  b,
  fa,
  fb 
)
Value:
p0 = -a*v0[X] + b*v0[Z]; \
p2 = -a*v2[X] + b*v2[Z]; \
if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} \
rad = fa * boxhalfsize[X] + fb * boxhalfsize[Z]; \
if(min>rad || max<-rad) return false;
#define Z
Definition: CollisionDetection.cpp:2283
#define X
Definition: CollisionDetection.cpp:2281
#define false
Definition: CascPort.h:18
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
#define AXISTEST_Y1 (   a,
  b,
  fa,
  fb 
)
Value:
p0 = -a*v0[X] + b*v0[Z]; \
p1 = -a*v1[X] + b*v1[Z]; \
if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} \
rad = fa * boxhalfsize[X] + fb * boxhalfsize[Z]; \
if(min>rad || max<-rad) return false;
#define Z
Definition: CollisionDetection.cpp:2283
#define X
Definition: CollisionDetection.cpp:2281
#define false
Definition: CascPort.h:18
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
#define AXISTEST_Z0 (   a,
  b,
  fa,
  fb 
)
Value:
p0 = a*v0[X] - b*v0[Y]; \
p1 = a*v1[X] - b*v1[Y]; \
if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} \
rad = fa * boxhalfsize[X] + fb * boxhalfsize[Y]; \
if(min>rad || max<-rad) return false;
#define X
Definition: CollisionDetection.cpp:2281
#define false
Definition: CascPort.h:18
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
#define Y
Definition: CollisionDetection.cpp:2282
#define AXISTEST_Z12 (   a,
  b,
  fa,
  fb 
)
Value:
p1 = a*v1[X] - b*v1[Y]; \
p2 = a*v2[X] - b*v2[Y]; \
if(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;} \
rad = fa * boxhalfsize[X] + fb * boxhalfsize[Y]; \
if(min>rad || max<-rad) return false;
#define X
Definition: CollisionDetection.cpp:2281
#define false
Definition: CascPort.h:18
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
#define Y
Definition: CollisionDetection.cpp:2282
#define FINDMINMAX (   x0,
  x1,
  x2,
  min,
  max 
)
Value:
min = max = x0; \
if(x1<min) min=x1;\
if(x1>max) max=x1;\
if(x2<min) min=x2;\
if(x2>max) max=x2;
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
#define IR (   x)    ((uint32&)x)
#define X   0
#define Y   1
#define Z   2