From f7b64a62d115d4955a47ea6735960f535ed8133c Mon Sep 17 00:00:00 2001 From: reduz Date: Mon, 28 Dec 2015 21:05:57 -0300 Subject: -renamed function get_relative_transform() to get_relative_transform_to_parent(), makes more sense -fixed newly introduced bug in onready keyword, fixes #3155 --- modules/gdscript/gd_parser.cpp | 8 ++------ scene/2d/navigation_polygon.cpp | 8 ++++---- scene/2d/node_2d.cpp | 7 ++++--- scene/2d/node_2d.h | 2 +- scene/2d/tile_map.cpp | 4 ++-- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 95e172e26e..3da12fc38b 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -2769,12 +2769,8 @@ void GDParser::_parse_class(ClassNode *p_class) { }; //fallthrough to var case GDTokenizer::TK_PR_ONREADY: { - if (tokenizer->get_token(-1)==GDTokenizer::TK_PR_EXPORT) { - current_export=PropertyInfo(); - _set_error("Expected 'var' (can't combine with 'onready')."); - return; - } else { - + if (token==GDTokenizer::TK_PR_ONREADY) { + //may be fallthrough from export, ignore if so tokenizer->advance(); if (tokenizer->get_token()!=GDTokenizer::TK_PR_VAR) { _set_error("Expected 'var'."); diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp index 792f079ab0..4c00d8cec9 100644 --- a/scene/2d/navigation_polygon.cpp +++ b/scene/2d/navigation_polygon.cpp @@ -273,7 +273,7 @@ void NavigationPolygonInstance::set_enabled(bool p_enabled) { if (navpoly.is_valid()) { - nav_id = navigation->navpoly_create(navpoly,get_relative_transform(navigation),this); + nav_id = navigation->navpoly_create(navpoly,get_relative_transform_to_parent(navigation),this); } } @@ -309,7 +309,7 @@ void NavigationPolygonInstance::_notification(int p_what) { if (enabled && navpoly.is_valid()) { - nav_id = navigation->navpoly_create(navpoly,get_relative_transform(navigation),this); + nav_id = navigation->navpoly_create(navpoly,get_relative_transform_to_parent(navigation),this); } break; } @@ -321,7 +321,7 @@ void NavigationPolygonInstance::_notification(int p_what) { case NOTIFICATION_TRANSFORM_CHANGED: { if (navigation && nav_id!=-1) { - navigation->navpoly_set_transform(nav_id,get_relative_transform(navigation)); + navigation->navpoly_set_transform(nav_id,get_relative_transform_to_parent(navigation)); } } break; @@ -409,7 +409,7 @@ void NavigationPolygonInstance::set_navigation_polygon(const Refnavpoly_create(navpoly,get_relative_transform(navigation),this); + nav_id = navigation->navpoly_create(navpoly,get_relative_transform_to_parent(navigation),this); } //update_gizmo(); _change_notify("navpoly"); diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index 975827bc7e..0683d31fc6 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -333,17 +333,18 @@ int Node2D::get_z() const{ return z; } -Matrix32 Node2D::get_relative_transform(const Node *p_parent) const { +Matrix32 Node2D::get_relative_transform_to_parent(const Node *p_parent) const { if (p_parent==this) return Matrix32(); Node2D *parent_2d = get_parent()->cast_to(); + ERR_FAIL_COND_V(!parent_2d,Matrix32()); if (p_parent==parent_2d) return get_transform(); else - return parent_2d->get_relative_transform(p_parent) * get_transform(); + return parent_2d->get_relative_transform_to_parent(p_parent) * get_transform(); } @@ -396,7 +397,7 @@ void Node2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("edit_set_pivot","pivot"),&Node2D::edit_set_pivot); - ObjectTypeDB::bind_method(_MD("get_relative_transform","parent"),&Node2D::get_relative_transform); + ObjectTypeDB::bind_method(_MD("get_relative_transform_to_parent","parent"),&Node2D::get_relative_transform_to_parent); ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"transform/pos"),_SCS("set_pos"),_SCS("get_pos")); ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"transform/rot",PROPERTY_HINT_RANGE,"-1440,1440,0.1"),_SCS("_set_rotd"),_SCS("_get_rotd")); diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h index 8efce33cda..a964a6ae34 100644 --- a/scene/2d/node_2d.h +++ b/scene/2d/node_2d.h @@ -99,7 +99,7 @@ public: void set_z_as_relative(bool p_enabled); bool is_z_relative() const; - Matrix32 get_relative_transform(const Node *p_parent) const; + Matrix32 get_relative_transform_to_parent(const Node *p_parent) const; diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 1d48a9c8a0..679ff719c5 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -118,7 +118,7 @@ void TileMap::_update_quadrant_transform() { Matrix32 nav_rel; if (navigation) - nav_rel = get_relative_transform(navigation); + nav_rel = get_relative_transform_to_parent(navigation); for (Map::Element *E=quadrant_map.front();E;E=E->next()) { @@ -261,7 +261,7 @@ void TileMap::_update_dirty_quadrants() { Vector2 tcenter = cell_size/2; Matrix32 nav_rel; if (navigation) - nav_rel = get_relative_transform(navigation); + nav_rel = get_relative_transform_to_parent(navigation); Vector2 qofs; -- cgit v1.2.3