From aa5ade834c8646b81e2320089314393c00ee8020 Mon Sep 17 00:00:00 2001 From: anneomcl Date: Mon, 19 Sep 2016 21:36:24 -0700 Subject: Fix for #6158. Converting Vector2 to Size2 for scaling functions. --- scene/2d/node_2d.cpp | 2 +- scene/2d/node_2d.h | 4 +--- scene/2d/polygon_2d.cpp | 4 ++-- scene/2d/polygon_2d.h | 6 +++--- 4 files changed, 7 insertions(+), 9 deletions(-) (limited to 'scene/2d') diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index df43e8e373..b3f925cb14 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -253,7 +253,7 @@ void Node2D::global_translate(const Vector2& p_amount) { set_global_pos( get_global_pos() + p_amount ); } -void Node2D::scale(const Vector2& p_amount) { +void Node2D::scale(const Size2& p_amount) { set_scale( get_scale() * p_amount ); } diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h index aa8d0ef33c..b31ee08af6 100644 --- a/scene/2d/node_2d.h +++ b/scene/2d/node_2d.h @@ -79,7 +79,7 @@ public: void move_y(float p_delta,bool p_scaled=false); void translate(const Vector2& p_amount); void global_translate(const Vector2& p_amount); - void scale(const Vector2& p_amount); + void scale(const Size2& p_amount); Point2 get_pos() const; float get_rot() const; @@ -110,8 +110,6 @@ public: Matrix32 get_relative_transform_to_parent(const Node *p_parent) const; - - Matrix32 get_transform() const; Node2D(); diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index cfb87fb998..12893524d1 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -288,12 +288,12 @@ float Polygon2D::_get_texture_rotationd() const{ } -void Polygon2D::set_texture_scale(const Vector2& p_scale){ +void Polygon2D::set_texture_scale(const Size2& p_scale){ tex_scale=p_scale; update(); } -Vector2 Polygon2D::get_texture_scale() const{ +Size2 Polygon2D::get_texture_scale() const{ return tex_scale; } diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h index 04e8aeb6fd..cecb9081f7 100644 --- a/scene/2d/polygon_2d.h +++ b/scene/2d/polygon_2d.h @@ -40,7 +40,7 @@ class Polygon2D : public Node2D { DVector vertex_colors; Color color; Ref texture; - Vector2 tex_scale; + Size2 tex_scale; Vector2 tex_ofs; bool tex_tile; float tex_rot; @@ -81,8 +81,8 @@ public: void set_texture_rotation(float p_rot); float get_texture_rotation() const; - void set_texture_scale(const Vector2& p_scale); - Vector2 get_texture_scale() const; + void set_texture_scale(const Size2& p_scale); + Size2 get_texture_scale() const; void set_invert(bool p_rot); bool get_invert() const; -- cgit v1.2.3 From f9a21baa26427badcac2871253052039eb514674 Mon Sep 17 00:00:00 2001 From: Pawel Kowal Date: Thu, 29 Sep 2016 18:12:45 +0200 Subject: Fix #6480, area duplicated param --- scene/2d/area_2d.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scene/2d') diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index 71728966fd..e8954b7e98 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -650,8 +650,8 @@ void Area2D::_bind_methods() { ADD_SIGNAL( MethodInfo("body_enter",PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D"))); ADD_SIGNAL( MethodInfo("body_exit",PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D"))); - ADD_SIGNAL( MethodInfo("area_enter_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape"))); - ADD_SIGNAL( MethodInfo("area_exit_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape"))); + ADD_SIGNAL( MethodInfo("area_enter_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape"))); + ADD_SIGNAL( MethodInfo("area_exit_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape"))); ADD_SIGNAL( MethodInfo("area_enter",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"))); ADD_SIGNAL( MethodInfo("area_exit",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"))); -- cgit v1.2.3 From 7494a8c3c6738ae212cc9ec62eb478056b846e3d Mon Sep 17 00:00:00 2001 From: Karol Walasek Date: Tue, 9 Aug 2016 19:52:15 +0200 Subject: Added force_raycast_update GDScript method for RayCast[2D] --- scene/2d/ray_cast_2d.cpp | 48 +++++++++++++++++++++++++++--------------------- scene/2d/ray_cast_2d.h | 3 +++ 2 files changed, 30 insertions(+), 21 deletions(-) (limited to 'scene/2d') diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp index b5d62adfb4..bd7f4faae5 100644 --- a/scene/2d/ray_cast_2d.cpp +++ b/scene/2d/ray_cast_2d.cpp @@ -187,39 +187,44 @@ void RayCast2D::_notification(int p_what) { if (!enabled) break; + _update_raycast_state(); - Ref w2d = get_world_2d(); - ERR_BREAK( w2d.is_null() ); - - Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(w2d->get_space()); - ERR_BREAK( !dss ); - - Matrix32 gt = get_global_transform(); + } break; + } +} - Vector2 to = cast_to; - if (to==Vector2()) - to=Vector2(0,0.01); +void RayCast2D::_update_raycast_state() { + Ref w2d = get_world_2d(); + ERR_FAIL_COND( w2d.is_null() ); - Physics2DDirectSpaceState::RayResult rr; + Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(w2d->get_space()); + ERR_FAIL_COND( !dss ); - if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude,layer_mask,type_mask)) { + Matrix32 gt = get_global_transform(); - collided=true; - against=rr.collider_id; - collision_point=rr.position; - collision_normal=rr.normal; - against_shape=rr.shape; - } else { - collided=false; - } + Vector2 to = cast_to; + if (to==Vector2()) + to=Vector2(0,0.01); + Physics2DDirectSpaceState::RayResult rr; + if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude,layer_mask,type_mask)) { - } break; + collided=true; + against=rr.collider_id; + collision_point=rr.position; + collision_normal=rr.normal; + against_shape=rr.shape; + } else { + collided=false; } } +void RayCast2D::force_raycast_update() { + _update_raycast_state(); +} + void RayCast2D::add_exception_rid(const RID& p_rid) { exclude.insert(p_rid); @@ -265,6 +270,7 @@ void RayCast2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_cast_to"),&RayCast2D::get_cast_to); ObjectTypeDB::bind_method(_MD("is_colliding"),&RayCast2D::is_colliding); + ObjectTypeDB::bind_method(_MD("force_raycast_update"),&RayCast2D::force_raycast_update); ObjectTypeDB::bind_method(_MD("get_collider"),&RayCast2D::get_collider); ObjectTypeDB::bind_method(_MD("get_collider_shape"),&RayCast2D::get_collider_shape); diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h index e1caa8b63e..9bdcc2e199 100644 --- a/scene/2d/ray_cast_2d.h +++ b/scene/2d/ray_cast_2d.h @@ -52,6 +52,7 @@ class RayCast2D : public Node2D { protected: void _notification(int p_what); + void _update_raycast_state(); static void _bind_methods(); public: @@ -70,6 +71,8 @@ public: void set_exclude_parent_body(bool p_exclude_parent_body); bool get_exclude_parent_body() const; + void force_raycast_update(); + bool is_colliding() const; Object *get_collider() const; int get_collider_shape() const; -- cgit v1.2.3 From 34c02fad5ac54f6c10730c9a930b883b08e51e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Tue, 4 Oct 2016 16:44:59 +0200 Subject: Add editor_only param to Light2D --- scene/2d/light_2d.cpp | 34 +++++++++++++++++++++++++++++++++- scene/2d/light_2d.h | 4 ++++ 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'scene/2d') diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp index f37cef673d..3e548a24b0 100644 --- a/scene/2d/light_2d.cpp +++ b/scene/2d/light_2d.cpp @@ -67,7 +67,23 @@ void Light2D::_update_light_visibility() { if (!is_inside_tree()) return; - VS::get_singleton()->canvas_light_set_enabled(canvas_light,enabled && is_visible()); + bool editor_ok=true; + +#ifdef TOOLS_ENABLED + if (editor_only) { + if (!get_tree()->is_editor_hint()) { + editor_ok=false; + } else { + editor_ok = (get_tree()->get_edited_scene_root() && (this==get_tree()->get_edited_scene_root() || get_owner()==get_tree()->get_edited_scene_root())); + } + } +#else + if (editor_only) { + editor_ok=false; + } +#endif + + VS::get_singleton()->canvas_light_set_enabled(canvas_light,enabled && is_visible() && editor_ok); } void Light2D::set_enabled( bool p_enabled) { @@ -82,6 +98,17 @@ bool Light2D::is_enabled() const { return enabled; } +void Light2D::set_editor_only(bool p_editor_only) { + + editor_only=p_editor_only; + _update_light_visibility(); +} + +bool Light2D::is_editor_only() const{ + + return editor_only; +} + void Light2D::set_texture( const Ref& p_texture) { texture=p_texture; @@ -328,6 +355,9 @@ void Light2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&Light2D::set_enabled); ObjectTypeDB::bind_method(_MD("is_enabled"),&Light2D::is_enabled); + ObjectTypeDB::bind_method(_MD("set_editor_only","editor_only"), &Light2D::set_editor_only ); + ObjectTypeDB::bind_method(_MD("is_editor_only"), &Light2D::is_editor_only ); + ObjectTypeDB::bind_method(_MD("set_texture","texture"),&Light2D::set_texture); ObjectTypeDB::bind_method(_MD("get_texture"),&Light2D::get_texture); @@ -383,6 +413,7 @@ void Light2D::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled")); + ADD_PROPERTY( PropertyInfo(Variant::BOOL, "editor_only"),_SCS("set_editor_only"),_SCS("is_editor_only")); ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture")); ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_texture_offset"),_SCS("get_texture_offset")); ADD_PROPERTY( PropertyInfo(Variant::REAL,"scale",PROPERTY_HINT_RANGE,"0.01,50,0.01"),_SCS("set_texture_scale"),_SCS("get_texture_scale")); @@ -413,6 +444,7 @@ Light2D::Light2D() { canvas_light=VisualServer::get_singleton()->canvas_light_create(); enabled=true; + editor_only=false; shadow=false; color=Color(1,1,1); height=0; diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h index c03ef96eff..57c89b15e7 100644 --- a/scene/2d/light_2d.h +++ b/scene/2d/light_2d.h @@ -45,6 +45,7 @@ public: private: RID canvas_light; bool enabled; + bool editor_only; bool shadow; Color color; Color shadow_color; @@ -78,6 +79,9 @@ public: void set_enabled( bool p_enabled); bool is_enabled() const; + void set_editor_only(bool p_editor_only); + bool is_editor_only() const; + void set_texture( const Ref& p_texture); Ref get_texture() const; -- cgit v1.2.3 From 9d67895c7c3801e830d2c6e8c0fdf66f3ffc0893 Mon Sep 17 00:00:00 2001 From: Andreas Haas Date: Tue, 11 Oct 2016 15:14:05 +0200 Subject: Sprite: Fix inspector not showing changes on "frame" property. Fixes #6562 --- scene/2d/sprite.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'scene/2d') diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp index c5b338bf59..8723db95d6 100644 --- a/scene/2d/sprite.cpp +++ b/scene/2d/sprite.cpp @@ -214,6 +214,7 @@ void Sprite::set_frame(int p_frame) { frame=p_frame; + _change_notify("frame"); emit_signal(SceneStringNames::get_singleton()->frame_changed); } -- cgit v1.2.3 From fc8ccd5b8c8b779bffd0f4d7f22f2f964c939163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 17 Oct 2016 08:50:25 +0200 Subject: SCsub: Add python shebang as a hint for syntax highlighting Also switch existing shebangs to "better" /usr/bin/env python. --- scene/2d/SCsub | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scene/2d') diff --git a/scene/2d/SCsub b/scene/2d/SCsub index bbe59b3054..9fa89edbf7 100644 --- a/scene/2d/SCsub +++ b/scene/2d/SCsub @@ -1,3 +1,5 @@ +#!/usr/bin/env python + Import('env') env.add_source_files(env.scene_sources,"*.cpp") -- cgit v1.2.3