OPC_Collider.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_COLLIDER_H__
21 #define __OPC_COLLIDER_H__
22 
24  {
25  OPC_FIRST_CONTACT = (1<<0),
27  OPC_CONTACT = (1<<2),
28  OPC_TEMPORAL_HIT = (1<<3),
30 
33 
34  OPC_FORCE_DWORD = 0x7fffffff
35  };
36 
38  {
39  public:
40  // Constructor / Destructor
41  Collider();
42  virtual ~Collider();
43 
44  // Collision report
45 
47 
51  inline_ BOOL GetContactStatus() const { return mFlags & OPC_CONTACT; }
53 
55 
59  inline_ BOOL FirstContactEnabled() const { return mFlags & OPC_FIRST_CONTACT; }
61 
63 
67  inline_ BOOL TemporalCoherenceEnabled() const { return mFlags & OPC_TEMPORAL_COHERENCE; }
69 
71 
75  inline_ BOOL ContactFound() const { return (mFlags&OPC_CONTACT_FOUND)==OPC_CONTACT_FOUND; }
77 
79 
83  inline_ BOOL TemporalHit() const { return mFlags & OPC_TEMPORAL_HIT; }
85 
87 
91  inline_ BOOL SkipPrimitiveTests() const { return mFlags & OPC_NO_PRIMITIVE_TESTS; }
93 
94  // Settings
95 
97 
103  inline_ void SetFirstContact(bool flag)
105  {
106  if(flag) mFlags |= OPC_FIRST_CONTACT;
107  else mFlags &= ~OPC_FIRST_CONTACT;
108  }
109 
111 
117  inline_ void SetTemporalCoherence(bool flag)
119  {
120  if(flag) mFlags |= OPC_TEMPORAL_COHERENCE;
121  else mFlags &= ~OPC_TEMPORAL_COHERENCE;
122  }
123 
125 
129  inline_ void SetPrimitiveTests(bool flag)
131  {
132  if(!flag) mFlags |= OPC_NO_PRIMITIVE_TESTS;
133  else mFlags &= ~OPC_NO_PRIMITIVE_TESTS;
134  }
135 
137 
141  virtual const char* ValidateSettings() = 0;
143 
144  protected:
147  // User mesh interface
149 
150  // Internal methods
152 
157  inline_ BOOL Setup(const BaseModel* model)
159  {
160  // Keep track of current model
161  mCurrentModel = model;
162  if(!mCurrentModel) return FALSE;
163 
164  mIMesh = model->GetMeshInterface();
165  return mIMesh!=null;
166  }
167 
169 
172  virtual inline_ void InitQuery() { mFlags &= ~OPC_TEMPORAL_CONTACT; }
174  };
175 
176 #endif // __OPC_COLLIDER_H__
#define FALSE
Definition: OPC_IceHook.h:9
#define null
our own NULL pointer
Definition: IceTypes.h:57
Final contact status after a collision query.
Definition: OPC_Collider.h:27
CollisionFlag
Definition: OPC_Collider.h:23
inline_ const MeshInterface * GetMeshInterface() const
#define inline_
Use temporal coherence or not.
Definition: OPC_Collider.h:26
#define OPCODE_API
Definition: Opcode.h:68
int BOOL
Another boolean type.
Definition: IceTypes.h:102
unsigned int udword
sizeof(udword) must be 4
Definition: IceTypes.h:65
udword mFlags
Bit flags.
Definition: OPC_Collider.h:145
const BaseModel * mCurrentModel
Current model for collision query (owner of touched faces)
Definition: OPC_Collider.h:146
const MeshInterface * mIMesh
User-defined mesh interface.
Definition: OPC_Collider.h:148
There has been an early exit due to temporal coherence.
Definition: OPC_Collider.h:28
Report all contacts (false) or only first one (true)
Definition: OPC_Collider.h:25
png_infop png_uint_32 flag
Definition: png.h:2159
Keep or discard primitive-bv tests in leaf nodes (volume-mesh queries)
Definition: OPC_Collider.h:29


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat Apr 13 2019 02:14:24