fix CanvasItem.get_global_transform() and CanvasItem.get_local_transform(), closes #4075

This commit is contained in:
Juan Linietsky 2016-06-20 21:19:12 -03:00
parent 9d4cdc6d8a
commit fa0d1cd27c
2 changed files with 6 additions and 3 deletions

View File

@ -1756,7 +1756,7 @@ Error Image::_decompress_bc() {
int rofs=0;
int wofs=0;
print_line("width: "+itos(wd)+" height: "+itos(ht));
//print_line("width: "+itos(wd)+" height: "+itos(ht));
for(int i=0;i<=mm;i++) {

View File

@ -1003,11 +1003,14 @@ InputEvent CanvasItem::make_input_local(const InputEvent& p_event) const {
Vector2 CanvasItem::get_global_mouse_pos() const {
return get_viewport_transform().affine_inverse().xform(Input::get_singleton()->get_mouse_pos());
ERR_FAIL_COND_V(!get_viewport(),Vector2());
return get_canvas_transform().affine_inverse().xform( get_viewport()->get_mouse_pos() );
}
Vector2 CanvasItem::get_local_mouse_pos() const{
return (get_viewport_transform() * get_global_transform()).affine_inverse().xform(Input::get_singleton()->get_mouse_pos());
ERR_FAIL_COND_V(!get_viewport(),Vector2());
return get_global_transform().affine_inverse().xform( get_global_mouse_pos() );
}