1#include "Library/MapObj/BackHideParts.h"
2
3#include "Library/Camera/CameraUtil.h"
4#include "Library/LiveActor/ActorInitFunction.h"
5#include "Library/LiveActor/ActorInitUtil.h"
6#include "Library/LiveActor/ActorModelFunction.h"
7#include "Library/LiveActor/ActorPoseUtil.h"
8#include "Library/Math/MathUtil.h"
9#include "Library/Model/ModelKeeper.h"
10#include "Library/Placement/PlacementFunction.h"
11
12namespace al {
13BackHideDitherAnimator::BackHideDitherAnimator(LiveActor* actor)
14 : DitherAnimator("背面ディザアニメーター"), mActor(actor) {}
15
16void BackHideDitherAnimator::update() {
17 sead::Vector3f cameraFront;
18 calcCameraFront(&cameraFront, user: mActor, viewIdx: 0);
19
20 f32 cameraOffset = (getCameraPos(user: mActor, viewIdx: 0) - getTrans(actor: mActor)).length();
21
22 sead::Vector3f actorFront;
23 calcFrontDir(front: &actorFront, actor: mActor);
24
25 f32 angleDegree = normalize(x: calcAngleDegree(a: cameraFront, b: actorFront), min: 60.0f, max: 90.0f);
26 cameraOffset = normalize(x: cameraOffset, min: 10000.0f, max: 12000.0f);
27
28 f32 actorAlpha = sead::Mathf::clamp(value: lerpValue(a: angleDegree, b: 1.0f, t: cameraOffset), low: 0.0f, high: 1.0f);
29 setModelAlphaMask(actor: mActor, actorAlpha);
30
31 if (isNearZero(value: actorAlpha, tolerance: 0.001)) {
32 hideModelIfShow(actor: mActor);
33
34 return;
35 }
36
37 showModelIfHide(actor: mActor);
38}
39
40BackHideParts::BackHideParts(const char* name) : LiveActor(name) {}
41
42// NON_MATCHING: regswap (https://decomp.me/scratch/j5tRy)
43void BackHideParts::init(const ActorInitInfo& info) {
44 const char* suffix = nullptr;
45 tryGetStringArg(arg: &suffix, initInfo: info, key: "Suffix");
46 initMapPartsActor(actor: this, initInfo: info, suffix);
47
48 mBackHideDitherAnimator = new BackHideDitherAnimator(this);
49 getModelKeeper()->setDitherAnimator(mBackHideDitherAnimator);
50
51 trySyncStageSwitchAppearAndKill(actor: this);
52}
53} // namespace al
54