]> git.localhorst.tv Git - blobs.git/blob - src/creature/Steering.hpp
cca757ee0b72763ec8b4f6558b8259d45ceedca2
[blobs.git] / src / creature / Steering.hpp
1 #ifndef BLOBS_CREATURE_STEERING_HPP_
2 #define BLOBS_CREATURE_STEERING_HPP_
3
4 #include "Situation.hpp"
5 #include "../math/glm.hpp"
6
7
8 namespace blobs {
9 namespace creature {
10
11 class Steering {
12
13 public:
14         Steering();
15         ~Steering();
16
17 public:
18         void MaxAcceleration(double a) noexcept { max_accel = a; }
19         double MaxAcceleration() const noexcept { return max_accel; }
20
21         void MaxSpeed(double s) noexcept { max_speed = s; }
22         double MaxSpeed() const noexcept { return max_speed; }
23
24 public:
25         void Halt() noexcept;
26         void Pass(const glm::dvec3 &) noexcept;
27         void GoTo(const glm::dvec3 &) noexcept;
28
29         glm::dvec3 Acceleration(const Situation::State &) const noexcept;
30
31 private:
32         bool SumForce(glm::dvec3 &out, const glm::dvec3 &in) const noexcept;
33         glm::dvec3 TargetVelocity(const Situation::State &, const glm::dvec3 &) const noexcept;
34
35 private:
36         glm::dvec3 target;
37
38         double max_accel = 1.0;
39         double max_speed = 1.0;
40
41         bool halting;
42         bool seeking;
43         bool arriving;
44
45 };
46
47 }
48 }
49
50 #endif