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

Function xModelBucket_Add

src/SB/Core/x/xModelBucket.cpp:278–340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276}
277
278void xModelBucket_Add(xModelInstance* minst)
279{
280 if ((minst->Flags & 0x401) != 0x1)
281 return;
282
283 RpAtomic* model = minst->Data;
284 if (iModelCull(model, minst->Mat))
285 return;
286
287 xMat4x3* cammat = &xglobals->camera.mat;
288 F32 camdist2 = SQR(model->worldBoundingSphere.center.x - cammat->pos.x) +
289 SQR(model->worldBoundingSphere.center.y - cammat->pos.y) +
290 SQR(model->worldBoundingSphere.center.z - cammat->pos.z);
291 if (camdist2 >= SQR(minst->FadeEnd))
292 return;
293
294 if ((minst->PipeFlags & 0xC0) != 0x40)
295 {
296 minst->LightKit = gLastLightKit;
297 }
298
299 xModelBucket* bucket;
300 F32 camdot = cammat->at.x * (model->worldBoundingSphere.center.x - cammat->pos.x) +
301 cammat->at.y * (model->worldBoundingSphere.center.y - cammat->pos.y) +
302 cammat->at.z * (model->worldBoundingSphere.center.z - cammat->pos.z);
303 if (camdot < 1.5f * model->worldBoundingSphere.radius)
304 {
305 bucket = minst->Bucket[1];
306 }
307 else
308 {
309 bucket = minst->Bucket[0];
310 }
311
312 F32 alphaFade = 1.0f;
313 if (camdist2 > SQR(minst->FadeStart))
314 {
315 alphaFade = (minst->FadeEnd - xsqrt(camdist2)) / (minst->FadeEnd - minst->FadeStart);
316 if (alphaFade <= 0.0f)
317 return;
318 alphaFade = MIN(alphaFade, 1.0f);
319 }
320
321 if ((minst->PipeFlags & 0xFF00) || alphaFade != 1.0f || minst->Alpha != 1.0f)
322 {
323 if (sAlphaCurr < sAlphaCount)
324 {
325 sAlphaList[sAlphaCurr].Data = bucket->Data;
326 sAlphaList[sAlphaCurr].MInst = minst;
327 sAlphaList[sAlphaCurr].AlphaFade = alphaFade;
328 sAlphaList[sAlphaCurr].SortValue = (model->worldBoundingSphere.radius > 25.0f) ?
329 (camdot + model->worldBoundingSphere.radius) :
330 camdot;
331 sAlphaList[sAlphaCurr].Layer = (minst->PipeFlags >> 19) & 0x1F;
332 sAlphaCurr++;
333 }
334 }
335 else

Callers 2

xModelRenderFunction · 0.70
zEntPickup_RenderFunction · 0.50

Calls 2

iModelCullFunction · 0.85
xsqrtFunction · 0.85

Tested by

no test coverage detected