Prevent division by 0
This commit is contained in:
parent
01d6270b62
commit
24e7ce555a
1 changed files with 10 additions and 8 deletions
|
|
@ -139,6 +139,7 @@ void DrawCamera::update_main(World& w) {
|
||||||
// Ignore the value of scrollAmount, since that leads to problems on macOS
|
// Ignore the value of scrollAmount, since that leads to problems on macOS
|
||||||
|
|
||||||
WorldScalar zoomFactor(1.0 + w.main.toolbar.scrollZoomSpeed);
|
WorldScalar zoomFactor(1.0 + w.main.toolbar.scrollZoomSpeed);
|
||||||
|
if(zoomFactor != WorldScalar(0)) {
|
||||||
if(w.main.input.mouse.scrollAmount.y() < 0.0)
|
if(w.main.input.mouse.scrollAmount.y() < 0.0)
|
||||||
zoomFactor = WorldScalar(1) / zoomFactor;
|
zoomFactor = WorldScalar(1) / zoomFactor;
|
||||||
|
|
||||||
|
|
@ -150,6 +151,7 @@ void DrawCamera::update_main(World& w) {
|
||||||
c.pos = w.get_mouse_world_pos() + mVec / zoomFactor;
|
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()) {
|
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);
|
c.rotate_about(c.from_space(w.main.window.size.cast<float>() * 0.5f), -w.main.deltaTime);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue