X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=src%2Fai%2Fai.cpp;h=4b76856ea9664db0bb5dc17681155bfe501090be;hb=f5de855fbd4bf5b0df1cad950cbe9069e41369ca;hp=a2f5938eb707c3c58fc9199c3759a935b51a3393;hpb=4727825186798902f68df5b99a6a32f0ef618454;p=blank.git diff --git a/src/ai/ai.cpp b/src/ai/ai.cpp index a2f5938..4b76856 100644 --- a/src/ai/ai.cpp +++ b/src/ai/ai.cpp @@ -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);