OPC_SweepAndPrune.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_SWEEPANDPRUNE_H__
21 #define __OPC_SWEEPANDPRUNE_H__
22 
24 
31  typedef BOOL (*PairCallback) (udword id0, udword id1, void* user_data);
33 
34  class SAP_Element;
35  class SAP_EndPoint;
36  class SAP_Box;
37 
39  {
40  public:
41  SAP_PairData();
42  ~SAP_PairData();
43 
44  bool Init(udword nb_objects);
45 
46  void AddPair(udword id1, udword id2);
47  void RemovePair(udword id1, udword id2);
48 
49  void DumpPairs(Pairs& pairs) const;
50  void DumpPairs(PairCallback callback, void* user_data) const;
51  private:
54  SAP_Element* mElementPool;
55  SAP_Element* mFirstFree;
56 
58  SAP_Element** mArray;
59  // Internal methods
60  SAP_Element* GetFreeElem(udword id, SAP_Element* next, udword* remap=null);
61  inline_ void FreeElem(SAP_Element* elem);
62  void Release();
63  };
64 
66  {
67  public:
68  SweepAndPrune();
69  ~SweepAndPrune();
70 
71  bool Init(udword nb_objects, const AABB** boxes);
72  bool UpdateObject(udword i, const AABB& box);
73 
74  void GetPairs(Pairs& pairs) const;
75  void GetPairs(PairCallback callback, void* user_data) const;
76  private:
78 
80  SAP_Box* mBoxes;
81  SAP_EndPoint* mList[3];
82  // Internal methods
83  bool CheckListsIntegrity();
84  };
85 
86 #endif //__OPC_SWEEPANDPRUNE_H__
udword mNbUsedElements
Number of used elements.
#define null
our own NULL pointer
Definition: IceTypes.h:57
SAP_PairData mPairs
#define inline_
BOOL(* PairCallback)(udword id0, udword id1, void *user_data)
png_uint_32 i
Definition: png.h:2735
Definition: IcePairs.h:25
#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
Definition: IceAABB.h:267
SAP_Element * mElementPool
Array of mNbElements elements.
udword mNbObjects
Max number of objects we can handle.
SAP_Element ** mArray
Pointers to pool.
SAP_Element * mFirstFree
First free element in the pool.
udword mNbElements
Total number of elements in the pool.
Definition: jquant2.c:258


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat May 8 2021 02:42:40