X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FEntityController.hpp;fp=src%2Fworld%2FEntityController.hpp;h=526a3222fa4d985fc53094ab7e2c649376dfdd2e;hb=0ab149c70b3f984b2cc0c7a122b4aa347bc5fd79;hp=8b14ca8a3d9606c687ba9c35da1107fa4682bb6d;hpb=d122d3e445d64f7d710c1cfaf285ff01bbe955b9;p=blank.git diff --git a/src/world/EntityController.hpp b/src/world/EntityController.hpp index 8b14ca8..526a322 100644 --- a/src/world/EntityController.hpp +++ b/src/world/EntityController.hpp @@ -1,13 +1,14 @@ #ifndef BLANK_WORLD_ENTITYCONTROLLER_HPP_ #define BLANK_WORLD_ENTITYCONTROLLER_HPP_ +#include "EntityState.hpp" + #include namespace blank { class Entity; -class EntityState; struct EntityController { @@ -15,7 +16,25 @@ struct EntityController { virtual void Update(Entity &, float dt) = 0; - virtual glm::vec3 ControlForce(const EntityState &) const = 0; + virtual glm::vec3 ControlForce(const Entity &, const EntityState &) const = 0; + + + /// try to add as much of add to out so it doesn't exceed max + /// returns true if it's maxed out + static bool MaxOutForce( + glm::vec3 &out, + const glm::vec3 &add, + float max + ) noexcept; + /// give a force that makes state's velocity converge with given target velocity + /// over 1/n seconds + static inline glm::vec3 TargetVelocity( + const glm::vec3 &target, + const EntityState &state, + float n + ) noexcept { + return (target - state.velocity) * n; + } };