From dca89789f212b8f1875334a2366d626d7397b44a Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 28 Oct 2022 14:06:29 -0700 Subject: [PATCH] Add CCollisionActorManager --- asm/MetroidPrime/CCollisionActorManager.s | 5 +- asm/MetroidPrime/Enemies/CBabygoth.s | 4 +- asm/MetroidPrime/Enemies/CElitePirate.s | 8 +- asm/MetroidPrime/Enemies/CFlaahgra.s | 12 +- asm/MetroidPrime/Enemies/CFlaahgraTentacle.s | 4 +- asm/MetroidPrime/Enemies/CIceSheegoth.s | 4 +- asm/MetroidPrime/Enemies/CMagdolite.s | 4 +- asm/MetroidPrime/Enemies/CMetroidBeta.s | 4 +- .../Enemies/CMetroidPrimeEssence.s | 4 +- asm/MetroidPrime/Enemies/CMetroidPrimeExo.s | 4 +- asm/MetroidPrime/Enemies/CNewIntroBoss.s | 4 +- asm/MetroidPrime/Enemies/COmegaPirate.s | 8 +- asm/MetroidPrime/Enemies/CParasite.s | 4 +- asm/MetroidPrime/Enemies/CRidley.s | 8 +- asm/MetroidPrime/Enemies/CSpankWeed.s | 4 +- asm/MetroidPrime/Enemies/CThardus.s | 12 +- .../Enemies/CThardusRockProjectile.s | 4 +- .../ScriptObjects/CScriptGunTurret.s | 4 +- include/Collision/CMaterialList.hpp | 6 +- include/Kyoto/Animation/CSegId.hpp | 1 + include/Kyoto/Math/CVector3f.hpp | 4 + include/MetroidPrime/CActor.hpp | 7 +- include/MetroidPrime/CBoneTracking.hpp | 22 ++++ .../MetroidPrime/CCollisionActorManager.hpp | 51 +++++++++ include/MetroidPrime/CEntity.hpp | 2 +- .../Collision/CJointCollisionDescription.hpp | 75 +++++++++++++ .../MetroidPrime/Enemies/CNewIntroBoss.hpp | 61 ++++++++++ include/MetroidPrime/Enemies/CPatterned.hpp | 1 + src/MetroidPrime/CCollisionActorManager.cpp | 104 ++++++++++++++++++ src/MetroidPrime/Enemies/CNewIntroBoss.cpp | 62 +++++++++++ 30 files changed, 441 insertions(+), 56 deletions(-) create mode 100644 include/MetroidPrime/CBoneTracking.hpp create mode 100644 include/MetroidPrime/CCollisionActorManager.hpp create mode 100644 include/MetroidPrime/Collision/CJointCollisionDescription.hpp create mode 100644 include/MetroidPrime/Enemies/CNewIntroBoss.hpp create mode 100644 src/MetroidPrime/CCollisionActorManager.cpp create mode 100644 src/MetroidPrime/Enemies/CNewIntroBoss.cpp diff --git a/asm/MetroidPrime/CCollisionActorManager.s b/asm/MetroidPrime/CCollisionActorManager.s index 775a4160..3e34e99f 100644 --- a/asm/MetroidPrime/CCollisionActorManager.s +++ b/asm/MetroidPrime/CCollisionActorManager.s @@ -706,8 +706,8 @@ lbl_801A78B8: /* 801A78D4 001A4834 38 21 03 A0 */ addi r1, r1, 0x3a0 /* 801A78D8 001A4838 4E 80 00 20 */ blr -.global sub_801a78dc -sub_801a78dc: +.global __dt__22CCollisionActorManagerFv +__dt__22CCollisionActorManagerFv: /* 801A78DC 001A483C 94 21 FF F0 */ stwu r1, -0x10(r1) /* 801A78E0 001A4840 7C 08 02 A6 */ mflr r0 /* 801A78E4 001A4844 90 01 00 14 */ stw r0, 0x14(r1) @@ -1826,4 +1826,3 @@ lbl_803D1498: # ROM: 0x3CE498 .asciz "??(??)" .balign 4 - diff --git a/asm/MetroidPrime/Enemies/CBabygoth.s b/asm/MetroidPrime/Enemies/CBabygoth.s index d7b3db42..f3c9b83b 100644 --- a/asm/MetroidPrime/Enemies/CBabygoth.s +++ b/asm/MetroidPrime/Enemies/CBabygoth.s @@ -2445,7 +2445,7 @@ sub_8021f1a0: lbl_8021F240: /* 8021F240 0021C1A0 80 7A 09 28 */ lwz r3, 0x928(r26) /* 8021F244 0021C1A4 38 80 00 01 */ li r4, 1 -/* 8021F248 0021C1A8 4B F8 86 95 */ bl sub_801a78dc +/* 8021F248 0021C1A8 4B F8 86 95 */ bl __dt__22CCollisionActorManagerFv /* 8021F24C 0021C1AC 93 1A 09 28 */ stw r24, 0x928(r26) /* 8021F250 0021C1B0 7F 64 DB 78 */ mr r4, r27 /* 8021F254 0021C1B4 88 1A 00 30 */ lbz r0, 0x30(r26) @@ -7183,7 +7183,7 @@ lbl_80223654: /* 80223658 002205B8 41 82 00 10 */ beq lbl_80223668 /* 8022365C 002205BC 80 7E 09 28 */ lwz r3, 0x928(r30) /* 80223660 002205C0 38 80 00 01 */ li r4, 1 -/* 80223664 002205C4 4B F8 42 79 */ bl sub_801a78dc +/* 80223664 002205C4 4B F8 42 79 */ bl __dt__22CCollisionActorManagerFv lbl_80223668: /* 80223668 002205C8 34 1E 08 F0 */ addic. r0, r30, 0x8f0 /* 8022366C 002205CC 41 82 00 14 */ beq lbl_80223680 diff --git a/asm/MetroidPrime/Enemies/CElitePirate.s b/asm/MetroidPrime/Enemies/CElitePirate.s index 2221db7c..41057228 100644 --- a/asm/MetroidPrime/Enemies/CElitePirate.s +++ b/asm/MetroidPrime/Enemies/CElitePirate.s @@ -3221,7 +3221,7 @@ sub_80229bc4: lbl_80229CAC: /* 80229CAC 00226C0C 80 7D 07 30 */ lwz r3, 0x730(r29) /* 80229CB0 00226C10 38 80 00 01 */ li r4, 1 -/* 80229CB4 00226C14 4B F7 DC 29 */ bl sub_801a78dc +/* 80229CB4 00226C14 4B F7 DC 29 */ bl __dt__22CCollisionActorManagerFv /* 80229CB8 00226C18 93 9D 07 30 */ stw r28, 0x730(r29) /* 80229CBC 00226C1C 7F C4 F3 78 */ mr r4, r30 /* 80229CC0 00226C20 88 1D 00 30 */ lbz r0, 0x30(r29) @@ -3396,7 +3396,7 @@ lbl_80229EC0: lbl_80229F30: /* 80229F30 00226E90 80 7D 05 D4 */ lwz r3, 0x5d4(r29) /* 80229F34 00226E94 38 80 00 01 */ li r4, 1 -/* 80229F38 00226E98 4B F7 D9 A5 */ bl sub_801a78dc +/* 80229F38 00226E98 4B F7 D9 A5 */ bl __dt__22CCollisionActorManagerFv /* 80229F3C 00226E9C 93 9D 05 D4 */ stw r28, 0x5d4(r29) /* 80229F40 00226EA0 7F A3 EB 78 */ mr r3, r29 /* 80229F44 00226EA4 7F C4 F3 78 */ mr r4, r30 @@ -7309,7 +7309,7 @@ lbl_8022D700: /* 8022D704 0022A664 41 82 00 10 */ beq lbl_8022D714 /* 8022D708 0022A668 80 7E 07 30 */ lwz r3, 0x730(r30) /* 8022D70C 0022A66C 38 80 00 01 */ li r4, 1 -/* 8022D710 0022A670 4B F7 A1 CD */ bl sub_801a78dc +/* 8022D710 0022A670 4B F7 A1 CD */ bl __dt__22CCollisionActorManagerFv lbl_8022D714: /* 8022D714 0022A674 34 1E 06 F8 */ addic. r0, r30, 0x6f8 /* 8022D718 0022A678 41 82 00 14 */ beq lbl_8022D72C @@ -7329,7 +7329,7 @@ lbl_8022D744: /* 8022D748 0022A6A8 41 82 00 10 */ beq lbl_8022D758 /* 8022D74C 0022A6AC 80 7E 05 D4 */ lwz r3, 0x5d4(r30) /* 8022D750 0022A6B0 38 80 00 01 */ li r4, 1 -/* 8022D754 0022A6B4 4B F7 A1 89 */ bl sub_801a78dc +/* 8022D754 0022A6B4 4B F7 A1 89 */ bl __dt__22CCollisionActorManagerFv lbl_8022D758: /* 8022D758 0022A6B8 7F C3 F3 78 */ mr r3, r30 /* 8022D75C 0022A6BC 38 80 00 00 */ li r4, 0 diff --git a/asm/MetroidPrime/Enemies/CFlaahgra.s b/asm/MetroidPrime/Enemies/CFlaahgra.s index b362c34f..37ba5606 100644 --- a/asm/MetroidPrime/Enemies/CFlaahgra.s +++ b/asm/MetroidPrime/Enemies/CFlaahgra.s @@ -2770,7 +2770,7 @@ sub_801af52c: lbl_801AF61C: /* 801AF61C 001AC57C 80 7F 07 9C */ lwz r3, 0x79c(r31) /* 801AF620 001AC580 38 80 00 01 */ li r4, 1 -/* 801AF624 001AC584 4B FF 82 B9 */ bl sub_801a78dc +/* 801AF624 001AC584 4B FF 82 B9 */ bl __dt__22CCollisionActorManagerFv /* 801AF628 001AC588 93 9F 07 9C */ stw r28, 0x79c(r31) /* 801AF62C 001AC58C 7F E3 FB 78 */ mr r3, r31 /* 801AF630 001AC590 7F C5 F3 78 */ mr r5, r30 @@ -2812,7 +2812,7 @@ lbl_801AF61C: lbl_801AF6C0: /* 801AF6C0 001AC620 80 7F 07 A0 */ lwz r3, 0x7a0(r31) /* 801AF6C4 001AC624 38 80 00 01 */ li r4, 1 -/* 801AF6C8 001AC628 4B FF 82 15 */ bl sub_801a78dc +/* 801AF6C8 001AC628 4B FF 82 15 */ bl __dt__22CCollisionActorManagerFv /* 801AF6CC 001AC62C 93 9F 07 A0 */ stw r28, 0x7a0(r31) /* 801AF6D0 001AC630 7F E3 FB 78 */ mr r3, r31 /* 801AF6D4 001AC634 7F C5 F3 78 */ mr r5, r30 @@ -2854,7 +2854,7 @@ lbl_801AF6C0: lbl_801AF764: /* 801AF764 001AC6C4 80 7F 07 A4 */ lwz r3, 0x7a4(r31) /* 801AF768 001AC6C8 38 80 00 01 */ li r4, 1 -/* 801AF76C 001AC6CC 4B FF 81 71 */ bl sub_801a78dc +/* 801AF76C 001AC6CC 4B FF 81 71 */ bl __dt__22CCollisionActorManagerFv /* 801AF770 001AC6D0 93 9F 07 A4 */ stw r28, 0x7a4(r31) /* 801AF774 001AC6D4 7F E3 FB 78 */ mr r3, r31 /* 801AF778 001AC6D8 7F C5 F3 78 */ mr r5, r30 @@ -7372,19 +7372,19 @@ lbl_801B37F4: /* 801B37F8 001B0758 41 82 00 10 */ beq lbl_801B3808 /* 801B37FC 001B075C 80 7E 07 A4 */ lwz r3, 0x7a4(r30) /* 801B3800 001B0760 38 80 00 01 */ li r4, 1 -/* 801B3804 001B0764 4B FF 40 D9 */ bl sub_801a78dc +/* 801B3804 001B0764 4B FF 40 D9 */ bl __dt__22CCollisionActorManagerFv lbl_801B3808: /* 801B3808 001B0768 34 1E 07 A0 */ addic. r0, r30, 0x7a0 /* 801B380C 001B076C 41 82 00 10 */ beq lbl_801B381C /* 801B3810 001B0770 80 7E 07 A0 */ lwz r3, 0x7a0(r30) /* 801B3814 001B0774 38 80 00 01 */ li r4, 1 -/* 801B3818 001B0778 4B FF 40 C5 */ bl sub_801a78dc +/* 801B3818 001B0778 4B FF 40 C5 */ bl __dt__22CCollisionActorManagerFv lbl_801B381C: /* 801B381C 001B077C 34 1E 07 9C */ addic. r0, r30, 0x79c /* 801B3820 001B0780 41 82 00 10 */ beq lbl_801B3830 /* 801B3824 001B0784 80 7E 07 9C */ lwz r3, 0x79c(r30) /* 801B3828 001B0788 38 80 00 01 */ li r4, 1 -/* 801B382C 001B078C 4B FF 40 B1 */ bl sub_801a78dc +/* 801B382C 001B078C 4B FF 40 B1 */ bl __dt__22CCollisionActorManagerFv lbl_801B3830: /* 801B3830 001B0790 34 1E 07 70 */ addic. r0, r30, 0x770 /* 801B3834 001B0794 41 82 00 58 */ beq lbl_801B388C diff --git a/asm/MetroidPrime/Enemies/CFlaahgraTentacle.s b/asm/MetroidPrime/Enemies/CFlaahgraTentacle.s index 9ee063d7..c0896560 100644 --- a/asm/MetroidPrime/Enemies/CFlaahgraTentacle.s +++ b/asm/MetroidPrime/Enemies/CFlaahgraTentacle.s @@ -553,7 +553,7 @@ SetupCollisionManager__17CFlaahgraTentacleFR13CStateManager: lbl_801F0498: /* 801F0498 001ED3F8 80 7D 05 6C */ lwz r3, 0x56c(r29) /* 801F049C 001ED3FC 38 80 00 01 */ li r4, 1 -/* 801F04A0 001ED400 4B FB 74 3D */ bl sub_801a78dc +/* 801F04A0 001ED400 4B FB 74 3D */ bl __dt__22CCollisionActorManagerFv /* 801F04A4 001ED404 93 9D 05 6C */ stw r28, 0x56c(r29) /* 801F04A8 001ED408 3B E0 00 00 */ li r31, 0 /* 801F04AC 001ED40C 48 00 01 50 */ b lbl_801F05FC @@ -1339,7 +1339,7 @@ __dt__17CFlaahgraTentacleFv: /* 801F0F74 001EDED4 41 82 00 10 */ beq lbl_801F0F84 /* 801F0F78 001EDED8 80 7E 05 6C */ lwz r3, 0x56c(r30) /* 801F0F7C 001EDEDC 38 80 00 01 */ li r4, 1 -/* 801F0F80 001EDEE0 4B FB 69 5D */ bl sub_801a78dc +/* 801F0F80 001EDEE0 4B FB 69 5D */ bl __dt__22CCollisionActorManagerFv lbl_801F0F84: /* 801F0F84 001EDEE4 7F C3 F3 78 */ mr r3, r30 /* 801F0F88 001EDEE8 38 80 00 00 */ li r4, 0 diff --git a/asm/MetroidPrime/Enemies/CIceSheegoth.s b/asm/MetroidPrime/Enemies/CIceSheegoth.s index 08731452..b9405331 100644 --- a/asm/MetroidPrime/Enemies/CIceSheegoth.s +++ b/asm/MetroidPrime/Enemies/CIceSheegoth.s @@ -2459,7 +2459,7 @@ sub_8019ffe8: lbl_801A00B4: /* 801A00B4 0019D014 80 7E 0A 2C */ lwz r3, 0xa2c(r30) /* 801A00B8 0019D018 38 80 00 01 */ li r4, 1 -/* 801A00BC 0019D01C 48 00 78 21 */ bl sub_801a78dc +/* 801A00BC 0019D01C 48 00 78 21 */ bl __dt__22CCollisionActorManagerFv /* 801A00C0 0019D020 92 FE 0A 2C */ stw r23, 0xa2c(r30) /* 801A00C4 0019D024 7F E4 FB 78 */ mr r4, r31 /* 801A00C8 0019D028 88 1E 00 30 */ lbz r0, 0x30(r30) @@ -8896,7 +8896,7 @@ lbl_801A5D10: /* 801A5D14 001A2C74 41 82 00 10 */ beq lbl_801A5D24 /* 801A5D18 001A2C78 80 7E 0A 2C */ lwz r3, 0xa2c(r30) /* 801A5D1C 001A2C7C 38 80 00 01 */ li r4, 1 -/* 801A5D20 001A2C80 48 00 1B BD */ bl sub_801a78dc +/* 801A5D20 001A2C80 48 00 1B BD */ bl __dt__22CCollisionActorManagerFv lbl_801A5D24: /* 801A5D24 001A2C84 34 1E 09 F4 */ addic. r0, r30, 0x9f4 /* 801A5D28 001A2C88 41 82 00 14 */ beq lbl_801A5D3C diff --git a/asm/MetroidPrime/Enemies/CMagdolite.s b/asm/MetroidPrime/Enemies/CMagdolite.s index 17526105..31d8f24a 100644 --- a/asm/MetroidPrime/Enemies/CMagdolite.s +++ b/asm/MetroidPrime/Enemies/CMagdolite.s @@ -425,7 +425,7 @@ lbl_8023475C: /* 80234760 002316C0 41 82 00 10 */ beq lbl_80234770 /* 80234764 002316C4 80 7E 05 80 */ lwz r3, 0x580(r30) /* 80234768 002316C8 38 80 00 01 */ li r4, 1 -/* 8023476C 002316CC 4B F7 31 71 */ bl sub_801a78dc +/* 8023476C 002316CC 4B F7 31 71 */ bl __dt__22CCollisionActorManagerFv lbl_80234770: /* 80234770 002316D0 7F C3 F3 78 */ mr r3, r30 /* 80234774 002316D4 38 80 00 00 */ li r4, 0 @@ -2774,7 +2774,7 @@ lbl_80236880: lbl_802368E8: /* 802368E8 00233848 80 7D 05 80 */ lwz r3, 0x580(r29) /* 802368EC 0023384C 38 80 00 01 */ li r4, 1 -/* 802368F0 00233850 4B F7 0F ED */ bl sub_801a78dc +/* 802368F0 00233850 4B F7 0F ED */ bl __dt__22CCollisionActorManagerFv /* 802368F4 00233854 93 9D 05 80 */ stw r28, 0x580(r29) /* 802368F8 00233858 3B 20 00 00 */ li r25, 0 /* 802368FC 0023385C 48 00 00 50 */ b lbl_8023694C diff --git a/asm/MetroidPrime/Enemies/CMetroidBeta.s b/asm/MetroidPrime/Enemies/CMetroidBeta.s index 0a5868a3..d3ece10a 100644 --- a/asm/MetroidPrime/Enemies/CMetroidBeta.s +++ b/asm/MetroidPrime/Enemies/CMetroidBeta.s @@ -1496,7 +1496,7 @@ sub_801c1cac: lbl_801C1D48: /* 801C1D48 001BECA8 80 7E 07 64 */ lwz r3, 0x764(r30) /* 801C1D4C 001BECAC 38 80 00 01 */ li r4, 1 -/* 801C1D50 001BECB0 4B FE 5B 8D */ bl sub_801a78dc +/* 801C1D50 001BECB0 4B FE 5B 8D */ bl __dt__22CCollisionActorManagerFv /* 801C1D54 001BECB4 93 BE 07 64 */ stw r29, 0x764(r30) /* 801C1D58 001BECB8 7F E4 FB 78 */ mr r4, r31 /* 801C1D5C 001BECBC 88 1E 00 30 */ lbz r0, 0x30(r30) @@ -6102,7 +6102,7 @@ lbl_801C5FDC: /* 801C5FE0 001C2F40 41 82 00 10 */ beq lbl_801C5FF0 /* 801C5FE4 001C2F44 80 7E 07 64 */ lwz r3, 0x764(r30) /* 801C5FE8 001C2F48 38 80 00 01 */ li r4, 1 -/* 801C5FEC 001C2F4C 4B FE 18 F1 */ bl sub_801a78dc +/* 801C5FEC 001C2F4C 4B FE 18 F1 */ bl __dt__22CCollisionActorManagerFv lbl_801C5FF0: /* 801C5FF0 001C2F50 34 1E 06 7C */ addic. r0, r30, 0x67c /* 801C5FF4 001C2F54 41 82 00 60 */ beq lbl_801C6054 diff --git a/asm/MetroidPrime/Enemies/CMetroidPrimeEssence.s b/asm/MetroidPrime/Enemies/CMetroidPrimeEssence.s index da00a38f..563837b1 100644 --- a/asm/MetroidPrime/Enemies/CMetroidPrimeEssence.s +++ b/asm/MetroidPrime/Enemies/CMetroidPrimeEssence.s @@ -3728,7 +3728,7 @@ sub_8027f960: lbl_8027FA08: /* 8027FA08 0027C968 80 7E 06 58 */ lwz r3, 0x658(r30) /* 8027FA0C 0027C96C 38 80 00 01 */ li r4, 1 -/* 8027FA10 0027C970 4B F2 7E CD */ bl sub_801a78dc +/* 8027FA10 0027C970 4B F2 7E CD */ bl __dt__22CCollisionActorManagerFv /* 8027FA14 0027C974 93 BE 06 58 */ stw r29, 0x658(r30) /* 8027FA18 0027C978 7F E4 FB 78 */ mr r4, r31 /* 8027FA1C 0027C97C 88 1E 00 30 */ lbz r0, 0x30(r30) @@ -4203,7 +4203,7 @@ lbl_802800EC: /* 802800F0 0027D050 41 82 00 10 */ beq lbl_80280100 /* 802800F4 0027D054 80 7E 06 58 */ lwz r3, 0x658(r30) /* 802800F8 0027D058 38 80 00 01 */ li r4, 1 -/* 802800FC 0027D05C 4B F2 77 E1 */ bl sub_801a78dc +/* 802800FC 0027D05C 4B F2 77 E1 */ bl __dt__22CCollisionActorManagerFv lbl_80280100: /* 80280100 0027D060 34 1E 05 74 */ addic. r0, r30, 0x574 /* 80280104 0027D064 41 82 00 60 */ beq lbl_80280164 diff --git a/asm/MetroidPrime/Enemies/CMetroidPrimeExo.s b/asm/MetroidPrime/Enemies/CMetroidPrimeExo.s index d22f3c14..05b0454b 100644 --- a/asm/MetroidPrime/Enemies/CMetroidPrimeExo.s +++ b/asm/MetroidPrime/Enemies/CMetroidPrimeExo.s @@ -1434,7 +1434,7 @@ lbl_80271BE8: /* 80271BEC 0026EB4C 41 82 00 10 */ beq lbl_80271BFC /* 80271BF0 0026EB50 80 7E 05 6C */ lwz r3, 0x56c(r30) /* 80271BF4 0026EB54 38 80 00 01 */ li r4, 1 -/* 80271BF8 0026EB58 4B F3 5C E5 */ bl sub_801a78dc +/* 80271BF8 0026EB58 4B F3 5C E5 */ bl __dt__22CCollisionActorManagerFv lbl_80271BFC: /* 80271BFC 0026EB5C 7F C3 F3 78 */ mr r3, r30 /* 80271C00 0026EB60 38 80 00 00 */ li r4, 0 @@ -9963,7 +9963,7 @@ lbl_802794C0: lbl_80279528: /* 80279528 00276488 80 7D 05 6C */ lwz r3, 0x56c(r29) /* 8027952C 0027648C 38 80 00 01 */ li r4, 1 -/* 80279530 00276490 4B F2 E3 AD */ bl sub_801a78dc +/* 80279530 00276490 4B F2 E3 AD */ bl __dt__22CCollisionActorManagerFv /* 80279534 00276494 93 9D 05 6C */ stw r28, 0x56c(r29) /* 80279538 00276498 3B 20 00 00 */ li r25, 0 /* 8027953C 0027649C 48 00 00 AC */ b lbl_802795E8 diff --git a/asm/MetroidPrime/Enemies/CNewIntroBoss.s b/asm/MetroidPrime/Enemies/CNewIntroBoss.s index 49124e3f..9d1a089b 100644 --- a/asm/MetroidPrime/Enemies/CNewIntroBoss.s +++ b/asm/MetroidPrime/Enemies/CNewIntroBoss.s @@ -220,7 +220,7 @@ __dt__13CNewIntroBossFv: /* 80189DC4 00186D24 41 82 00 10 */ beq lbl_80189DD4 /* 80189DC8 00186D28 80 7E 05 EC */ lwz r3, 0x5ec(r30) /* 80189DCC 00186D2C 38 80 00 01 */ li r4, 1 -/* 80189DD0 00186D30 48 01 DB 0D */ bl sub_801a78dc +/* 80189DD0 00186D30 48 01 DB 0D */ bl __dt__22CCollisionActorManagerFv lbl_80189DD4: /* 80189DD4 00186D34 34 1E 05 DC */ addic. r0, r30, 0x5dc /* 80189DD8 00186D38 41 82 00 0C */ beq lbl_80189DE4 @@ -1044,7 +1044,7 @@ lbl_8018A980: lbl_8018A9E8: /* 8018A9E8 00187948 80 7F 05 EC */ lwz r3, 0x5ec(r31) /* 8018A9EC 0018794C 38 80 00 01 */ li r4, 1 -/* 8018A9F0 00187950 48 01 CE ED */ bl sub_801a78dc +/* 8018A9F0 00187950 48 01 CE ED */ bl __dt__22CCollisionActorManagerFv /* 8018A9F4 00187954 92 FF 05 EC */ stw r23, 0x5ec(r31) /* 8018A9F8 00187958 38 61 01 5C */ addi r3, r1, 0x15c /* 8018A9FC 0018795C 38 80 FF FF */ li r4, -1 diff --git a/asm/MetroidPrime/Enemies/COmegaPirate.s b/asm/MetroidPrime/Enemies/COmegaPirate.s index 1b6acbc5..2c9435ac 100644 --- a/asm/MetroidPrime/Enemies/COmegaPirate.s +++ b/asm/MetroidPrime/Enemies/COmegaPirate.s @@ -2738,7 +2738,7 @@ sub_8028d460: lbl_8028D508: /* 8028D508 0028A468 80 7E 0A 38 */ lwz r3, 0xa38(r30) /* 8028D50C 0028A46C 38 80 00 01 */ li r4, 1 -/* 8028D510 0028A470 4B F1 A3 CD */ bl sub_801a78dc +/* 8028D510 0028A470 4B F1 A3 CD */ bl __dt__22CCollisionActorManagerFv /* 8028D514 0028A474 93 BE 0A 38 */ stw r29, 0xa38(r30) /* 8028D518 0028A478 7F C3 F3 78 */ mr r3, r30 /* 8028D51C 0028A47C 7F E5 FB 78 */ mr r5, r31 @@ -2811,7 +2811,7 @@ lbl_8028D59C: lbl_8028D624: /* 8028D624 0028A584 80 7E 0A 9C */ lwz r3, 0xa9c(r30) /* 8028D628 0028A588 38 80 00 01 */ li r4, 1 -/* 8028D62C 0028A58C 4B F1 A2 B1 */ bl sub_801a78dc +/* 8028D62C 0028A58C 4B F1 A2 B1 */ bl __dt__22CCollisionActorManagerFv /* 8028D630 0028A590 93 BE 0A 9C */ stw r29, 0xa9c(r30) /* 8028D634 0028A594 7F C3 F3 78 */ mr r3, r30 /* 8028D638 0028A598 7F E5 FB 78 */ mr r5, r31 @@ -9131,13 +9131,13 @@ lbl_80292120: /* 80292130 0028F090 41 82 00 10 */ beq lbl_80292140 /* 80292134 0028F094 80 7E 0A 9C */ lwz r3, 0xa9c(r30) /* 80292138 0028F098 38 80 00 01 */ li r4, 1 -/* 8029213C 0028F09C 4B F1 57 A1 */ bl sub_801a78dc +/* 8029213C 0028F09C 4B F1 57 A1 */ bl __dt__22CCollisionActorManagerFv lbl_80292140: /* 80292140 0028F0A0 34 1E 0A 38 */ addic. r0, r30, 0xa38 /* 80292144 0028F0A4 41 82 00 10 */ beq lbl_80292154 /* 80292148 0028F0A8 80 7E 0A 38 */ lwz r3, 0xa38(r30) /* 8029214C 0028F0AC 38 80 00 01 */ li r4, 1 -/* 80292150 0028F0B0 4B F1 57 8D */ bl sub_801a78dc +/* 80292150 0028F0B0 4B F1 57 8D */ bl __dt__22CCollisionActorManagerFv lbl_80292154: /* 80292154 0028F0B4 38 7E 09 F0 */ addi r3, r30, 0x9f0 /* 80292158 0028F0B8 38 80 FF FF */ li r4, -1 diff --git a/asm/MetroidPrime/Enemies/CParasite.s b/asm/MetroidPrime/Enemies/CParasite.s index 0782c262..aa6f824a 100644 --- a/asm/MetroidPrime/Enemies/CParasite.s +++ b/asm/MetroidPrime/Enemies/CParasite.s @@ -307,7 +307,7 @@ lbl_801569DC: /* 801569E0 00153940 41 82 00 10 */ beq lbl_801569F0 /* 801569E4 00153944 80 7D 06 20 */ lwz r3, 0x620(r29) /* 801569E8 00153948 38 80 00 01 */ li r4, 1 -/* 801569EC 0015394C 48 05 0E F1 */ bl sub_801a78dc +/* 801569EC 0015394C 48 05 0E F1 */ bl __dt__22CCollisionActorManagerFv lbl_801569F0: /* 801569F0 00153950 34 1D 05 D8 */ addic. r0, r29, 0x5d8 /* 801569F4 00153954 41 82 00 44 */ beq lbl_80156A38 @@ -685,7 +685,7 @@ lbl_80156EB0: lbl_80156F28: /* 80156F28 00153E88 80 7E 06 20 */ lwz r3, 0x620(r30) /* 80156F2C 00153E8C 38 80 00 01 */ li r4, 1 -/* 80156F30 00153E90 48 05 09 AD */ bl sub_801a78dc +/* 80156F30 00153E90 48 05 09 AD */ bl __dt__22CCollisionActorManagerFv /* 80156F34 00153E94 93 BE 06 20 */ stw r29, 0x620(r30) /* 80156F38 00153E98 38 61 00 40 */ addi r3, r1, 0x40 /* 80156F3C 00153E9C 38 80 FF FF */ li r4, -1 diff --git a/asm/MetroidPrime/Enemies/CRidley.s b/asm/MetroidPrime/Enemies/CRidley.s index 4a26890b..f25d3e3d 100644 --- a/asm/MetroidPrime/Enemies/CRidley.s +++ b/asm/MetroidPrime/Enemies/CRidley.s @@ -745,13 +745,13 @@ lbl_80252748: /* 8025274C 0024F6AC 41 82 00 10 */ beq lbl_8025275C /* 80252750 0024F6B0 80 7E 09 84 */ lwz r3, 0x984(r30) /* 80252754 0024F6B4 38 80 00 01 */ li r4, 1 -/* 80252758 0024F6B8 4B F5 51 85 */ bl sub_801a78dc +/* 80252758 0024F6B8 4B F5 51 85 */ bl __dt__22CCollisionActorManagerFv lbl_8025275C: /* 8025275C 0024F6BC 34 1E 09 80 */ addic. r0, r30, 0x980 /* 80252760 0024F6C0 41 82 00 10 */ beq lbl_80252770 /* 80252764 0024F6C4 80 7E 09 80 */ lwz r3, 0x980(r30) /* 80252768 0024F6C8 38 80 00 01 */ li r4, 1 -/* 8025276C 0024F6CC 4B F5 51 71 */ bl sub_801a78dc +/* 8025276C 0024F6CC 4B F5 51 71 */ bl __dt__22CCollisionActorManagerFv lbl_80252770: /* 80252770 0024F6D0 38 7E 05 68 */ addi r3, r30, 0x568 /* 80252774 0024F6D4 38 80 FF FF */ li r4, -1 @@ -5997,7 +5997,7 @@ lbl_802571F4: lbl_80257288: /* 80257288 002541E8 80 7D 09 80 */ lwz r3, 0x980(r29) /* 8025728C 002541EC 38 80 00 01 */ li r4, 1 -/* 80257290 002541F0 4B F5 06 4D */ bl sub_801a78dc +/* 80257290 002541F0 4B F5 06 4D */ bl __dt__22CCollisionActorManagerFv /* 80257294 002541F4 93 9D 09 80 */ stw r28, 0x980(r29) /* 80257298 002541F8 80 01 01 38 */ lwz r0, 0x138(r1) /* 8025729C 002541FC 83 01 01 40 */ lwz r24, 0x140(r1) @@ -6112,7 +6112,7 @@ lbl_802573B0: lbl_8025743C: /* 8025743C 0025439C 80 7D 09 84 */ lwz r3, 0x984(r29) /* 80257440 002543A0 38 80 00 01 */ li r4, 1 -/* 80257444 002543A4 4B F5 04 99 */ bl sub_801a78dc +/* 80257444 002543A4 4B F5 04 99 */ bl __dt__22CCollisionActorManagerFv /* 80257448 002543A8 93 9D 09 84 */ stw r28, 0x984(r29) /* 8025744C 002543AC 38 80 00 03 */ li r4, 3 /* 80257450 002543B0 80 7D 09 84 */ lwz r3, 0x984(r29) diff --git a/asm/MetroidPrime/Enemies/CSpankWeed.s b/asm/MetroidPrime/Enemies/CSpankWeed.s index fdfb5d64..6a898037 100644 --- a/asm/MetroidPrime/Enemies/CSpankWeed.s +++ b/asm/MetroidPrime/Enemies/CSpankWeed.s @@ -235,7 +235,7 @@ __dt__10CSpankWeedFv: /* 80154C38 00151B98 41 82 00 10 */ beq lbl_80154C48 /* 80154C3C 00151B9C 80 7E 05 94 */ lwz r3, 0x594(r30) /* 80154C40 00151BA0 38 80 00 01 */ li r4, 1 -/* 80154C44 00151BA4 48 05 2C 99 */ bl sub_801a78dc +/* 80154C44 00151BA4 48 05 2C 99 */ bl __dt__22CCollisionActorManagerFv lbl_80154C48: /* 80154C48 00151BA8 7F C3 F3 78 */ mr r3, r30 /* 80154C4C 00151BAC 38 80 00 00 */ li r4, 0 @@ -1557,7 +1557,7 @@ lbl_80155E68: lbl_80155ED0: /* 80155ED0 00152E30 80 7F 05 94 */ lwz r3, 0x594(r31) /* 80155ED4 00152E34 38 80 00 01 */ li r4, 1 -/* 80155ED8 00152E38 48 05 1A 05 */ bl sub_801a78dc +/* 80155ED8 00152E38 48 05 1A 05 */ bl __dt__22CCollisionActorManagerFv /* 80155EDC 00152E3C 92 FF 05 94 */ stw r23, 0x594(r31) /* 80155EE0 00152E40 38 00 00 00 */ li r0, 0 /* 80155EE4 00152E44 38 60 00 00 */ li r3, 0 diff --git a/asm/MetroidPrime/Enemies/CThardus.s b/asm/MetroidPrime/Enemies/CThardus.s index cae396b4..8a63305d 100644 --- a/asm/MetroidPrime/Enemies/CThardus.s +++ b/asm/MetroidPrime/Enemies/CThardus.s @@ -784,19 +784,19 @@ lbl_801DAA6C: /* 801DAA70 001D79D0 41 82 00 10 */ beq lbl_801DAA80 /* 801DAA74 001D79D4 80 7E 05 F8 */ lwz r3, 0x5f8(r30) /* 801DAA78 001D79D8 38 80 00 01 */ li r4, 1 -/* 801DAA7C 001D79DC 4B FC CE 61 */ bl sub_801a78dc +/* 801DAA7C 001D79DC 4B FC CE 61 */ bl __dt__22CCollisionActorManagerFv lbl_801DAA80: /* 801DAA80 001D79E0 34 1E 05 F4 */ addic. r0, r30, 0x5f4 /* 801DAA84 001D79E4 41 82 00 10 */ beq lbl_801DAA94 /* 801DAA88 001D79E8 80 7E 05 F4 */ lwz r3, 0x5f4(r30) /* 801DAA8C 001D79EC 38 80 00 01 */ li r4, 1 -/* 801DAA90 001D79F0 4B FC CE 4D */ bl sub_801a78dc +/* 801DAA90 001D79F0 4B FC CE 4D */ bl __dt__22CCollisionActorManagerFv lbl_801DAA94: /* 801DAA94 001D79F4 34 1E 05 F0 */ addic. r0, r30, 0x5f0 /* 801DAA98 001D79F8 41 82 00 10 */ beq lbl_801DAAA8 /* 801DAA9C 001D79FC 80 7E 05 F0 */ lwz r3, 0x5f0(r30) /* 801DAAA0 001D7A00 38 80 00 01 */ li r4, 1 -/* 801DAAA4 001D7A04 4B FC CE 39 */ bl sub_801a78dc +/* 801DAAA4 001D7A04 4B FC CE 39 */ bl __dt__22CCollisionActorManagerFv lbl_801DAAA8: /* 801DAAA8 001D7A08 34 1E 05 DC */ addic. r0, r30, 0x5dc /* 801DAAAC 001D7A0C 41 82 00 50 */ beq lbl_801DAAFC @@ -4360,7 +4360,7 @@ sub_801ddbe4: lbl_801DDCB4: /* 801DDCB4 001DAC14 80 7E 05 F0 */ lwz r3, 0x5f0(r30) /* 801DDCB8 001DAC18 38 80 00 01 */ li r4, 1 -/* 801DDCBC 001DAC1C 4B FC 9C 21 */ bl sub_801a78dc +/* 801DDCBC 001DAC1C 4B FC 9C 21 */ bl __dt__22CCollisionActorManagerFv /* 801DDCC0 001DAC20 93 9E 05 F0 */ stw r28, 0x5f0(r30) /* 801DDCC4 001DAC24 7F C3 F3 78 */ mr r3, r30 /* 801DDCC8 001DAC28 7F E5 FB 78 */ mr r5, r31 @@ -4390,7 +4390,7 @@ lbl_801DDCB4: lbl_801DDD28: /* 801DDD28 001DAC88 80 7E 05 F4 */ lwz r3, 0x5f4(r30) /* 801DDD2C 001DAC8C 38 80 00 01 */ li r4, 1 -/* 801DDD30 001DAC90 4B FC 9B AD */ bl sub_801a78dc +/* 801DDD30 001DAC90 4B FC 9B AD */ bl __dt__22CCollisionActorManagerFv /* 801DDD34 001DAC94 93 9E 05 F4 */ stw r28, 0x5f4(r30) /* 801DDD38 001DAC98 7F C3 F3 78 */ mr r3, r30 /* 801DDD3C 001DAC9C 7F E5 FB 78 */ mr r5, r31 @@ -4432,7 +4432,7 @@ lbl_801DDD28: lbl_801DDDCC: /* 801DDDCC 001DAD2C 80 7E 05 F8 */ lwz r3, 0x5f8(r30) /* 801DDDD0 001DAD30 38 80 00 01 */ li r4, 1 -/* 801DDDD4 001DAD34 4B FC 9B 09 */ bl sub_801a78dc +/* 801DDDD4 001DAD34 4B FC 9B 09 */ bl __dt__22CCollisionActorManagerFv /* 801DDDD8 001DAD38 93 7E 05 F8 */ stw r27, 0x5f8(r30) /* 801DDDDC 001DAD3C 7F C3 F3 78 */ mr r3, r30 /* 801DDDE0 001DAD40 7F E5 FB 78 */ mr r5, r31 diff --git a/asm/MetroidPrime/Enemies/CThardusRockProjectile.s b/asm/MetroidPrime/Enemies/CThardusRockProjectile.s index 55392db6..3ed42338 100644 --- a/asm/MetroidPrime/Enemies/CThardusRockProjectile.s +++ b/asm/MetroidPrime/Enemies/CThardusRockProjectile.s @@ -317,7 +317,7 @@ lbl_802037D0: /* 802037D4 00200734 41 82 00 10 */ beq lbl_802037E4 /* 802037D8 00200738 80 7E 05 78 */ lwz r3, 0x578(r30) /* 802037DC 0020073C 38 80 00 01 */ li r4, 1 -/* 802037E0 00200740 4B FA 40 FD */ bl sub_801a78dc +/* 802037E0 00200740 4B FA 40 FD */ bl __dt__22CCollisionActorManagerFv lbl_802037E4: /* 802037E4 00200744 7F C3 F3 78 */ mr r3, r30 /* 802037E8 00200748 38 80 00 00 */ li r4, 0 @@ -1331,7 +1331,7 @@ InitializeCollisionManager__22CThardusRockProjectileFR13CStateManager: lbl_8020468C: /* 8020468C 002015EC 80 7E 05 78 */ lwz r3, 0x578(r30) /* 80204690 002015F0 38 80 00 01 */ li r4, 1 -/* 80204694 002015F4 4B FA 32 49 */ bl sub_801a78dc +/* 80204694 002015F4 4B FA 32 49 */ bl __dt__22CCollisionActorManagerFv /* 80204698 002015F8 93 7E 05 78 */ stw r27, 0x578(r30) /* 8020469C 002015FC 7F C3 F3 78 */ mr r3, r30 /* 802046A0 00201600 7F E5 FB 78 */ mr r5, r31 diff --git a/asm/MetroidPrime/ScriptObjects/CScriptGunTurret.s b/asm/MetroidPrime/ScriptObjects/CScriptGunTurret.s index ed0975ac..10719063 100644 --- a/asm/MetroidPrime/ScriptObjects/CScriptGunTurret.s +++ b/asm/MetroidPrime/ScriptObjects/CScriptGunTurret.s @@ -596,7 +596,7 @@ lbl_80215DC0: lbl_80215E28: /* 80215E28 00212D88 80 7B 04 9C */ lwz r3, 0x49c(r27) /* 80215E2C 00212D8C 38 80 00 01 */ li r4, 1 -/* 80215E30 00212D90 4B F9 1A AD */ bl sub_801a78dc +/* 80215E30 00212D90 4B F9 1A AD */ bl __dt__22CCollisionActorManagerFv /* 80215E34 00212D94 93 5B 04 9C */ stw r26, 0x49c(r27) /* 80215E38 00212D98 7F 84 E3 78 */ mr r4, r28 /* 80215E3C 00212D9C 88 1B 00 30 */ lbz r0, 0x30(r27) @@ -5850,7 +5850,7 @@ lbl_8021AA44: /* 8021AA48 002179A8 41 82 00 10 */ beq lbl_8021AA58 /* 8021AA4C 002179AC 80 7E 04 9C */ lwz r3, 0x49c(r30) /* 8021AA50 002179B0 38 80 00 01 */ li r4, 1 -/* 8021AA54 002179B4 4B F8 CE 89 */ bl sub_801a78dc +/* 8021AA54 002179B4 4B F8 CE 89 */ bl __dt__22CCollisionActorManagerFv lbl_8021AA58: /* 8021AA58 002179B8 34 1E 04 90 */ addic. r0, r30, 0x490 /* 8021AA5C 002179BC 41 82 00 30 */ beq lbl_8021AA8C diff --git a/include/Collision/CMaterialList.hpp b/include/Collision/CMaterialList.hpp index 045ecb8d..67e0bc7b 100644 --- a/include/Collision/CMaterialList.hpp +++ b/include/Collision/CMaterialList.hpp @@ -103,9 +103,9 @@ public: CMaterialList(u64 value) : value(value) {} void Add(EMaterialTypes material) { value |= u64(1) << material; } - // Add__13CMaterialListFRC13CMaterialList weak - // Remove__13CMaterialListF14EMaterialTypes weak - // Remove__13CMaterialListFRC13CMaterialList weak + void Add(const CMaterialList& material) { value |= material.value; } + void Remove(EMaterialTypes material) { value &= ~(u64(1) << material); } + void Remove(const CMaterialList& material) { value &= ~material.value; } const CMaterialList& Union(const CMaterialList& other) { value |= other.value; return *this; diff --git a/include/Kyoto/Animation/CSegId.hpp b/include/Kyoto/Animation/CSegId.hpp index 2b933234..6c174a13 100644 --- a/include/Kyoto/Animation/CSegId.hpp +++ b/include/Kyoto/Animation/CSegId.hpp @@ -7,6 +7,7 @@ class CSegId { public: + CSegId() : x0_id(-1) {} CSegId(CInputStream& in) : x0_id(in.Get()) {} private: uchar x0_id; diff --git a/include/Kyoto/Math/CVector3f.hpp b/include/Kyoto/Math/CVector3f.hpp index 2b465e38..c589e94f 100644 --- a/include/Kyoto/Math/CVector3f.hpp +++ b/include/Kyoto/Math/CVector3f.hpp @@ -31,6 +31,10 @@ public: void SetY(float y) { mY = y; } void SetZ(float z) { mZ = z; } + static CVector3f ByElementMultiply(const CVector3f& lhs, const CVector3f& rhs) { + return CVector3f(lhs.GetX() * rhs.GetX(), lhs.GetY() * rhs.GetY(), lhs.GetZ() * rhs.GetZ()); + } + // ByElementMultiply__9CVector3fFRC9CVector3fRC9CVector3f static CVector3f Slerp(const CVector3f& a, const CVector3f& b, const CRelAngle& angle); CVector3f& Normalize(); diff --git a/include/MetroidPrime/CActor.hpp b/include/MetroidPrime/CActor.hpp index daf16a57..631a767f 100644 --- a/include/MetroidPrime/CActor.hpp +++ b/include/MetroidPrime/CActor.hpp @@ -220,6 +220,9 @@ public: virtual void Render(const CStateManager&) const; virtual bool CanRenderUnsorted(const CStateManager&) const; virtual void CalculateRenderBounds(); + const CHealthInfo* GetHealthInfo(const CStateManager& mgr) const { + return const_cast< CActor* >(this)->HealthInfo(const_cast< CStateManager& >(mgr)); + } virtual CHealthInfo* HealthInfo(CStateManager&); virtual const CDamageVulnerability* GetDamageVulnerability() const; virtual const CDamageVulnerability* GetDamageVulnerability(const CVector3f&, const CVector3f&, @@ -330,7 +333,9 @@ public: void AddMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&); void AddMaterial(EMaterialTypes, EMaterialTypes, CStateManager&); void AddMaterial(EMaterialTypes, CStateManager&); - void AddMaterial(const CMaterialList& l); + void AddMaterial(const CMaterialList& l) { + x68_material.Add(l); + } const CAABox& GetRenderBoundsCached() const { return x9c_renderBounds; } void SetRenderBounds(const CAABox& bounds) { x9c_renderBounds = bounds; } diff --git a/include/MetroidPrime/CBoneTracking.hpp b/include/MetroidPrime/CBoneTracking.hpp new file mode 100644 index 00000000..35747649 --- /dev/null +++ b/include/MetroidPrime/CBoneTracking.hpp @@ -0,0 +1,22 @@ +#ifndef _CBONETRACKING +#define _CBONETRACKING + +#include "Kyoto/Animation/CSegId.hpp" +#include "Kyoto/Math/CQuaternion.hpp" +#include "Kyoto/Math/CVector3f.hpp" + +#include "rstl/optional_object.hpp" +class CBoneTracking { +private: + CQuaternion x0_rotation; + float x10_; + CSegId x14_segId; + float x18_time; + float x1c_maxTrackingAngle; + float x20_angSpeed; + rstl::optional_object x24_targetPosition; + TUniqueId x34_target; + uchar x36_flags; +}; + +#endif // _CBONETRACKING diff --git a/include/MetroidPrime/CCollisionActorManager.hpp b/include/MetroidPrime/CCollisionActorManager.hpp new file mode 100644 index 00000000..58efb800 --- /dev/null +++ b/include/MetroidPrime/CCollisionActorManager.hpp @@ -0,0 +1,51 @@ +#ifndef _CCOLLISIONACTORMANAGER +#define _CCOLLISIONACTORMANAGER + +#include "MetroidPrime/Collision/CJointCollisionDescription.hpp" +#include "MetroidPrime/TGameTypes.hpp" + +#include "Kyoto/Math/CTransform4f.hpp" + +#include "rstl/optional_object.hpp" +#include "rstl/vector.hpp" + +class CMaterialList; +class CAnimData; +class CStateManager; +class CCollisionActorManager { +public: + enum EUpdateOptions { + kUO_ObjectSpace, + kUO_WorldSpace, + }; + + CCollisionActorManager(CStateManager& mgr, TUniqueId owner, TAreaId areaId, + const rstl::vector< CJointCollisionDescription >& descs, bool active); + ~CCollisionActorManager(); + + void Update(float dt, CStateManager& mgr, EUpdateOptions opts) const; + void Destroy(CStateManager& mgr) const; + void SetActive(CStateManager& mgr, bool active); + uchar GetActive() const; + void AddMaterial(CStateManager& mgr, const CMaterialList& list); + void SetMovable(CStateManager& mgr, bool movable); + + uint GetNumCollisionActors() const { return x0_jointDescriptions.size(); } + rstl::optional_object< CVector3f > GetDeviation(const CStateManager& mgr, CSegId seg); + const CJointCollisionDescription& GetCollisionDescFromIndex(uint i) const { + return x0_jointDescriptions[i]; + } + + static CTransform4f GetWRLocatorTransform(const CAnimData& animData, CSegId id, + const CTransform4f& worldXf, + const CTransform4f& localXf); + +private: + rstl::vector< CJointCollisionDescription > x0_jointDescriptions; + TUniqueId x10_ownerId; + uchar x12_active; + mutable bool x13_destroyed; + bool x14_movable; +}; + +#endif // _CCOLLISIONACTORMANAGER diff --git a/include/MetroidPrime/CEntity.hpp b/include/MetroidPrime/CEntity.hpp index 5a6a8658..42bca04d 100644 --- a/include/MetroidPrime/CEntity.hpp +++ b/include/MetroidPrime/CEntity.hpp @@ -32,7 +32,7 @@ public: const rstl::string& GetDebugName() const { return x10_name; } TAreaId GetAreaId() const; TAreaId GetCurrentAreaId() const { return x4_areaId; } - bool GetActive() const { return x30_24_active; } + uchar GetActive() const { return x30_24_active; } bool IsScriptingBlocked() const { return x30_26_scriptingBlocked; } // might be fake? diff --git a/include/MetroidPrime/Collision/CJointCollisionDescription.hpp b/include/MetroidPrime/Collision/CJointCollisionDescription.hpp new file mode 100644 index 00000000..a37b105d --- /dev/null +++ b/include/MetroidPrime/Collision/CJointCollisionDescription.hpp @@ -0,0 +1,75 @@ +#ifndef _CJOINTCOLLISIONDESCRIPTION +#define _CJOINTCOLLISIONDESCRIPTION + +#include "Kyoto/Animation/CSegId.hpp" +#include "Kyoto/Math/CVector3f.hpp" + +#include "MetroidPrime/TGameTypes.hpp" + +#include "rstl/string.hpp" + +class CJointCollisionDescription { +public: + enum ECollisionType { + kCT_Sphere, + kCT_SphereSubdivide, + kCT_AABox, + kCT_OBBAutoSize, + kCT_OBB, + }; + + enum EOrientationType { + kOT_Zero, + kOT_One, + }; + + CJointCollisionDescription(ECollisionType colType, CSegId pivotId, CSegId nextId, + const CVector3f& bounds, const CVector3f& pivotPoint, float radius, + float maxSeparation, EOrientationType orientType, + const rstl::string& name, float mass) + : x0_colType(colType) + , x4_orientType(orientType) + , x8_pivotId(pivotId) + , x9_nextId(nextId) + , xc_bounds(bounds) + , x18_pivotPoint(pivotPoint) + , x24_radius(radius) + , x28_maxSeparation(maxSeparation) + , x2c_name(name) + , x3c_actorId(kInvalidUniqueId) + , x40_mass(mass) {} + + void ScaleAllBounds(const CVector3f& scale); + + TUniqueId GetCollisionActorId() const { return x3c_actorId; } + static CJointCollisionDescription SphereSubdivideCollision(CSegId pivotId, CSegId nextId, + float radius, float maxSeparation, + EOrientationType orientType, + const rstl::string& name, float mass); + static CJointCollisionDescription SphereCollision(CSegId pivotId, float radius, + const rstl::string& name, float mass); + static CJointCollisionDescription AABoxCollision(CSegId pivotId, const CVector3f& bounds, + const rstl::string& name, float mass); + static CJointCollisionDescription OBBAutoSizeCollision(CSegId pivotId, CSegId nextId, + const CVector3f& bounds, + EOrientationType orientType, + const rstl::string&, float mass); + static CJointCollisionDescription OBBCollision(CSegId pivotId, const CVector3f& bounds, + const CVector3f& pivotPoint, + const rstl::string& name, float mass); + +private: + ECollisionType x0_colType; + EOrientationType x4_orientType; + CSegId x8_pivotId; + CSegId x9_nextId; + CVector3f xc_bounds; + CVector3f x18_pivotPoint; + float x24_radius; + float x28_maxSeparation; + rstl::string x2c_name; + TUniqueId x3c_actorId; + float x40_mass; +}; + +#endif // _CJOINTCOLLISIONDESCRIPTION diff --git a/include/MetroidPrime/Enemies/CNewIntroBoss.hpp b/include/MetroidPrime/Enemies/CNewIntroBoss.hpp new file mode 100644 index 00000000..877c7dd2 --- /dev/null +++ b/include/MetroidPrime/Enemies/CNewIntroBoss.hpp @@ -0,0 +1,61 @@ +#ifndef _CNEWINTROBOSS +#define _CNEWINTROBOSS + +#include "MetroidPrime/Enemies/CPatterned.hpp" + +#include "MetroidPrime/CBoneTracking.hpp" +#include "MetroidPrime/Weapons/CProjectileInfo.hpp" +#include "Kyoto/Animation/CharacterCommon.hpp" + +class CCollisionActorManager; +class CPatternedInfo; +class CNewIntroBoss : public CPatterned { +public: + CNewIntroBoss(TUniqueId, const rstl::string&, const CEntityInfo& info, const CTransform4f& xf, + const CModelData& mData, const CPatternedInfo& pInfo, + const CActorParameters& actParms, float minTurnAngle, CAssetId projectile, + const CDamageInfo& dInfo, CAssetId beamContactFxId, CAssetId beamPulseFxId, + CAssetId beamTextureId, CAssetId beamGlowTextureId); + + pas::ELocomotionType GetLocoForHealth(const CStateManager& mgr) const; + pas::EGenerateType GetGenerateForHealth(const CStateManager& mgr) const; + float GetNextAttackTime(CStateManager& mgr) const; + CVector3f PlayerPos(const CStateManager& mgr) const; + void DeleteBeam(CStateManager& mgr); + void StopRumble(CStateManager& mgr); + + float GetInitialHP() const { return x640_initialHp; } + + void Generate(CStateManager& mgr, EStateMsg msg, float arg); +private: + pas::ELocomotionType x568_locomotion; + u32 x56c_stateProg; + float x570_minTurnAngle; + CBoneTracking x574_boneTracking; + CProjectileInfo x5ac_projectileInfo; + TUniqueId x5d4_stage1Projectile; + TUniqueId x5d6_stage2Projectile; + TUniqueId x5d8_stage3Projectile; + rstl::string x5dc_damageLocator; // ??? + rstl::single_ptr< CCollisionActorManager > x5ec_collisionManager; + CAssetId x5f0_beamContactFxId; + CAssetId x5f4_beamPulseFxId; + CAssetId x5f8_beamTextureId; + CAssetId x5fc_beamGlowTextureId; + TUniqueId x600_headActor; + TUniqueId x602_pelvisActor; + CVector3f x604_predictedPlayerPos; + CVector3f x610_lookPos; + CVector3f x61c_startPlayerPos; + float x628_firingTime; + CVector3f x62c_targetPos; + float x638_; + float x63c_attackTime; + float x640_initialHp; + CTransform4f x644_initialXf; + s16 x674_rumbleVoice; + TUniqueId x676_curProjectile; + bool x678_; +}; + +#endif // _CNEWINTROBOSS diff --git a/include/MetroidPrime/Enemies/CPatterned.hpp b/include/MetroidPrime/Enemies/CPatterned.hpp index 056f8abd..fa95b6ce 100644 --- a/include/MetroidPrime/Enemies/CPatterned.hpp +++ b/include/MetroidPrime/Enemies/CPatterned.hpp @@ -67,6 +67,7 @@ public: private: char data[0xf4]; ECharacter x34c_characterType; + char data2[0x568 - 0x350]; }; #endif // _CPATTERNED diff --git a/src/MetroidPrime/CCollisionActorManager.cpp b/src/MetroidPrime/CCollisionActorManager.cpp new file mode 100644 index 00000000..3290e9f8 --- /dev/null +++ b/src/MetroidPrime/CCollisionActorManager.cpp @@ -0,0 +1,104 @@ +#include "MetroidPrime/CCollisionActorManager.hpp" + +#include "MetroidPrime/CActor.hpp" +#include "MetroidPrime/CStateManager.hpp" + +#include "MetroidPrime/TCastTo.hpp" + +CJointCollisionDescription CJointCollisionDescription::SphereCollision(CSegId pivotId, float radius, + const rstl::string& name, + float mass) { + + return CJointCollisionDescription(kCT_Sphere, pivotId, CSegId(), CVector3f::Zero(), + CVector3f::Zero(), radius, 0.f, kOT_Zero, name, mass); +} + +CJointCollisionDescription CJointCollisionDescription::SphereSubdivideCollision( + CSegId pivotId, CSegId nextId, float radius, float maxSeparation, EOrientationType orientType, + const rstl::string& name, float mass) { + return CJointCollisionDescription(kCT_SphereSubdivide, pivotId, nextId, CVector3f::Zero(), + CVector3f::Zero(), radius, maxSeparation, orientType, name, + mass); +} + +CJointCollisionDescription CJointCollisionDescription::AABoxCollision(CSegId pivotId, + const CVector3f& bounds, + const rstl::string& name, + float mass) { + return CJointCollisionDescription(kCT_AABox, pivotId, CSegId(), bounds, CVector3f::Zero(), 0.f, + 0.f, kOT_Zero, name, mass); +} + +CJointCollisionDescription CJointCollisionDescription::OBBAutoSizeCollision( + CSegId pivotId, CSegId nextId, const CVector3f& bounds, EOrientationType orientType, + const rstl::string& name, float mass) { + return CJointCollisionDescription(kCT_OBBAutoSize, pivotId, nextId, bounds, CVector3f::Zero(), + 0.f, 0.f, orientType, name, mass); +} + +CJointCollisionDescription CJointCollisionDescription::OBBCollision(CSegId pivotId, + const CVector3f& bounds, + const CVector3f& pivotPoint, + const rstl::string& name, + float mass) { + + return CJointCollisionDescription(kCT_OBB, pivotId, CSegId(), bounds, pivotPoint, 0.f, 0.f, + kOT_Zero, name, mass); +} + +void CJointCollisionDescription::ScaleAllBounds(const CVector3f& scale) { + xc_bounds = CVector3f::ByElementMultiply(scale, xc_bounds); + x24_radius *= scale.GetX(); + x28_maxSeparation *= scale.GetX(); + x18_pivotPoint = CVector3f::ByElementMultiply(scale, x18_pivotPoint); +} + +CCollisionActorManager::CCollisionActorManager( + CStateManager& mgr, TUniqueId owner, TAreaId areaId, + const rstl::vector< CJointCollisionDescription >& descs, bool active) +: x10_ownerId(owner), x12_active(active), x13_destroyed(false), x14_movable(true) { + x0_jointDescriptions.reserve(descs.size()); + for (int i = 0; i < i < descs.size(); ++i) { + TUniqueId uid = mgr.AllocateUniqueId(); + } +} + +CCollisionActorManager::~CCollisionActorManager() {} + +void CCollisionActorManager::Update(float dt, CStateManager& mgr, + EUpdateOptions updateOptions) const {} + +void CCollisionActorManager::Destroy(CStateManager& mgr) const { + for (int i = 0; i < x0_jointDescriptions.size(); ++i) { + mgr.FreeScriptObject(x0_jointDescriptions[i].GetCollisionActorId()); + } + + x13_destroyed = true; +} + +uchar CCollisionActorManager::GetActive() const { return x12_active; } + +void CCollisionActorManager::SetActive(CStateManager& mgr, bool active) { + x12_active = active; + for (int i = 0; i < x0_jointDescriptions.size(); ++i) { + CActor* act = + static_cast< CActor* >(mgr.ObjectById(x0_jointDescriptions[i].GetCollisionActorId())); + if (act != nullptr) { + if (active != act->GetActive()) { + act->SetActive(active); + if (active != false) { + Update(0.f, mgr, kUO_WorldSpace); + } + } + } + } +} + +void CCollisionActorManager::AddMaterial(CStateManager& mgr, const CMaterialList& list) { + for (int i = 0; i < x0_jointDescriptions.size(); ++i) { + CActor* act = TCastToPtr< CActor >(mgr.ObjectById(x0_jointDescriptions[i].GetCollisionActorId())); + if (act != nullptr) { + act->AddMaterial(list); + } + } +} diff --git a/src/MetroidPrime/Enemies/CNewIntroBoss.cpp b/src/MetroidPrime/Enemies/CNewIntroBoss.cpp new file mode 100644 index 00000000..0c65151a --- /dev/null +++ b/src/MetroidPrime/Enemies/CNewIntroBoss.cpp @@ -0,0 +1,62 @@ +#include "MetroidPrime/Enemies/CNewIntroBoss.hpp" + +#include "MetroidPrime/CCollisionActorManager.hpp" +#include "MetroidPrime/CHealthInfo.hpp" + +pas::ELocomotionType CNewIntroBoss::GetLocoForHealth(const CStateManager& mgr) const { + const CHealthInfo* hInfo = GetHealthInfo(mgr); + + if (hInfo->GetHP() > (.66f * x640_initialHp)) { + return pas::kLT_Relaxed; + } + + if (hInfo->GetHP() > (.33f * x640_initialHp)) { + return pas::kLT_Lurk; + } + + return pas::kLT_Combat; +} + +pas::EGenerateType CNewIntroBoss::GetGenerateForHealth(const CStateManager& mgr) const { + return GetHealthInfo(mgr)->GetHP() > 0.33f * x640_initialHp ? pas::kGType_Three + : pas::kGType_Four; +} + +float CNewIntroBoss::GetNextAttackTime(CStateManager& mgr) const { + float attackTime = 2.f * mgr.Random()->Float() + 6.f; + const CHealthInfo* hInfo = GetHealthInfo(mgr); + + if (hInfo->GetHP() > .66f * x640_initialHp) { + return attackTime; + } + if (hInfo->GetHP() > .33f * x640_initialHp) { + return attackTime - (0.4125f * attackTime); + } + + return attackTime - (0.825f * attackTime); +} + + +void CNewIntroBoss::Generate(CStateManager& mgr, EStateMsg msg, float arg) { + /* + if (msg == kStateMsg_Activate) { + x56c_stateProg = 0; + x568_locomotion = GetLocoForHealth(mgr); + SendScriptMsgs(kSS_Entered, mgr, kSM_None); + } else if (msg == kStateMsg_Update) { + if (x56c_stateProg == 0) { + if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::kAS_Generate) { + x56c_stateProg = 2; + return; + } + + x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(GetGenerateForHealth(mgr))); + } else if (x56c_stateProg == 2) { + if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::kAS_Generate) { + x56c_stateProg = 3; + SendScriptMsgs(EScriptObjectState::Exited, mgr, kSM_None); + } + } + } + */ +}