| 1 | #include "Library/Area/AreaShapeCube.h" |
|---|---|
| 2 | |
| 3 | namespace al { |
| 4 | |
| 5 | AreaShapeCube::AreaShapeCube(AreaShapeCube::OriginType originType) : mOriginType(originType) {} |
| 6 | |
| 7 | bool AreaShapeCube::isInVolume(const sead::Vector3f& trans) const { |
| 8 | sead::Vector3f localPos = sead::Vector3f::zero; |
| 9 | calcLocalPos(localPos: &localPos, trans); |
| 10 | |
| 11 | return isInLocalVolume(localPos); |
| 12 | } |
| 13 | |
| 14 | bool AreaShapeCube::isInLocalVolume(const sead::Vector3f& trans) const { |
| 15 | f32 bottom = mOriginType == OriginType::Base ? |
| 16 | 0.0f : |
| 17 | (mOriginType == OriginType::Top ? -1000.0f : 500.0f); |
| 18 | f32 top = mOriginType == OriginType::Base ? 1000.0f : |
| 19 | (mOriginType == OriginType::Top ? 0.0f : 500.0f); |
| 20 | |
| 21 | sead::Vector3f min = {-500.0f, bottom, -500.0f}; |
| 22 | sead::Vector3f max = {500.0f, top, 500.0f}; |
| 23 | |
| 24 | if ((trans.y < min.y || max.y < trans.y) || (trans.x < min.x || max.x < trans.x) || |
| 25 | (trans.z < min.z || max.z < trans.z)) |
| 26 | return false; |
| 27 | |
| 28 | return true; |
| 29 | } |
| 30 | |
| 31 | } // namespace al |
| 32 |