diff options
author | Anton Yabchinskiy <arn@bestmx.ru> | 2015-02-17 15:57:24 +0300 |
---|---|---|
committer | Anton Yabchinskiy <arn@bestmx.ru> | 2015-02-17 15:57:24 +0300 |
commit | e024ff89b224f803fe335efa95d3e99bffc3423f (patch) | |
tree | 84ca5323c97ef24cfcae202447ac6967783e9248 /scene/main | |
parent | 6f93e6812edaf6c8c79c28dadbe5f1c4a8ced93e (diff) | |
parent | 2bea642583efeb68886e71950384f297f2d7ee12 (diff) |
Merge branch 'master' of https://github.com/okamstudio/godot
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/viewport.cpp | 9 | ||||
-rw-r--r-- | scene/main/viewport.h | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index e6c787cf9e..fa163bf96d 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -29,6 +29,8 @@ #include "viewport.h" #include "os/os.h" #include "scene/3d/spatial.h" +#include "os/input.h" + //#include "scene/3d/camera.h" #include "servers/spatial_sound_server.h" @@ -1100,6 +1102,12 @@ void Viewport::_vp_unhandled_input(const InputEvent& p_ev) { } +void Viewport::warp_mouse(const Vector2& p_pos) { + + Vector2 gpos = (get_final_transform().affine_inverse() * _get_input_pre_xform()).affine_inverse().xform(p_pos); + Input::get_singleton()->warp_mouse_pos(gpos); +} + void Viewport::input(const InputEvent& p_event) { ERR_FAIL_COND(!is_inside_tree()); @@ -1289,6 +1297,7 @@ void Viewport::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_audio_listener_2d","enable"), &Viewport::is_audio_listener_2d); ObjectTypeDB::bind_method(_MD("set_render_target_to_screen_rect"), &Viewport::set_render_target_to_screen_rect); + ObjectTypeDB::bind_method(_MD("warp_mouse","to_pos"), &Viewport::warp_mouse); ADD_PROPERTY( PropertyInfo(Variant::RECT2,"rect"), _SCS("set_rect"), _SCS("get_rect") ); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"own_world"), _SCS("set_use_own_world"), _SCS("is_using_own_world") ); diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 4bb5735731..832a6b6107 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -246,6 +246,8 @@ public: void set_render_target_to_screen_rect(const Rect2& p_rect); Rect2 get_render_target_to_screen_rect() const; + void warp_mouse(const Vector2& p_pos); + void set_physics_object_picking(bool p_enable); bool get_physics_object_picking(); |