Add CRainSplashGenerator

This commit is contained in:
Henrique Gemignani Passos Lima 2023-01-08 00:59:28 +02:00
parent 472e1538ab
commit cfe395c7f4
No known key found for this signature in database
GPG Key ID: E224F951761145F8
6 changed files with 313 additions and 34 deletions

View File

@ -16,7 +16,7 @@ SetPoint__Q220CRainSplashGenerator11SRainSplashFRC9CVector3f:
/* 80269CA4 00266C04 48 00 00 10 */ b lbl_80269CB4 /* 80269CA4 00266C04 48 00 00 10 */ b lbl_80269CB4
lbl_80269CA8: lbl_80269CA8:
/* 80269CA8 00266C08 7F E3 FB 78 */ mr r3, r31 /* 80269CA8 00266C08 7F E3 FB 78 */ mr r3, r31
/* 80269CAC 00266C0C 48 00 05 41 */ bl SetActive__Q220CRainSplashGenerator11SSplashLine /* 80269CAC 00266C0C 48 00 05 41 */ bl SetActive__Q220CRainSplashGenerator11SSplashLineFv
/* 80269CB0 00266C10 3B FF 00 18 */ addi r31, r31, 0x18 /* 80269CB0 00266C10 3B FF 00 18 */ addi r31, r31, 0x18
lbl_80269CB4: lbl_80269CB4:
/* 80269CB4 00266C14 80 1D 00 00 */ lwz r0, 0(r29) /* 80269CB4 00266C14 80 1D 00 00 */ lwz r0, 0(r29)
@ -39,8 +39,8 @@ lbl_80269CB4:
/* 80269CF8 00266C58 38 21 00 20 */ addi r1, r1, 0x20 /* 80269CF8 00266C58 38 21 00 20 */ addi r1, r1, 0x20
/* 80269CFC 00266C5C 4E 80 00 20 */ blr /* 80269CFC 00266C5C 4E 80 00 20 */ blr
.global IsActive__Q220CRainSplashGenerator11SRainSplashCFfR13CStateManager .global IsActive__Q220CRainSplashGenerator11SRainSplashCFv
IsActive__Q220CRainSplashGenerator11SRainSplashCFfR13CStateManager: IsActive__Q220CRainSplashGenerator11SRainSplashCFv:
/* 80269D00 00266C60 80 03 00 00 */ lwz r0, 0(r3) /* 80269D00 00266C60 80 03 00 00 */ lwz r0, 0(r3)
/* 80269D04 00266C64 38 A3 00 04 */ addi r5, r3, 4 /* 80269D04 00266C64 38 A3 00 04 */ addi r5, r3, 4
/* 80269D08 00266C68 38 80 00 00 */ li r4, 0 /* 80269D08 00266C68 38 80 00 00 */ li r4, 0
@ -136,8 +136,8 @@ lbl_80269E10:
/* 80269E40 00266DA0 38 21 00 20 */ addi r1, r1, 0x20 /* 80269E40 00266DA0 38 21 00 20 */ addi r1, r1, 0x20
/* 80269E44 00266DA4 4E 80 00 20 */ blr /* 80269E44 00266DA4 4E 80 00 20 */ blr
.global __ct__Q220CRainSplashGenerator11SRainSplash .global __ct__Q220CRainSplashGenerator11SRainSplashFv
__ct__Q220CRainSplashGenerator11SRainSplash: __ct__Q220CRainSplashGenerator11SRainSplashFv:
/* 80269E48 00266DA8 94 21 FF E0 */ stwu r1, -0x20(r1) /* 80269E48 00266DA8 94 21 FF E0 */ stwu r1, -0x20(r1)
/* 80269E4C 00266DAC 38 A0 00 01 */ li r5, 1 /* 80269E4C 00266DAC 38 A0 00 01 */ li r5, 1
/* 80269E50 00266DB0 C0 62 BB 54 */ lfs f3, lbl_805AD874@sda21(r2) /* 80269E50 00266DB0 C0 62 BB 54 */ lfs f3, lbl_805AD874@sda21(r2)
@ -389,8 +389,8 @@ lbl_8026A1D4:
/* 8026A1E4 00267144 38 21 00 20 */ addi r1, r1, 0x20 /* 8026A1E4 00267144 38 21 00 20 */ addi r1, r1, 0x20
/* 8026A1E8 00267148 4E 80 00 20 */ blr /* 8026A1E8 00267148 4E 80 00 20 */ blr
.global SetActive__Q220CRainSplashGenerator11SSplashLine .global SetActive__Q220CRainSplashGenerator11SSplashLineFv
SetActive__Q220CRainSplashGenerator11SSplashLine: SetActive__Q220CRainSplashGenerator11SSplashLineFv:
/* 8026A1EC 0026714C 88 03 00 16 */ lbz r0, 0x16(r3) /* 8026A1EC 0026714C 88 03 00 16 */ lbz r0, 0x16(r3)
/* 8026A1F0 00267150 38 80 00 01 */ li r4, 1 /* 8026A1F0 00267150 38 80 00 01 */ li r4, 1
/* 8026A1F4 00267154 50 80 3E 30 */ rlwimi r0, r4, 7, 0x18, 0x18 /* 8026A1F4 00267154 50 80 3E 30 */ rlwimi r0, r4, 7, 0x18, 0x18
@ -649,7 +649,7 @@ lbl_8026A560:
/* 8026A570 002674D0 7F E3 FB 78 */ mr r3, r31 /* 8026A570 002674D0 7F E3 FB 78 */ mr r3, r31
/* 8026A574 002674D4 4B FF F8 59 */ bl Update__Q220CRainSplashGenerator11SRainSplashFfR13CStateManager /* 8026A574 002674D4 4B FF F8 59 */ bl Update__Q220CRainSplashGenerator11SRainSplashFfR13CStateManager
/* 8026A578 002674D8 7F E3 FB 78 */ mr r3, r31 /* 8026A578 002674D8 7F E3 FB 78 */ mr r3, r31
/* 8026A57C 002674DC 4B FF F7 85 */ bl IsActive__Q220CRainSplashGenerator11SRainSplashCFfR13CStateManager /* 8026A57C 002674DC 4B FF F7 85 */ bl IsActive__Q220CRainSplashGenerator11SRainSplashCFv
/* 8026A580 002674E0 54 60 06 3F */ clrlwi. r0, r3, 0x18 /* 8026A580 002674E0 54 60 06 3F */ clrlwi. r0, r3, 0x18
/* 8026A584 002674E4 40 82 00 34 */ bne lbl_8026A5B8 /* 8026A584 002674E4 40 82 00 34 */ bne lbl_8026A5B8
/* 8026A588 002674E8 80 7A 00 40 */ lwz r3, 0x40(r26) /* 8026A588 002674E8 80 7A 00 40 */ lwz r3, 0x40(r26)
@ -841,15 +841,15 @@ lbl_8026A804:
/* 8026A824 00267784 88 1F 00 48 */ lbz r0, 0x48(r31) /* 8026A824 00267784 88 1F 00 48 */ lbz r0, 0x48(r31)
/* 8026A828 00267788 50 A0 36 72 */ rlwimi r0, r5, 6, 0x19, 0x19 /* 8026A828 00267788 50 A0 36 72 */ rlwimi r0, r5, 6, 0x19, 0x19
/* 8026A82C 0026778C 98 1F 00 48 */ stb r0, 0x48(r31) /* 8026A82C 0026778C 98 1F 00 48 */ stb r0, 0x48(r31)
/* 8026A830 00267790 48 00 03 89 */ bl sub_8026abb8 /* 8026A830 00267790 48 00 03 89 */ bl "reserve__Q24rstl72vector<Q220CRainSplashGenerator11SRainSplash,Q24rstl17rmemory_allocator>Fi"
/* 8026A834 00267794 3B C0 00 00 */ li r30, 0 /* 8026A834 00267794 3B C0 00 00 */ li r30, 0
/* 8026A838 00267798 48 00 00 74 */ b lbl_8026A8AC /* 8026A838 00267798 48 00 00 74 */ b lbl_8026A8AC
lbl_8026A83C: lbl_8026A83C:
/* 8026A83C 0026779C 38 61 00 08 */ addi r3, r1, 8 /* 8026A83C 0026779C 38 61 00 08 */ addi r3, r1, 8
/* 8026A840 002677A0 4B FF F6 09 */ bl __ct__Q220CRainSplashGenerator11SRainSplash /* 8026A840 002677A0 4B FF F6 09 */ bl __ct__Q220CRainSplashGenerator11SRainSplashFv
/* 8026A844 002677A4 7F E3 FB 78 */ mr r3, r31 /* 8026A844 002677A4 7F E3 FB 78 */ mr r3, r31
/* 8026A848 002677A8 38 81 00 08 */ addi r4, r1, 8 /* 8026A848 002677A8 38 81 00 08 */ addi r4, r1, 8
/* 8026A84C 002677AC 48 00 00 9D */ bl "push_back__Q24rstl45vector<Q220CRainSplashGenerator11SRainSplash>FRCQ220CRainSplashGenerator11SRainSplash" /* 8026A84C 002677AC 48 00 00 9D */ bl "push_back__Q24rstl72vector<Q220CRainSplashGenerator11SRainSplash,Q24rstl17rmemory_allocator>FRCQ220CRainSplashGenerator11SRainSplash"
/* 8026A850 002677B0 80 A1 00 08 */ lwz r5, 8(r1) /* 8026A850 002677B0 80 A1 00 08 */ lwz r5, 8(r1)
/* 8026A854 002677B4 38 60 00 00 */ li r3, 0 /* 8026A854 002677B4 38 60 00 00 */ li r3, 0
/* 8026A858 002677B8 2C 05 00 00 */ cmpwi r5, 0 /* 8026A858 002677B8 2C 05 00 00 */ cmpwi r5, 0
@ -894,8 +894,8 @@ lbl_8026A8AC:
/* 8026A8E0 00267840 38 21 00 B0 */ addi r1, r1, 0xb0 /* 8026A8E0 00267840 38 21 00 B0 */ addi r1, r1, 0xb0
/* 8026A8E4 00267844 4E 80 00 20 */ blr /* 8026A8E4 00267844 4E 80 00 20 */ blr
.global "push_back__Q24rstl45vector<Q220CRainSplashGenerator11SRainSplash>FRCQ220CRainSplashGenerator11SRainSplash" .global "push_back__Q24rstl72vector<Q220CRainSplashGenerator11SRainSplash,Q24rstl17rmemory_allocator>FRCQ220CRainSplashGenerator11SRainSplash"
"push_back__Q24rstl45vector<Q220CRainSplashGenerator11SRainSplash>FRCQ220CRainSplashGenerator11SRainSplash": "push_back__Q24rstl72vector<Q220CRainSplashGenerator11SRainSplash,Q24rstl17rmemory_allocator>FRCQ220CRainSplashGenerator11SRainSplash":
/* 8026A8E8 00267848 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8026A8E8 00267848 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 8026A8EC 0026784C 7C 08 02 A6 */ mflr r0 /* 8026A8EC 0026784C 7C 08 02 A6 */ mflr r0
/* 8026A8F0 00267850 90 01 00 14 */ stw r0, 0x14(r1) /* 8026A8F0 00267850 90 01 00 14 */ stw r0, 0x14(r1)
@ -912,14 +912,14 @@ lbl_8026A8AC:
/* 8026A91C 0026787C 41 82 00 08 */ beq lbl_8026A924 /* 8026A91C 0026787C 41 82 00 08 */ beq lbl_8026A924
/* 8026A920 00267880 54 A4 08 3C */ slwi r4, r5, 1 /* 8026A920 00267880 54 A4 08 3C */ slwi r4, r5, 1
lbl_8026A924: lbl_8026A924:
/* 8026A924 00267884 48 00 02 95 */ bl sub_8026abb8 /* 8026A924 00267884 48 00 02 95 */ bl "reserve__Q24rstl72vector<Q220CRainSplashGenerator11SRainSplash,Q24rstl17rmemory_allocator>Fi"
lbl_8026A928: lbl_8026A928:
/* 8026A928 00267888 80 1E 00 04 */ lwz r0, 4(r30) /* 8026A928 00267888 80 1E 00 04 */ lwz r0, 4(r30)
/* 8026A92C 0026788C 7F E4 FB 78 */ mr r4, r31 /* 8026A92C 0026788C 7F E4 FB 78 */ mr r4, r31
/* 8026A930 00267890 80 7E 00 0C */ lwz r3, 0xc(r30) /* 8026A930 00267890 80 7E 00 0C */ lwz r3, 0xc(r30)
/* 8026A934 00267894 1C 00 00 74 */ mulli r0, r0, 0x74 /* 8026A934 00267894 1C 00 00 74 */ mulli r0, r0, 0x74
/* 8026A938 00267898 7C 63 02 14 */ add r3, r3, r0 /* 8026A938 00267898 7C 63 02 14 */ add r3, r3, r0
/* 8026A93C 0026789C 48 00 00 29 */ bl __ct__Q220CRainSplashGenerator11SRainSplashFRCQ220CRainSplashGenerator11SRainSplash /* 8026A93C 0026789C 48 00 00 29 */ bl __ct__Q220CRainSplashGenerator11SRainSplashFvFRCQ220CRainSplashGenerator11SRainSplash
/* 8026A940 002678A0 80 7E 00 04 */ lwz r3, 4(r30) /* 8026A940 002678A0 80 7E 00 04 */ lwz r3, 4(r30)
/* 8026A944 002678A4 38 03 00 01 */ addi r0, r3, 1 /* 8026A944 002678A4 38 03 00 01 */ addi r0, r3, 1
/* 8026A948 002678A8 90 1E 00 04 */ stw r0, 4(r30) /* 8026A948 002678A8 90 1E 00 04 */ stw r0, 4(r30)
@ -930,8 +930,8 @@ lbl_8026A928:
/* 8026A95C 002678BC 38 21 00 10 */ addi r1, r1, 0x10 /* 8026A95C 002678BC 38 21 00 10 */ addi r1, r1, 0x10
/* 8026A960 002678C0 4E 80 00 20 */ blr /* 8026A960 002678C0 4E 80 00 20 */ blr
.global __ct__Q220CRainSplashGenerator11SRainSplashFRCQ220CRainSplashGenerator11SRainSplash .global __ct__Q220CRainSplashGenerator11SRainSplashFvFRCQ220CRainSplashGenerator11SRainSplash
__ct__Q220CRainSplashGenerator11SRainSplashFRCQ220CRainSplashGenerator11SRainSplash: __ct__Q220CRainSplashGenerator11SRainSplashFvFRCQ220CRainSplashGenerator11SRainSplash:
/* 8026A964 002678C4 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8026A964 002678C4 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 8026A968 002678C8 7C 08 02 A6 */ mflr r0 /* 8026A968 002678C8 7C 08 02 A6 */ mflr r0
/* 8026A96C 002678CC 28 03 00 00 */ cmplwi r3, 0 /* 8026A96C 002678CC 28 03 00 00 */ cmplwi r3, 0
@ -1097,8 +1097,8 @@ lbl_8026AB74:
/* 8026ABB0 00267B10 38 21 00 80 */ addi r1, r1, 0x80 /* 8026ABB0 00267B10 38 21 00 80 */ addi r1, r1, 0x80
/* 8026ABB4 00267B14 4E 80 00 20 */ blr /* 8026ABB4 00267B14 4E 80 00 20 */ blr
.global sub_8026abb8 .global "reserve__Q24rstl72vector<Q220CRainSplashGenerator11SRainSplash,Q24rstl17rmemory_allocator>Fi"
sub_8026abb8: "reserve__Q24rstl72vector<Q220CRainSplashGenerator11SRainSplash,Q24rstl17rmemory_allocator>Fi":
/* 8026ABB8 00267B18 94 21 FF D0 */ stwu r1, -0x30(r1) /* 8026ABB8 00267B18 94 21 FF D0 */ stwu r1, -0x30(r1)
/* 8026ABBC 00267B1C 7C 08 02 A6 */ mflr r0 /* 8026ABBC 00267B1C 7C 08 02 A6 */ mflr r0
/* 8026ABC0 00267B20 90 01 00 34 */ stw r0, 0x34(r1) /* 8026ABC0 00267B20 90 01 00 34 */ stw r0, 0x34(r1)
@ -1134,7 +1134,7 @@ lbl_8026AC0C:
/* 8026AC30 00267B90 90 C1 00 08 */ stw r6, 8(r1) /* 8026AC30 00267B90 90 C1 00 08 */ stw r6, 8(r1)
/* 8026AC34 00267B94 90 01 00 10 */ stw r0, 0x10(r1) /* 8026AC34 00267B94 90 01 00 10 */ stw r0, 0x10(r1)
/* 8026AC38 00267B98 90 01 00 14 */ stw r0, 0x14(r1) /* 8026AC38 00267B98 90 01 00 14 */ stw r0, 0x14(r1)
/* 8026AC3C 00267B9C 48 00 00 BD */ bl sub_8026acf8 /* 8026AC3C 00267B9C 48 00 00 BD */ bl "uninitialized_copy<Q24rstl164pointer_iterator<Q220CRainSplashGenerator11SRainSplash,Q24rstl72vector<Q220CRainSplashGenerator11SRainSplash,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>,Q220CRainSplashGenerator11SRainSplash>__4rstlFQ24rstl164pointer_iterator<Q220CRainSplashGenerator11SRainSplash,Q24rstl72vector<Q220CRainSplashGenerator11SRainSplash,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl164pointer_iterator<Q220CRainSplashGenerator11SRainSplash,Q24rstl72vector<Q220CRainSplashGenerator11SRainSplash,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>PQ220CRainSplashGenerator11SRainSplash"
/* 8026AC40 00267BA0 80 1E 00 04 */ lwz r0, 4(r30) /* 8026AC40 00267BA0 80 1E 00 04 */ lwz r0, 4(r30)
/* 8026AC44 00267BA4 80 DE 00 0C */ lwz r6, 0xc(r30) /* 8026AC44 00267BA4 80 DE 00 0C */ lwz r6, 0xc(r30)
/* 8026AC48 00267BA8 1C 00 00 74 */ mulli r0, r0, 0x74 /* 8026AC48 00267BA8 1C 00 00 74 */ mulli r0, r0, 0x74
@ -1191,8 +1191,8 @@ lbl_8026ACDC:
/* 8026ACF0 00267C50 38 21 00 30 */ addi r1, r1, 0x30 /* 8026ACF0 00267C50 38 21 00 30 */ addi r1, r1, 0x30
/* 8026ACF4 00267C54 4E 80 00 20 */ blr /* 8026ACF4 00267C54 4E 80 00 20 */ blr
.global sub_8026acf8 .global "uninitialized_copy<Q24rstl164pointer_iterator<Q220CRainSplashGenerator11SRainSplash,Q24rstl72vector<Q220CRainSplashGenerator11SRainSplash,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>,Q220CRainSplashGenerator11SRainSplash>__4rstlFQ24rstl164pointer_iterator<Q220CRainSplashGenerator11SRainSplash,Q24rstl72vector<Q220CRainSplashGenerator11SRainSplash,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl164pointer_iterator<Q220CRainSplashGenerator11SRainSplash,Q24rstl72vector<Q220CRainSplashGenerator11SRainSplash,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>PQ220CRainSplashGenerator11SRainSplash"
sub_8026acf8: "uninitialized_copy<Q24rstl164pointer_iterator<Q220CRainSplashGenerator11SRainSplash,Q24rstl72vector<Q220CRainSplashGenerator11SRainSplash,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>,Q220CRainSplashGenerator11SRainSplash>__4rstlFQ24rstl164pointer_iterator<Q220CRainSplashGenerator11SRainSplash,Q24rstl72vector<Q220CRainSplashGenerator11SRainSplash,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl164pointer_iterator<Q220CRainSplashGenerator11SRainSplash,Q24rstl72vector<Q220CRainSplashGenerator11SRainSplash,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>PQ220CRainSplashGenerator11SRainSplash":
/* 8026ACF8 00267C58 94 21 FF E0 */ stwu r1, -0x20(r1) /* 8026ACF8 00267C58 94 21 FF E0 */ stwu r1, -0x20(r1)
/* 8026ACFC 00267C5C 7C 08 02 A6 */ mflr r0 /* 8026ACFC 00267C5C 7C 08 02 A6 */ mflr r0
/* 8026AD00 00267C60 90 01 00 24 */ stw r0, 0x24(r1) /* 8026AD00 00267C60 90 01 00 24 */ stw r0, 0x24(r1)
@ -1206,7 +1206,7 @@ sub_8026acf8:
lbl_8026AD20: lbl_8026AD20:
/* 8026AD20 00267C80 7F C3 F3 78 */ mr r3, r30 /* 8026AD20 00267C80 7F C3 F3 78 */ mr r3, r30
/* 8026AD24 00267C84 7F E4 FB 78 */ mr r4, r31 /* 8026AD24 00267C84 7F E4 FB 78 */ mr r4, r31
/* 8026AD28 00267C88 4B FF FC 3D */ bl __ct__Q220CRainSplashGenerator11SRainSplashFRCQ220CRainSplashGenerator11SRainSplash /* 8026AD28 00267C88 4B FF FC 3D */ bl __ct__Q220CRainSplashGenerator11SRainSplashFvFRCQ220CRainSplashGenerator11SRainSplash
/* 8026AD2C 00267C8C 3B DE 00 74 */ addi r30, r30, 0x74 /* 8026AD2C 00267C8C 3B DE 00 74 */ addi r30, r30, 0x74
/* 8026AD30 00267C90 3B FF 00 74 */ addi r31, r31, 0x74 /* 8026AD30 00267C90 3B FF 00 74 */ addi r31, r31, 0x74
lbl_8026AD34: lbl_8026AD34:

View File

@ -342,7 +342,7 @@ LIBS = [
"MetroidPrime/Player/CGameHintInfo", "MetroidPrime/Player/CGameHintInfo",
"MetroidPrime/Enemies/CWallWalker", "MetroidPrime/Enemies/CWallWalker",
["MetroidPrime/CErrorOutputWindow", False], ["MetroidPrime/CErrorOutputWindow", False],
"MetroidPrime/CRainSplashGenerator", ["MetroidPrime/CRainSplashGenerator", False],
"MetroidPrime/Factories/CWorldSaveGameInfoFactory", "MetroidPrime/Factories/CWorldSaveGameInfoFactory",
"MetroidPrime/CFluidPlaneRender", "MetroidPrime/CFluidPlaneRender",
"MetroidPrime/Enemies/CBurrower", "MetroidPrime/Enemies/CBurrower",

View File

@ -43,6 +43,8 @@ public:
static void Initialize(); static void Initialize();
void SetFxDensity(int, float); void SetFxDensity(int, float);
void SetSplashRate(float f) { xb54_baseSplashRate = f; } void SetSplashRate(float f) { xb54_baseSplashRate = f; }
bool IsSplashActive() const { return x24_enableSplash; }
float GetRainMagnitude() const { return x30_fxDensity; }
void Cleanup(); void Cleanup();
private: private:

View File

@ -10,6 +10,8 @@
class CVector3f; class CVector3f;
class CStateManager; class CStateManager;
class CTransform4f;
class SSkinningWorkspace;
class CRainSplashGenerator { class CRainSplashGenerator {
struct SSplashLine { struct SSplashLine {
@ -21,20 +23,34 @@ class CRainSplashGenerator {
uchar x14_; uchar x14_;
uchar x15_length; uchar x15_length;
bool x16_active : 1; bool x16_active : 1;
SSplashLine();
SSplashLine()
: x0_t(0.0f)
, x4_xEnd(0.0f)
, x8_yEnd(0.0f)
, xc_speed(4.0f)
, x10_zParabolaHeight(0.015625f) // 1/64?
, x14_(3)
, x15_length(1)
, x16_active(true) {}
void Update(float dt, CStateManager& mgr); void Update(float dt, CStateManager& mgr);
void Draw(float alpha, float dt, const CVector3f& pos); void Draw(float alpha, float dt, const CVector3f& pos) const;
void SetActive() { x16_active = true; } void SetActive();
}; };
struct SRainSplash { struct SRainSplash {
rstl::reserved_vector< SSplashLine, 4 > x0_lines; rstl::reserved_vector< SSplashLine, 4 > x0_lines;
CVector3f x64_pos; CVector3f x64_pos;
float x70_; float x70_;
SRainSplash(); SRainSplash();
SRainSplash(const SRainSplash&);
void operator=(const SRainSplash&);
void Update(float dt, CStateManager& mgr); void Update(float dt, CStateManager& mgr);
bool IsActive() const; bool IsActive() const;
void Draw(float alpha, float dt, const CVector3f& pos); void Draw(float alpha, float dt, const CVector3f& pos) const;
void SetPoint(const CVector3f& pos); void SetPoint(const CVector3f& pos);
}; };
@ -43,8 +59,9 @@ public:
float alpha); float alpha);
~CRainSplashGenerator() {} ~CRainSplashGenerator() {}
bool IsRaining() const { return x48_25_raining; } bool IsRaining() const { return x48_25_raining; }
void Update(float dt, CStateManager& mgr);
void Draw(const CTransform4f& xf) const; void Draw(const CTransform4f& xf) const;
void GeneratePoints(const CVector3f* vertices, const CVector3f* normals, int count); void GeneratePoints(const CVector3f* vertices, const CVector3f* normals, int count);
@ -57,13 +74,20 @@ private:
float x28_dt; float x28_dt;
float x2c_minZ; float x2c_minZ;
float x30_alpha; float x30_alpha;
uint x34_curPoint; int x34_curPoint;
uint x38_queueTail; int x38_queueTail;
uint x3c_queueHead; int x3c_queueHead;
uint x40_queueSize; int x40_queueSize;
uint x44_genRate; int x44_genRate;
bool x48_24 : 1; bool x48_24 : 1;
bool x48_25_raining : 1; bool x48_25_raining : 1;
void UpdateRainSplashRange(CStateManager& mgr, int start, int end, float dt);
void UpdateRainSplashes(CStateManager& mgr, float magnitude, float dt);
void AddPoint(const CVector3f& pos);
void DoDraw(const CTransform4f& xf) const;
int GetNextBestPt(int, const CVector3f*, const CVector3f*, int, CRandom16&, float);
}; };
CHECK_SIZEOF(CRainSplashGenerator, 0x4c) CHECK_SIZEOF(CRainSplashGenerator, 0x4c)

View File

@ -87,6 +87,7 @@ public:
TAreaId GetCurrentAreaId() const { return x68_curAreaId; } TAreaId GetCurrentAreaId() const { return x68_curAreaId; }
TAreaId GetAreaIdForSaveId(int saveId) const; TAreaId GetAreaIdForSaveId(int saveId) const;
const rstl::vector< CRelay >& GetRelays() const { return x2c_relays; } const rstl::vector< CRelay >& GetRelays() const { return x2c_relays; }
EEnvFxType GetNeededEnvFx() const { return xc4_neededFx; }
static void PropogateAreaChain(CGameArea::EOcclusionState occlusionState, CGameArea* area, static void PropogateAreaChain(CGameArea::EOcclusionState occlusionState, CGameArea* area,
CWorld* world); CWorld* world);

View File

@ -0,0 +1,252 @@
#include "MetroidPrime/CRainSplashGenerator.hpp"
#include "MetroidPrime/CEnvFxManager.hpp"
#include "MetroidPrime/CStateManager.hpp"
#include "MetroidPrime/CWorld.hpp"
#include "Kyoto/Graphics/CGX.hpp"
#include "Kyoto/Graphics/CGraphics.hpp"
#include "rstl/math.hpp"
GXVtxDescList vtxDescv[] = {
{GX_VA_POS, GX_DIRECT},
{GX_VA_CLR0, GX_DIRECT},
{GX_VA_NULL, GX_NONE},
};
int CRainSplashGenerator::GetNextBestPt(int pt, const CVector3f* vertices, const CVector3f* normals,
int count, CRandom16& rand, float minZ) {
const CVector3f& refVert = vertices[pt];
float maxDist = 0.f;
int nextPt = pt;
for (int i = 0; i < 3; ++i) {
bool goodNorm = false;
const int idx = rand.Range(0, count - 1);
const CVector3f& vert = vertices[idx];
const CVector3f& norm = normals[idx];
const float distSq = (refVert - vert).MagSquared();
const float normDot = CVector3f::Dot(norm, CVector3f::Up());
if (0.0f <= normDot && normDot <= 1.0f) {
goodNorm = true;
}
bool goodZ = minZ < 0.0f || minZ < vert.GetZ();
if (distSq > maxDist && goodNorm && goodZ) {
nextPt = idx;
maxDist = distSq;
}
}
return nextPt;
}
CRainSplashGenerator::CRainSplashGenerator(const CVector3f& scale, int maxSplashes, int genRate,
float minZ, float alpha)
: x14_scale(scale)
, x20_generateTimer(0.f)
, x28_dt(0.f)
, x2c_minZ(minZ)
, x30_alpha(alpha > 1.0f ? 255.f : alpha * 255.f)
, x34_curPoint(0)
, x38_queueTail(0)
, x3c_queueHead(0)
, x40_queueSize(0)
, x44_genRate(rstl::min_val(maxSplashes, genRate)) {
x0_rainSplashes.reserve(maxSplashes);
for (int i = 0; i < maxSplashes; ++i)
x0_rainSplashes.push_back(SRainSplash());
}
// CRainSplashGenerator::SSplashLine::SSplashLine() {}
void CRainSplashGenerator::AddPoint(const CVector3f& pos) {
if (x38_queueTail >= x0_rainSplashes.size())
x38_queueTail = 0;
x0_rainSplashes[x38_queueTail].SetPoint(pos);
x40_queueSize += 1;
x38_queueTail += 1;
}
void CRainSplashGenerator::GeneratePoints(const CVector3f* vertices, const CVector3f* normals, int count) {
if (!x48_25_raining)
return;
if (x20_generateTimer > x24_generateInterval) {
int pt = x34_curPoint;
for (int i = 0; i < x44_genRate; ++i) {
if (x40_queueSize >= x0_rainSplashes.size())
break;
pt = GetNextBestPt(x34_curPoint, vertices, normals, count, x10_random, x2c_minZ);
AddPoint(CVector3f::ByElementMultiply(x14_scale, vertices[pt]));
}
x34_curPoint = pt;
x20_generateTimer = 0.f;
}
}
void CRainSplashGenerator::UpdateRainSplashRange(CStateManager& mgr, int start, int end, float dt) {
for (int i = start; i < end; ++i) {
SRainSplash& set = x0_rainSplashes[i];
set.Update(dt, mgr);
if (!set.IsActive()) {
x40_queueSize -= 1;
x3c_queueHead += 1;
if (x3c_queueHead >= x0_rainSplashes.size())
x3c_queueHead = 0;
}
}
}
void CRainSplashGenerator::UpdateRainSplashes(CStateManager& mgr, float magnitude, float dt) {
x20_generateTimer += dt;
x24_generateInterval = 1.f / (70.f * magnitude);
if (x40_queueSize > 0) {
if (x38_queueTail <= x3c_queueHead) {
UpdateRainSplashRange(mgr, x3c_queueHead, int(x0_rainSplashes.size()), dt);
UpdateRainSplashRange(mgr, 0, x38_queueTail, dt);
} else {
UpdateRainSplashRange(mgr, x3c_queueHead, x38_queueTail, dt);
}
}
}
void CRainSplashGenerator::Update(float dt, CStateManager& mgr) {
EEnvFxType neededFx = mgr.GetWorld()->GetNeededEnvFx();
x28_dt = dt;
x48_25_raining = false;
if (neededFx != kEFX_None && mgr.GetEnvFxManager()->IsSplashActive()) {
if (mgr.GetEnvFxManager()->GetRainMagnitude() != 0.f) {
switch (neededFx) {
case kEFX_Rain:
UpdateRainSplashes(mgr, mgr.GetEnvFxManager()->GetRainMagnitude(), dt);
x48_25_raining = true;
break;
default:
break;
}
}
}
}
void CRainSplashGenerator::Draw(const CTransform4f& xf) const {
if (!x48_25_raining) {
return;
}
DoDraw(xf);
}
void CRainSplashGenerator::DoDraw(const CTransform4f& xf) const {
if (!(x28_dt <= 0.0f)) {
CGX::SetVtxDescv(vtxDescv);
CGX::SetNumChans(1);
CGX::SetNumTevStages(1);
CGX::SetChanCtrl(CGX::Channel0, false, GX_SRC_VTX, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE,
GX_AF_NONE);
CGX::SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
CGX::SetNumTexGens(0);
CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
CGX::SetZMode(true, GX_LEQUAL, false);
CGraphics::SetTevOp(kTS_Stage0, CGraphics::kEnvPassthru);
CGraphics::SetTevOp(kTS_Stage1, CGraphics::kEnvPassthru);
CGraphics::SetModelMatrix(xf);
if (x40_queueSize > 0) {
if (x38_queueTail <= x3c_queueHead) {
for (int i = x3c_queueHead; i < x0_rainSplashes.size(); ++i) {
const SRainSplash& splash = x0_rainSplashes[i];
splash.Draw(x30_alpha, x28_dt, splash.x64_pos);
}
for (int i = 0; i < x38_queueTail; ++i) {
const SRainSplash& splash = x0_rainSplashes[i];
splash.Draw(x30_alpha, x28_dt, splash.x64_pos);
}
} else {
for (int i = x3c_queueHead; i < x38_queueTail; ++i) {
const SRainSplash& splash = x0_rainSplashes[i];
splash.Draw(x30_alpha, x28_dt, splash.x64_pos);
}
}
}
CGX::SetLineWidth(6, GX_TO_ZERO);
}
}
void CRainSplashGenerator::SSplashLine::SetActive() { x16_active = true; }
void CRainSplashGenerator::SSplashLine::Update(float dt, CStateManager& mgr) {
if (!x16_active)
return;
if (x0_t <= 0.8f) {
x14_ = u8(5.f * (1.f - x0_t) + 3.f * x0_t);
x0_t += dt * xc_speed;
} else if (x15_length != 0) {
x15_length -= 1;
} else {
x16_active = false;
xc_speed = mgr.Random()->Range(4.0f, 8.0f);
x10_zParabolaHeight = mgr.Random()->Range(0.015625f, 0.03125f);
x4_xEnd = mgr.Random()->Range(-0.125f, 0.125f);
x8_yEnd = mgr.Random()->Range(-0.125f, 0.125f);
x15_length = u8(mgr.Random()->Range(1, 2));
}
}
void CRainSplashGenerator::SSplashLine::Draw(float alpha, float dt, const CVector3f& pos) const {
if (x0_t > 0.f) {
float delta = dt * xc_speed;
float vt = x0_t - delta * x15_length;
if (vt < 0.0f) {
vt = 0.0f;
}
int vertCount = int((x0_t - vt) / delta + 1.f);
CGX::SetLineWidth(x14_ * 6, GX_TO_ZERO);
CGX::Begin(GX_LINESTRIP, GX_VTXFMT0, vertCount);
int i = 0;
while (i < vertCount) {
GXPosition3f32(vt * x4_xEnd + pos.GetX(), vt * x8_yEnd + pos.GetY(),
-4.f * vt * (vt - 1.f) * x10_zParabolaHeight + pos.GetZ());
uint a = vt * alpha;
vt += delta;
i++;
GXColor1u32(a | 0xffffff00);
}
CGX::End();
}
}
CRainSplashGenerator::SRainSplash::SRainSplash()
: x0_lines(SSplashLine()), x64_pos(CVector3f::Zero()), x70_(0.0f) {}
void CRainSplashGenerator::SRainSplash::Update(float dt, CStateManager& mgr) {
for (rstl::reserved_vector< SSplashLine, 4 >::iterator it = x0_lines.begin();
it != x0_lines.end(); +it)
it->Update(dt, mgr);
}
void CRainSplashGenerator::SRainSplash::Draw(float alpha, float dt, const CVector3f& pos) const {
for (rstl::reserved_vector< SSplashLine, 4 >::const_iterator it = x0_lines.begin();
it != x0_lines.end(); +it) {
it->Draw(alpha, dt, pos);
}
}
bool CRainSplashGenerator::SRainSplash::IsActive() const {
bool ret = false;
for (rstl::reserved_vector< SSplashLine, 4 >::const_iterator it = x0_lines.begin();
it != x0_lines.end(); +it) {
ret |= it->x16_active;
}
return ret;
}
void CRainSplashGenerator::SRainSplash::SetPoint(const CVector3f& pos) {
for (rstl::reserved_vector< SSplashLine, 4 >::iterator it = x0_lines.begin();
it != x0_lines.end(); +it)
it->SetActive();
x64_pos = pos;
}