diff options
author | Juan Linietsky <reduzio@gmail.com> | 2014-04-18 11:43:54 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2014-04-18 11:43:54 -0300 |
commit | 0360b454a432dc851cc1c5b0c365049ebafcec46 (patch) | |
tree | c868fbef7de718007e671448865a75381b8c8302 /scene | |
parent | b8593c6f3fd4726584e56e684c9ebb5a8147ff0c (diff) |
-Fixed viewport stretch bugs
-Fixed input in viewport stretch bugs
-Fixed tilemap pixel overlap (really?)
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/tile_map.cpp | 4 | ||||
-rw-r--r-- | scene/gui/control.cpp | 22 | ||||
-rw-r--r-- | scene/gui/control.h | 1 | ||||
-rw-r--r-- | scene/main/scene_main_loop.cpp | 1 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 29 | ||||
-rw-r--r-- | scene/main/viewport.h | 1 |
6 files changed, 30 insertions, 28 deletions
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index b9e44d5053..57424d6654 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -585,8 +585,8 @@ TileMap::TileMap() { center_x=false; center_y=false; - fp_adjust=0.4; - fp_adjust=0.4; + fp_adjust=0.01; + fp_adjust=0.01; } TileMap::~TileMap() { diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index e0604b7cb8..4b4b4b3c73 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -645,19 +645,6 @@ void Control::_notification(int p_notification) { } -Size2 Control::_window_get_pos() const { - - if (data.viewport) { - - Rect2 r = data.viewport->get_visible_rect(); - return r.pos; - } else - return Point2(); - - //return get_global_transform().get_origin(); -} - - bool Control::clips_input() const { return false; @@ -956,12 +943,11 @@ void Control::_window_input_event(InputEvent p_event) { window->key_event_accepted=false; Point2 mpos =(get_canvas_transform()).affine_inverse().xform(Point2(p_event.mouse_button.x,p_event.mouse_button.y)); - if (p_event.mouse_button.pressed) { - Size2 pos = mpos - _window_get_pos(); + Size2 pos = mpos; if (window->mouse_focus && p_event.mouse_button.button_index!=window->mouse_focus_button) { //do not steal mouse focus and stuff @@ -1062,7 +1048,7 @@ void Control::_window_input_event(InputEvent p_event) { if (window->mouse_over && window->drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) { - Size2 pos = mpos - _window_get_pos(); + Size2 pos = mpos; pos = window->focus_inv_xform.xform(pos); window->mouse_over->drop_data(pos,window->drag_data); window->drag_data=Variant(); @@ -1072,7 +1058,7 @@ void Control::_window_input_event(InputEvent p_event) { break; } - Size2 pos = mpos - _window_get_pos(); + Size2 pos = mpos; p_event.mouse_button.global_x = pos.x; p_event.mouse_button.global_y = pos.y; pos = window->focus_inv_xform.xform(pos); @@ -1103,7 +1089,7 @@ void Control::_window_input_event(InputEvent p_event) { window->key_event_accepted=false; Matrix32 localizer = (get_canvas_transform()).affine_inverse(); - Size2 pos = localizer.xform(Size2(p_event.mouse_motion.x,p_event.mouse_motion.y)) - _window_get_pos(); + Size2 pos = localizer.xform(Size2(p_event.mouse_motion.x,p_event.mouse_motion.y)); Vector2 speed = localizer.basis_xform(Point2(p_event.mouse_motion.speed_x,p_event.mouse_motion.speed_y)); Vector2 rel = localizer.basis_xform(Point2(p_event.mouse_motion.relative_x,p_event.mouse_motion.relative_y)); diff --git a/scene/gui/control.h b/scene/gui/control.h index dd8854f80e..f9225a1c2b 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -193,7 +193,6 @@ private: float _get_parent_range(int p_idx) const; float _get_range(int p_idx) const; - Point2 _window_get_pos() const; float _s2a(float p_val, AnchorType p_anchor,float p_range) const; float _a2s(float p_val, AnchorType p_anchor,float p_range) const; void _modal_stack_remove(); diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp index 5ec416fb47..492c7633c1 100644 --- a/scene/main/scene_main_loop.cpp +++ b/scene/main/scene_main_loop.cpp @@ -940,7 +940,6 @@ void SceneMainLoop::_update_root_rect() { } break; case STRETCH_MODE_VIEWPORT: { - print_line("VP SIZE: "+viewport_size); root->set_rect(Rect2(Point2(),viewport_size)); root->set_size_override_stretch(false); root->set_size_override(false,Size2()); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 0e32fd006d..c13b4eb060 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -764,13 +764,30 @@ bool Viewport::get_render_target_vflip() const{ } +Matrix32 Viewport::_get_input_pre_xform() const { + + Matrix32 pre_xf; + if (render_target) { + + ERR_FAIL_COND_V(to_screen_rect.size.x==0,pre_xf); + ERR_FAIL_COND_V(to_screen_rect.size.y==0,pre_xf); + pre_xf.scale(rect.size/to_screen_rect.size); + pre_xf.elements[2]=-to_screen_rect.pos; + } else { + + pre_xf.elements[2]=-rect.pos; + } + + return pre_xf; +} + void Viewport::_make_input_local(InputEvent& ev) { switch(ev.type) { case InputEvent::MOUSE_BUTTON: { - Matrix32 ai = get_final_transform().affine_inverse(); + Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform(); Vector2 g = ai.xform(Vector2(ev.mouse_button.global_x,ev.mouse_button.global_y)); Vector2 l = ai.xform(Vector2(ev.mouse_button.x,ev.mouse_button.y)); ev.mouse_button.x=l.x; @@ -781,7 +798,7 @@ void Viewport::_make_input_local(InputEvent& ev) { } break; case InputEvent::MOUSE_MOTION: { - Matrix32 ai = get_final_transform().affine_inverse(); + Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform(); Vector2 g = ai.xform(Vector2(ev.mouse_motion.global_x,ev.mouse_motion.global_y)); Vector2 l = ai.xform(Vector2(ev.mouse_motion.x,ev.mouse_motion.y)); Vector2 r = ai.xform(Vector2(ev.mouse_motion.relative_x,ev.mouse_motion.relative_y)); @@ -795,7 +812,7 @@ void Viewport::_make_input_local(InputEvent& ev) { } break; case InputEvent::SCREEN_TOUCH: { - Matrix32 ai = get_final_transform().affine_inverse(); + Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform(); Vector2 t = ai.xform(Vector2(ev.screen_touch.x,ev.screen_touch.y)); ev.screen_touch.x=t.x; ev.screen_touch.y=t.y; @@ -803,7 +820,7 @@ void Viewport::_make_input_local(InputEvent& ev) { } break; case InputEvent::SCREEN_DRAG: { - Matrix32 ai = get_final_transform().affine_inverse(); + Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform(); Vector2 t = ai.xform(Vector2(ev.screen_drag.x,ev.screen_drag.y)); Vector2 r = ai.xform(Vector2(ev.screen_drag.relative_x,ev.screen_drag.relative_y)); Vector2 s = ai.xform(Vector2(ev.screen_drag.speed_x,ev.screen_drag.speed_y)); @@ -821,13 +838,13 @@ void Viewport::_make_input_local(InputEvent& ev) { void Viewport::_vp_input(const InputEvent& p_ev) { - if (render_target) + if (render_target && to_screen_rect==Rect2()) return; //if render target, can't get input events //this one handles system input, p_ev are in system coordinates //they are converted to viewport coordinates - InputEvent ev = p_ev; + InputEvent ev = p_ev; _make_input_local(ev); input(ev); diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 33e1f27b93..178a7517f0 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -146,6 +146,7 @@ friend class RenderTargetTexture; void update_worlds(); + _FORCE_INLINE_ Matrix32 _get_input_pre_xform() const; void _vp_enter_scene(); void _vp_exit_scene(); |