| 394 | } |
| 395 | |
| 396 | Collision SceneGraph::lineCheckCollidable(const vec3& start, const vec3& end, Object* not_hit) { |
| 397 | std::vector<Collision> collisions; |
| 398 | LineCheckAll(start, end, &collisions); |
| 399 | Collision* closest = NULL; |
| 400 | float closest_distance; |
| 401 | for (auto& c : collisions) { |
| 402 | if (c.hit_what->collidable && c.hit_what != not_hit) { |
| 403 | float dist = distance_squared(start, c.hit_where); |
| 404 | if (!closest || dist < closest_distance) { |
| 405 | closest = &c; |
| 406 | closest_distance = dist; |
| 407 | } |
| 408 | } |
| 409 | } |
| 410 | if (closest) { |
| 411 | return *closest; |
| 412 | } else { |
| 413 | return Collision(); |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | void SceneGraph::LineCheckAll(const vec3& start, const vec3& end, std::vector<Collision>* collisions) { |
| 418 | PROFILER_ZONE(g_profiler_ctx, "SceneGraph::LineCheckAll"); |
no test coverage detected