MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / zLOD_Update

Function zLOD_Update

src/SB/Game/zLOD.cpp:159–244  ·  view source on GitHub ↗

WIP

Source from the content-addressed store, hash-verified

157
158// WIP
159void zLOD_Update(U32 percent_update)
160{
161 if (sManagerCount == 0)
162 {
163 return;
164 }
165
166 U32 numUpdates = (sManagerCount * percent_update) / 100;
167 if (numUpdates == 0)
168 {
169 numUpdates = 1;
170 }
171
172 for (U32 i = 0; i < numUpdates; i++)
173 {
174 sManagerIndex++;
175 if (sManagerIndex >= sManagerCount)
176 sManagerIndex = 0;
177
178 zLODManager* mgr = &sManagerList[sManagerIndex];
179 xModelInstance* model = mgr->model;
180 zLODTable* lod = mgr->lod;
181
182 if (!mgr || !model || !lod)
183 {
184 continue;
185 }
186
187 RwMatrix* mat = model->Mat;
188 F32 distscale = mat->right.x * mat->right.x + mat->up.x * mat->up.x + mat->at.x * mat->at.x;
189 if (distscale < 0.0001f)
190 distscale = 1.0f;
191
192 xVec3* camPos = &globals.camera.mat.pos;
193 F32 camdist2 = 0.0f;
194 if (mat)
195 {
196 F32 dx = camPos->x - mat->pos.x;
197 F32 dy = camPos->y - mat->pos.y;
198 F32 dz = camPos->z - mat->pos.z;
199 camdist2 = (dx * dx + dy * dy + dz * dz) / distscale;
200 }
201
202 if (camdist2 >= mgr->adjustNoRenderDist)
203 {
204 model->PipeFlags |= 0x400;
205
206 if (mgr->numextra)
207 {
208 for (xModelInstance* extra = model->Next; extra; extra = extra->Next)
209 extra->PipeFlags |= 0x400;
210 }
211 }
212 else
213 {
214 model->PipeFlags &= ~0x400;
215
216 if (lod->baseBucket)

Callers 3

zSceneResetFunction · 0.70
zSceneUpdateFunction · 0.70
zGameSetupFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected