Prevent division by 0

This commit is contained in:
Yousef Khadadeh 2025-10-04 09:29:29 +03:00
parent 01d6270b62
commit 24e7ce555a

View file

@ -139,6 +139,7 @@ void DrawCamera::update_main(World& w) {
// Ignore the value of scrollAmount, since that leads to problems on macOS
WorldScalar zoomFactor(1.0 + w.main.toolbar.scrollZoomSpeed);
if(zoomFactor != WorldScalar(0)) {
if(w.main.input.mouse.scrollAmount.y() < 0.0)
zoomFactor = WorldScalar(1) / zoomFactor;
@ -150,6 +151,7 @@ void DrawCamera::update_main(World& w) {
c.pos = w.get_mouse_world_pos() + mVec / zoomFactor;
}
}
}
if(w.main.input.key(InputManager::KEY_CAMERA_ROTATE_COUNTERCLOCKWISE).held && !w.main.input.text.get_accepting_input()) {
c.rotate_about(c.from_space(w.main.window.size.cast<float>() * 0.5f), -w.main.deltaTime);
}