]> git.localhorst.tv Git - blank.git/blobdiff - src/ai/ai.cpp
geometry stuff
[blank.git] / src / ai / ai.cpp
index a2f5938eb707c3c58fc9199c3759a935b51a3393..4b76856ea9664db0bb5dc17681155bfe501090be 100644 (file)
@@ -169,7 +169,7 @@ Player *AIController::ClosestVisiblePlayer(const Entity &e) noexcept {
 
                // LOS test, assumes all entities are see-through
                WorldCollision col;
-               if (world.Intersection(aim, glm::mat4(1.0f), reference, col) && col.depth < dist) {
+               if (world.Intersection(aim, reference, col) && col.depth < dist) {
                        continue;
                }
 
@@ -189,7 +189,7 @@ bool AIController::LineOfSight(const Entity &from, const Entity &to) const noexc
                return false;
        }
        WorldCollision col;
-       if (world.Intersection(aim, glm::mat4(1.0f), reference, col) && col.depth < dist) {
+       if (world.Intersection(aim, reference, col) && col.depth < dist) {
                return false;
        }
        return true;
@@ -281,7 +281,7 @@ glm::vec3 AIController::GetObstacleAvoidanceForce(const Entity &e, const EntityS
        for (WorldCollision &c : col) {
                // diff points from block to state
                glm::vec3 diff = state.RelativePosition(c.ChunkPos()) - c.BlockCoords();
-               float dist = length_squared(diff);
+               float dist = length2(diff);
                if (dist < distance) {
                        nearest = &c;
                        difference = diff;
@@ -530,7 +530,7 @@ void ChaseState::Update(AIController &ctrl, Entity &e, float dt) const {
                return;
        }
        // halt if we're close enough, flee if we're too close
-       float dist_sq = length_squared(e.AbsoluteDifference(ctrl.GetPursuitTarget()));
+       float dist_sq = length2(e.AbsoluteDifference(ctrl.GetPursuitTarget()));
        if (dist_sq < 8.0f) {
                ctrl.SetFleeTarget(ctrl.GetPursuitTarget());
                ctrl.SetState(flee);