OPC_Collider.h
Go to the documentation of this file.
00001 
00002 /*
00003  *      OPCODE - Optimized Collision Detection
00004  *      Copyright (C) 2001 Pierre Terdiman
00005  *      Homepage: http://www.codercorner.com/Opcode.htm
00006  */
00008 
00010 
00016 
00017 
00019 // Include Guard
00020 #ifndef __OPC_COLLIDER_H__
00021 #define __OPC_COLLIDER_H__
00022 
00023         enum CollisionFlag
00024         {
00025                 OPC_FIRST_CONTACT               = (1<<0),               
00026                 OPC_TEMPORAL_COHERENCE  = (1<<1),               
00027                 OPC_CONTACT                             = (1<<2),               
00028                 OPC_TEMPORAL_HIT                = (1<<3),               
00029                 OPC_NO_PRIMITIVE_TESTS  = (1<<4),               
00030 
00031                 OPC_CONTACT_FOUND               = OPC_FIRST_CONTACT | OPC_CONTACT,
00032                 OPC_TEMPORAL_CONTACT    = OPC_TEMPORAL_HIT | OPC_CONTACT,
00033 
00034                 OPC_FORCE_DWORD                 = 0x7fffffff
00035         };
00036 
00037         class OPCODE_API Collider
00038         {
00039                 public:
00040                 // Constructor / Destructor
00041                                                                                         Collider();
00042                 virtual                                                         ~Collider();
00043 
00044                 // Collision report
00045 
00047 
00051 
00052                 inline_                         BOOL                    GetContactStatus()                      const   { return mFlags & OPC_CONTACT;                                                  }
00053 
00055 
00059 
00060                 inline_                         BOOL                    FirstContactEnabled()           const   { return mFlags & OPC_FIRST_CONTACT;                                    }
00061 
00063 
00067 
00068                 inline_                         BOOL                    TemporalCoherenceEnabled()      const   { return mFlags & OPC_TEMPORAL_COHERENCE;                               }
00069 
00071 
00075 
00076                 inline_                         BOOL                    ContactFound()                          const   { return (mFlags&OPC_CONTACT_FOUND)==OPC_CONTACT_FOUND; }
00077 
00079 
00083 
00084                 inline_                         BOOL                    TemporalHit()                           const   { return mFlags & OPC_TEMPORAL_HIT;                                             }
00085 
00087 
00091 
00092                 inline_                         BOOL                    SkipPrimitiveTests()            const   { return mFlags & OPC_NO_PRIMITIVE_TESTS;                               }
00093 
00094                 // Settings
00095 
00097 
00103 
00104                 inline_                         void                    SetFirstContact(bool flag)
00105                                                                                         {
00106                                                                                                 if(flag)        mFlags |= OPC_FIRST_CONTACT;
00107                                                                                                 else            mFlags &= ~OPC_FIRST_CONTACT;
00108                                                                                         }
00109 
00111 
00117 
00118                 inline_                         void                    SetTemporalCoherence(bool flag)
00119                                                                                         {
00120                                                                                                 if(flag)        mFlags |= OPC_TEMPORAL_COHERENCE;
00121                                                                                                 else            mFlags &= ~OPC_TEMPORAL_COHERENCE;
00122                                                                                         }
00123 
00125 
00129 
00130                 inline_                         void                    SetPrimitiveTests(bool flag)
00131                                                                                         {
00132                                                                                                 if(!flag)       mFlags |= OPC_NO_PRIMITIVE_TESTS;
00133                                                                                                 else            mFlags &= ~OPC_NO_PRIMITIVE_TESTS;
00134                                                                                         }
00135 
00137 
00141 
00142                 virtual                         const char*             ValidateSettings()      = 0;
00143 
00144                 protected:
00145                                                         udword                  mFlags;                 
00146                                         const   BaseModel*              mCurrentModel;  
00147                 // User mesh interface
00148                                         const   MeshInterface*  mIMesh;                 
00149 
00150                 // Internal methods
00152 
00157 
00158                 inline_                         BOOL                    Setup(const BaseModel* model)
00159                                                                                         {
00160                                                                                                 // Keep track of current model
00161                                                                                                 mCurrentModel = model;
00162                                                                                                 if(!mCurrentModel)      return FALSE;
00163 
00164                                                                                                 mIMesh = model->GetMeshInterface();
00165                                                                                                 return mIMesh!=null;
00166                                                                                         }
00167 
00169 
00172 
00173                 virtual inline_         void                    InitQuery()             { mFlags &= ~OPC_TEMPORAL_CONTACT;      }
00174         };
00175 
00176 #endif // __OPC_COLLIDER_H__


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:55