MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / lineCheckCollidable

Method lineCheckCollidable

Source/Main/scenegraph.cpp:396–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

394}
395
396Collision 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
417void SceneGraph::LineCheckAll(const vec3& start, const vec3& end, std::vector<Collision>* collisions) {
418 PROFILER_ZONE(g_profiler_ctx, "SceneGraph::LineCheckAll");

Callers 3

BoxSelectEntitiesFunction · 0.80
HandleShortcutsMethod · 0.80

Calls 2

distance_squaredFunction · 0.50
CollisionClass · 0.50

Tested by

no test coverage detected