X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fui%2Fui.cpp;fp=src%2Fui%2Fui.cpp;h=1af9e8722f75cbc60c503b7882b6c187abde12a5;hb=150d065f431d665326fd8028748c48a74ad956bb;hp=5a39fa8109ebfc810ed1a333c0d089d407db7706;hpb=80a9a59d71a7b144c12f64cbef4644751bd54745;p=blank.git diff --git a/src/ui/ui.cpp b/src/ui/ui.cpp index 5a39fa8..1af9e87 100644 --- a/src/ui/ui.cpp +++ b/src/ui/ui.cpp @@ -40,7 +40,7 @@ PlayerController::PlayerController(World &world, Player &player) , dirty(true) , aim_world() , aim_entity() { - + player.GetEntity().SetController(*this); } void PlayerController::SetMovement(const glm::vec3 &m) noexcept { @@ -52,6 +52,11 @@ 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(); +} + void PlayerController::TurnHead(float dp, float dy) noexcept { player.GetEntity().TurnHead(dp, dy); } @@ -77,10 +82,7 @@ void PlayerController::Invalidate() noexcept { } void PlayerController::UpdatePlayer() noexcept { - constexpr float max_vel = 5.0f; // in m/s if (dirty) { - player.GetEntity().TargetVelocity(glm::rotateY(move_dir * max_vel, player.GetEntity().Yaw())); - Ray aim = player.Aim(); if (!world.Intersection(aim, glm::mat4(1.0f), player.GetEntity().ChunkCoords(), aim_world)) { aim_world = WorldCollision(); @@ -104,12 +106,12 @@ void PlayerController::UpdatePlayer() noexcept { DirectInput::DirectInput(World &world, Player &player, WorldManipulator &manip) : PlayerController(world, player) , manip(manip) -, place_timer(256) -, remove_timer(256) { +, place_timer(0.25f) +, remove_timer(0.25f) { } -void DirectInput::Update(int dt) { +void DirectInput::Update(Entity &, float dt) { Invalidate(); // world has changed in the meantime UpdatePlayer();