51 auto end1 = std::upper_bound(start1,
endpoints[0].end(), p);
54 size_t start_id = (size_t)(start1 -
endpoints[0].begin());
55 size_t end_id = (size_t)(end1 -
endpoints[0].begin());
56 size_t cur_id = (size_t)(start_id);
58 for (
size_t i = start_id; i < end_id; ++i) {
74 auto end2 = std::upper_bound(start2,
endpoints[1].end(), p);
77 size_t start_id = (size_t)(start2 -
endpoints[1].begin());
78 size_t end_id = (size_t)(end2 -
endpoints[1].begin());
79 size_t cur_id = (size_t)(start_id);
81 for (
size_t i = start_id; i < end_id; ++i) {
97 auto end3 = std::upper_bound(start3,
endpoints[2].end(), p);
100 size_t start_id = (size_t)(start3 -
endpoints[2].begin());
101 size_t end_id = (size_t)(end3 -
endpoints[2].begin());
102 size_t cur_id = (size_t)(start_id);
104 for (
size_t i = start_id; i < end_id; ++i) {
238 for (
int i = 0; i < 3; ++i) {
241 old_aabb.
min_[i] = it->second->low;
242 old_aabb.
max_[i] = it->second->high;
243 it->second->low = new_aabb.
min_[i];
244 it->second->high = new_aabb.
max_[i];
249 typename std::vector<EndPoint>::iterator it;
250 for (
int i = 0; i < 3; ++i) {
254 if (it->obj == updated_obj && it->minmax == 0) {
255 it->value = new_aabb.
min_[i];
263 if (it->obj == updated_obj && it->minmax == 0) {
264 it->value = new_aabb.
max_[i];
275 const std::vector<CollisionObject*>& updated_objs) {
276 for (
size_t i = 0; i < updated_objs.size(); ++i)
update(updated_objs[i]);
292 for (
int i = 0; i < 3; ++i) {
307 std::vector<CollisionObject*>& objs)
const {
322 if (
size() == 0)
return;
329 static const unsigned int CUTOFF = 100;
331 std::deque<detail::SimpleInterval*> results0, results1, results2;
335 if (results0.size() > CUTOFF) {
338 if (results1.size() > CUTOFF) {
341 if (results2.size() > CUTOFF) {
342 size_t d1 = results0.size();
343 size_t d2 = results1.size();
344 size_t d3 = results2.size();
346 if (
d1 >= d2 &&
d1 >= d3)
348 else if (d2 >=
d1 && d2 >= d3)
364 if (
size() == 0)
return;
365 CoalScalar min_dist = (std::numeric_limits<CoalScalar>::max)();
373 static const unsigned int CUTOFF = 100;
377 if (min_dist < (std::numeric_limits<CoalScalar>::max)()) {
378 Vec3s min_dist_delta(min_dist, min_dist, min_dist);
379 aabb.
expand(min_dist_delta);
386 bool dist_res =
false;
388 old_min_distance = min_dist;
390 std::deque<detail::SimpleInterval*> results0, results1, results2;
393 if (results0.size() > CUTOFF) {
395 if (results1.size() > CUTOFF) {
397 if (results2.size() > CUTOFF) {
398 size_t d1 = results0.size();
399 size_t d2 = results1.size();
400 size_t d3 = results2.size();
402 if (
d1 >= d2 &&
d1 >= d3)
403 dist_res =
checkDist(results0.begin(), results0.end(), obj,
405 else if (d2 >=
d1 && d2 >= d3)
406 dist_res =
checkDist(results1.begin(), results1.end(), obj,
409 dist_res =
checkDist(results2.begin(), results2.end(), obj,
421 if (dist_res)
return true;
428 if (old_min_distance < (std::numeric_limits<CoalScalar>::max)())
431 if (min_dist < old_min_distance) {
432 Vec3s min_dist_delta(min_dist, min_dist, min_dist);
442 }
else if (status == 0)
453 if (
size() == 0)
return;
455 std::set<CollisionObject*> active;
456 std::set<std::pair<CollisionObject*, CollisionObject*> >
overlap;
463 if (diff_y > diff_x && diff_y > diff_z)
465 else if (diff_z > diff_y && diff_z > diff_x)
468 for (
unsigned int i = 0; i < n; ++i) {
471 if (endpoint.
minmax == 0) {
472 auto iter = active.begin();
473 auto end = active.end();
474 for (; iter != end; ++iter) {
479 int axis2 = (
axis + 1) % 3;
480 int axis3 = (
axis + 2) % 3;
487 if (active_index <
index)
488 insert_res =
overlap.insert(std::make_pair(active_index,
index));
490 insert_res =
overlap.insert(std::make_pair(
index, active_index));
492 if (insert_res.second) {
497 active.insert(
index);
507 if (
size() == 0)
return;
511 CoalScalar min_dist = (std::numeric_limits<CoalScalar>::max)();
513 for (
size_t i = 0; i <
endpoints[0].size(); ++i)
528 if ((
size() == 0) || (other_manager->
size() == 0))
return;
530 if (
this == other_manager) {
535 if (this->
size() < other_manager->
size()) {
552 if ((
size() == 0) || (other_manager->
size() == 0))
return;
554 if (
this == other_manager) {
559 CoalScalar min_dist = (std::numeric_limits<CoalScalar>::max)();
561 if (this->
size() < other_manager->
size()) {
584 typename std::deque<detail::SimpleInterval*>::const_iterator pos_start,
585 typename std::deque<detail::SimpleInterval*>::const_iterator pos_end,
587 while (pos_start < pos_end) {
589 if (ivl->
obj != obj) {
603 typename std::deque<detail::SimpleInterval*>::const_iterator pos_start,
604 typename std::deque<detail::SimpleInterval*>::const_iterator pos_end,
607 while (pos_start < pos_end) {
609 if (ivl->
obj != obj) {
612 if ((*
callback)(ivl->
obj, obj, min_dist))
return true;
617 if ((*
callback)(ivl->
obj, obj, min_dist))
return true;
641 : detail::SimpleInterval() {