OPC_SweepAndPrune.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_SWEEPANDPRUNE_H__
00021 #define __OPC_SWEEPANDPRUNE_H__
00022 
00024 
00031 
00032         typedef BOOL    (*PairCallback) (udword id0, udword id1, void* user_data);
00033 
00034         class SAP_Element;
00035         class SAP_EndPoint;
00036         class SAP_Box;
00037 
00038         class OPCODE_API SAP_PairData
00039         {
00040                 public:
00041                                                                 SAP_PairData();
00042                                                                 ~SAP_PairData();
00043 
00044                                 bool                    Init(udword nb_objects);
00045 
00046                                 void                    AddPair(udword id1, udword id2);
00047                                 void                    RemovePair(udword id1, udword id2);
00048 
00049                                 void                    DumpPairs(Pairs& pairs)                                                         const;
00050                                 void                    DumpPairs(PairCallback callback, void* user_data)       const;
00051                 private:
00052                                 udword                  mNbElements;            
00053                                 udword                  mNbUsedElements;        
00054                                 SAP_Element*    mElementPool;           
00055                                 SAP_Element*    mFirstFree;                     
00056 
00057                                 udword                  mNbObjects;                     
00058                                 SAP_Element**   mArray;                         
00059                 // Internal methods
00060                                 SAP_Element*    GetFreeElem(udword id, SAP_Element* next, udword* remap=null);
00061                 inline_ void                    FreeElem(SAP_Element* elem);
00062                                 void                    Release();
00063         };
00064 
00065         class OPCODE_API SweepAndPrune
00066         {
00067                 public:
00068                                                                 SweepAndPrune();
00069                                                                 ~SweepAndPrune();
00070 
00071                                 bool                    Init(udword nb_objects, const AABB** boxes);
00072                                 bool                    UpdateObject(udword i, const AABB& box);
00073 
00074                                 void                    GetPairs(Pairs& pairs)                                                          const;
00075                                 void                    GetPairs(PairCallback callback, void* user_data)        const;
00076                 private:
00077                                 SAP_PairData    mPairs;
00078 
00079                                 udword                  mNbObjects;
00080                                 SAP_Box*                mBoxes;
00081                                 SAP_EndPoint*   mList[3];
00082                 // Internal methods
00083                                 bool                    CheckListsIntegrity();
00084         };
00085 
00086 #endif //__OPC_SWEEPANDPRUNE_H__


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:18