Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00037 #ifndef FCL_BROAD_PHASE_INTERVAL_TREE_H
00038 #define FCL_BROAD_PHASE_INTERVAL_TREE_H
00039
00040 #include "fcl/broadphase/broadphase.h"
00041 #include "fcl/broadphase/interval_tree.h"
00042 #include <deque>
00043 #include <map>
00044
00045 namespace fcl
00046 {
00047
00049 class IntervalTreeCollisionManager : public BroadPhaseCollisionManager
00050 {
00051 public:
00052 IntervalTreeCollisionManager() : setup_(false)
00053 {
00054 for(int i = 0; i < 3; ++i)
00055 interval_trees[i] = NULL;
00056 }
00057
00058 ~IntervalTreeCollisionManager()
00059 {
00060 clear();
00061 }
00062
00064 void registerObject(CollisionObject* obj);
00065
00067 void unregisterObject(CollisionObject* obj);
00068
00070 void setup();
00071
00073 void update();
00074
00076 void update(CollisionObject* updated_obj);
00077
00079 void update(const std::vector<CollisionObject*>& updated_objs);
00080
00082 void clear();
00083
00085 void getObjects(std::vector<CollisionObject*>& objs) const;
00086
00088 void collide(CollisionObject* obj, void* cdata, CollisionCallBack callback) const;
00089
00091 void distance(CollisionObject* obj, void* cdata, DistanceCallBack callback) const;
00092
00094 void collide(void* cdata, CollisionCallBack callback) const;
00095
00097 void distance(void* cdata, DistanceCallBack callback) const;
00098
00100 void collide(BroadPhaseCollisionManager* other_manager, void* cdata, CollisionCallBack callback) const;
00101
00103 void distance(BroadPhaseCollisionManager* other_manager, void* cdata, DistanceCallBack callback) const;
00104
00106 bool empty() const;
00107
00109 inline size_t size() const { return endpoints[0].size() / 2; }
00110
00111 protected:
00112
00113
00115 struct EndPoint
00116 {
00118 CollisionObject* obj;
00119
00121 FCL_REAL value;
00122
00124 char minmax;
00125 };
00126
00128 struct SAPInterval : public SimpleInterval
00129 {
00130 CollisionObject* obj;
00131 SAPInterval(double low_, double high_, CollisionObject* obj_) : SimpleInterval()
00132 {
00133 low = low_;
00134 high = high_;
00135 obj = obj_;
00136 }
00137 };
00138
00139
00140 bool checkColl(std::deque<SimpleInterval*>::const_iterator pos_start, std::deque<SimpleInterval*>::const_iterator pos_end, CollisionObject* obj, void* cdata, CollisionCallBack callback) const;
00141
00142 bool checkDist(std::deque<SimpleInterval*>::const_iterator pos_start, std::deque<SimpleInterval*>::const_iterator pos_end, CollisionObject* obj, void* cdata, DistanceCallBack callback, FCL_REAL& min_dist) const;
00143
00144 bool collide_(CollisionObject* obj, void* cdata, CollisionCallBack callback) const;
00145
00146 bool distance_(CollisionObject* obj, void* cdata, DistanceCallBack callback, FCL_REAL& min_dist) const;
00147
00149 std::vector<EndPoint> endpoints[3];
00150
00152 IntervalTree* interval_trees[3];
00153
00154 std::map<CollisionObject*, SAPInterval*> obj_interval_maps[3];
00155
00157 bool setup_;
00158 };
00159
00160
00161 }
00162
00163 #endif