MCPcopy Create free account
hub / github.com/axmolengine/axmol / intersects

Method intersects

core/3d/OBB.cpp:417–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

415}
416
417bool OBB::intersects(const OBB& box) const
418{
419 float min1, max1, min2, max2;
420 for (int i = 0; i < 3; i++)
421 {
422 getInterval(*this, getFaceDirection(i), min1, max1);
423 getInterval(box, getFaceDirection(i), min2, max2);
424 if (max1 < min2 || max2 < min1)
425 return false;
426 }
427
428 for (int i = 0; i < 3; i++)
429 {
430 getInterval(*this, box.getFaceDirection(i), min1, max1);
431 getInterval(box, box.getFaceDirection(i), min2, max2);
432 if (max1 < min2 || max2 < min1)
433 return false;
434 }
435
436 for (int i = 0; i < 3; i++)
437 {
438 for (int j = 0; j < 3; j++)
439 {
440 Vec3 axis;
441 Vec3::cross(getEdgeDirection(i), box.getEdgeDirection(j), &axis);
442 getInterval(*this, axis, min1, max1);
443 getInterval(box, axis, min2, max2);
444 if (max1 < min2 || max2 < min1)
445 return false;
446 }
447 }
448
449 return true;
450}
451
452void OBB::transform(const Mat4& mat)
453{

Callers 3

onTouchesBeganMethod · 0.45
updateMethod · 0.45

Calls 3

getFaceDirectionMethod · 0.80
getEdgeDirectionMethod · 0.80
crossFunction · 0.50

Tested by 2

onTouchesBeganMethod · 0.36
updateMethod · 0.36