| 263 | } |
| 264 | |
| 265 | static RpCollisionTriangle* sphereHitsEnv3CB(RpIntersection* isx, RpWorldSector* sector, |
| 266 | RpCollisionTriangle* tri, F32 dist, void* data) |
| 267 | { |
| 268 | xCollis* colls = (xCollis*)data; |
| 269 | F32 radius = isx->t.line.end.x; |
| 270 | xVec3* center = (xVec3*)&isx->t.line.start; |
| 271 | xVec3 tohit; |
| 272 | xVec3 hdng; |
| 273 | U8 idx = 0; |
| 274 | F32 dot; |
| 275 | F32 odot; |
| 276 | F32 ndot; |
| 277 | F32 scale; |
| 278 | |
| 279 | dist = FLOAT_MAX; |
| 280 | properSphereIsectTri(center, radius, &tohit, &dist, tri); |
| 281 | if (0.0f == dist) |
| 282 | { |
| 283 | return tri; |
| 284 | } |
| 285 | if (dist > radius) |
| 286 | { |
| 287 | return tri; |
| 288 | } |
| 289 | |
| 290 | if (SQR(tohit.x) + SQR(tohit.y) > SQR(tohit.y)) |
| 291 | { |
| 292 | idx = FLOOR; |
| 293 | if (FLOOR == 0xff) |
| 294 | { |
| 295 | idx = cbnumcs; |
| 296 | FLOOR = cbnumcs; |
| 297 | cbnumcs++; |
| 298 | } |
| 299 | else if (tohit.y < 0.0f) |
| 300 | { |
| 301 | if (colls[idx].hdng.y > 0.0f || |
| 302 | (colls[idx].dist > dist && |
| 303 | (iabs(dist - colls[idx].dist) < 0.001f && tri->normal.y > colls[idx].norm.y))) |
| 304 | { |
| 305 | idx = FLOOR; |
| 306 | } |
| 307 | else |
| 308 | { |
| 309 | return tri; |
| 310 | } |
| 311 | } |
| 312 | else |
| 313 | { |
| 314 | if (colls[idx].hdng.y > 0.0f || |
| 315 | (colls[idx].dist > dist && |
| 316 | (iabs(dist - colls[idx].dist) < 0.001f && tri->normal.y > colls[idx].norm.y))) |
| 317 | { |
| 318 | idx = FLOOR; |
| 319 | } |
| 320 | else |
| 321 | { |
| 322 | return tri; |
no test coverage detected