#include "../geometry/distance.hpp"
#include "../geometry/rotation.hpp"
+#include "../graphics/glm.hpp"
#include "../rand/GaloisLFSR.hpp"
#include "../world/Entity.hpp"
#include "../world/World.hpp"
#include <cmath>
#include <limits>
-#include <glm/glm.hpp>
namespace blank {
// orient head towards heading
glm::vec3 heading(e.Heading());
// only half pitch, so we don't crane our neck
- float tgt_pitch = std::atan(heading.y / length(glm::vec2(heading.x, heading.z))) * 0.5f;
+ float tgt_pitch = std::atan(heading.y / glm::length(glm::vec2(heading.x, heading.z))) * 0.5f;
// always look straight ahead
// maybe look at the pursuit target if there is one
float tgt_yaw = 0.0f;
// distance test
const glm::vec3 diff(pe.AbsoluteDifference(e));
- float dist = length(diff);
+ float dist = glm::length(diff);
if (dist > distance) continue;
// FOV test, 45° in each direction
- if (dot(diff / dist, aim.dir) < sight_angle) {
+ if (glm::dot(diff / dist, aim.dir) < sight_angle) {
continue;
}
const glm::ivec3 &reference(from.ChunkCoords());
Ray aim(from.Aim(reference));
const glm::vec3 diff(to.AbsoluteDifference(from));
- float dist = length(diff);
- if (dist > sight_dist || dot(diff / dist, aim.dir) < sight_angle) {
+ float dist = glm::length(diff);
+ if (dist > sight_dist || glm::dot(diff / dist, aim.dir) < sight_angle) {
return false;
}
WorldCollision col;
// chase
-void ChaseState::Enter(AIController &ctrl, Entity &e) const {
+void ChaseState::Enter(AIController &, Entity &e) const {
e.GetSteering()
- .SetAcceleration(1.0f)
+ .SetAcceleration(5.0f)
.SetSpeed(4.0f)
.Enable(Steering::PURSUE_TARGET)
;
}
-void ChaseState::Update(AIController &ctrl, Entity &e, float dt) const {
+void ChaseState::Update(AIController &ctrl, Entity &e, float) const {
Steering &steering = e.GetSteering();
// check if target still alive and in sight
if (
return;
}
// halt if we're close enough, flee if we're too close
- float dist_sq = length2(e.AbsoluteDifference(steering.GetTargetEntity()));
+ float dist_sq = glm::length2(e.AbsoluteDifference(steering.GetTargetEntity()));
if (dist_sq < 8.0f) {
ctrl.SetState(flee, e);
} else if (dist_sq < 25.0f) {
}
}
-void ChaseState::Exit(AIController &ctrl, Entity &e) const {
+void ChaseState::Exit(AIController &, Entity &e) const {
e.GetSteering().Disable(Steering::HALT | Steering::PURSUE_TARGET);
}
void FleeState::Enter(AIController &ctrl, Entity &e) const {
e.GetSteering()
- .SetAcceleration(1.0f)
+ .SetAcceleration(5.0f)
.SetSpeed(4.0f)
.Enable(Steering::EVADE_TARGET)
;
ctrl.CueDecision(6.0f, 3.0f);
}
-void FleeState::Update(AIController &ctrl, Entity &e, float dt) const {
+void FleeState::Update(AIController &ctrl, Entity &e, float) const {
if (!ctrl.DecisionDue()) return;
ctrl.SetState(idle, e);
}
-void FleeState::Exit(AIController &ctrl, Entity &e) const {
+void FleeState::Exit(AIController &, Entity &e) const {
e.GetSteering().Disable(Steering::EVADE_TARGET);
}
ctrl.CueDecision(10.0f, 5.0f);
}
-void IdleState::Update(AIController &ctrl, Entity &e, float dt) const {
+void IdleState::Update(AIController &ctrl, Entity &e, float) const {
if (ctrl.MayThink()) {
const Player *player = ctrl.ClosestVisiblePlayer(e);
if (player) {
ctrl.CueDecision(10.0f, 5.0f);
}
-void IdleState::Exit(AIController &ctrl, Entity &e) const {
+void IdleState::Exit(AIController &, Entity &e) const {
e.GetSteering().Disable(Steering::HALT | Steering::WANDER);
}
ctrl.CueDecision(10.0f, 5.0f);
}
-void RoamState::Update(AIController &ctrl, Entity &e, float dt) const {
+void RoamState::Update(AIController &ctrl, Entity &e, float) const {
if (ctrl.MayThink()) {
const Player *player = ctrl.ClosestVisiblePlayer(e);
if (player) {
ctrl.CueDecision(10.0f, 5.0f);
}
-void RoamState::Exit(AIController &ctrl, Entity &e) const {
+void RoamState::Exit(AIController &, Entity &e) const {
e.GetSteering().Disable(Steering::WANDER);
}