1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Implement warped mouse panning for 2D & 3D editors

Enabled by default as in Blender, but can be disabled separately for 2D & 3D;
the core functionality is in Input so this could be reused or even exposed to scripts in the future
This commit is contained in:
Pedro J. Estébanez
2017-03-22 21:18:47 +01:00
parent 33a2c5def0
commit f5004b78d0
6 changed files with 35 additions and 3 deletions

View File

@@ -478,6 +478,17 @@ void InputDefault::warp_mouse_pos(const Vector2 &p_to) {
OS::get_singleton()->warp_mouse_pos(p_to);
}
Point2i InputDefault::warp_mouse_motion(const InputEventMouseMotion &p_motion, const Rect2 &p_rect) {
const Point2i rel_warped(Math::fmod(p_motion.relative_x, p_rect.size.x), Math::fmod(p_motion.relative_y, p_rect.size.y));
const Point2i pos_local = Point2i(p_motion.global_x, p_motion.global_y) - p_rect.pos;
const Point2i pos_warped(Math::fposmod(pos_local.x, p_rect.size.x), Math::fposmod(pos_local.y, p_rect.size.y));
if (pos_warped != pos_local) {
OS::get_singleton()->warp_mouse_pos(pos_warped + p_rect.pos);
}
return rel_warped;
}
void InputDefault::iteration(float p_step) {
}