]> git.localhorst.tv Git - blank.git/blobdiff - src/ui/ui.cpp
measure packet round trip time
[blank.git] / src / ui / ui.cpp
index 1af9e8722f75cbc60c503b7882b6c187abde12a5..6a2e2ee167042720101bab5f7d1062d3c2cc610f 100644 (file)
@@ -43,6 +43,12 @@ PlayerController::PlayerController(World &world, Player &player)
        player.GetEntity().SetController(*this);
 }
 
+PlayerController::~PlayerController() {
+       if (&player.GetEntity().GetController() == this) {
+               player.GetEntity().UnsetController();
+       }
+}
+
 void PlayerController::SetMovement(const glm::vec3 &m) noexcept {
        if (dot(m, m) > 1.0f) {
                move_dir = normalize(m);
@@ -52,9 +58,8 @@ void PlayerController::SetMovement(const glm::vec3 &m) noexcept {
        Invalidate();
 }
 
-glm::vec3 PlayerController::ControlForce(const EntityState &s) const {
-       glm::vec3 target(rotateY(move_dir * player.GetEntity().MaxVelocity(), s.yaw) - s.velocity);
-       return target * player.GetEntity().MaxControlForce();
+glm::vec3 PlayerController::ControlForce(const Entity &e, const EntityState &s) const {
+       return TargetVelocity(rotateY(move_dir * e.MaxVelocity(), s.yaw), s, 5.0f);
 }
 
 void PlayerController::TurnHead(float dp, float dy) noexcept {