From 73fee556758b6d251888b5d6a69c303378ed02f5 Mon Sep 17 00:00:00 2001 From: elijah-thomas774 Date: Thu, 29 May 2025 22:50:43 -0400 Subject: [PATCH] some progress --- config/SOUE01/symbols.txt | 32 +-- include/d/a/e/d_a_e_sm.h | 2 +- include/d/a/obj/d_a_obj_tbox.h | 2 +- include/toBeSorted/blur_and_palette_manager.h | 108 +++++--- src/REL/d/a/e/d_a_e_sm.cpp | 4 +- src/d/a/obj/d_a_obj_tbox.cpp | 20 +- src/toBeSorted/blur_and_palette_manager.cpp | 255 +++++++++++++++++- 7 files changed, 349 insertions(+), 74 deletions(-) diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index baf51582..cfb9c0c5 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -795,23 +795,23 @@ fn_80022010 = .text:0x80022010; // type:function size:0x28 fn_80022040 = .text:0x80022040; // type:function size:0x80 fn_800220C0 = .text:0x800220C0; // type:function size:0x8 fn_800220D0 = .text:0x800220D0; // type:function size:0xD0 -fn_800221A0 = .text:0x800221A0; // type:function size:0xC4 -fn_80022270 = .text:0x80022270; // type:function size:0x5C -fn_800222D0 = .text:0x800222D0; // type:function size:0xC8 -fn_800223A0__21BlurAndPaletteManagerFP11LightParams = .text:0x800223A0; // type:function size:0x94 -fn_80022440__21BlurAndPaletteManagerFP11LightParams = .text:0x80022440; // type:function size:0x34 -fn_80022480 = .text:0x80022480; // type:function size:0xCC -fn_80022550 = .text:0x80022550; // type:function size:0x74 +vectle_calc__FPC7mVec3_cP7mVec3_c = .text:0x800221A0; // type:function size:0xC4 +get_vectle_calc__21BlurAndPaletteManagerFPC7mVec3_cPC7mVec3_cP7mVec3_c = .text:0x80022270; // type:function size:0x5C +sphere_to_cartesian__21BlurAndPaletteManagerFffP7mVec3_c = .text:0x800222D0; // type:function size:0xC8 +efplight_set__21BlurAndPaletteManagerFP15LIGHT_INFLUENCE = .text:0x800223A0; // type:function size:0x94 +efplight_cut__21BlurAndPaletteManagerFP15LIGHT_INFLUENCE = .text:0x80022440; // type:function size:0x34 +eflight_influence__21BlurAndPaletteManagerFPC7mVec3_c = .text:0x80022480; // type:function size:0xCC +SordFlush_set__21BlurAndPaletteManagerFPC7mVec3_cl = .text:0x80022550; // type:function size:0x74 __as__7mVec3_cFRC7mVec3_c = .text:0x800225D0; // type:function size:0x1C -fn_800225F0 = .text:0x800225F0; // type:function size:0xEC -fn_800226E0 = .text:0x800226E0; // type:function size:0x34 -fn_80022720 = .text:0x80022720; // type:function size:0xCC -fn_800227F0 = .text:0x800227F0; // type:function size:0xF0 -fn_800228E0 = .text:0x800228E0; // type:function size:0xEC -fn_800229D0 = .text:0x800229D0; // type:function size:0x34 -fn_80022A10 = .text:0x80022A10; // type:function size:0xD8 -fn_80022AF0__21BlurAndPaletteManagerFf = .text:0x80022AF0; // type:function size:0x3C -fn_80022B30 = .text:0x80022B30; // type:function size:0x8 +plight_set__21BlurAndPaletteManagerFP15LIGHT_INFLUENCE = .text:0x800225F0; // type:function size:0xEC +plight_cut__21BlurAndPaletteManagerFP15LIGHT_INFLUENCE = .text:0x800226E0; // type:function size:0x34 +light_influence__21BlurAndPaletteManagerFPC7mVec3_cb = .text:0x80022720; // type:function size:0xCC +light_influence2__21BlurAndPaletteManagerFPC7mVec3_cb = .text:0x800227F0; // type:function size:0xF0 +shadow_set__21BlurAndPaletteManagerFP16SHADOW_INFLUENCE = .text:0x800228E0; // type:function size:0xEC +shadow_cut__21BlurAndPaletteManagerFP16SHADOW_INFLUENCE = .text:0x800229D0; // type:function size:0x34 +shadow_influence__21BlurAndPaletteManagerFPC7mVec3_c = .text:0x80022A10; // type:function size:0xD8 +setLightFilter__21BlurAndPaletteManagerFf = .text:0x80022AF0; // type:function size:0x3C +set0x35B0__21BlurAndPaletteManagerFf = .text:0x80022B30; // type:function size:0x8 fn_80022B40 = .text:0x80022B40; // type:function size:0x58 fn_80022BA0 = .text:0x80022BA0; // type:function size:0xC fn_80022BB0 = .text:0x80022BB0; // type:function size:0xC diff --git a/include/d/a/e/d_a_e_sm.h b/include/d/a/e/d_a_e_sm.h index 76a1882a..762eabfe 100644 --- a/include/d/a/e/d_a_e_sm.h +++ b/include/d/a/e/d_a_e_sm.h @@ -213,7 +213,7 @@ private: /* 0xBCC */ u8 field_0xBCC; /* 0xBCD */ u8 field_0xBCD; /* 0xBCE */ u8 field_0xBCE; - /* 0xBD0 */ LightParams mLightInfo; + /* 0xBD0 */ LIGHT_INFLUENCE mLightInfo; static bool sSomeArrayInit; static bool sSomeArray[9]; diff --git a/include/d/a/obj/d_a_obj_tbox.h b/include/d/a/obj/d_a_obj_tbox.h index 9c52e759..72b126f5 100644 --- a/include/d/a/obj/d_a_obj_tbox.h +++ b/include/d/a/obj/d_a_obj_tbox.h @@ -139,7 +139,7 @@ private: /* 0x049C */ m3d::anmTexPat_c mAnmGoddessPat; /* 0x04C8 */ dScnCallback_c mScnCallback; /* 0x04D4 */ dShadowCircle_c mShadowCircle; - /* 0x04DC */ LightParams mLightInfo; + /* 0x04DC */ LIGHT_INFLUENCE mLightInfo; /* 0x04F8 */ dBgW mBgWs[2]; /* 0x0918 */ dCcD_Linked_Unk mCcD1; /* 0x0B30 */ dCcD_Linked_Unk mCcD2; diff --git a/include/toBeSorted/blur_and_palette_manager.h b/include/toBeSorted/blur_and_palette_manager.h index 1891a7e0..81724265 100644 --- a/include/toBeSorted/blur_and_palette_manager.h +++ b/include/toBeSorted/blur_and_palette_manager.h @@ -8,6 +8,24 @@ #include "rvl/GX/GXTypes.h" #include "toBeSorted/tlist.h" +struct LIGHT_INFLUENCE { + void SetColor(mColor clr) { + mClr = clr; + } + void SetScale(f32 scale) { + mScale = scale; + } + void SetPosition(const mVec3_c &pos) { + mPos = pos; + } + + /* 0x00 */ mVec3_c mPos; + /* 0x0C */ mColor mClr; + /* 0x10 */ f32 mScale; + /* 0x14 */ s32 mIdx; + /* 0x18 */ bool field_0x18; +}; + struct UnkBlurPaletteListNode { TListNode mNode; }; @@ -143,20 +161,23 @@ struct Sff { SffSub field_0x00[3]; }; -struct Bpm1 { - Bpm1() {} - ~Bpm1() {} +struct EFLIGHT_PROC { + EFLIGHT_PROC() {} + ~EFLIGHT_PROC() {} - u8 field_0x00[0x14 - 0x00]; - mColor field_0x14; + /* 0x00 */ u8 mState; + /* 0x01 */ u8 mFrame; + /* 0x04 */ int mLightType; + /* 0x08 */ LIGHT_INFLUENCE field_0x8; }; struct Bpm2 { Bpm2() {} ~Bpm2() {} - // maybe - u8 _0x00[0x14 - 0x00]; + /* 0x00 */ mVec3_c mPosition; + /* 0x0C */ u32 field_0x0C; + /* 0x10 */ f32 field_0x10; }; struct PaletteEAF_smol_entry { @@ -203,18 +224,21 @@ struct Bpm4 { PaletteEAF_big field_0x00[0x20]; }; -struct Bpm7 { - Bpm7() {} - ~Bpm7() {} +struct SHADOW_INFLUENCE { + SHADOW_INFLUENCE() {} + ~SHADOW_INFLUENCE() {} - u8 _0x00[0x14 - 0x00]; + /* 0x00 */ mVec3_c mPos; + /* 0x0C */ f32 mRadius; + /* 0x10 */ s16 mIdx; }; - struct Bpm8 { Bpm8() {} ~Bpm8() {} - u8 _0x00[0x14 - 0x00]; + /* 0x00 */ mVec3_c mPos; + /* 0x0C */ f32 field_0x0C; + /* 0x10 */ s32 field_0x10; }; struct Bpm9 { @@ -224,24 +248,6 @@ struct Bpm9 { u8 _0x00[0x14 - 0x00]; }; -struct LightParams { - void SetColor(mColor clr) { - mClr = clr; - } - void SetScale(f32 scale) { - mScale = scale; - } - void SetPosition(const mVec3_c &pos) { - mPos = pos; - } - - /* 0x00 */ EGG::Vector3f mPos; - /* 0x0C */ mColor mClr; - /* 0x10 */ f32 mScale; - /* 0x14 */ s32 mIdx; - /* 0x18 */ s32 field_0x18; -}; - class BlurAndPaletteManager { public: BlurAndPaletteManager(); @@ -257,15 +263,32 @@ public: return sPInstance; } + void get_vectle_calc(const mVec3_c *, const mVec3_c *, mVec3_c *); + void sphere_to_cartesian(f32 ang_y, f32 ang_xz, mVec3_c *); + + void efplight_set(LIGHT_INFLUENCE *pLightInfo); + void efplight_cut(LIGHT_INFLUENCE *pLightInfo); + LIGHT_INFLUENCE *eflight_influence(const mVec3_c *); + + void SordFlush_set(const mVec3_c *pPos, s32 lightType); // Name is guess based on closest func in tp + + void plight_set(LIGHT_INFLUENCE *pLightInfo); + void plight_cut(LIGHT_INFLUENCE *pLightInfo); + LIGHT_INFLUENCE *light_influence(const mVec3_c *, bool param2); + LIGHT_INFLUENCE *light_influence2(const mVec3_c *, bool param2); + + void shadow_set(SHADOW_INFLUENCE *pShadowInfo); + void shadow_cut(SHADOW_INFLUENCE *pShadowInfo); + SHADOW_INFLUENCE *shadow_influence(const mVec3_c *); + + void setLightFilter(f32 ratio); + void set0x35B0(f32 f); + void fn_800247D0(mVec3_c, f32); - void fn_80022AF0(f32); void setField_0x2F20(f32 arg) { field_0x2F20 = arg; } - void fn_800223A0(LightParams *); - void fn_80022440(LightParams *); - void fn_800225F0(LightParams *); - void fn_800226E0(LightParams *); + // light pillar related void fn_80024240(s16, s16, s16); bool fn_80024770(int); @@ -314,7 +337,7 @@ private: /* 0x2DE0 */ u8 field_0x2DE0[0x2DEC - 0x2DE0]; /* 0x2DEC */ mColor field_0x2DEC; /* 0x2DF0 */ u8 field_0x2DF0[0x2DF4 - 0x2DF0]; - /* 0x2DF4 */ mColor field_0x2DF4; + /* 0x2DF4 */ mColor field_0x2DF4; // Controls Light filtering /* 0x2DF8 */ mVec3_c field_0x2DF8; /* 0x2E04 */ u8 field_0x2E04[0x2E08 - 0x2E04]; /* 0x2E08 */ mVec3_c field_0x2E08[5]; @@ -332,13 +355,12 @@ private: /* 0x2F1C */ f32 field_0x2F1C; /* 0x2F20 */ f32 field_0x2F20; /* 0x2F24 */ u8 field_0x2F24[4]; - /* 0x2F28 */ LightParams *field_0x2F28[5]; - /* 0x2F3C */ LightParams *field_0x2F3C[200]; - /* 0x325C */ u8 field_0x325C[0x357C - 0x325C]; - /* 0x357C */ Bpm1 field_0x357C; - /* 0x3594 */ u8 _0x3594[0x35A0 - 0x3594]; + /* 0x2F28 */ LIGHT_INFLUENCE *efplight[5]; + /* 0x2F3C */ LIGHT_INFLUENCE *pointlight[200]; + /* 0x325C */ SHADOW_INFLUENCE *pshadow[200]; + /* 0x357C */ EFLIGHT_PROC eflight; /* 0x35A0 */ Bpm2 field_0x35A0; - /* 0x35B4 */ Bpm7 field_0x35B4[8]; + /* 0x35B4 */ SHADOW_INFLUENCE field_0x35B4[8]; /* 0x3654 */ Bpm8 field_0x3654[10]; /* 0x371C */ Bpm9 field_0x371C[20]; /* 0x38AC */ u8 _0x38AC[0x38B4 - 0x38AC]; diff --git a/src/REL/d/a/e/d_a_e_sm.cpp b/src/REL/d/a/e/d_a_e_sm.cpp index dae7f886..3c5e5bf0 100644 --- a/src/REL/d/a/e/d_a_e_sm.cpp +++ b/src/REL/d/a/e/d_a_e_sm.cpp @@ -198,7 +198,7 @@ int dAcEsm_c::actorCreate() { mLightInfo.SetColor(mColor(0xCC, 0xFF, 0xFF, 0xFF)); mLightInfo.SetScale(0.f); - BlurAndPaletteManager::GetPInstance()->fn_800225F0(&mLightInfo); + BlurAndPaletteManager::GetPInstance()->plight_set(&mLightInfo); if (field_0xBBF == 1) { rotation.x = 0x8000; field_0xBCC = 1; @@ -315,7 +315,7 @@ int dAcEsm_c::actorPostCreate() { } int dAcEsm_c::doDelete() { - BlurAndPaletteManager::GetPInstance()->fn_800226E0(&mLightInfo); + BlurAndPaletteManager::GetPInstance()->plight_cut(&mLightInfo); return SUCCEEDED; } diff --git a/src/d/a/obj/d_a_obj_tbox.cpp b/src/d/a/obj/d_a_obj_tbox.cpp index eea6e056..4859ee76 100644 --- a/src/d/a/obj/d_a_obj_tbox.cpp +++ b/src/d/a/obj/d_a_obj_tbox.cpp @@ -1977,14 +1977,14 @@ void dAcTbox_c::executeState_Open() { if (mVariant == GODDESS) { if (0.4f < field_0x11EC) { sLib::chase(&field_0x11EC, 0.4f, getSomeRate()); - BlurAndPaletteManager::GetInstance().fn_80022AF0(field_0x11EC); + BlurAndPaletteManager::GetInstance().setLightFilter(field_0x11EC); BlurAndPaletteManager::GetInstance().setField_0x2F20(field_0x11EC); } } else if (mVariant != SMALL) { // exact same code as in the other branch if (0.4f < field_0x11EC) { sLib::chase(&field_0x11EC, 0.4f, getSomeRate()); - BlurAndPaletteManager::GetInstance().fn_80022AF0(field_0x11EC); + BlurAndPaletteManager::GetInstance().setLightFilter(field_0x11EC); BlurAndPaletteManager::GetInstance().setField_0x2F20(field_0x11EC); } } @@ -2010,13 +2010,13 @@ void dAcTbox_c::executeState_PresentItem() { if (mVariant == GODDESS) { if (0.4f < field_0x11EC) { sLib::chase(&field_0x11EC, 0.4f, getSomeRate()); - BlurAndPaletteManager::GetInstance().fn_80022AF0(field_0x11EC); + BlurAndPaletteManager::GetInstance().setLightFilter(field_0x11EC); BlurAndPaletteManager::GetInstance().setField_0x2F20(field_0x11EC); } } else if (mVariant != SMALL) { if (0.4f < field_0x11EC) { sLib::chase(&field_0x11EC, 0.4f, getSomeRate()); - BlurAndPaletteManager::GetInstance().fn_80022AF0(field_0x11EC); + BlurAndPaletteManager::GetInstance().setLightFilter(field_0x11EC); BlurAndPaletteManager::GetInstance().setField_0x2F20(field_0x11EC); } } @@ -2059,7 +2059,7 @@ void dAcTbox_c::executeState_Close() { if (field_0x11FC <= 0) { if (field_0x11EC < 1.0f) { sLib::chase(&field_0x11EC, 1.0f, getSomeRate()); - BlurAndPaletteManager::GetInstance().fn_80022AF0(field_0x11EC); + BlurAndPaletteManager::GetInstance().setLightFilter(field_0x11EC); BlurAndPaletteManager::GetInstance().setField_0x2F20(field_0x11EC); } } else { @@ -2088,7 +2088,7 @@ void dAcTbox_c::executeState_Close() { if (field_0x11FC <= 0) { if (field_0x11EC < 1.0f) { sLib::chase(&field_0x11EC, 1.0f, getSomeRate()); - BlurAndPaletteManager::GetInstance().fn_80022AF0(field_0x11EC); + BlurAndPaletteManager::GetInstance().setLightFilter(field_0x11EC); BlurAndPaletteManager::GetInstance().setField_0x2F20(field_0x11EC); } } else { @@ -2140,7 +2140,7 @@ void dAcTbox_c::executeState_Wait() { if (field_0x11FC <= 0) { if (field_0x11EC < 1.0f) { sLib::chase(&field_0x11EC, 1.0f, getSomeRate()); - BlurAndPaletteManager::GetInstance().fn_80022AF0(field_0x11EC); + BlurAndPaletteManager::GetInstance().setLightFilter(field_0x11EC); BlurAndPaletteManager::GetInstance().setField_0x2F20(field_0x11EC); } } else { @@ -2165,7 +2165,7 @@ void dAcTbox_c::executeState_GoddessWait() { if (field_0x11FC <= 0) { if (field_0x11EC < 1.0f) { sLib::chase(&field_0x11EC, 1.0f, getSomeRate()); - BlurAndPaletteManager::GetInstance().fn_80022AF0(field_0x11EC); + BlurAndPaletteManager::GetInstance().setLightFilter(field_0x11EC); // this is apparently not needed here // BlurAndPaletteManager::GetInstance().setField_0x2F20(field_0x11EC); } @@ -2232,14 +2232,14 @@ void dAcTbox_c::unsetShouldCloseFlag() { void dAcTbox_c::fn_8026D370() { if (isNotSmall()) { field_0x11F0 = 1; - BlurAndPaletteManager::GetInstance().fn_800223A0(&mLightInfo); + BlurAndPaletteManager::GetInstance().efplight_set(&mLightInfo); } } void dAcTbox_c::fn_8026D3C0() { if (mAnmChr.isStop() && mAnmTexSrt1.isStop(0) && mAnmMatClr2.isStop(0)) { field_0x11F0 = 0; - BlurAndPaletteManager::GetInstance().fn_80022440(&mLightInfo); + BlurAndPaletteManager::GetInstance().efplight_cut(&mLightInfo); } else { mAnmChr.play(); mAnmTexSrt1.play(); diff --git a/src/toBeSorted/blur_and_palette_manager.cpp b/src/toBeSorted/blur_and_palette_manager.cpp index 54a233b4..d6a4f53d 100644 --- a/src/toBeSorted/blur_and_palette_manager.cpp +++ b/src/toBeSorted/blur_and_palette_manager.cpp @@ -1,12 +1,266 @@ #include "toBeSorted/blur_and_palette_manager.h" +#include "common.h" +#include "d/a/d_a_player.h" #include "m/m_color.h" +#include "m/m_vec.h" +#include "nw4r/math/math_arithmetic.h" BlurAndPaletteManager BlurAndPaletteManager::sInstance; BlurAndPaletteManager *BlurAndPaletteManager::sPInstance; TList sPlayingEffectsList; +// Same as vectle_calc in d_kankyo_rain from tp +static void vectle_calc(const mVec3_c *pIn, mVec3_c *pOut) { + f32 s = nw4r::math::FSqrt(pIn->squaredLength()); + if (s != 0.0f) { + pOut->x = pIn->x / s; + pOut->y = pIn->y / s; + pOut->z = pIn->z / s; + } else { + pOut->x = 0.0f; + pOut->y = 0.0f; + pOut->z = 0.0f; + } +} + +// Same as get_vectle_calc in d_kankyo_rain from tp +void BlurAndPaletteManager::get_vectle_calc(const mVec3_c *pInA, const mVec3_c *pInB, mVec3_c *pOut) { + mVec3_c pos; + pos.x = pInB->x - pInA->x; + pos.y = pInB->y - pInA->y; + pos.z = pInB->z - pInA->z; + vectle_calc(&pos, pOut); +} + +// TODO(??) +inline f32 sinf(f32 x) { + return sin(x); +} + +// TODO(??) +inline f32 cosf(f32 x) { + return cos(x); +} + +void BlurAndPaletteManager::sphere_to_cartesian(f32 angY, f32 angXZ, mVec3_c *pOut) { + f32 radY = angY / (180.f / M_PI); + f32 radXZ = angXZ / (180.f / M_PI); + + mVec3_c pos; + pos.x = cosf(radY) * sinf(radXZ); + pos.y = sinf(radY); + pos.z = cosf(radY) * cosf(radXZ); + + pOut->x = pos.x; + pOut->y = pos.y; + pOut->z = pos.z; +} + +void BlurAndPaletteManager::efplight_set(LIGHT_INFLUENCE *pLightInfo) { + if (pLightInfo == nullptr) { + return; + } + + pLightInfo->mIdx = 0; + for (int i = 0; i < 5; ++i) { + if (efplight[i] == pLightInfo) { + return; + } + } + for (int i = 0; i < 5; i++) { + if (efplight[i] == NULL) { + efplight[i] = pLightInfo; + efplight[i]->mIdx = i + 1; + break; + } + } +} +void BlurAndPaletteManager::efplight_cut(LIGHT_INFLUENCE *pLightInfo) { + if (pLightInfo == nullptr) { + return; + } + + if (pLightInfo->mIdx != 0) { + int idx = pLightInfo->mIdx - 1; + if (idx >= 0 && idx < 5) { + efplight[idx] = nullptr; + } + } +} + +LIGHT_INFLUENCE *BlurAndPaletteManager::eflight_influence(const mVec3_c *pPos) { + f32 max = 1000000.f; + LIGHT_INFLUENCE *pOut = nullptr; + + for (int i = 0; i < 5; i++) { + if (efplight[i] != nullptr) { + if (max > pPos->distance(efplight[i]->mPos) && efplight[i]->mScale > 0.01f) { + max = pPos->distance(efplight[i]->mPos); + pOut = efplight[i]; + } + } + } + + return pOut; +} + +void BlurAndPaletteManager::SordFlush_set(const mVec3_c *pPos, s32 lightType) { + if (eflight.mState == 0) { + eflight.mState = 1; + eflight.mLightType = lightType; + eflight.field_0x8.mPos = *pPos; + } else if (eflight.mState == 2 || eflight.mState == 10 || eflight.mState == 11) { + eflight.mState = 4; + eflight.mLightType = lightType; + eflight.field_0x8.mPos = *pPos; + } +} + +void BlurAndPaletteManager::plight_set(LIGHT_INFLUENCE *pLightInfo) { + if (pLightInfo == nullptr) { + return; + } + pLightInfo->mIdx = 0; + + for (int i = 0; i < 200; i++) { + // @bug shouldnt this be pointlight instead of efplight? + if (efplight[i] == pLightInfo) { + return; + } + } + + for (int i = 0; i < 200; i++) { + if (pointlight[i] == NULL) { + pointlight[i] = pLightInfo; + pointlight[i]->mIdx = i + 1; + break; + } + } +} +void BlurAndPaletteManager::plight_cut(LIGHT_INFLUENCE *pLightInfo) { + if (pLightInfo == nullptr) { + return; + } + + if (pLightInfo->mIdx != 0) { + int idx = pLightInfo->mIdx - 1; + if (idx >= 0 && idx < 200) { + pointlight[idx] = nullptr; + } + } +} + +LIGHT_INFLUENCE *BlurAndPaletteManager::light_influence(const mVec3_c *pPos, bool param2) { + f32 max = 1000000.f; + LIGHT_INFLUENCE *pOut = nullptr; + + if (dAcPy_c::GetLink() && dAcPy_c::GetLink()->checkActionFlagsCont(0x400000)) { + return nullptr; + } + + for (int i = 0; i < 200; i++) { + if (pointlight[i] != nullptr && pointlight[i]->field_0x18 == param2) { + if (max > pPos->distance(pointlight[i]->mPos)) { + max = pPos->distance(pointlight[i]->mPos); + pOut = pointlight[i]; + } + } + } + + return pOut; +} + +LIGHT_INFLUENCE *BlurAndPaletteManager::light_influence2(const mVec3_c *pPos, bool param2) { + f32 max = 1000000.f; + f32 temp = 1000000.f; + LIGHT_INFLUENCE *pOut2 = nullptr; + LIGHT_INFLUENCE *pOut = nullptr; + + if (dAcPy_c::GetLink() && dAcPy_c::GetLink()->checkActionFlagsCont(0x400000)) { + return nullptr; + } + for (int i = 0; i < 200; i++) { + if (pointlight[i] != nullptr && pointlight[i]->field_0x18 == param2) { + f32 dist = pPos->distance(pointlight[i]->mPos); + if (dist < temp) { + if (dist < max) { + temp = max; + max = dist; + pOut = pOut2; + pOut2 = pointlight[i]; + } else { + temp = dist; + pOut = pointlight[i]; + } + } + } + } + + return pOut; +} + +void BlurAndPaletteManager::shadow_set(SHADOW_INFLUENCE *pShadowInfo) { + if (pShadowInfo == nullptr) { + return; + } + + pShadowInfo->mIdx = 0; + for (int i = 0; i < 200; ++i) { + if (pshadow[i] == pShadowInfo) { + return; + } + } + for (int i = 0; i < 200; i++) { + if (pshadow[i] == NULL) { + pshadow[i] = pShadowInfo; + pshadow[i]->mIdx = i + 1; + break; + } + } +} + +void BlurAndPaletteManager::shadow_cut(SHADOW_INFLUENCE *pShadowInfo) { + if (pShadowInfo == nullptr) { + return; + } + + if (pShadowInfo->mIdx != 0) { + int idx = pShadowInfo->mIdx - 1; + if (idx >= 0 && idx < 200) { + pshadow[idx] = nullptr; + } + } +} + +SHADOW_INFLUENCE *BlurAndPaletteManager::shadow_influence(const mVec3_c *pPos) { + f32 max = 1000000.f; + SHADOW_INFLUENCE *pOut = nullptr; + + for (int i = 0; i < 200; i++) { + if (pshadow[i] != nullptr && pPos->y < pshadow[i]->mPos.y) { + if (max > pPos->distance(pshadow[i]->mPos)) { + if (pPos->distance(pshadow[i]->mPos) < pshadow[i]->mRadius) { + max = pPos->distance(pshadow[i]->mPos); + pOut = pshadow[i]; + } + } + } + } + + return pOut; +} + +void BlurAndPaletteManager::setLightFilter(f32 ratio) { + field_0x2DF4.r = ratio * 255.f; + field_0x2DF4.g = ratio * 255.f; + field_0x2DF4.b = ratio * 255.f; +} +void BlurAndPaletteManager::set0x35B0(f32 f) { + field_0x35A0.field_0x10 = f; +} + mColor BlurAndPaletteManager::combineColors(const mColor &c1, const mColor &c2, f32 ratio) { mColor result; result.Set(0xff, 0xff, 0xff, 0xff); @@ -176,7 +430,6 @@ BlurAndPaletteManager::BlurAndPaletteManager() { } } - field_0x5CE4.MA00_kColor3 = mColor(0xff, 0xff, 0xff, 0xff); field_0x5CE4.MA01_tevReg1 = mColor(0xff, 0xff, 0xff, 0xff); field_0x5CE4.MA01_kColor2 = mColor(0xff, 0xff, 0xff, 0xff);