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

Function xSceneNearestFloorPoly

src/SB/Core/x/xScene.cpp:1062–1126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1060}
1061
1062U32 xSceneNearestFloorPoly(xScene* sc, xNearFloorPoly* nfpoly, U8 collType, U8 chk)
1063{
1064 sNearestBound.type = XBOUND_TYPE_BOX;
1065 sNearestBound.box.box = nfpoly->box;
1066
1067 xVec3Lerp(&sNearestBound.box.center, &sNearestBound.box.box.upper, &sNearestBound.box.box.lower,
1068 0.5f);
1069 xQuickCullForBox(&sNearestBound.qcd, &sNearestBound.box.box);
1070
1071 RpIntersection isx;
1072 isx.type = rpINTERSECTBOX;
1073 isx.t.box.sup = *(RwV3d*)&sNearestBound.box.box.upper;
1074 isx.t.box.inf = *(RwV3d*)&sNearestBound.box.box.lower;
1075
1076 sSphereIsx.type = rpINTERSECTSPHERE;
1077 sSphereIsx.t.sphere.radius =
1078 xsqrt((SQR(isx.t.box.sup.x - isx.t.box.inf.x) + SQR(isx.t.box.sup.y - isx.t.box.inf.y) +
1079 SQR(isx.t.box.sup.z - isx.t.box.inf.z)) *
1080 0.25f);
1081 sSphereIsx.t.sphere.center = *(RwV3d*)&sNearestBound.box.center;
1082
1083 nfpoly->neardist = HUGE;
1084 nfpoly->center = sNearestBound.box.center;
1085 nfpoly->oid = NULL;
1086 nfpoly->optr = NULL;
1087 nfpoly->mptr = NULL;
1088
1089 if (chk & (XENT_COLLTYPE_STAT | XENT_COLLTYPE_DYN))
1090 {
1091 sNearestChk = chk;
1092 sNearestCollType = collType;
1093 xGridCheckPosition(&colls_grid, &sNearestBound.box.center, &sNearestBound.qcd,
1094 gridNearestFloorCB, nfpoly);
1095 xGridCheckPosition(&colls_oso_grid, &sNearestBound.box.center, &sNearestBound.qcd,
1096 gridNearestFloorCB, nfpoly);
1097 }
1098
1099 if (chk & 0x20)
1100 {
1101 sTestOPtr = NULL;
1102 sTestMPtr = NULL;
1103 sBoxTestMat = NULL;
1104
1105 if (sc->env->geom->jsp)
1106 {
1107 sUseJSP = true;
1108 xClumpColl_ForAllIntersections(sc->env->geom->jsp->colltree, &isx, sectorNearestFloorCB,
1109 nfpoly);
1110 sUseJSP = false;
1111 }
1112 else
1113 {
1114 RpCollisionWorldForAllIntersections(sc->env->geom->world, &isx, sectorNearestFloorCB,
1115 nfpoly);
1116 }
1117 }
1118
1119 if (nfpoly->neardist != HUGE)

Callers

nothing calls this directly

Calls 5

xVec3LerpFunction · 0.85
xsqrtFunction · 0.85
xQuickCullForBoxFunction · 0.70
xGridCheckPositionFunction · 0.70

Tested by

no test coverage detected