| 540 | } |
| 541 | |
| 542 | bool Frustum::intersect(const AABB& aabb) const { |
| 543 | for (const auto& plane : planes) { |
| 544 | auto p = aabb.min; |
| 545 | if (plane.normal.x >= 0) p.x = aabb.max.x; |
| 546 | if (plane.normal.y >= 0) p.y = aabb.max.y; |
| 547 | if (plane.normal.z >= 0) p.z = aabb.max.z; |
| 548 | auto result = ktm::dot(*r_cast<const ktm::fvec3*>(&plane.normal), *r_cast<const ktm::fvec3*>(&p)); |
| 549 | if (result + plane.distance < 0) { |
| 550 | return false; |
| 551 | } |
| 552 | } |
| 553 | return true; |
| 554 | } |
| 555 | |
| 556 | NS_DORA_END |