X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2Fstates.cpp;h=92879b4683bc724a5cbd23e35d1bc973cdbb9d0c;hb=d921cba26f21e4a75b22f5e9d9be988707bf6a8f;hp=cfac2fa8450565d4ccf5b4403f3c3ce4e9cb385d;hpb=dd8b3145a03ed676b0ae6311c29fc3d68f666b15;p=blobs.git diff --git a/src/app/states.cpp b/src/app/states.cpp index cfac2fa..92879b4 100644 --- a/src/app/states.cpp +++ b/src/app/states.cpp @@ -19,11 +19,13 @@ MasterState::MasterState(Assets &assets, world::Simulation &sim) noexcept , assets(assets) , sim(sim) , cam(sim.Root()) -, cam_dist(10.0) -, cam_tgt_dist(10.0) -, cam_orient(PI * 0.125, 0.0, 0.0) +, cam_dist(5.0) +, cam_tgt_dist(5.0) +, cam_orient(PI * 0.375, PI * 0.25, 0.0) , cam_dragging(false) , cp(assets) +, rp(sim) +, tp(sim) , remain(0) , thirds(0) , paused(false) { @@ -50,8 +52,15 @@ void MasterState::OnResize(int w, int h) { void MasterState::OnUpdate(int dt) { remain += dt; - while (remain >= FrameMS()) { +#ifdef NDEBUG + int max_tick = 10; +#else + // one tick per frame when debugging so pausing execution doesn't result in more ticks + int max_tick = 1; +#endif + while (remain >= FrameMS() && max_tick > 0) { Tick(); + --max_tick; } } @@ -100,7 +109,7 @@ void MasterState::OnMouseMotion(const SDL_MouseMotionEvent &e) { constexpr double pitch_scale = PI * 0.001; constexpr double yaw_scale = PI * 0.002; if (cam_dragging) { - cam_orient.x = glm::clamp(cam_orient.x + double(e.yrel) * pitch_scale, 0.0, PI * 0.5); + cam_orient.x = glm::clamp(cam_orient.x + double(e.yrel) * pitch_scale, 0.0, PI * 0.499); cam_orient.y = std::fmod(cam_orient.y + double(e.xrel) * yaw_scale, PI * 2.0); } } @@ -110,7 +119,7 @@ void MasterState::OnMouseWheel(const SDL_MouseWheelEvent &e) { constexpr double zoom_scale = -1.0; constexpr double zoom_base = 1.125; cam_orient.z = glm::clamp(cam_orient.z + double(e.x) * roll_scale, PI * -0.5, PI * 0.5); - cam_tgt_dist = std::max(1.0, cam_tgt_dist * std::pow(zoom_base, double(e.y) * zoom_scale)); + cam_tgt_dist = std::max(cp.GetCreature().Size() * 2.0, cam_tgt_dist * std::pow(zoom_base, double(e.y) * zoom_scale)); } void MasterState::OnRender(graphics::Viewport &viewport) { @@ -185,7 +194,9 @@ void MasterState::OnRender(graphics::Viewport &viewport) { } viewport.ClearDepth(); - cp.Draw(assets, viewport); + cp.Draw(viewport); + rp.Draw(viewport); + tp.Draw(viewport); } }