SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
DrawBufferGroup.cpp
1#include "Game/System/DrawBufferGroup.hpp"
2
3#include <algorithm>
4
5DrawBufferGroup::DrawBufferGroup() : _0(), _C() {
6 mCount = 0;
7 _1C = -1;
8 _20 = -1;
9}
10
11void DrawBufferGroup::init(s32 count) {
12 _0.mArray.mArr = new DrawBufferExecuter*[count];
13 _0.mArray.mMaxSize = count;
14 _C.mArray.mArr = new DrawBufferExecuter*[count];
15 _C.mArray.mMaxSize = count;
16}
17
18s32 DrawBufferGroup::registerDrawBuffer(LiveActor *pActor) {
19 const char* modelName = MR::getModelResName(pActor);
20 s32 idx = findExecuterIndex(modelName);
21
22 // executer does not exist
23 if (idx < 0) {
24 DrawBufferExecuter* exec = new DrawBufferExecuter(modelName, MR::getJ3DModel(pActor), 0x10);
25
26 idx = _0.mCount;
27 _0.push_back(exec);
28
29 if (_20 == -1) {
30 exec->onExecuteLight(_1C);
31 }
32 }
33
34 _0.mArray.mArr[idx]->mDrawBufferCount++;
35
36 return idx;
37}
38
39void DrawBufferGroup::active(LiveActor *pActor, s32 a2) {
40 DrawBufferExecuter* exec = _0.mArray.mArr[a2];
41 bool isEmpty = !(exec->_8 != 0);
42 exec->add(pActor);
43
44 if (isEmpty) {
45 _C.push_back(_0.mArray.mArr[a2]);
46 }
47}
48
49// DrawBufferGroup::deactive
50
51void DrawBufferGroup::findLightInfo(LiveActor *pActor, s32 a2) {
52 MR::initActorLightInfoLightType(pActor, _1C);
53 _0.mArray.mArr[a2]->findLightInfo(pActor);
54
55 if (_20 != -1) {
56 for (u32 i = 0; i < _0.mCount; i++) {
57 _0.mArray.mArr[i]->onExecuteLight(_1C);
58 }
59
60 _20 = -1;
61 }
62
63 _0.mArray.mArr[a2]->offExecuteLight();
64}
65
66#ifdef NON_MATCHING
67// mem_fun doesn't get inlined...why?
68void DrawBufferGroup::entry() {
69 for_each(_C.mArray.mArr, &_C.mArray.mArr[_C.mArray.mMaxSize], mem_fun(&DrawBufferExecuter::calcViewAndEntry));
70}
71#endif
72
73// DrawBufferGroup::drawOpa
74// DrawBufferGroup::drawXlu
75
76void DrawBufferGroup::setDrawCameraType(s32 type) {
77 mCount = type;
78}
79
80void DrawBufferGroup::setLightType(s32 type) {
81 _1C = type;
82 _20 = type;
83}
84
85s32 DrawBufferGroup::findExecuterIndex(const char *pName) const {
86 for (u32 i = 0; i < _0.mCount; i++) {
87 if (MR::isEqualString(_0.mArray.mArr[i]->mName, pName)) {
88 return i;
89 }
90 }
91
92 return -1;
93}
The basis of a drawable actor that can contain states (see: Nerve)
Definition LiveActor.hpp:24