OPC_VolumeCollider.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_VOLUMECOLLIDER_H__
00021 #define __OPC_VOLUMECOLLIDER_H__
00022 
00023         struct OPCODE_API VolumeCache
00024         {
00025                                                         VolumeCache() : Model(null)             {}
00026                                                         ~VolumeCache()                                  {}
00027 
00028                 Container                       TouchedPrimitives;      
00029                 const BaseModel*        Model;                          
00030         };
00031 
00032         class OPCODE_API VolumeCollider : public Collider
00033         {
00034                 public:
00035                 // Constructor / Destructor
00036                                                                                         VolumeCollider();
00037                 virtual                                                         ~VolumeCollider() = 0;
00038 
00039                 // Collision report
00040 
00042 
00048 
00049                 inline_                         udword                  GetNbTouchedPrimitives()        const   { return mTouchedPrimitives ? mTouchedPrimitives->GetNbEntries() : 0;   }
00050 
00052 
00058 
00059                 inline_         const   udword*                 GetTouchedPrimitives()          const   { return mTouchedPrimitives ? mTouchedPrimitives->GetEntries() : null;  }
00060 
00061                 // Stats
00062 
00064 
00069 
00070                 inline_                         udword                  GetNbVolumeBVTests()            const   { return mNbVolumeBVTests;                                                                                              }
00071 
00073 
00078 
00079                 inline_                         udword                  GetNbVolumePrimTests()          const   { return mNbVolumePrimTests;                                                                                    }
00080 
00081                 // Settings
00082 
00084 
00088 
00089                 override(Collider)      const char*             ValidateSettings();
00090 
00091                 protected:
00092                 // Touched primitives
00093                                                         Container*              mTouchedPrimitives;     
00094 
00095                 // Dequantization coeffs
00096                                                         Point                   mCenterCoeff;
00097                                                         Point                   mExtentsCoeff;
00098                 // Stats
00099                                                         udword                  mNbVolumeBVTests;       
00100                                                         udword                  mNbVolumePrimTests;     
00101                 // Internal methods
00102                                                         void                    _Dump(const AABBCollisionNode* node);
00103                                                         void                    _Dump(const AABBNoLeafNode* node);
00104                                                         void                    _Dump(const AABBQuantizedNode* node);
00105                                                         void                    _Dump(const AABBQuantizedNoLeafNode* node);
00106 
00108 
00111 
00112                 override(Collider) inline_      void    InitQuery()
00113                                                                                         {
00114                                                                                                 // Reset stats & contact status
00115                                                                                                 mNbVolumeBVTests        = 0;
00116                                                                                                 mNbVolumePrimTests      = 0;
00117                                                                                                 Collider::InitQuery();
00118                                                                                         }
00119 
00120                 inline_                         BOOL                    IsCacheValid(VolumeCache& cache)
00121                                                                                         {
00122                                                                                                 // We're going to do a volume-vs-model query.
00123                                                                                                 if(cache.Model!=mCurrentModel)
00124                                                                                                 {
00125                                                                                                         // Cached list was for another model so we can't keep it
00126                                                                                                         // Keep track of new owner and reset cache
00127                                                                                                         cache.Model = mCurrentModel;
00128                                                                                                         return FALSE;
00129                                                                                                 }
00130                                                                                                 else
00131                                                                                                 {
00132                                                                                                         // Same models, no problem
00133                                                                                                         return TRUE;
00134                                                                                                 }
00135                                                                                         }
00136         };
00137 
00138 #endif // __OPC_VOLUMECOLLIDER_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:56