SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
PartsModel.cpp
1#include "Game/LiveActor/PartsModel.hpp"
2#include "Game/NameObj/NameObjExecuteHolder.hpp"
3
4PartsModel::PartsModel(LiveActor *pActor, const char *pName, const char *pModelName, MtxPtr mtx, int a5, bool a6) : LiveActor(pName) {
5 mHost = pActor;
6 mFixedPos = nullptr;
7 mMtx = mtx;
8 mCalcOwnMtx = true;
9 _99 = false;
10 mIsDead = false;
11
12 if (a5 > 0) {
13 a5 = 8;
14 }
15
16 if (mMtx) {
17 mPosition.set<f32>(mMtx[0][3], mMtx[1][3], mMtx[2][3]);
18 }
19 else {
20 mPosition.set<f32>(pActor->mPosition);
21 }
22
23 mRotation.set<f32>(pActor->mRotation);
24 mScale.set<f32>(pActor->mScale);
25
26 initModelManagerWithAnm(pModelName, nullptr, a6);
27
28 u32 v14 = 43;
29 u32 v15 = 11;
30
31 if ((a5 - 21) <= (u32)2) {
32 v14 = 38;
33 v15 = 10;
34 }
35
36 if (a5 == 16 || a5 == 27) {
37 v14 = 40;
38 v15 = 6;
39 }
40 MR::connectToScene(this, v14, v15, a5, -1);
41}
42
43void PartsModel::makeActorAppeared() {
44 LiveActor::makeActorAppeared();
45 mIsDead = false;
46}
47
48void PartsModel::makeActorDead() {
49 LiveActor::makeActorDead();
50 mIsDead = true;
51}
52
53// 99.9% sure the call to makeActorAppered is meant to be inlined but ¯\_(ツ)_/¯ this matches
54void PartsModel::init(const JMapInfoIter &rIter) {
55 initEffectKeeper(8, nullptr, false);
56 initSound(8, false);
57 MR::isInvalidClipping(this);
58 makeActorAppeared();
59 mIsDead = false;
60}
61
62void PartsModel::movement() {
63 if (MR::isDead(this) || MR::isDead(mHost) || MR::isClipped(mHost) || !_99 && MR::isHiddenModel(mHost)) {
64 if (!mIsDead) {
65 mIsDead = true;
66 MR::invalidateHitSensors(this);
67
68 if (!MR::isHiddenModel(this)) {
69 MR::disconnectToDrawTemporarily(this);
70 }
71 }
72 }
73 else {
74 if (mIsDead) {
75 mIsDead = false;
76 MR::validateHitSensors(this);
77
78 if (!MR::isHiddenModel(this)) {
79 MR::connectToDrawTemporarily(this);
80 }
81 }
82 LiveActor::movement();
83 }
84}
85
86#ifdef NON_MATCHING
87void PartsModel::calcAnim() {
88 if (mIsDead || MR::isDead(this) || MR::isNoCalcAnim(this) || MR::isClipped(this)) {
89 return;
90 }
91
92 if (mFixedPos) {
93 mFixedPos->calc();
94 }
95 LiveActor::calcAnim();
96}
97#endif
98
99void PartsModel::calcViewAndEntry() {
100 if (!mIsDead) {
101 LiveActor::calcViewAndEntry();
102 }
103}
104
105void PartsModel::initFixedPosition(const TVec3f &rLocalTrans, const TVec3f &a2, const char *pJointName) {
106 if (pJointName) {
107 mFixedPos = new FixedPosition(mHost, pJointName, rLocalTrans, a2);
108 }
109 else {
110 mFixedPos = new FixedPosition(mHost, rLocalTrans, a2);
111 }
112 mMtx = (MtxPtr)&mFixedPos->_1C;
113}
114
115void PartsModel::initFixedPosition(const char *pJointName) {
116 initFixedPosition(TVec3f(0.0f, 0.0f, 0.0f), TVec3f(0.0f, 0.0f, 0.0f), pJointName);
117}
118
119void PartsModel::initFixedPosition(MtxPtr mtx, const TVec3f &rLocalTrans, const TVec3f &a3) {
120 mFixedPos = new FixedPosition(mtx, rLocalTrans, a3);
121 mMtx = (MtxPtr)&mFixedPos->_1C;
122}
123
124void PartsModel::loadFixedPosition(const char *pJointName) {
125 mFixedPos = new FixedPosition(mHost, pJointName, nullptr);
126 mMtx = (MtxPtr)&mFixedPos->_1C;
127}
128
129void PartsModel::offFixedPosNormalizeScale() {
130 mFixedPos->mNormalizeScale = false;
131}
132
134 if (mMtx && mCalcOwnMtx) {
135 mPosition.set<f32>(mMtx[0][3], mMtx[1][3], mMtx[2][3]);
136 MR::setBaseTRMtx(this, mMtx);
137 }
138 else {
140 }
141}
The basis of a drawable actor that can contain states (see: Nerve)
Definition LiveActor.hpp:24
TVec3f mRotation
3D vector of the actor's rotation.
Definition LiveActor.hpp:96
TVec3f mPosition
3D vector of the actor's position.
Definition LiveActor.hpp:95
TVec3f mScale
3D vector of the actor's scale.
Definition LiveActor.hpp:97
virtual void calcAndSetBaseMtx()
Calculates and sets the base matrix of the actor.
virtual void calcAndSetBaseMtx()
Calculates and sets the base matrix of the actor.
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.