Minor kdtree fixes/workarounds

Not sure why, but it misses some collisions with that t >= 0.0 clause...
This commit is contained in:
karl 2021-01-15 13:56:53 +01:00
parent 90b6769278
commit ba98ae3386
2 changed files with 2 additions and 2 deletions

View File

@ -83,7 +83,7 @@ class CollisionSystem : public EntitySystem {
glm::vec3 direction_glm = mouse_look->get_look_direction();
Vector direction = Vector(direction_glm.x, direction_glm.y, direction_glm.z);
Ray ray(origin, direction * 5.0);
Ray ray(origin, direction);
Vector collision_position(0, 0, 0);
Triangle *result = kdtree->intersect_ray(ray, collision_position);

View File

@ -122,7 +122,7 @@ class KDTree {
// No collision here either. Does it make sense to also check the far node?
// Only if the axes are not parallel and if that area is not behind us
if (ray.direction[node->axis] != 0.0 && t >= 0.0) {
if (ray.direction[node->axis] != 0.0) { // FIXME: should include && t >= 0.0
// It does make sense to check the far node.
// For this, calculate a new ray origin and continue towards that direction, but with
// the new origin (we can leave behind what we already checked)