1 #ifndef BLANK_WORLD_ENTITYCONTROLLER_HPP_
2 #define BLANK_WORLD_ENTITYCONTROLLER_HPP_
4 #include "EntityState.hpp"
13 struct EntityController {
15 virtual ~EntityController();
17 virtual void Update(Entity &, float dt) = 0;
19 virtual glm::vec3 ControlForce(const Entity &, const EntityState &) const = 0;
22 /// try to add as much of add to out so it doesn't exceed max
23 /// returns true if it's maxed out
24 static bool MaxOutForce(
29 /// give a force that makes state's velocity converge with given target velocity
31 static inline glm::vec3 TargetVelocity(
32 const glm::vec3 &target,
33 const EntityState &state,
36 return (target - state.velocity) * n;
38 /// give a force that makes state come to a halt over 1/n seconds
39 static inline glm::vec3 Halt(
40 const EntityState &state,
43 return state.velocity * -n;