| 1 | #pragma once |
| 2 | |
| 3 | #include <math/seadMatrix.h> |
| 4 | #include <math/seadVector.h> |
| 5 | #include <prim/seadStorageFor.h> |
| 6 | |
| 7 | namespace al { |
| 8 | class Triangle; |
| 9 | class KCollisionServer; |
| 10 | } // namespace al |
| 11 | |
| 12 | bool operator==(const al::Triangle& tri1, const al::Triangle& tri2); |
| 13 | bool operator!=(const al::Triangle& tri1, const al::Triangle& tri2); |
| 14 | |
| 15 | namespace al { |
| 16 | class ByamlIter; |
| 17 | class CollisionParts; |
| 18 | class HitSensor; |
| 19 | struct KCPrismData; |
| 20 | struct ; |
| 21 | class LiveActor; |
| 22 | |
| 23 | class Triangle { |
| 24 | public: |
| 25 | Triangle(); |
| 26 | (const CollisionParts& parts, const KCPrismData* data, const KCPrismHeader* ); |
| 27 | |
| 28 | void (const CollisionParts& parts, const KCPrismData* data, |
| 29 | const KCPrismHeader* ); |
| 30 | void fill(const sead::Vector3f& pos1, const sead::Vector3f& pos2, const sead::Vector3f& pos3); |
| 31 | const LiveActor* getHostActor() const; |
| 32 | bool isHostMoved() const; |
| 33 | bool isValid() const; |
| 34 | const sead::Vector3f& getNormal(s32 index) const; |
| 35 | const sead::Vector3f& getFaceNormal() const; |
| 36 | const sead::Vector3f& getEdgeNormal(s32 index) const; |
| 37 | const sead::Vector3f& getPos(s32 index) const; |
| 38 | void calcCenterPos(sead::Vector3f* center) const; |
| 39 | const sead::Vector3f& calcAndGetNormal(s32 index); |
| 40 | const sead::Vector3f& calcAndGetFaceNormal(); |
| 41 | const sead::Vector3f& calcAndGetEdgeNormal(s32 index); |
| 42 | const sead::Vector3f& calcAndGetPos(s32 index); |
| 43 | void getLocalPos(sead::Vector3f* localPos, s32 index) const; |
| 44 | void calcForceMovePower(sead::Vector3f* movePower, const sead::Vector3f& pos) const; |
| 45 | void calcForceRotatePower(sead::Quatf* rotatePower) const; |
| 46 | bool getAttributes(ByamlIter* iter) const; |
| 47 | const HitSensor* getSensor() const; |
| 48 | const sead::Matrix34f& getBaseMtx() const; |
| 49 | const sead::Matrix34f& getBaseInvMtx() const; |
| 50 | const sead::Matrix34f& getPrevBaseMtx() const; |
| 51 | |
| 52 | // clang-format off |
| 53 | friend bool ::operator==(const Triangle& tri1, const Triangle& tri2); |
| 54 | friend bool ::operator!=(const Triangle& tri1, const Triangle& tri2); |
| 55 | // clang-format on |
| 56 | |
| 57 | private: |
| 58 | const CollisionParts* mCollisionParts; |
| 59 | const KCPrismData* mKCPrismData; |
| 60 | const KCPrismHeader* ; |
| 61 | sead::Vector3f mNormals[4]; // FaceNormal, then three EdgeNormals |
| 62 | sead::Vector3f mPositions[3]; |
| 63 | }; |
| 64 | |
| 65 | enum class CollisionLocation : u8 { |
| 66 | None = 0, |
| 67 | Face = 1, |
| 68 | Edge1 = 2, |
| 69 | Edge2 = 3, |
| 70 | Edge3 = 4, |
| 71 | Corner1 = 5, |
| 72 | Corner2 = 6, |
| 73 | Corner3 = 7, |
| 74 | }; |
| 75 | |
| 76 | struct HitInfo { |
| 77 | HitInfo(); |
| 78 | |
| 79 | bool isCollisionAtFace() const; |
| 80 | bool isCollisionAtEdge() const; |
| 81 | bool isCollisionAtCorner() const; |
| 82 | const sead::Vector3f& tryGetHitEdgeNormal() const; |
| 83 | |
| 84 | Triangle triangle; |
| 85 | f32 _70 = 0.0f; |
| 86 | sead::Vector3f collisionHitPos = {0.0f, 0.0f, 0.0f}; |
| 87 | sead::Vector3f _80 = {0.0f, 0.0f, 0.0f}; |
| 88 | sead::Vector3f collisionMovingReaction = {0.0f, 0.0f, 0.0f}; |
| 89 | CollisionLocation collisionLocation = CollisionLocation::None; |
| 90 | }; |
| 91 | |
| 92 | struct ArrowHitInfo { |
| 93 | HitInfo* operator*() { return hitInfo.data(); } |
| 94 | |
| 95 | const HitInfo* operator*() const { return hitInfo.data(); } |
| 96 | |
| 97 | HitInfo& operator->() { return *hitInfo; } |
| 98 | |
| 99 | const HitInfo& operator->() const { return *hitInfo; } |
| 100 | |
| 101 | sead::StorageFor<HitInfo> hitInfo{sead::ZeroInitializeTag{}}; |
| 102 | }; |
| 103 | |
| 104 | struct SphereHitInfo { |
| 105 | void calcFixVector(sead::Vector3f* a1, sead::Vector3f* a2) const; |
| 106 | void calcFixVectorNormal(sead::Vector3f* a1, sead::Vector3f* a2) const; |
| 107 | |
| 108 | HitInfo* operator*() { return hitInfo.data(); } |
| 109 | |
| 110 | const HitInfo* operator*() const { return hitInfo.data(); } |
| 111 | |
| 112 | HitInfo& operator->() { return *hitInfo; } |
| 113 | |
| 114 | const HitInfo& operator->() const { return *hitInfo; } |
| 115 | |
| 116 | sead::StorageFor<HitInfo> hitInfo{sead::ZeroInitializeTag{}}; |
| 117 | }; |
| 118 | |
| 119 | struct DiskHitInfo { |
| 120 | void calcFixVector(sead::Vector3f* a1, sead::Vector3f* a2) const; |
| 121 | void calcFixVectorNormal(sead::Vector3f* a1, sead::Vector3f* a2) const; |
| 122 | |
| 123 | HitInfo* operator*() { return hitInfo.data(); } |
| 124 | |
| 125 | const HitInfo* operator*() const { return hitInfo.data(); } |
| 126 | |
| 127 | HitInfo& operator->() { return *hitInfo; } |
| 128 | |
| 129 | const HitInfo& operator->() const { return *hitInfo; } |
| 130 | |
| 131 | sead::StorageFor<HitInfo> hitInfo{sead::ZeroInitializeTag{}}; |
| 132 | }; |
| 133 | |
| 134 | } // namespace al |
| 135 | |