45 if (
a->getAABB().min_[0] <
b->getAABB().min_[0])
return true;
53 if (
a->getAABB().min_[1] <
b->getAABB().min_[1])
return true;
61 if (
a->getAABB().min_[2] <
b->getAABB().min_[2])
return true;
83 auto pos_start1 =
objs_x.begin();
87 while (pos_start1 < pos_end1) {
88 if (*pos_start1 == obj) {
95 auto pos_start2 =
objs_y.begin();
99 while (pos_start2 < pos_end2) {
100 if (*pos_start2 == obj) {
107 auto pos_start3 =
objs_z.begin();
111 while (pos_start3 < pos_end3) {
112 if (*pos_start3 == obj) {
159 std::vector<CollisionObject*>& objs)
const {
160 objs.resize(
objs_x.size());
166 std::vector<CollisionObject*>::const_iterator pos_start,
167 std::vector<CollisionObject*>::const_iterator pos_end,
CollisionObject* obj,
169 while (pos_start < pos_end) {
170 if (*pos_start != obj)
172 if ((*pos_start)->getAABB().overlap(obj->
getAABB())) {
173 if ((*
callback)(*pos_start, obj))
return true;
183 typename std::vector<CollisionObject*>::const_iterator pos_start,
184 typename std::vector<CollisionObject*>::const_iterator pos_end,
187 while (pos_start < pos_end) {
188 if (*pos_start != obj)
190 if ((*pos_start)->getAABB().distance(obj->
getAABB()) < min_dist) {
191 if ((*
callback)(*pos_start, obj, min_dist))
return true;
204 if (
size() == 0)
return;
212 static const unsigned int CUTOFF = 100;
215 bool coll_res =
false;
217 const auto pos_start1 =
objs_x.begin();
218 const auto pos_end1 =
220 long d1 = pos_end1 - pos_start1;
223 const auto pos_start2 =
objs_y.begin();
224 const auto pos_end2 =
226 long d2 = pos_end2 - pos_start2;
229 const auto pos_start3 =
objs_z.begin();
230 const auto pos_end3 =
232 long d3 = pos_end3 - pos_start3;
235 if (d3 <= d2 && d3 <=
d1)
238 if (d2 <= d3 && d2 <=
d1)
257 if (
size() == 0)
return;
259 CoalScalar min_dist = (std::numeric_limits<CoalScalar>::max)();
267 static const unsigned int CUTOFF = 100;
270 if (min_dist < (std::numeric_limits<CoalScalar>::max)())
271 dummy_vector +=
Vec3s(min_dist, min_dist, min_dist);
273 typename std::vector<CollisionObject*>::const_iterator pos_start1 =
275 typename std::vector<CollisionObject*>::const_iterator pos_start2 =
277 typename std::vector<CollisionObject*>::const_iterator pos_start3 =
279 typename std::vector<CollisionObject*>::const_iterator pos_end1 =
281 typename std::vector<CollisionObject*>::const_iterator pos_end2 =
283 typename std::vector<CollisionObject*>::const_iterator pos_end3 =
290 old_min_distance = min_dist;
295 long d1 = pos_end1 - pos_start1;
297 bool dist_res =
false;
302 long d2 = pos_end2 - pos_start2;
305 pos_end3 = std::upper_bound(pos_start3,
objs_z.end(), &dummyHigh,
307 long d3 = pos_end3 - pos_start3;
310 if (d3 <= d2 && d3 <=
d1)
313 if (d2 <= d3 && d2 <=
d1)
328 if (dist_res)
return true;
331 if (old_min_distance < (std::numeric_limits<CoalScalar>::max)())
336 if (min_dist < old_min_distance) {
342 if (dummy_vector.isApprox(
345 dummy_vector = dummy_vector + delta;
347 dummy_vector = dummy_vector * 2 - obj->
getAABB().
max_;
355 }
else if (status == 0)
364 const std::vector<CollisionObject*>& objs_x,
365 const std::vector<CollisionObject*>& objs_y,
366 const std::vector<CollisionObject*>& objs_z,
367 typename std::vector<CollisionObject*>::const_iterator& it_beg,
368 typename std::vector<CollisionObject*>::const_iterator& it_end) {
371 (
objs_x[0])->getAABB().min_[0];
373 (
objs_y[0])->getAABB().min_[1];
375 (
objs_z[0])->getAABB().min_[2];
378 if (delta_y > delta_x && delta_y > delta_z)
380 else if (delta_z > delta_y && delta_z > delta_x)
404 if (
size() == 0)
return;
406 typename std::vector<CollisionObject*>::const_iterator
pos, run_pos, pos_end;
408 int axis2 = (
axis + 1 > 2) ? 0 : (
axis + 1);
409 int axis3 = (axis2 + 1 > 2) ? 0 : (axis2 + 1);
413 while ((run_pos < pos_end) && (
pos < pos_end)) {
419 if (run_pos == pos_end)
break;
427 if (run_pos < pos_end) {
428 typename std::vector<CollisionObject*>::const_iterator run_pos2 = run_pos;
442 if (run_pos2 == pos_end)
break;
451 if (
size() == 0)
return;
453 typename std::vector<CollisionObject*>::const_iterator it, it_end;
456 CoalScalar min_dist = (std::numeric_limits<CoalScalar>::max)();
457 for (; it != it_end; ++it) {
469 if ((
size() == 0) || (other_manager->
size() == 0))
return;
471 if (
this == other_manager) {
476 typename std::vector<CollisionObject*>::const_iterator it, end;
477 if (this->
size() < other_manager->
size()) {
478 for (it =
objs_x.begin(), end =
objs_x.end(); it != end; ++it)
481 for (it = other_manager->
objs_x.begin(), end = other_manager->
objs_x.end();
494 if ((
size() == 0) || (other_manager->
size() == 0))
return;
496 if (
this == other_manager) {
501 CoalScalar min_dist = (std::numeric_limits<CoalScalar>::max)();
502 typename std::vector<CollisionObject*>::const_iterator it, end;
503 if (this->
size() < other_manager->
size()) {
504 for (it =
objs_x.begin(), end =
objs_x.end(); it != end; ++it)
507 for (it = other_manager->
objs_x.begin(), end = other_manager->
objs_x.end();