From b060c73b132943233a26e81a9a561e0f2ef636e0 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Mon, 28 Nov 2022 19:00:49 +0200 Subject: [PATCH] Add CStateManager::BuildDynamicLightListForWorld Former-commit-id: 0c29161e11d45057804ea758af525813b846f879 --- asm/MetaRender/CCubeRenderer.s | 4 +- asm/MetroidPrime/CGameArea.s | 10 ++--- asm/MetroidPrime/CStateManager.s | 62 +++++++++++++------------- asm/MetroidPrime/CWorldTransManager.s | 6 +-- include/Kyoto/Graphics/CLight.hpp | 3 +- include/MetroidPrime/CStateManager.hpp | 1 + src/MetroidPrime/CStateManager.cpp | 46 +++++++++++++++++++ 7 files changed, 90 insertions(+), 42 deletions(-) diff --git a/asm/MetaRender/CCubeRenderer.s b/asm/MetaRender/CCubeRenderer.s index c581c4fe..e6e6c005 100644 --- a/asm/MetaRender/CCubeRenderer.s +++ b/asm/MetaRender/CCubeRenderer.s @@ -2260,7 +2260,7 @@ lbl_802B7A24: /* 802B7A6C 002B49CC 38 81 00 50 */ addi r4, r1, 0x50 /* 802B7A70 002B49D0 90 01 00 58 */ stw r0, 0x58(r1) /* 802B7A74 002B49D4 90 01 00 5C */ stw r0, 0x5c(r1) -/* 802B7A78 002B49D8 4B D8 DF F1 */ bl sub_80045a68 +/* 802B7A78 002B49D8 4B D8 DF F1 */ bl "__as__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>FRCQ24rstl42vector<6CLight,Q24rstl17rmemory_allocator>" /* 802B7A7C 002B49DC 80 01 00 54 */ lwz r0, 0x54(r1) /* 802B7A80 002B49E0 80 61 00 5C */ lwz r3, 0x5c(r1) /* 802B7A84 002B49E4 1C 00 00 50 */ mulli r0, r0, 0x50 @@ -2282,7 +2282,7 @@ lbl_802B7AA8: lbl_802B7ABC: /* 802B7ABC 002B4A1C 7F A4 EB 78 */ mr r4, r29 /* 802B7AC0 002B4A20 38 7C 03 00 */ addi r3, r28, 0x300 -/* 802B7AC4 002B4A24 4B D8 DF A5 */ bl sub_80045a68 +/* 802B7AC4 002B4A24 4B D8 DF A5 */ bl "__as__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>FRCQ24rstl42vector<6CLight,Q24rstl17rmemory_allocator>" /* 802B7AC8 002B4A28 83 FC 00 20 */ lwz r31, 0x20(r28) /* 802B7ACC 002B4A2C 48 00 01 3C */ b lbl_802B7C08 lbl_802B7AD0: diff --git a/asm/MetroidPrime/CGameArea.s b/asm/MetroidPrime/CGameArea.s index 187f93af..31a02bd2 100644 --- a/asm/MetroidPrime/CGameArea.s +++ b/asm/MetroidPrime/CGameArea.s @@ -4512,7 +4512,7 @@ lbl_800617C4: /* 800617D4 0005E734 80 7F 01 2C */ lwz r3, 0x12c(r31) /* 800617D8 0005E738 7F 24 CB 78 */ mr r4, r25 /* 800617DC 0005E73C 38 63 00 70 */ addi r3, r3, 0x70 -/* 800617E0 0005E740 4B FE EA 25 */ bl sub_80050204 +/* 800617E0 0005E740 4B FE EA 25 */ bl "reserve__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>Fi" /* 800617E4 0005E744 3A C0 00 00 */ li r22, 0 /* 800617E8 0005E748 3B 00 00 00 */ li r24, 0 /* 800617EC 0005E74C 48 00 00 48 */ b lbl_80061834 @@ -4531,7 +4531,7 @@ lbl_800617F0: /* 8006181C 0005E77C 48 24 5D E1 */ bl GetAsCGraphicsLight__11CWorldLightCFv /* 80061820 0005E780 38 7D 00 70 */ addi r3, r29, 0x70 /* 80061824 0005E784 38 81 02 80 */ addi r4, r1, 0x280 -/* 80061828 0005E788 4B FE 41 9D */ bl sub_800459c4 +/* 80061828 0005E788 4B FE 41 9D */ bl "push_back__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>FRC6CLight" /* 8006182C 0005E78C 3B 18 00 44 */ addi r24, r24, 0x44 /* 80061830 0005E790 3A D6 00 01 */ addi r22, r22, 1 lbl_80061834: @@ -4550,7 +4550,7 @@ lbl_80061834: /* 80061864 0005E7C4 80 7F 01 2C */ lwz r3, 0x12c(r31) /* 80061868 0005E7C8 7F 24 CB 78 */ mr r4, r25 /* 8006186C 0005E7CC 38 63 00 90 */ addi r3, r3, 0x90 -/* 80061870 0005E7D0 4B FE E9 95 */ bl sub_80050204 +/* 80061870 0005E7D0 4B FE E9 95 */ bl "reserve__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>Fi" /* 80061874 0005E7D4 3A C0 00 00 */ li r22, 0 /* 80061878 0005E7D8 3B 00 00 00 */ li r24, 0 /* 8006187C 0005E7DC 48 00 00 48 */ b lbl_800618C4 @@ -4569,7 +4569,7 @@ lbl_80061880: /* 800618AC 0005E80C 48 24 5D 51 */ bl GetAsCGraphicsLight__11CWorldLightCFv /* 800618B0 0005E810 38 7D 00 90 */ addi r3, r29, 0x90 /* 800618B4 0005E814 38 81 01 EC */ addi r4, r1, 0x1ec -/* 800618B8 0005E818 4B FE 41 0D */ bl sub_800459c4 +/* 800618B8 0005E818 4B FE 41 0D */ bl "push_back__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>FRC6CLight" /* 800618BC 0005E81C 3B 18 00 44 */ addi r24, r24, 0x44 /* 800618C0 0005E820 3A D6 00 01 */ addi r22, r22, 1 lbl_800618C4: @@ -4586,7 +4586,7 @@ lbl_800618CC: /* 800618E8 0005E848 80 9F 01 2C */ lwz r4, 0x12c(r31) /* 800618EC 0005E84C 38 64 00 90 */ addi r3, r4, 0x90 /* 800618F0 0005E850 38 84 00 70 */ addi r4, r4, 0x70 -/* 800618F4 0005E854 4B FE 41 75 */ bl sub_80045a68 +/* 800618F4 0005E854 4B FE 41 75 */ bl "__as__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>FRCQ24rstl42vector<6CLight,Q24rstl17rmemory_allocator>" lbl_800618F8: /* 800618F8 0005E858 3C 80 80 3F */ lis r4, __vt__15CMemoryInStream@ha /* 800618FC 0005E85C 38 61 01 A4 */ addi r3, r1, 0x1a4 diff --git a/asm/MetroidPrime/CStateManager.s b/asm/MetroidPrime/CStateManager.s index f9607f7a..de6f6fe4 100644 --- a/asm/MetroidPrime/CStateManager.s +++ b/asm/MetroidPrime/CStateManager.s @@ -2330,7 +2330,7 @@ BuildDynamicLightListForWorld__13CStateManagerFv: /* 800457C4 00042724 38 81 00 5C */ addi r4, r1, 0x5c /* 800457C8 00042728 90 01 00 64 */ stw r0, 0x64(r1) /* 800457CC 0004272C 90 01 00 68 */ stw r0, 0x68(r1) -/* 800457D0 00042730 48 00 02 99 */ bl sub_80045a68 +/* 800457D0 00042730 48 00 02 99 */ bl "__as__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>FRCQ24rstl42vector<6CLight,Q24rstl17rmemory_allocator>" /* 800457D4 00042734 80 01 00 60 */ lwz r0, 0x60(r1) /* 800457D8 00042738 80 61 00 68 */ lwz r3, 0x68(r1) /* 800457DC 0004273C 1C 00 00 50 */ mulli r0, r0, 0x50 @@ -2364,7 +2364,7 @@ lbl_80045818: /* 80045840 000427A0 38 81 00 4C */ addi r4, r1, 0x4c /* 80045844 000427A4 90 01 00 54 */ stw r0, 0x54(r1) /* 80045848 000427A8 90 01 00 58 */ stw r0, 0x58(r1) -/* 8004584C 000427AC 48 00 02 1D */ bl sub_80045a68 +/* 8004584C 000427AC 48 00 02 1D */ bl "__as__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>FRCQ24rstl42vector<6CLight,Q24rstl17rmemory_allocator>" /* 80045850 000427B0 80 01 00 50 */ lwz r0, 0x50(r1) /* 80045854 000427B4 80 61 00 58 */ lwz r3, 0x58(r1) /* 80045858 000427B8 1C 00 00 50 */ mulli r0, r0, 0x50 @@ -2386,7 +2386,7 @@ lbl_8004587C: lbl_80045890: /* 80045890 000427F0 7F A4 EB 78 */ mr r4, r29 /* 80045894 000427F4 38 7E 08 E0 */ addi r3, r30, 0x8e0 -/* 80045898 000427F8 48 00 A9 6D */ bl sub_80050204 +/* 80045898 000427F8 48 00 A9 6D */ bl "reserve__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>Fi" /* 8004589C 000427FC 48 00 00 3C */ b lbl_800458D8 lbl_800458A0: /* 800458A0 00042800 80 1E 08 E4 */ lwz r0, 0x8e4(r30) @@ -2433,7 +2433,7 @@ lbl_800458E0: /* 80045934 00042894 40 81 00 10 */ ble lbl_80045944 /* 80045938 00042898 7F 84 E3 78 */ mr r4, r28 /* 8004593C 0004289C 38 7E 08 E0 */ addi r3, r30, 0x8e0 -/* 80045940 000428A0 48 00 00 85 */ bl sub_800459c4 +/* 80045940 000428A0 48 00 00 85 */ bl "push_back__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>FRC6CLight" lbl_80045944: /* 80045944 000428A4 2C 1D FF FF */ cmpwi r29, -1 /* 80045948 000428A8 41 82 00 14 */ beq lbl_8004595C @@ -2460,7 +2460,7 @@ lbl_80045960: /* 80045994 000428F4 90 C1 00 3C */ stw r6, 0x3c(r1) /* 80045998 000428F8 90 01 00 44 */ stw r0, 0x44(r1) /* 8004599C 000428FC 90 01 00 48 */ stw r0, 0x48(r1) -/* 800459A0 00042900 48 00 9F 39 */ bl sub_8004f8d8 +/* 800459A0 00042900 48 00 9F 39 */ bl "sort,Q24rstl17rmemory_allocator>,15CLightPredicate>__4rstlFQ24rstl104pointer_iterator<6CLight,Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl104pointer_iterator<6CLight,Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>15CLightPredicate" lbl_800459A4: /* 800459A4 00042904 80 01 00 D4 */ lwz r0, 0xd4(r1) /* 800459A8 00042908 83 E1 00 CC */ lwz r31, 0xcc(r1) @@ -2471,8 +2471,8 @@ lbl_800459A4: /* 800459BC 0004291C 38 21 00 D0 */ addi r1, r1, 0xd0 /* 800459C0 00042920 4E 80 00 20 */ blr -.global sub_800459c4 -sub_800459c4: +.global "push_back__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>FRC6CLight" +"push_back__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>FRC6CLight": /* 800459C4 00042924 94 21 FF F0 */ stwu r1, -0x10(r1) /* 800459C8 00042928 7C 08 02 A6 */ mflr r0 /* 800459CC 0004292C 90 01 00 14 */ stw r0, 0x14(r1) @@ -2489,14 +2489,14 @@ sub_800459c4: /* 800459F8 00042958 41 82 00 08 */ beq lbl_80045A00 /* 800459FC 0004295C 54 A4 08 3C */ slwi r4, r5, 1 lbl_80045A00: -/* 80045A00 00042960 48 00 A8 05 */ bl sub_80050204 +/* 80045A00 00042960 48 00 A8 05 */ bl "reserve__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>Fi" lbl_80045A04: /* 80045A04 00042964 80 1E 00 04 */ lwz r0, 4(r30) /* 80045A08 00042968 7F E4 FB 78 */ mr r4, r31 /* 80045A0C 0004296C 80 7E 00 0C */ lwz r3, 0xc(r30) /* 80045A10 00042970 1C 00 00 50 */ mulli r0, r0, 0x50 /* 80045A14 00042974 7C 63 02 14 */ add r3, r3, r0 -/* 80045A18 00042978 48 00 00 29 */ bl sub_80045a40 +/* 80045A18 00042978 48 00 00 29 */ bl "construct<6CLight>__4rstlFPvRC6CLight" /* 80045A1C 0004297C 80 7E 00 04 */ lwz r3, 4(r30) /* 80045A20 00042980 38 03 00 01 */ addi r0, r3, 1 /* 80045A24 00042984 90 1E 00 04 */ stw r0, 4(r30) @@ -2507,8 +2507,8 @@ lbl_80045A04: /* 80045A38 00042998 38 21 00 10 */ addi r1, r1, 0x10 /* 80045A3C 0004299C 4E 80 00 20 */ blr -.global sub_80045a40 -sub_80045a40: +.global "construct<6CLight>__4rstlFPvRC6CLight" +"construct<6CLight>__4rstlFPvRC6CLight": /* 80045A40 000429A0 94 21 FF F0 */ stwu r1, -0x10(r1) /* 80045A44 000429A4 7C 08 02 A6 */ mflr r0 /* 80045A48 000429A8 28 03 00 00 */ cmplwi r3, 0 @@ -2521,8 +2521,8 @@ lbl_80045A58: /* 80045A60 000429C0 38 21 00 10 */ addi r1, r1, 0x10 /* 80045A64 000429C4 4E 80 00 20 */ blr -.global sub_80045a68 -sub_80045a68: +.global "__as__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>FRCQ24rstl42vector<6CLight,Q24rstl17rmemory_allocator>" +"__as__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>FRCQ24rstl42vector<6CLight,Q24rstl17rmemory_allocator>": /* 80045A68 000429C8 94 21 FF E0 */ stwu r1, -0x20(r1) /* 80045A6C 000429CC 7C 08 02 A6 */ mflr r0 /* 80045A70 000429D0 90 01 00 24 */ stw r0, 0x24(r1) @@ -2565,13 +2565,13 @@ lbl_80045AE4: /* 80045AF4 00042A54 48 00 00 2C */ b lbl_80045B20 lbl_80045AF8: /* 80045AF8 00042A58 7F C3 F3 78 */ mr r3, r30 -/* 80045AFC 00042A5C 48 00 A7 09 */ bl sub_80050204 +/* 80045AFC 00042A5C 48 00 A7 09 */ bl "reserve__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>Fi" /* 80045B00 00042A60 80 1F 00 04 */ lwz r0, 4(r31) /* 80045B04 00042A64 80 7F 00 0C */ lwz r3, 0xc(r31) /* 80045B08 00042A68 1C 00 00 50 */ mulli r0, r0, 0x50 /* 80045B0C 00042A6C 80 BE 00 0C */ lwz r5, 0xc(r30) /* 80045B10 00042A70 7C 83 02 14 */ add r4, r3, r0 -/* 80045B14 00042A74 48 00 00 29 */ bl sub_80045b3c +/* 80045B14 00042A74 48 00 00 29 */ bl "uninitialized_copy__4rstlFPC6CLightPC6CLightP6CLight" /* 80045B18 00042A78 80 1F 00 04 */ lwz r0, 4(r31) /* 80045B1C 00042A7C 90 1E 00 04 */ stw r0, 4(r30) lbl_80045B20: @@ -2584,8 +2584,8 @@ lbl_80045B24: /* 80045B34 00042A94 38 21 00 20 */ addi r1, r1, 0x20 /* 80045B38 00042A98 4E 80 00 20 */ blr -.global sub_80045b3c -sub_80045b3c: +.global "uninitialized_copy__4rstlFPC6CLightPC6CLightP6CLight" +"uninitialized_copy__4rstlFPC6CLightPC6CLightP6CLight": /* 80045B3C 00042A9C 94 21 FF E0 */ stwu r1, -0x20(r1) /* 80045B40 00042AA0 7C 08 02 A6 */ mflr r0 /* 80045B44 00042AA4 90 01 00 24 */ stw r0, 0x24(r1) @@ -2599,7 +2599,7 @@ sub_80045b3c: lbl_80045B64: /* 80045B64 00042AC4 7F E3 FB 78 */ mr r3, r31 /* 80045B68 00042AC8 7F C4 F3 78 */ mr r4, r30 -/* 80045B6C 00042ACC 4B FF FE D5 */ bl sub_80045a40 +/* 80045B6C 00042ACC 4B FF FE D5 */ bl "construct<6CLight>__4rstlFPvRC6CLight" /* 80045B70 00042AD0 3B FF 00 50 */ addi r31, r31, 0x50 /* 80045B74 00042AD4 3B DE 00 50 */ addi r30, r30, 0x50 lbl_80045B78: @@ -13818,8 +13818,8 @@ lbl_8004F8C4: /* 8004F8D0 0004C830 38 21 00 60 */ addi r1, r1, 0x60 /* 8004F8D4 0004C834 4E 80 00 20 */ blr -.global sub_8004f8d8 -sub_8004f8d8: +.global "sort,Q24rstl17rmemory_allocator>,15CLightPredicate>__4rstlFQ24rstl104pointer_iterator<6CLight,Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl104pointer_iterator<6CLight,Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>15CLightPredicate" +"sort,Q24rstl17rmemory_allocator>,15CLightPredicate>__4rstlFQ24rstl104pointer_iterator<6CLight,Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl104pointer_iterator<6CLight,Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>15CLightPredicate": /* 8004F8D8 0004C838 94 21 FF 50 */ stwu r1, -0xb0(r1) /* 8004F8DC 0004C83C 7C 08 02 A6 */ mflr r0 /* 8004F8E0 0004C840 90 01 00 B4 */ stw r0, 0xb4(r1) @@ -13867,7 +13867,7 @@ lbl_8004F964: /* 8004F984 0004C8E4 98 01 00 10 */ stb r0, 0x10(r1) /* 8004F988 0004C8E8 7F 83 22 14 */ add r28, r3, r4 /* 8004F98C 0004C8EC 7F 84 E3 78 */ mr r4, r28 -/* 8004F990 0004C8F0 48 00 0E ED */ bl sub_8005087c +/* 8004F990 0004C8F0 48 00 0E ED */ bl "__sort3<6CLight,15CLightPredicate>__4rstlFR6CLightR6CLightR6CLight15CLightPredicate" /* 8004F994 0004C8F4 7F 84 E3 78 */ mr r4, r28 /* 8004F998 0004C8F8 38 61 00 40 */ addi r3, r1, 0x40 /* 8004F99C 0004C8FC 4B FE BB D5 */ bl __ct__6CLightFRC6CLight @@ -13962,7 +13962,7 @@ lbl_8004FABC: /* 8004FAD4 0004CA34 98 E1 00 0C */ stb r7, 0xc(r1) /* 8004FAD8 0004CA38 90 C1 00 20 */ stw r6, 0x20(r1) /* 8004FADC 0004CA3C 90 01 00 24 */ stw r0, 0x24(r1) -/* 8004FAE0 0004CA40 4B FF FD F9 */ bl sub_8004f8d8 +/* 8004FAE0 0004CA40 4B FF FD F9 */ bl "sort,Q24rstl17rmemory_allocator>,15CLightPredicate>__4rstlFQ24rstl104pointer_iterator<6CLight,Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl104pointer_iterator<6CLight,Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>15CLightPredicate" /* 8004FAE4 0004CA44 88 FF 00 00 */ lbz r7, 0(r31) /* 8004FAE8 0004CA48 38 61 00 1C */ addi r3, r1, 0x1c /* 8004FAEC 0004CA4C 80 DE 00 00 */ lwz r6, 0(r30) @@ -13972,7 +13972,7 @@ lbl_8004FABC: /* 8004FAFC 0004CA5C 98 E1 00 08 */ stb r7, 8(r1) /* 8004FB00 0004CA60 90 C1 00 18 */ stw r6, 0x18(r1) /* 8004FB04 0004CA64 90 01 00 1C */ stw r0, 0x1c(r1) -/* 8004FB08 0004CA68 4B FF FD D1 */ bl sub_8004f8d8 +/* 8004FB08 0004CA68 4B FF FD D1 */ bl "sort,Q24rstl17rmemory_allocator>,15CLightPredicate>__4rstlFQ24rstl104pointer_iterator<6CLight,Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl104pointer_iterator<6CLight,Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>15CLightPredicate" lbl_8004FB0C: /* 8004FB0C 0004CA6C 80 01 00 B4 */ lwz r0, 0xb4(r1) /* 8004FB10 0004CA70 CB E1 00 A8 */ lfd f31, 0xa8(r1) @@ -14462,8 +14462,8 @@ lbl_800501EC: /* 800501FC 0004D15C 38 21 00 10 */ addi r1, r1, 0x10 /* 80050200 0004D160 4E 80 00 20 */ blr -.global sub_80050204 -sub_80050204: +.global "reserve__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>Fi" +"reserve__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>Fi": /* 80050204 0004D164 94 21 FF D0 */ stwu r1, -0x30(r1) /* 80050208 0004D168 7C 08 02 A6 */ mflr r0 /* 8005020C 0004D16C 90 01 00 34 */ stw r0, 0x34(r1) @@ -14541,7 +14541,7 @@ sub_800502e0: lbl_80050308: /* 80050308 0004D268 7F C3 F3 78 */ mr r3, r30 /* 8005030C 0004D26C 7F E4 FB 78 */ mr r4, r31 -/* 80050310 0004D270 4B FF 57 31 */ bl sub_80045a40 +/* 80050310 0004D270 4B FF 57 31 */ bl "construct<6CLight>__4rstlFPvRC6CLight" /* 80050314 0004D274 3B DE 00 50 */ addi r30, r30, 0x50 /* 80050318 0004D278 3B FF 00 50 */ addi r31, r31, 0x50 lbl_8005031C: @@ -14955,8 +14955,8 @@ lbl_80050860: /* 80050874 0004D7D4 38 21 00 30 */ addi r1, r1, 0x30 /* 80050878 0004D7D8 4E 80 00 20 */ blr -.global sub_8005087c -sub_8005087c: +.global "__sort3<6CLight,15CLightPredicate>__4rstlFR6CLightR6CLightR6CLight15CLightPredicate" +"__sort3<6CLight,15CLightPredicate>__4rstlFR6CLightR6CLightR6CLight15CLightPredicate": /* 8005087C 0004D7DC 94 21 FF 80 */ stwu r1, -0x80(r1) /* 80050880 0004D7E0 7C 08 02 A6 */ mflr r0 /* 80050884 0004D7E4 90 01 00 84 */ stw r0, 0x84(r1) @@ -14991,7 +14991,7 @@ lbl_800508E8: /* 800508EC 0004D84C 41 82 00 10 */ beq lbl_800508FC /* 800508F0 0004D850 7F A3 EB 78 */ mr r3, r29 /* 800508F4 0004D854 7F C4 F3 78 */ mr r4, r30 -/* 800508F8 0004D858 48 00 03 51 */ bl sub_80050c48 +/* 800508F8 0004D858 48 00 03 51 */ bl "swap<6CLight>__4rstlFR6CLightR6CLight" lbl_800508FC: /* 800508FC 0004D85C 80 7F 00 3C */ lwz r3, 0x3c(r31) /* 80050900 0004D860 80 1E 00 3C */ lwz r0, 0x3c(r30) @@ -15213,8 +15213,8 @@ lbl_80050C24: /* 80050C40 0004DBA0 38 21 00 80 */ addi r1, r1, 0x80 /* 80050C44 0004DBA4 4E 80 00 20 */ blr -.global sub_80050c48 -sub_80050c48: +.global "swap<6CLight>__4rstlFR6CLightR6CLight" +"swap<6CLight>__4rstlFR6CLightR6CLight": /* 80050C48 0004DBA8 94 21 FF A0 */ stwu r1, -0x60(r1) /* 80050C4C 0004DBAC 7C 08 02 A6 */ mflr r0 /* 80050C50 0004DBB0 90 01 00 64 */ stw r0, 0x64(r1) diff --git a/asm/MetroidPrime/CWorldTransManager.s b/asm/MetroidPrime/CWorldTransManager.s index 2e209d09..df02726a 100644 --- a/asm/MetroidPrime/CWorldTransManager.s +++ b/asm/MetroidPrime/CWorldTransManager.s @@ -1806,7 +1806,7 @@ lbl_8020A6C4: /* 8020A71C 0020767C 48 0F BC 41 */ bl SetColor__6CLightFRC6CColor /* 8020A720 00207680 7F E3 FB 78 */ mr r3, r31 /* 8020A724 00207684 38 81 00 94 */ addi r4, r1, 0x94 -/* 8020A728 00207688 4B E3 B2 9D */ bl sub_800459c4 +/* 8020A728 00207688 4B E3 B2 9D */ bl "push_back__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>FRC6CLight" /* 8020A72C 0020768C 48 13 F8 89 */ bl Black__6CColorFv /* 8020A730 00207690 FC 20 F8 90 */ fmr f1, f31 /* 8020A734 00207694 7C 64 1B 78 */ mr r4, r3 @@ -1819,7 +1819,7 @@ lbl_8020A6C4: lbl_8020A750: /* 8020A750 002076B0 7F E3 FB 78 */ mr r3, r31 /* 8020A754 002076B4 38 81 00 E4 */ addi r4, r1, 0xe4 -/* 8020A758 002076B8 4B E3 B2 6D */ bl sub_800459c4 +/* 8020A758 002076B8 4B E3 B2 6D */ bl "push_back__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>FRC6CLight" lbl_8020A75C: /* 8020A75C 002076BC E3 E1 01 98 */ psq_l f31, 408(r1), 0, qr0 /* 8020A760 002076C0 80 01 01 A4 */ lwz r0, 0x1a4(r1) @@ -2876,7 +2876,7 @@ sub_8020b4e4: /* 8020B640 002085A0 D0 1F 01 D4 */ stfs f0, 0x1d4(r31) /* 8020B644 002085A4 D0 1F 01 D8 */ stfs f0, 0x1d8(r31) /* 8020B648 002085A8 98 1F 01 DC */ stb r0, 0x1dc(r31) -/* 8020B64C 002085AC 4B E4 4B B9 */ bl sub_80050204 +/* 8020B64C 002085AC 4B E4 4B B9 */ bl "reserve__Q24rstl42vector<6CLight,Q24rstl17rmemory_allocator>Fi" /* 8020B650 002085B0 80 01 01 44 */ lwz r0, 0x144(r1) /* 8020B654 002085B4 7F E3 FB 78 */ mr r3, r31 /* 8020B658 002085B8 83 E1 01 3C */ lwz r31, 0x13c(r1) diff --git a/include/Kyoto/Graphics/CLight.hpp b/include/Kyoto/Graphics/CLight.hpp index ab8b26b8..0dcd714c 100644 --- a/include/Kyoto/Graphics/CLight.hpp +++ b/include/Kyoto/Graphics/CLight.hpp @@ -49,6 +49,7 @@ public: float GetRadius() const; const CColor& GetColor() const { return x18_color; } + int GetPriority() const { return x3c_priority; } void SetPriority(uint priority) { x3c_priority = priority; } void SetLightId(uint lightId) { x40_lightId = lightId; } @@ -75,7 +76,7 @@ private: float x30_angleC; float x34_angleL; float x38_angleQ; - uint x3c_priority; + int x3c_priority; uint x40_lightId; mutable float x44_cachedRadius; mutable float x48_cachedIntensity; diff --git a/include/MetroidPrime/CStateManager.hpp b/include/MetroidPrime/CStateManager.hpp index d422e56a..38f5d668 100644 --- a/include/MetroidPrime/CStateManager.hpp +++ b/include/MetroidPrime/CStateManager.hpp @@ -149,6 +149,7 @@ public: float length, const CMaterialFilter& filter, const TEntityList& list) const; void BuildColliderList(TEntityList& out, const CActor& actor, const CAABox& aabb) const; + void BuildDynamicLightListForWorld(); CEntity* ObjectById(TUniqueId uid); const CEntity* GetObjectById(TUniqueId uid) const; diff --git a/src/MetroidPrime/CStateManager.cpp b/src/MetroidPrime/CStateManager.cpp index 6d5e78d6..d0be814c 100644 --- a/src/MetroidPrime/CStateManager.cpp +++ b/src/MetroidPrime/CStateManager.cpp @@ -3,6 +3,7 @@ #include "MetroidPrime/CControlMapper.hpp" #include "MetroidPrime/CEnvFxManager.hpp" #include "MetroidPrime/CGameCollision.hpp" +#include "MetroidPrime/CGameLight.hpp" #include "MetroidPrime/CMapWorldInfo.hpp" #include "MetroidPrime/CRipple.hpp" #include "MetroidPrime/CRumbleManager.hpp" @@ -59,6 +60,21 @@ bool area_sorter::operator()(const CGameArea* a, const CGameArea* b) const { } // namespace + +class CLightPredicate { +public: + bool operator()(const CLight& a, const CLight& b) const { + if (b.GetPriority() > a.GetPriority()) { + return true; + } else if (b.GetPriority() == a.GetPriority()) { + return a.GetIntensity() > b.GetIntensity(); + } else { + return false; + } + } +}; + + CStateManager::CStateManager(const rstl::ncrc_ptr< CScriptMailbox >& mailbox, const rstl::ncrc_ptr< CMapWorldInfo >& mwInfo, const rstl::ncrc_ptr< CPlayerState >& playerState, @@ -405,3 +421,33 @@ void CStateManager::DrawWorld() const { rstl::sort(&areaArr[0], &areaArr[areaCount], area_sorter(CGraphics::GetViewpoint(), visAreaId)); } + +void CStateManager::BuildDynamicLightListForWorld() { + if (x8b8_playerState->GetActiveVisor(*this) == CPlayerState::kPV_Thermal) { + x8e0_dynamicLights = rstl::vector< CLight >(); + return; + } + + const CObjectList& list = GetObjectListById(kOL_GameLight); + if (list.size() == 0) { + return; + } + + if (x8e0_dynamicLights.capacity() != list.size()) { + x8e0_dynamicLights = rstl::vector< CLight >(); + x8e0_dynamicLights.reserve(list.size()); + } else { + x8e0_dynamicLights.clear(); + } + + for (int idx = list.GetFirstObjectIndex(); idx != -1; idx = list.GetNextObjectIndex(idx)) { + const CGameLight* light = static_cast< const CGameLight* >(list[idx]); + if (light && light->GetActive()) { + const CLight& l = light->GetLight(); + if (l.GetIntensity() > FLT_EPSILON && l.GetRadius() > FLT_EPSILON) { + x8e0_dynamicLights.push_back(l); + } + } + } + rstl::sort(x8e0_dynamicLights.begin(), x8e0_dynamicLights.end(), CLightPredicate()); +}