SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
MirrorActor.cpp
1#include "Game/LiveActor/MirrorActor.hpp"
2#include "Game/LiveActor/MirrorCamera.hpp"
3#include "Game/NameObj/NameObjExecuteHolder.hpp"
4#include "JSystem/JMath/JMath.hpp"
5
6MirrorActor::~MirrorActor() {
7
8}
9
10MirrorActor::MirrorActor(LiveActor *pActor, const char *a2, const char *a3) : LiveActor(a2) {
11 _8C = pActor;
12 _A0 = 0;
13 initModelManagerWithAnm(a3, 0, 0);
14}
15
16#ifdef NON_MATCHING
17void MirrorActor::init(const JMapInfoIter &rIter) {
18 MR::connectToSceneMirrorMapObj(this);
19 MR::copyJointAnimation(this, _8C);
20 MR::syncMaterialAnimation(this, _8C);
21 MR::invalidateClipping(this);
22
23 TBox3f modelBB;
24 MR::calcModelBoundingBox(&modelBB, _8C);
25
26 register TVec3f stack_14;
27 JMAVECLerp((const Vec*)&modelBB.mMax, (const Vec*)&modelBB.mMin, (Vec*)&stack_14, 0.5f);
28 register TVec3f stack_8(modelBB.mMax);
29
30 register TVec3f* ptrStack = &stack_8;
31
32 __asm {
33 psq_l f1, 0x20(r1), 0, 0
34 psq_l f0, 0(ptrStack), 0, 0
35 psq_l f2, 8(ptrStack), 1, 0
36 ps_sub f0, f0, f1
37 psq_l f3, 0x28(r1), 1, 0
38 ps_sub f1, f2, f3
39 psq_st f0, 0(ptrStack), 0, 0
40 psq_st f1, 8(ptrStack), 1, 0
41 };
42
43 f32 mag = PSVECMag((const Vec*)&stack_8);
44 _9C = 0.5f * mag;
45
46 __asm {
47 psq_l f0, 0x14(r1), 0, 0
48 lfs f1, 0x1C(r1)
49 psq_st f0, 0x90(r31), 0, 0
50 stfs f1, 0x98(r31)
51 };
52
53 makeActorAppeared();
54}
55#endif
56
57void MirrorActor::movement() {
58 if (MR::isDead(this) || MR::isDead(_8C) || MR::isClipped(_8C) || MR::isHiddenModel(_8C) || isHostInTheOtherSideOfMirror()) {
59 if (_A0) {
60 _A0 = 1;
61
62 if (!MR::isHiddenModel(this)) {
63 MR::disconnectToDrawTemporarily(this);
64 }
65 }
66 }
67 else {
68 if (_A0) {
69 _A0 = 0;
70
71 if (!MR::isHiddenModel(this)) {
72 MR::connectToDrawTemporarily(this);
73 }
74 }
75
76 LiveActor::movement();
77 }
78}
79
80void MirrorActor::calcAnim() {
81 MR::copyJointAnimation(this, _8C);
82 MR::updateMaterial(this);
83}
84
85void MirrorActor::calcViewAndEntry() {
86 mModelManager->calcView();
87}
88
89#ifdef NON_MATCHING
90// weird function call to getHostCenterPos
91bool MirrorActor::isHostInTheOtherSideOfMirror() const {
92 if (MR::isExistMirrorCamera()) {
93 TVec3f centerPos;
94 centerPos = getHostCenterPos();
95 f32 dist = MR::getDistanceToMirror(centerPos);
96 return dist < 0.0f;
97 }
98
99 return false;
100}
101#endif
The basis of a drawable actor that can contain states (see: Nerve)
Definition LiveActor.hpp:24
ModelManager * mModelManager
A pointer to a ModelManager instance, used for drawing a 3D model.
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.