| 1316 | |
| 1317 | sws->hitIt = 1; |
| 1318 | sws->worldPos.x = sws->basis.xm.pos.x + sws->curdist * sws->basis.xm.at.x; |
| 1319 | sws->worldPos.y = sws->basis.xm.pos.y + sws->curdist * sws->basis.xm.at.y; |
| 1320 | sws->worldPos.z = sws->basis.xm.pos.z + sws->curdist * sws->basis.xm.at.z; |
| 1321 | |
| 1322 | xMat4x3Toworld(&sws->worldContact, &sws->basis.xm, &sws->contact); |
| 1323 | xMat3x3RMulVec(&sws->worldPolynorm, &sws->basis.xm, &sws->polynorm); |
| 1324 | |
| 1325 | sws->worldNormal.x = sws->worldPos.x - sws->worldContact.x; |
| 1326 | sws->worldNormal.y = sws->worldPos.y - sws->worldContact.y; |
| 1327 | sws->worldNormal.z = sws->worldPos.z - sws->worldContact.z; |
| 1328 | |
| 1329 | xVec3Normalize(&sws->worldNormal, &sws->worldNormal); |
| 1330 | |
| 1331 | xVec3Cross(&tanplane, &sws->basis.xm.at, &sws->worldNormal); |
| 1332 | if (xVec3Length2(&tanplane) < 1e-7f) |
| 1333 | { |
| 1334 | xVec3Cross(&tanplane, &sws->basis.xm.up, &sws->worldNormal); |
| 1335 | } |
| 1336 | |
| 1337 | xVec3Cross(&sws->worldTangent, &tanplane, &sws->worldNormal); |
| 1338 | xVec3Normalize(&sws->worldTangent, &sws->worldTangent); |
| 1339 | |
| 1340 | tandot = sws->worldTangent.x * sws->basis.xm.at.x + sws->worldTangent.y * sws->basis.xm.at.y + |
| 1341 | sws->worldTangent.z * sws->basis.xm.at.z; |
| 1342 | if (tandot < 0.0f) |
| 1343 | { |
| 1344 | sws->worldTangent.x = -sws->worldTangent.x; |
| 1345 | sws->worldTangent.y = -sws->worldTangent.y; |
| 1346 | sws->worldTangent.z = -sws->worldTangent.z; |
| 1347 | } |
| 1348 | } |
| 1349 | |
| 1350 | S32 xSweptSphereToTriangle(xSweptSphere* sws, xVec3* v0, xVec3* v1, xVec3* v2) |
| 1351 | { |
| 1352 | S32 i; |
| 1353 | |
| 1354 | if (!sws->dist) |
| 1355 | return 0; |
| 1356 | |
| 1357 | xVec3 xform[4]; |
| 1358 | xMat4x3Toworld(&xform[0], &sws->invbasis.xm, v0); |
| 1359 | xMat4x3Toworld(&xform[1], &sws->invbasis.xm, v1); |
| 1360 | xMat4x3Toworld(&xform[2], &sws->invbasis.xm, v2); |
| 1361 | |
| 1362 | F32 rad = sws->radius; |
| 1363 | |
| 1364 | if ((xform[0].x <= -rad && xform[1].x <= -rad && xform[2].x <= -rad) || |
no test coverage detected