| Linderdaum Engine: Collision.cpp File Reference | ![]() |
Basic collision detection. More...
#include "Math/Collision.h"#include "Math/LMath.h"#include "Math/LPoly.h"#include "Math/LHull.h"#include "Math/LGeomUtils.h"Defines | |
| #define | TEST_SEP_PLANE(PARAM_AxisName, PARAM_RelativeVal, PARAM_R0, PARAM_R1, PARAM_Normal) |
| #define | TEST_SEP_AXIS(PARAM_AxisName, PARAM_DirA, PARAM_DirB, PARAM_RelativeVal, PARAM_R0, PARAM_R1) |
| #define | BUILD_REFERENCE_POLY(PARAM_AxisName, PARAM_Height, PARAM_Extent0, PARAM_Extent1, PARAM_Axis0, PARAM_Axis1) |
| #define | CHECK_INCIDENT_AXIS(PARAM_ICenter, PARAM_Normal, PARAM_V1, PARAM_V2, PARAM_Size1, PARAM_Size2) |
Enumerations | |
| enum | eBoxSeparatingAxis { S_AXIS_NONE = -1, S_AXIS_A0 = 0, S_AXIS_A1 = 1, S_AXIS_A2 = 2, S_AXIS_B0 = 3, S_AXIS_B1 = 4, S_AXIS_B2 = 5, S_AXIS_A0B0 = 6, S_AXIS_A0B1 = 7, S_AXIS_A0B2 = 8, S_AXIS_A1B0 = 9, S_AXIS_A1B1 = 10, S_AXIS_A1B2 = 11, S_AXIS_A2B0 = 12, S_AXIS_A2B1 = 13, S_AXIS_A2B2 = 14 } |
| Possible axes for box-box separation. More... | |
Basic collision detection.
| #define BUILD_REFERENCE_POLY | ( | PARAM_AxisName, | |
| PARAM_Height, | |||
| PARAM_Extent0, | |||
| PARAM_Extent1, | |||
| PARAM_Axis0, | |||
| PARAM_Axis1 | |||
| ) |
case PARAM_AxisName : \ {\ ReferenceExtent0 = PARAM_Height; \ ReferencePoly.FVertices[0] = - PARAM_Extent0 * PARAM_Axis0 - PARAM_Extent1 * PARAM_Axis1; \ ReferencePoly.FVertices[1] = + PARAM_Extent0 * PARAM_Axis0 - PARAM_Extent1 * PARAM_Axis1; \ ReferencePoly.FVertices[2] = + PARAM_Extent0 * PARAM_Axis0 + PARAM_Extent1 * PARAM_Axis1; \ ReferencePoly.FVertices[3] = - PARAM_Extent0 * PARAM_Axis0 + PARAM_Extent1 * PARAM_Axis1; \ break; \ }
| #define CHECK_INCIDENT_AXIS | ( | PARAM_ICenter, | |
| PARAM_Normal, | |||
| PARAM_V1, | |||
| PARAM_V2, | |||
| PARAM_Size1, | |||
| PARAM_Size2 | |||
| ) |
TmpVec = PARAM_ICenter; \
Dist1 = DistanceToPlane( TmpVec, ReferenceCenter, ReferenceNormal); \
\
if ( Dist > Dist1 ) \
{ \
IncidentCenter = TmpVec; \
IncidentNormal = PARAM_Normal; \
IncidentAxis1 = PARAM_V1; \
IncidentAxis2 = PARAM_V2; \
IncidentSize1 = PARAM_Size1; \
IncidentSize2 = PARAM_Size2; \
Dist = Dist1; \
}
| #define TEST_SEP_AXIS | ( | PARAM_AxisName, | |
| PARAM_DirA, | |||
| PARAM_DirB, | |||
| PARAM_RelativeVal, | |||
| PARAM_R0, | |||
| PARAM_R1 | |||
| ) |
TempAxis = PARAM_DirA .Cross( PARAM_DirB ); \
AxisLen = TempAxis.SqrLength(); \
\
if ( AxisLen > Linderdaum::Math::EPSILON) \
{ \
R = PARAM_RelativeVal; \
R0 = PARAM_R0; \
R1 = PARAM_R1; \
\
TmpDepth = R0 + R1 - fabs(R); \
if (TmpDepth < 0) return false; \
\
if (MaxDepth * AxisLen > TmpDepth ) \
{ \
MaxDepth = TmpDepth / AxisLen; \
SeparatingAxis = PARAM_AxisName; \
\
DirA = PARAM_DirA; \
DirB = PARAM_DirB; \
\
RelNormal = TempAxis; \
InvertNormal = (PARAM_RelativeVal < 0); \
} \
}
| #define TEST_SEP_PLANE | ( | PARAM_AxisName, | |
| PARAM_RelativeVal, | |||
| PARAM_R0, | |||
| PARAM_R1, | |||
| PARAM_Normal | |||
| ) |
R = fabs(PARAM_RelativeVal); \ R0 = PARAM_R0; \ R1 = PARAM_R1; \ /* If (R>R0+R1) Then there is no intersection */\ TmpDepth = R0 + R1 - R; \ if (TmpDepth < 0) return false; \ \ if (MaxDepth > TmpDepth) { \ MaxDepth = TmpDepth; \ SeparatingAxis = PARAM_AxisName; \ Normal = PARAM_Normal; \ InvertNormal = (PARAM_RelativeVal < 0); \ }
| enum eBoxSeparatingAxis |