SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
ShadowController.cpp
1#include "Game/LiveActor/ShadowController.hpp"
2#include "Game/LiveActor/ShadowDrawer.hpp"
3
4ShadowControllerHolder::ShadowControllerHolder() : NameObj("影管理"), _C(), _18(), _24(false) {
5 mFarClip = 4000.0f;
6 _C.init(0x500);
7 _18.init(0x400);
8 MR::connectToScene(this, 0x2D, -1, -1, -1);
9
10 if (MR::isEqualStageName("AstroGalaxy") || MR::isEqualStageName("PeachCastleGardenGalaxy") || MR::isEqualStageName("PeachCastleFinalGalaxy")) {
11 _24 = true;
12 }
13}
14
15void ShadowControllerHolder::movement() {
16 updateController();
17}
18
19void ShadowControllerHolder::initAfterPlacement() {
20 u32 count = _C.getCount();
21 for (u32 i = 0; i < count; i++) {
22 ShadowController* ctrl = _C[i];
23 ctrl->updateDirection();
24 ctrl->updateProjection();
25 }
26}
27
28void ShadowControllerHolder::updateController() {
29 u32 count = _18.getCount();
30
31 for (u32 i = 0; i < count; i++) {
32 if (_24) {
33 ShadowController* ctrl = _18[i];
34 ctrl->updateFarClipping(mFarClip);
35 }
36
37 ShadowController* ctrl = _18[i];
38 ctrl->update();
39 }
40
41 _18.mCount = 0;
42}
43
44ShadowControllerList::ShadowControllerList(LiveActor *pActor, u32 listCount) : mShadowList(), mHost(pActor) {
45 mShadowList.init(listCount);
46}
47
48void ShadowControllerList::addController(ShadowController *pController) {
49 mShadowList.push_back(pController);
50}
51
52u32 ShadowControllerList::getControllerCount() const {
53 return mShadowList.mCount;
54}
55
56ShadowController* ShadowControllerList::getController(u32 idx) const {
57 return mShadowList[idx];
58}
59
60ShadowController* ShadowControllerList::getController(const char *pName) const {
61 if (mShadowList.mCount == 1) {
62 return mShadowList[0];
63 }
64
65 for (u32 i = 0; i < mShadowList.mCount; i++) {
66 if (MR::isEqualString(pName, mShadowList[i]->mName)) {
67 return mShadowList[i];
68 }
69 }
70
71 return nullptr;
72}
73
74void ShadowControllerList::resetCalcCount() {
75 for (u32 i = 0; i < mShadowList.getCount(); i++) {
76 ShadowController* controller = mShadowList[i];
77 controller->_65 = 0;
78 controller->_66 = 0;
79 }
80}
81
82void ShadowControllerList::requestCalc() {
83 for (u32 i = 0; i < mShadowList.getCount(); i++) {
84 mShadowList[i]->requestCalc();
85 }
86}
87
88void ShadowController::requestCalc() {
89 if (!_64) {
90 _64 = 1;
91 appendToHolder();
92 }
93}
94
95void ShadowController::update() {
96 if (isDraw()) {
97 updateDirection();
98 updateProjection();
99 }
100
101 _64 = 0;
102}
103
104void ShadowController::updateFarClipping(f32 clip) {
105 TVec3f dropPos;
106 getDropPos(&dropPos);
107 f32 cameraDistZ = MR::calcCameraDistanceZ(dropPos);
108 _67 = cameraDistZ >= clip;
109}
110
111ShadowDrawer* ShadowController::getShadowDrawer() {
112 return mDrawer;
113}
114
115LiveActor* ShadowController::getHost() const {
116 return mActor;
117}
118
119void ShadowController::setShadowDrawer(ShadowDrawer *pDrawer) {
120 mDrawer = pDrawer;
121 pDrawer->setShadowController(this);
122}
123
124void ShadowController::getDropPos(TVec3f *pOut) const {
125 if (mDropPos) {
126 pOut->set(*mDropPos);
127 }
128 else {
129 if (_1C) {
130 PSMTXMultVec(_1C, (const Vec*)&_30, (Vec*)pOut);
131 }
132 else {
133 pOut->set(_30);
134 }
135 }
136}
137
138void ShadowController::getDropDir(TVec3f *pOut) const {
139 if (mDropDir) {
140 pOut->set(*mDropDir);
141 }
142 else {
143 pOut->set(_3C);
144 }
145}
146
147f32 ShadowController::getDropLength() const {
148 return mDropLength;
149}
150
151void ShadowController::getProjectionPos(TVec3f *pOut) const {
152 if (mProjPos) {
153 pOut->set(*mProjPos);
154 }
155 else {
156 pOut->set(_48);
157 }
158}
159
160void ShadowController::getProjectionNormal(TVec3f *pOut) const {
161 if (mProjNorm) {
162 pOut->set(*mProjNorm);
163 }
164 else {
165 pOut->set(_54);
166 }
167}
168
169bool ShadowController::isProjected() const {
170 return _63 != 0;
171}
172
173bool ShadowController::isDraw() const {
174 if (_67) {
175 return false;
176 }
177
178 if (!_71) {
179 return false;
180 }
181
182 if (!_72) {
183 return true;
184 }
185
186 return MR::isValidDraw(mActor);
187}
188
189/*
190bool ShadowController::isCalcCollision() const {
191 if (!_60) {
192 return false;
193 }
194
195 if (_60 == 2) {
196 return _65 >= 0;
197 }
198
199 return true;
200}
201*/
202
203/*
204bool ShadowController::isCalcShadowGravity() const {
205 return (_61 + 0xFC) <= 1;
206}
207*/
208
209void ShadowController::setGroupName(const char *pName) {
210 mGroupName = pName;
211}
212
213void ShadowController::setDropPosPtr(const TVec3f *pDropPos) {
214 mDropPos = pDropPos;
215 _1C = 0;
216}
217
218void ShadowController::setDropPosFix(const TVec3f &rPos) {
219 _30.set(rPos);
220 mDropPos = 0;
221 _1C = 0;
222}
223
224void ShadowController::setDropDirPtr(const TVec3f *pDropDir) {
225 mDropDir = pDropDir;
226 _61 = 0;
227}
228
229void ShadowController::setDropDirFix(const TVec3f &a1) {
230 _3C.set(a1);
231 mDropDir = 0;
232 _61= 0;
233}
234
235void ShadowController::setDropLength(f32 len) {
236 mDropLength = len;
237}
238
239void ShadowController::setDropStartOffset(f32 offs) {
240 mStartOffset = offs;
241}
242
243void ShadowController::setDropTypeNormal() {
244 _62 = 0;
245}
246
247void ShadowController::setDropTypeSurface() {
248 _62 = 1;
249}
250
251void ShadowController::setProjectionFix(const TVec3f &a1, const TVec3f &a2, bool a3) {
252 _48.set(a1);
253 _54.set(a2);
254 _63 = a3;
255 _10 = 0;
256}
257
258void ShadowController::onCalcCollision() {
259 _60 = 1;
260}
261
262void ShadowController::offCalcCollision() {
263 _60 = 0;
264}
265
266void ShadowController::onCalcCollisionOneTime() {
267 _60 = 2;
268 _65 = 0;
269}
270
271void ShadowController::onCalcDropGravity() {
272 TVec3f vec(0.0f, 1.0f, 0.0f);
273 _3C.set(vec);
274 mDropDir = 0;
275 _61 = 1;
276}
277
278void ShadowController::onCalcDropGravityOneTime() {
279 TVec3f vec(0.0f, 1.0f, 0.0f);
280 _3C.set(vec);
281 mDropDir = 0;
282 _61 = 2;
283 _66 = 0;
284}
285
286void ShadowController::offCalcDropGravity() {
287 _61 = 0;
288}
289
290void ShadowController::onCalcDropPrivateGravity() {
291 TVec3f vec(0.0f, 1.0f, 0.0f);
292 _3C.set(vec);
293 mDropDir = 0;
294 _61 = 4;
295}
296
297void ShadowController::onCalcDropPrivateGravityOneTime() {
298 TVec3f vec(0.0f, 1.0f, 0.0f);
299 _3C.set(vec);
300 mDropDir = 0;
301 _61 = 5;
302 _66 = 0;
303}
304
305void ShadowController::offCalcDropPrivateGravity() {
306 _61 = 3;
307}
308
309void ShadowController::setCollisionPartsFilter(CollisionPartsFilterBase *pBase) {
310 mCollisionPartsFilter = pBase;
311}
312
313void ShadowController::onFollowHostScale() {
314 _70 = 1;
315}
316
317void ShadowController::offFollowHostScale() {
318 _70 = 0;
319}
320
321bool ShadowController::isFollowHostScale() const {
322 return _70;
323}
324
325void ShadowController::onVisibleSyncHost() {
326 _72 = 1;
327}
328
329void ShadowController::offVisibleSyncHost() {
330 _72 = 0;
331}
332
333void ShadowController::validate() {
334 _71 = 1;
335}
336
337void ShadowController::invalidate() {
338 _71 = 0;
339}
340
341ShadowControllerHolder::~ShadowControllerHolder() {
342
343}
The basis of a drawable actor that can contain states (see: Nerve)
Definition LiveActor.hpp:24
The most basic form of an object.
Definition NameObj.hpp:11
virtual void init(const JMapInfoIter &rIter)
Intializes the NameObj and can set various settings and construct necessary classes.
Definition NameObj.cpp:17