]> git.localhorst.tv Git - blank.git/blobdiff - src/ai/ai.cpp
use collision structures for ray tests
[blank.git] / src / ai / ai.cpp
index 6b380e4d1027a8e7e2cc1cba11f5d1d24bb539e3..5f5474b5f3320030e2f7e902badbb86c58328a79 100644 (file)
@@ -5,6 +5,7 @@
 #include "../model/geometry.hpp"
 #include "../world/Entity.hpp"
 #include "../world/World.hpp"
+#include "../world/WorldCollision.hpp"
 
 #include <glm/glm.hpp>
 
@@ -34,12 +35,9 @@ void Chaser::Update(int dt) {
        bool line_of_sight = true;
        // FIXME: this only works if target is in the reference chunk (which is true for the player)
        Ray aim{Target().Position() - diff, norm_diff};
-       Chunk *chunk;
-       int blkid;
-       float distance;
-       glm::vec3 normal;
-       if (world.Intersection(aim, glm::mat4(1.0f), chunk, blkid, distance, normal)) {
-               line_of_sight = distance > dist;
+       WorldCollision coll;
+       if (world.Intersection(aim, glm::mat4(1.0f), coll)) {
+               line_of_sight = coll.depth > dist;
        }
 
        if (!line_of_sight) {