diff --git a/data/odyssey_functions.csv b/data/odyssey_functions.csv index f3dc1afa..849f54ce 100644 --- a/data/odyssey_functions.csv +++ b/data/odyssey_functions.csv @@ -7385,8 +7385,8 @@ Address,Quality,Size,Name 0x000000710012de7c,U,000036,_ZN13ImomuFunction29invalidateDepthShadowMapImomuEPN2al9LiveActorE 0x000000710012dea0,U,000112,_ZN13ImomuFunction16setVelocityZeroHEPN2al9LiveActorE 0x000000710012df10,U,000036,_ZN19ImomuDitherAnimatorD0Ev -0x000000710012df34,U,000004,_ZN2al14DitherAnimator4showEv -0x000000710012df38,U,000008,_ZNK2al14DitherAnimator15isValidNearClipEv +0x000000710012df34,O,000004,_ZN2al14DitherAnimator4showEv +0x000000710012df38,O,000008,_ZNK2al14DitherAnimator15isValidNearClipEv 0x000000710012df40,U,000012,_ZNK26ImomuJointMtxControllerTmp15getCtrlTypeNameEv 0x000000710012df4c,U,000164, 0x000000710012dff0,U,000204,_ZN5JangoC2EPKc @@ -30453,7 +30453,7 @@ Address,Quality,Size,Name 0x00000071004bcd3c,U,000052,_ZN2al19createActorFunctionI8FastenerEEPNS_9LiveActorEPKc 0x00000071004bcd70,U,000052,_ZN2al19createActorFunctionI11FastenerObjEEPNS_9LiveActorEPKc 0x00000071004bcda4,U,000052,_ZN2al19createActorFunctionINS_21AtmosScatterRequesterEEEPNS_9LiveActorEPKc -0x00000071004bcdd8,U,000052,_ZN2al19createActorFunctionINS_13BackHidePartsEEEPNS_9LiveActorEPKc +0x00000071004bcdd8,O,000052,_ZN2al19createActorFunctionINS_13BackHidePartsEEEPNS_9LiveActorEPKc 0x00000071004bce0c,U,000052,_ZN2al19createActorFunctionI17CapRotateMapPartsEEPNS_9LiveActorEPKc 0x00000071004bce40,U,000052,_ZN2al19createActorFunctionINS_13ClockMapPartsEEEPNS_9LiveActorEPKc 0x00000071004bce74,U,000052,_ZN2al19createActorFunctionINS_16ConveyerMapPartsEEEPNS_9LiveActorEPKc @@ -58139,12 +58139,12 @@ Address,Quality,Size,Name 0x0000007100910910,O,000096,_ZN2al14LiveActorGroup7killAllEv 0x0000007100910970,O,000080,_ZN2al14LiveActorGroup17makeActorAliveAllEv 0x00000071009109c0,O,000080,_ZN2al14LiveActorGroup16makeActorDeadAllEv -0x0000007100910a10,U,000064,_ZN2al22BackHideDitherAnimatorC1EPNS_9LiveActorE -0x0000007100910a50,U,000360,_ZN2al22BackHideDitherAnimator6updateEv -0x0000007100910bb8,U,000124,_ZN2al13BackHidePartsC2EPKc -0x0000007100910c34,U,000136,_ZN2al13BackHidePartsC1EPKc -0x0000007100910cbc,U,000144,_ZN2al13BackHideParts4initERKNS_13ActorInitInfoE -0x0000007100910d4c,U,000036,_ZN2al22BackHideDitherAnimatorD0Ev +0x0000007100910a10,O,000064,_ZN2al22BackHideDitherAnimatorC1EPNS_9LiveActorE +0x0000007100910a50,O,000360,_ZN2al22BackHideDitherAnimator6updateEv +0x0000007100910bb8,O,000124,_ZN2al13BackHidePartsC2EPKc +0x0000007100910c34,O,000136,_ZN2al13BackHidePartsC1EPKc +0x0000007100910cbc,m,000144,_ZN2al13BackHideParts4initERKNS_13ActorInitInfoE +0x0000007100910d4c,O,000036,_ZN2al22BackHideDitherAnimatorD0Ev 0x0000007100910d70,O,000140,_ZN2al17BreakMapPartsBaseC2EPKc 0x0000007100910dfc,O,000152,_ZN2al17BreakMapPartsBaseC1EPKc 0x0000007100910e94,O,000464,_ZN2al17BreakMapPartsBase4initERKNS_13ActorInitInfoE diff --git a/lib/al/Library/Anim/DitherAnimator.h b/lib/al/Library/Anim/DitherAnimator.h new file mode 100644 index 00000000..775d04b2 --- /dev/null +++ b/lib/al/Library/Anim/DitherAnimator.h @@ -0,0 +1,18 @@ +#pragma once + +#include "Library/Nerve/NerveExecutor.h" + +namespace al { +class LiveActor; + +class DitherAnimator : public NerveExecutor { +public: + DitherAnimator(const char* name) : NerveExecutor(name) {} + + virtual void update() = 0; + + virtual void show() {} + + virtual bool isValidNearClip() const { return false; } +}; +} // namespace al diff --git a/lib/al/Library/MapObj/BackHideParts.cpp b/lib/al/Library/MapObj/BackHideParts.cpp new file mode 100644 index 00000000..54ca6a2a --- /dev/null +++ b/lib/al/Library/MapObj/BackHideParts.cpp @@ -0,0 +1,54 @@ +#include "Library/MapObj/BackHideParts.h" + +#include "Library/Camera/CameraUtil.h" +#include "Library/LiveActor/ActorInitFunction.h" +#include "Library/LiveActor/ActorModelFunction.h" +#include "Library/LiveActor/ActorPoseKeeper.h" +#include "Library/Math/MathAngleUtil.h" +#include "Library/Math/MathLengthUtil.h" +#include "Library/Math/MathUtil.h" +#include "Library/Model/ModelKeeper.h" +#include "Library/Placement/PlacementFunction.h" + +namespace al { +BackHideDitherAnimator::BackHideDitherAnimator(LiveActor* actor) + : DitherAnimator("背面ディザアニメーター"), mActor(actor) {} + +void BackHideDitherAnimator::update() { + sead::Vector3f cameraFront; + calcCameraFront(&cameraFront, mActor, 0); + + f32 cameraOffset = (getCameraPos(mActor, 0) - getTrans(mActor)).length(); + + sead::Vector3f actorFront; + calcFrontDir(&actorFront, mActor); + + f32 angleDegree = normalize(calcAngleDegree(cameraFront, actorFront), 60.0f, 90.0f); + cameraOffset = normalize(cameraOffset, 10000.0f, 12000.0f); + + f32 actorAlpha = sead::Mathf::clamp(lerpValue(angleDegree, 1.0f, cameraOffset), 0.0f, 1.0f); + setModelAlphaMask(mActor, actorAlpha); + + if (isNearZero(actorAlpha, 0.001)) { + hideModelIfShow(mActor); + + return; + } + + showModelIfHide(mActor); +} + +BackHideParts::BackHideParts(const char* name) : LiveActor(name) {} + +// NON_MATCHING: regswap (https://decomp.me/scratch/j5tRy) +void BackHideParts::init(const ActorInitInfo& info) { + const char* suffix = nullptr; + tryGetStringArg(&suffix, info, "Suffix"); + initMapPartsActor(this, info, suffix); + + mBackHideDitherAnimator = new BackHideDitherAnimator(this); + getModelKeeper()->setDitherAnimator(mBackHideDitherAnimator); + + trySyncStageSwitchAppearAndKill(this); +} +} // namespace al diff --git a/lib/al/Library/MapObj/BackHideParts.h b/lib/al/Library/MapObj/BackHideParts.h new file mode 100644 index 00000000..9d998e9d --- /dev/null +++ b/lib/al/Library/MapObj/BackHideParts.h @@ -0,0 +1,26 @@ +#pragma once + +#include "Library/Anim/DitherAnimator.h" +#include "Library/LiveActor/LiveActor.h" + +namespace al { +class BackHideDitherAnimator : public DitherAnimator { +public: + BackHideDitherAnimator(LiveActor* actor); + + void update() override; + +private: + LiveActor* mActor; +}; + +class BackHideParts : public LiveActor { +public: + BackHideParts(const char* name); + + void init(const ActorInitInfo& info) override; + +private: + BackHideDitherAnimator* mBackHideDitherAnimator = nullptr; +}; +} // namespace al diff --git a/lib/al/Library/Model/ModelKeeper.h b/lib/al/Library/Model/ModelKeeper.h index d9726baa..ddc65e02 100644 --- a/lib/al/Library/Model/ModelKeeper.h +++ b/lib/al/Library/Model/ModelKeeper.h @@ -12,6 +12,7 @@ class AnimPlayerSimple; class AnimPlayerSkl; class AnimPlayerVis; class ModelCtrl; +class DitherAnimator; class ModelKeeper : public HioNode { public: @@ -22,6 +23,7 @@ public: void calc(const sead::Matrix34f&, const sead::Vector3f&); void initResource(); void createMatAnimForProgram(s32); + void setDitherAnimator(DitherAnimator* ditherAnimator); ModelCtrl* getModelCtrl() const { return mModelCtrl; } diff --git a/src/Scene/ProjectActorFactory.cpp b/src/Scene/ProjectActorFactory.cpp index 5d85c369..09d14316 100644 --- a/src/Scene/ProjectActorFactory.cpp +++ b/src/Scene/ProjectActorFactory.cpp @@ -2,6 +2,7 @@ #include "Library/Factory/Factory.h" #include "Library/LiveActor/CreateActorFunction.h" +#include "Library/MapObj/BackHideParts.h" #include "Library/MapObj/FallMapParts.h" #include "Library/MapObj/FixMapParts.h" #include "Library/MapObj/FloaterMapParts.h" @@ -550,7 +551,7 @@ static al::NameToCreator sProjectActorFactoryEntries[] {"Fastener", nullptr}, {"FastenerObj", nullptr}, {"AtmosScatterRequester", nullptr}, - {"BackHideParts", nullptr}, + {"BackHideParts", al::createActorFunction}, {"BreakMapParts", nullptr}, {"CapRotateMapParts", nullptr}, {"ClockMapParts", nullptr},