Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OPC_PlanesCollider.h
Go to the documentation of this file.
1 /*
3  * OPCODE - Optimized Collision Detection
4  * Copyright (C) 2001 Pierre Terdiman
5  * Homepage: http://www.codercorner.com/Opcode.htm
6  */
8 
10 
16 
19 // Include Guard
20 #ifndef __OPC_PLANESCOLLIDER_H__
21 #define __OPC_PLANESCOLLIDER_H__
22 
24  {
26  {
27  }
28  };
29 
31  {
32  public:
33  // Constructor / Destructor
35  virtual ~PlanesCollider();
36 
38 
52  bool Collide(PlanesCache& cache, const Plane* planes, udword nb_planes, const Model& model, const Matrix4x4* worldm=null);
54 
55  // Mutant box-with-planes collision queries
56  inline_ bool Collide(PlanesCache& cache, const OBB& box, const Model& model, const Matrix4x4* worldb=null, const Matrix4x4* worldm=null)
57  {
58  Plane PL[6];
59 
60  if(worldb)
61  {
62  // Create a new OBB in world space
63  OBB WorldBox;
64  box.Rotate(*worldb, WorldBox);
65  // Compute planes from the sides of the box
66  WorldBox.ComputePlanes(PL);
67  }
68  else
69  {
70  // Compute planes from the sides of the box
71  box.ComputePlanes(PL);
72  }
73 
74  // Collide with box planes
75  return Collide(cache, PL, 6, model, worldm);
76  }
77  // Settings
78 
80 
84  override(Collider) const char* ValidateSettings();
86 
87  protected:
88  // Planes in model space
91  // Leaf description
93  // Internal methods
94  void _Collide(const AABBCollisionNode* node, udword clip_mask);
95  void _Collide(const AABBNoLeafNode* node, udword clip_mask);
96  void _Collide(const AABBQuantizedNode* node, udword clip_mask);
97  void _Collide(const AABBQuantizedNoLeafNode* node, udword clip_mask);
98  void _CollideNoPrimitiveTest(const AABBCollisionNode* node, udword clip_mask);
99  void _CollideNoPrimitiveTest(const AABBNoLeafNode* node, udword clip_mask);
100  void _CollideNoPrimitiveTest(const AABBQuantizedNode* node, udword clip_mask);
101  void _CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node, udword clip_mask);
102  // Overlap tests
103  inline_ bool PlanesAABBOverlap(const Point& center, const Point& extents, udword& out_clip_mask, udword in_clip_mask);
104  inline_ bool PlanesTriOverlap(udword in_clip_mask);
105  // Init methods
106  bool InitQuery(PlanesCache& cache, const Plane* planes, udword nb_planes, const Matrix4x4* worldm=null);
107  };
108 
110  {
111  public:
112  // Constructor / Destructor
114  virtual ~HybridPlanesCollider();
115 
116  bool Collide(PlanesCache& cache, const Plane* planes, udword nb_planes, const HybridModel& model, const Matrix4x4* worldm=null);
117  protected:
119  };
120 
121 #endif // __OPC_PLANESCOLLIDER_H__