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

Function nearestFloorCB

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

Source from the content-addressed store, hash-verified

836}
837
838static RpCollisionTriangle* nearestFloorCB(RpIntersection*, RpCollisionTriangle* collTriangle,
839 RwReal, void* data)
840{
841 xNearFloorPoly* nfpoly = (xNearFloorPoly*)data;
842 F32 currnear = nfpoly->neardist;
843 xVec3 currpt;
844 S32 currvert, curredge;
845 xVec3 xformVert[4], xformNorm;
846 U32 potentialOID;
847 S32 i;
848 F32 pdx[3], pdz[3];
849 F32 numer, denom, t, testdist2, neardx, neardz, nearmag;
850 xVec3 edgevec, centvec, testpt;
851
852 if (sUseJSP)
853 {
854 if (((xClumpCollBSPTriangle*)collTriangle->index)->flags & 0x10)
855 {
856 return collTriangle;
857 }
858 potentialOID = ((xClumpCollBSPTriangle*)collTriangle->index)->matIndex;
859 }
860 else
861 {
862 potentialOID = collTriangle->index;
863 }
864
865 if (sBoxTestMat)
866 {
867 xMat4x3Toworld(&xformVert[0], sBoxTestMat, (xVec3*)collTriangle->vertices[0]);
868 xMat4x3Toworld(&xformVert[1], sBoxTestMat, (xVec3*)collTriangle->vertices[1]);
869 xMat4x3Toworld(&xformVert[2], sBoxTestMat, (xVec3*)collTriangle->vertices[2]);
870 xMat3x3RMulVec(&xformNorm, sBoxTestMat, (xVec3*)&collTriangle->normal);
871 xVec3Normalize(&xformNorm, &xformNorm);
872 }
873 else
874 {
875 xformVert[0] = *(xVec3*)collTriangle->vertices[0];
876 xformVert[1] = *(xVec3*)collTriangle->vertices[1];
877 xformVert[2] = *(xVec3*)collTriangle->vertices[2];
878 xformNorm = *(xVec3*)&collTriangle->normal;
879 }
880
881 if (xformNorm.y < nfpoly->floorDot)
882 {
883 return collTriangle;
884 }
885
886 pdx[0] = nfpoly->center.x - xformVert[0].x;
887 pdx[1] = nfpoly->center.x - xformVert[1].x;
888 pdx[2] = nfpoly->center.x - xformVert[2].x;
889 pdz[0] = nfpoly->center.z - xformVert[0].z;
890 pdz[1] = nfpoly->center.z - xformVert[1].z;
891 pdz[2] = nfpoly->center.z - xformVert[2].z;
892
893 F32 f3 = pdx[0] * pdz[1] - pdz[0] * pdx[1];
894 F32 f2 = pdx[1] * pdz[2] - pdz[1] * pdx[2];
895 F32 f1 = pdx[2] * pdz[0] - pdz[2] * pdx[0];

Callers 2

boxNearestFloorCBFunction · 0.70
sectorNearestFloorCBFunction · 0.70

Calls 4

xMat4x3ToworldFunction · 0.85
xsqrtFunction · 0.85
xMat3x3RMulVecFunction · 0.70
xVec3NormalizeFunction · 0.70

Tested by

no test coverage detected