Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_COLLISION_CONFIG_TYPES_H__
00009 #define __SP_COLLISION_CONFIG_TYPES_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013 #include "Base/spMeshBuffer.hpp"
00014 #include "SceneGraph/spSceneMesh.hpp"
00015
00016
00017 namespace sp
00018 {
00019 namespace scene
00020 {
00021
00022
00023
00024
00025
00026
00027 class CollisionMaterial;
00028 class CollisionNode;
00029 class CollisionSphere;
00030 class CollisionCapsule;
00031 class CollisionCylinder;
00032 class CollisionCone;
00033 class CollisionBox;
00034 class CollisionPlane;
00035 class CollisionMesh;
00036
00037
00038
00039
00040
00041
00043 enum ECollisionModels
00044 {
00045 COLLISION_NONE = 0,
00046 COLLISION_SPHERE,
00047 COLLISION_CAPSULE,
00048 COLLISION_CYLINDER,
00049 COLLISION_CONE,
00050 COLLISION_BOX,
00051 COLLISION_PLANE,
00052 COLLISION_MESH,
00053 };
00054
00056 enum ECollisionFlags
00057 {
00058 COLLISIONFLAG_NONE = 0x00,
00059
00060 COLLISIONFLAG_DETECTION = 0x01,
00061 COLLISIONFLAG_RESOLVE = 0x02 | COLLISIONFLAG_DETECTION,
00062 COLLISIONFLAG_INTERSECTION = 0x04,
00063 COLLISIONFLAG_PERMANENT_UPDATE = 0x08,
00064
00066 COLLISIONFLAG_FULL =
00067 COLLISIONFLAG_RESOLVE |
00068 COLLISIONFLAG_INTERSECTION |
00069 COLLISIONFLAG_PERMANENT_UPDATE,
00070 };
00071
00073 enum ECollisionSupportFlags
00074 {
00075 COLLISIONSUPPORT_NONE = 0x00,
00076
00077 COLLISIONSUPPORT_SPHERE = 0x01,
00078 COLLISIONSUPPORT_CAPSULE = 0x02,
00079 COLLISIONSUPPORT_CYLINDER = 0x04,
00080 COLLISIONSUPPORT_CONE = 0x08,
00081 COLLISIONSUPPORT_BOX = 0x10,
00082 COLLISIONSUPPORT_PLANE = 0x20,
00083 COLLISIONSUPPORT_MESH = 0x40,
00084
00085 COLLISIONSUPPORT_ALL = ~0,
00086 };
00087
00088
00089
00090
00091
00092
00093 struct SCollisionFace
00094 {
00095 SCollisionFace() :
00096 Mesh (0),
00097 Surface (0),
00098 Index (0)
00099 {
00100 }
00101 SCollisionFace(
00102 scene::Mesh* InitMesh, u32 InitSurface, u32 InitIndex, const dim::triangle3df &InitTriangle) :
00103 Mesh (InitMesh ),
00104 Surface (InitSurface ),
00105 Index (InitIndex ),
00106 Triangle(InitTriangle )
00107 {
00108 }
00109 ~SCollisionFace()
00110 {
00111 }
00112
00113
00114
00116 inline bool isBackFaceCulling(const video::EFaceTypes CollFace, const dim::vector3df &InversePoint) const
00117 {
00118 if (CollFace != video::FACE_BOTH)
00119 {
00120 bool isPointFront = dim::plane3df(Triangle).isPointFrontSide(InversePoint);
00121
00122 if ( ( CollFace == video::FACE_FRONT && !isPointFront ) ||
00123 ( CollFace == video::FACE_BACK && isPointFront ) )
00124 {
00125 return true;
00126 }
00127 }
00128 return false;
00129 }
00130
00132 inline bool isBackFaceCulling(const video::EFaceTypes CollFace, const dim::line3df &InverseLine) const
00133 {
00134 if (CollFace != video::FACE_BOTH)
00135 {
00136 bool isPointFrontA = dim::plane3df(Triangle).isPointFrontSide(InverseLine.Start);
00137 bool isPointFrontB = dim::plane3df(Triangle).isPointFrontSide(InverseLine.End);
00138
00139 if ( ( CollFace == video::FACE_FRONT && !isPointFrontA && !isPointFrontB ) ||
00140 ( CollFace == video::FACE_BACK && isPointFrontA && isPointFrontB ) )
00141 {
00142 return true;
00143 }
00144 }
00145 return false;
00146 }
00147
00148
00149 scene::Mesh* Mesh;
00150 u32 Surface;
00151 u32 Index;
00152 dim::triangle3df Triangle;
00153 };
00154
00155 struct SContactBase
00156 {
00157 SContactBase() :
00158 Impact (0.0f ),
00159 Face (0 )
00160 {
00161 }
00162 virtual ~SContactBase()
00163 {
00164 }
00165
00166
00167 dim::vector3df Point;
00168 dim::vector3df Normal;
00169 f32 Impact;
00170
00171 dim::triangle3df Triangle;
00172 SCollisionFace* Face;
00173 };
00174
00175 struct SIntersectionContact : public SContactBase
00176 {
00177 SIntersectionContact() :
00178 SContactBase( ),
00179 Object (0 ),
00180 DistanceSq (0.0f )
00181 {
00182 }
00183 ~SIntersectionContact()
00184 {
00185 }
00186
00187
00188 inline bool operator == (const SIntersectionContact &Other) const
00189 {
00190 return Object == Other.Object && Face == Other.Face;
00191 }
00192
00193
00194 const CollisionNode* Object;
00195 f32 DistanceSq;
00196 };
00197
00198 struct SCollisionContact : public SContactBase
00199 {
00200 SCollisionContact() :
00201 SContactBase()
00202 {
00203 }
00204 ~SCollisionContact()
00205 {
00206 }
00207
00208
00209 inline bool operator == (const SCollisionContact &Other) const
00210 {
00211 return Face == Other.Face;
00212 }
00213 };
00214
00215
00216 }
00217
00218 }
00219
00220
00221 #endif
00222
00223
00224
00225