| 1 | #include "Library/Area/AreaShapeSphere.h" |
| 2 | |
| 3 | #include <math/seadMathCalcCommon.h> |
| 4 | |
| 5 | namespace al { |
| 6 | |
| 7 | AreaShapeSphere::AreaShapeSphere() {} |
| 8 | |
| 9 | bool AreaShapeSphere::isInVolume(const sead::Vector3f& trans) const { |
| 10 | sead::Vector3f baseTrans; |
| 11 | calcTrans(trans: &baseTrans); |
| 12 | sead::Vector3f offsetTrans = trans - baseTrans; |
| 13 | f32 radius = getScale().x * 500.0f; |
| 14 | |
| 15 | return offsetTrans.squaredLength() <= sead::Mathf::square(t: radius); |
| 16 | } |
| 17 | |
| 18 | bool AreaShapeSphere::isInVolumeOffset(const sead::Vector3f& trans, f32 offset) const { |
| 19 | sead::Vector3f baseTrans; |
| 20 | calcTrans(trans: &baseTrans); |
| 21 | sead::Vector3f offsetTrans = trans - baseTrans; |
| 22 | f32 radius = getScale().x * 500.0f + offset; |
| 23 | |
| 24 | return offsetTrans.squaredLength() <= sead::Mathf::square(t: radius); |
| 25 | } |
| 26 | |
| 27 | bool AreaShapeSphere::calcNearestEdgePoint(sead::Vector3f* edgePoint, |
| 28 | const sead::Vector3f& trans) const { |
| 29 | sead::Vector3f localPos = sead::Vector3f::zero; |
| 30 | calcLocalPos(localPos: &localPos, trans); |
| 31 | f32 length = localPos.length(); |
| 32 | |
| 33 | if (length > 0.0f) |
| 34 | localPos *= 500.0f / length; |
| 35 | |
| 36 | calcWorldPos(worldPos: edgePoint, trans: localPos); |
| 37 | |
| 38 | return true; |
| 39 | } |
| 40 | |
| 41 | bool AreaShapeSphere::checkArrowCollision(sead::Vector3f*, sead::Vector3f*, const sead::Vector3f&, |
| 42 | const sead::Vector3f&) const { |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | bool AreaShapeSphere::calcLocalBoundingBox(sead::BoundBox3f* boundingBox) const { |
| 47 | boundingBox->set(min: {-500.0f, -500.0f, -500.0f}, max: {500.0f, 500.0f, 500.0f}); |
| 48 | return true; |
| 49 | } |
| 50 | |
| 51 | } // namespace al |
| 52 | |