mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-12-30 04:10:57 +01:00
input_common: Avoid potential division by zero
This commit is contained in:
parent
d8eb37fbec
commit
4c84bce171
1 changed files with 3 additions and 2 deletions
|
@ -160,8 +160,9 @@ void Mouse::Move(int x, int y, int center_x, int center_y) {
|
|||
last_mouse_change.y += mouse_change.y * y_sensitivity;
|
||||
|
||||
// Bind the mouse change to [0 <= deadzone_counterweight <= 1.0]
|
||||
if (last_mouse_change.Length() < deadzone_counterweight) {
|
||||
last_mouse_change /= last_mouse_change.Length();
|
||||
const float length = last_mouse_change.Length();
|
||||
if (length < deadzone_counterweight && length != 0.0f) {
|
||||
last_mouse_change /= length;
|
||||
last_mouse_change *= deadzone_counterweight;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue