My Project
Collider.h
1 #pragma once
2 
3 namespace ParaEngine
4 {
6 {
7  OPC_FIRST_CONTACT = (1<<0),
9  OPC_CONTACT = (1<<2),
10  OPC_TEMPORAL_HIT = (1<<3),
12 
13  OPC_CONTACT_FOUND = OPC_FIRST_CONTACT | OPC_CONTACT,
14  OPC_TEMPORAL_CONTACT = OPC_TEMPORAL_HIT | OPC_CONTACT,
15 
16  OPC_FORCE_DWORD = 0x7fffffff
17 };
18 
20 class Collider
21 {
22 public:
23  // Constructor / Destructor
24  Collider();
25  virtual ~Collider();
26 
27  // Collision report
28 
33  BOOL GetContactStatus() const { return mFlags & OPC_CONTACT; }
34 
39  BOOL FirstContactEnabled() const { return mFlags & OPC_FIRST_CONTACT; }
40 
46 
51  BOOL ContactFound() const { return (mFlags&OPC_CONTACT_FOUND)==OPC_CONTACT_FOUND; }
52 
57  BOOL TemporalHit() const { return mFlags & OPC_TEMPORAL_HIT; }
58 
64 
65  // Settings
66 
73  void SetFirstContact(bool flag)
74  {
75  if(flag) mFlags |= OPC_FIRST_CONTACT;
76  else mFlags &= ~OPC_FIRST_CONTACT;
77  }
78 
85  void SetTemporalCoherence(bool flag)
86  {
87  if(flag) mFlags |= OPC_TEMPORAL_COHERENCE;
89  }
90 
95  void SetPrimitiveTests(bool flag)
96  {
97  if(!flag) mFlags |= OPC_NO_PRIMITIVE_TESTS;
99  }
100 
101 protected:
102  DWORD mFlags;
103 
107  virtual void InitQuery() { mFlags &= ~OPC_TEMPORAL_CONTACT; }
108 };
109 
110 
111 } // namespace ParaEngine
base class for all colliders.
Definition: Collider.h:20
virtual void InitQuery()
Initializes a query.
Definition: Collider.h:107
different physics engine has different winding order.
Definition: EventBinding.h:32
CollisionFlag
Definition: Collider.h:5
Report all contacts (false) or only first one (true)
Definition: Collider.h:7
void SetPrimitiveTests(bool flag)
Enable/disable primitive tests.
Definition: Collider.h:95
BOOL TemporalCoherenceEnabled() const
Gets the temporal coherence mode.
Definition: Collider.h:45
void SetFirstContact(bool flag)
Reports all contacts (false) or first contact only (true)
Definition: Collider.h:73
void SetTemporalCoherence(bool flag)
Enable/disable temporal coherence.
Definition: Collider.h:85
Keep or discard primitive-bv tests in leaf nodes (volume-mesh queries)
Definition: Collider.h:11
DWORD mFlags
Bit flags.
Definition: Collider.h:102
BOOL SkipPrimitiveTests() const
Checks primitive tests are enabled;.
Definition: Collider.h:63
BOOL FirstContactEnabled() const
Gets the "first contact" mode.
Definition: Collider.h:39
BOOL ContactFound() const
Checks a first contact has already been found.
Definition: Collider.h:51
Use temporal coherence or not.
Definition: Collider.h:8
Final contact status after a collision query.
Definition: Collider.h:9
There has been an early exit due to temporal coherence.
Definition: Collider.h:10
BOOL GetContactStatus() const
Gets the last collision status after a collision query.
Definition: Collider.h:33
BOOL TemporalHit() const
Checks there&#39;s been an early exit due to temporal coherence;.
Definition: Collider.h:57