38 #ifndef FCL_BROAD_PHASE_BRUTE_FORCE_INL_H 39 #define FCL_BROAD_PHASE_BRUTE_FORCE_INL_H 41 #include "fcl/broadphase/broadphase_bruteforce.h" 62 std::copy(other_objs.begin(), other_objs.end(), std::back_inserter(objs));
101 template <
typename S>
104 objs_.resize(objs.size());
105 std::copy(objs.begin(), objs.end(), objs_.begin());
109 template <
typename S>
112 if(size() == 0)
return;
114 for(
auto* obj2 : objs)
116 if(callback(obj, obj2, cdata))
122 template <
typename S>
125 if(size() == 0)
return;
127 S min_dist = std::numeric_limits<S>::max();
128 for(
auto* obj2 : objs)
132 if(callback(obj, obj2, cdata, min_dist))
139 template <
typename S>
142 if(size() == 0)
return;
144 for(
typename std::list<
CollisionObject<S>*>::const_iterator it1 = objs.begin(), end = objs.end();
147 typename std::list<CollisionObject<S>*>::const_iterator it2 = it1; it2++;
148 for(; it2 != end; ++it2)
150 if((*it1)->getAABB().overlap((*it2)->getAABB()))
152 if(callback(*it1, *it2, cdata))
160 template <
typename S>
163 if(size() == 0)
return;
165 S min_dist = std::numeric_limits<S>::max();
166 for(
typename std::list<
CollisionObject<S>*>::const_iterator it1 = objs.begin(), end = objs.end(); it1 != end; ++it1)
168 typename std::list<CollisionObject<S>*>::const_iterator it2 = it1; it2++;
169 for(; it2 != end; ++it2)
171 if((*it1)->getAABB().distance((*it2)->getAABB()) < min_dist)
173 if(callback(*it1, *it2, cdata, min_dist))
181 template <
typename S>
186 if((size() == 0) || (other_manager->
size() == 0))
return;
188 if(
this == other_manager)
190 collide(cdata, callback);
194 for(
auto* obj1 : objs)
196 for(
auto* obj2 : other_manager->
objs)
198 if(obj1->getAABB().overlap(obj2->getAABB()))
200 if(callback(obj1, obj2, cdata))
208 template <
typename S>
213 if((size() == 0) || (other_manager->
size() == 0))
return;
215 if(
this == other_manager)
221 S min_dist = std::numeric_limits<S>::max();
222 for(
auto* obj1 : objs)
224 for(
auto* obj2 : other_manager->
objs)
226 if(obj1->getAABB().distance(obj2->getAABB()) < min_dist)
228 if(callback(obj1, obj2, cdata, min_dist))
236 template <
typename S>
243 template <
typename S>
void registerObject(CollisionObject< S > *obj)
add one object to the manager
Definition: broadphase_bruteforce-inl.h:74
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
void getObjects(std::vector< CollisionObject< S > * > &objs) const
return the objects managed by the manager
Definition: broadphase_bruteforce-inl.h:102
void distance(CollisionObject< S > *obj, void *cdata, DistanceCallBack< S > callback) const
perform distance computation between one object and all the objects belonging to the manager ...
Definition: broadphase_bruteforce-inl.h:123
size_t size() const
the number of objects managed by the manager
Definition: broadphase_bruteforce-inl.h:244
void clear()
clear the manager
Definition: broadphase_bruteforce-inl.h:95
bool(*)(CollisionObject< S > *o1, CollisionObject< S > *o2, void *cdata) CollisionCallBack
Callback for collision between two objects. Return value is whether can stop now. ...
Definition: broadphase_collision_manager.h:53
bool(*)(CollisionObject< S > *o1, CollisionObject< S > *o2, void *cdata, S &dist) DistanceCallBack
Callback for distance between two objects, Return value is whether can stop now, also return the mini...
Definition: broadphase_collision_manager.h:60
void update()
update the condition of manager
Definition: broadphase_bruteforce-inl.h:88
void collide(CollisionObject< S > *obj, void *cdata, CollisionCallBack< S > callback) const
perform collision test between one object and all the objects belonging to the manager ...
Definition: broadphase_bruteforce-inl.h:110
std::list< CollisionObject< S > * > objs
objects belonging to the manager are stored in a list structure
Definition: broadphase_bruteforce.h:102
void registerObjects(const std::vector< CollisionObject< S > * > &other_objs)
add objects to the manager
Definition: broadphase_bruteforce-inl.h:60
bool empty() const
whether the manager is empty
Definition: broadphase_bruteforce-inl.h:237
const AABB< S > & getAABB() const
get the AABB in world space
Definition: collision_object-inl.h:111
the object for collision or distance computation, contains the geometry and the transform information...
Definition: collision_object.h:51
Brute force N-body collision manager.
Definition: broadphase_bruteforce.h:49
void unregisterObject(CollisionObject< S > *obj)
remove one object from the manager
Definition: broadphase_bruteforce-inl.h:67
S distance(const Eigen::MatrixBase< DerivedA > &R0, const Eigen::MatrixBase< DerivedB > &T0, const kIOS< S > &b1, const kIOS< S > &b2, Vector3< S > *P, Vector3< S > *Q)
Approximate distance between two kIOS bounding volumes.
Definition: kIOS-inl.h:266
Base class for broad phase collision. It helps to accelerate the collision/distance between N objects...
Definition: broadphase_collision_manager.h:66
void setup()
initialize the manager, related with the specific type of manager
Definition: broadphase_bruteforce-inl.h:81
S distance(const AABB< S > &other, Vector3< S > *P, Vector3< S > *Q) const
Distance between two AABBs; P and Q, should not be nullptr, return the nearest points.
Definition: AABB-inl.h:237