1
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3
* OPCODE - Optimized Collision Detection
4
* Copyright (C) 2001 Pierre Terdiman
5
* Homepage: http://www.codercorner.com/Opcode.htm
7
* OPCODE modifications for scaled model support (and other things)
8
* Copyright (C) 2004 Gilvan Maia (gilvan 'at' vdl.ufc.br)
9
* Check http://www.vdl.ufc.br/gilvan/coll/opcode/index.htm for updates.
12
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
14
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16
* Contains code for a planes collider.
17
* \file OPC_PlanesCollider.h
18
* \author Pierre Terdiman
19
* \date January, 1st, 2002
21
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
25
#ifndef __OPC_PLANESCOLLIDER_H__
26
#define __OPC_PLANESCOLLIDER_H__
28
struct PlanesCache : VolumeCache
35
class PlanesCollider : public VolumeCollider
38
// Constructor / Destructor
40
virtual ~PlanesCollider();
42
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
44
* Generic collision query for generic OPCODE models. After the call, access the results:
45
* - with GetContactStatus()
46
* - with GetNbTouchedPrimitives()
47
* - with GetTouchedPrimitives()
49
* \param cache [in/out] a planes cache
50
* \param planes [in] list of planes in world space
51
* \param nb_planes [in] number of planes
52
* \param model [in] Opcode model to collide with
53
* \param worldm [in] model's world matrix, or null
54
* \return true if success
56
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
57
bool Collide(PlanesCache& cache, const IceMaths::Plane* planes, udword nb_planes, const Model& model, const IceMaths::Matrix4x4* worldm=null);
59
// Mutant box-with-planes collision queries
60
inline_ bool Collide(PlanesCache& cache, const IceMaths::OBB& box, const Model& model, const IceMaths::Matrix4x4* worldb=null, const IceMaths::Matrix4x4* worldm=null)
62
IceMaths::Plane PL[6];
66
// Create a new OBB in world space
67
IceMaths::OBB WorldBox;
68
box.Rotate(*worldb, WorldBox);
69
// Compute planes from the sides of the box
70
WorldBox.ComputePlanes(PL);
74
// Compute planes from the sides of the box
75
box.ComputePlanes(PL);
78
// Collide with box planes
79
return Collide(cache, PL, 6, model, worldm);
83
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
85
* Validates current settings. You should call this method after all the settings and callbacks have been defined for a collider.
86
* \return null if everything is ok, else a string describing the problem
88
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
89
override(Collider) const char* ValidateSettings();
92
// Planes in model space
94
IceMaths::Plane* mPlanes;
98
void _Collide(const AABBCollisionNode* node, udword clip_mask);
99
void _Collide(const AABBNoLeafNode* node, udword clip_mask);
100
void _Collide(const AABBQuantizedNode* node, udword clip_mask);
101
void _Collide(const AABBQuantizedNoLeafNode* node, udword clip_mask);
102
void _CollideNoPrimitiveTest(const AABBCollisionNode* node, udword clip_mask);
103
void _CollideNoPrimitiveTest(const AABBNoLeafNode* node, udword clip_mask);
104
void _CollideNoPrimitiveTest(const AABBQuantizedNode* node, udword clip_mask);
105
void _CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node, udword clip_mask);
107
inline_ BOOL PlanesAABBOverlap(const IceMaths::Point& center, const IceMaths::Point& extents, udword& out_clip_mask, udword in_clip_mask);
108
inline_ BOOL PlanesTriOverlap(udword in_clip_mask);
110
BOOL InitQuery(PlanesCache& cache, const IceMaths::Plane* planes, udword nb_planes, const IceMaths::Matrix4x4* worldm=null);
113
class HybridPlanesCollider : public PlanesCollider
116
// Constructor / Destructor
117
HybridPlanesCollider();
118
virtual ~HybridPlanesCollider();
120
bool Collide(PlanesCache& cache, const IceMaths::Plane* planes, udword nb_planes, const HybridModel& model, const IceMaths::Matrix4x4* worldm=null);
122
IceCore::Container mTouchedBoxes;
125
#endif // __OPC_PLANESCOLLIDER_H__