| 2031 | RpGeometry* geom = model->geometry; |
| 2032 | RpCollisionData* colldata = RpCollisionGeometryGetData(geom); |
| 2033 | RwLine line; |
| 2034 | |
| 2035 | if (colldata && colldata->tree) |
| 2036 | { |
| 2037 | F32 scale; |
| 2038 | xsqrtfast(scale, SQR(mat->right.x) + SQR(mat->right.y) + SQR(mat->right.z)); |
| 2039 | xMat4x3Tolocal((xVec3*)&line.start, (xMat4x3*)mat, &sws->start); |
| 2040 | xMat4x3Tolocal((xVec3*)&line.end, (xMat4x3*)mat, &sws->end); |
| 2041 | |
| 2042 | SweptSphereCollParam isData; |
| 2043 | isData.geometry = geom; |
| 2044 | isData.sws = sws; |
| 2045 | |
| 2046 | RwV3d delta; |
| 2047 | RwV3dSubMacro(&delta, &line.end, &line.start); |
| 2048 | |
| 2049 | RpV3dGradient grad; |
| 2050 | F32 recip; |
| 2051 | |
| 2052 | recip = (delta.x != 0.0f) ? (1.0f / delta.x) : 0.0f; |
| 2053 | grad.dydx = delta.y * recip; |
| 2054 | grad.dzdx = delta.z * recip; |
| 2055 | |
| 2056 | recip = (delta.y != 0.0f) ? (1.0f / delta.y) : 0.0f; |
| 2057 | grad.dxdy = delta.x * recip; |
| 2058 | grad.dzdy = delta.z * recip; |
| 2059 | |
| 2060 | recip = (delta.z != 0.0f) ? (1.0f / delta.z) : 0.0f; |
| 2061 | grad.dxdz = delta.x * recip; |
| 2062 | grad.dydz = delta.y * recip; |
| 2063 | |
| 2064 | _rpCollBSPTreeForAllCapsuleLeafNodeIntersections(colldata->tree, &line, sws->radius / scale, |
| 2065 | &grad, SweptSphereModelCB, &isData); |
| 2066 | } |
| 2067 | else |
| 2068 | { |
| 2069 | S32 i; |
| 2070 | S32 numT = geom->numTriangles; |
| 2071 | RpTriangle* tri = geom->triangles; |
| 2072 | RwV3d* vert = geom->morphTarget->verts; |
| 2073 | for (i = 0; i < numT; i++, tri++) |
| 2074 | { |
| 2075 | S32 vertIndex0 = tri->vertIndex[0]; |
| 2076 | S32 vertIndex1 = tri->vertIndex[1]; |
| 2077 | S32 vertIndex2 = tri->vertIndex[2]; |
| 2078 | RwV3d* v0 = &vert[vertIndex0]; |
| 2079 | RwV3d* v1 = &vert[vertIndex1]; |
| 2080 | RwV3d* v2 = &vert[vertIndex2]; |
| 2081 | if (xSweptSphereToTriangle(sws, (xVec3*)v0, (xVec3*)v1, (xVec3*)v2)) |
| 2082 | { |
| 2083 | sSweptSphereHitFound = 1; |
| 2084 | } |
| 2085 | } |
| 2086 | } |
| 2087 | |
| 2088 | sws->invbasis.xm = oldinvbasis; |
| 2089 | |
| 2090 | return sSweptSphereHitFound; |
no test coverage detected