Showing the changes to libraries/shared/src/AABox.cpp (1 of 3 files). Show all
Unified · Split
| @@ -436,6 +436,32 @@ glm::vec3 AABox::getClosestPointOnFace(const glm::vec4& origin, const glm::vec4& · 435 unmodified lines | ||
| 436 | 436 | return getClosestPointOnFace(glm::vec3(origin), face); |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | +bool AABox::touchesAAEllipsoid(const glm::vec3& center, glm::vec3 radials) const { | |
| 440 | + if (_corner.x - radials.x > center.x || | |
| 441 | + _corner.y - radials.y > center.y || | |
| 442 | + _corner.z - radials.z > center.z || | |
| 443 | + _corner.x + _scale.x + radials.x < center.x || | |
| 444 | + _corner.y + _scale.y + radials.y < center.y || | |
| 445 | + _corner.z + _scale.z + radials.z < center.z) { | |
| 446 | + return false; | |
| 447 | + } | |
| 448 | + | |
| 449 | + for (int i = 0; i < FACE_COUNT; i++) { | |
| 450 | + glm::vec3 closest = getClosestPointOnFace(center, (BoxFace)i) - center; | |
| 451 | + float x = closest.x; | |
| 452 | + float y = closest.y; | |
| 453 | + float z = closest.z; | |
| 454 | + float a = radials.x; | |
| 455 | + float b = radials.y; | |
| 456 | + float c = radials.z; | |
| 457 | + if (x*x/(a*a) + y*y/(b*b) + z*z/(c*c) < 1.0f) { | |
| 458 | + return true; | |
| 459 | + } | |
| 460 | + } | |
| 461 | + return false; | |
| 462 | +} | |
| 463 | + | |
| 464 | + | |
| 439 | 465 | glm::vec4 AABox::getPlane(BoxFace face) const { |
| 440 | 466 | switch (face) { |
| 441 | 467 | case MIN_X_FACE: return glm::vec4(-1.0f, 0.0f, 0.0f, _corner.x); |