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

Function xEntCollCheckOneGrid

src/SB/Core/x/xEnt.cpp:1357–1451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1355}
1356
1357static void xEntCollCheckOneGrid(xEnt* p, xScene* sc, xEnt* (*hitIt)(xEnt*, xScene*, void*),
1358 xGrid* grid)
1359{
1360 xVec3* r26 = xEntGetCenter(p);
1361 xGridIterator it;
1362 S32 px, pz;
1363
1364 xGridBound* cell = xGridIterFirstCell(grid, r26->x, r26->y, r26->z, px, pz, it);
1365
1366 while (cell)
1367 {
1368 if (xQuickCullIsects(&p->bound.qcd, (xQCData*)(cell + 1)))
1369 {
1370 hitIt((xEnt*)cell->data, sc, p);
1371 }
1372
1373 cell = xGridIterNextCell(it);
1374 }
1375
1376 // non-matching: float scheduling
1377
1378 F32 halfsizez = (grid->csizez * 0.5f);
1379 F32 halfsizex = (grid->csizex * 0.5f);
1380
1381 F32 clcenterx = grid->csizex * px;
1382 F32 clcenterz = grid->csizez * pz;
1383
1384 clcenterx += grid->minx;
1385 clcenterx += halfsizex;
1386
1387 clcenterz += halfsizez;
1388 clcenterz += grid->minz;
1389
1390 static S32 k;
1391
1392 if (r26->x < clcenterx)
1393 {
1394 if (r26->z < clcenterz)
1395 {
1396 k = 0;
1397 }
1398 else
1399 {
1400 k = 1;
1401 }
1402 }
1403 else
1404 {
1405 if (r26->z < clcenterz)
1406 {
1407 k = 3;
1408 }
1409 else
1410 {
1411 k = 2;
1412 }
1413 }
1414

Callers 2

xEntCollCheckByGridFunction · 0.70
xEntCollCheckNPCsByGridFunction · 0.70

Calls 4

xEntGetCenterFunction · 0.85
xGridIterNextCellFunction · 0.85
xGridIterFirstCellFunction · 0.70
xQuickCullIsectsFunction · 0.70

Tested by

no test coverage detected