summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/animated_sprite.cpp2
-rw-r--r--scene/2d/animated_sprite.h2
-rw-r--r--scene/2d/area_2d.cpp18
-rw-r--r--scene/2d/area_2d.h6
-rw-r--r--scene/2d/camera_2d.cpp43
-rw-r--r--scene/2d/camera_2d.h8
-rw-r--r--scene/2d/canvas_item.cpp35
-rw-r--r--scene/2d/canvas_item.h8
-rw-r--r--scene/2d/canvas_modulate.cpp13
-rw-r--r--scene/2d/collision_object_2d.cpp6
-rw-r--r--scene/2d/collision_object_2d.h2
-rw-r--r--scene/2d/collision_polygon_2d.cpp66
-rw-r--r--scene/2d/collision_polygon_2d.h3
-rw-r--r--scene/2d/collision_shape_2d.cpp8
-rw-r--r--scene/2d/collision_shape_2d.h2
-rw-r--r--scene/2d/joints_2d.cpp76
-rw-r--r--scene/2d/joints_2d.h7
-rw-r--r--scene/2d/light_2d.cpp20
-rw-r--r--scene/2d/light_2d.h2
-rw-r--r--scene/2d/light_occluder_2d.cpp5
-rw-r--r--scene/2d/navigation2d.cpp42
-rw-r--r--scene/2d/navigation_polygon.cpp8
-rw-r--r--scene/2d/node_2d.cpp11
-rw-r--r--scene/2d/node_2d.h4
-rw-r--r--scene/2d/node_2d_singleton.cpp2
-rw-r--r--scene/2d/node_2d_singleton.h2
-rw-r--r--scene/2d/parallax_background.cpp4
-rw-r--r--scene/2d/parallax_background.h2
-rw-r--r--scene/2d/parallax_layer.cpp2
-rw-r--r--scene/2d/parallax_layer.h2
-rw-r--r--scene/2d/particles_2d.cpp16
-rw-r--r--scene/2d/particles_2d.h3
-rw-r--r--scene/2d/path_2d.cpp10
-rw-r--r--scene/2d/path_2d.h2
-rw-r--r--scene/2d/physics_body_2d.cpp27
-rw-r--r--scene/2d/physics_body_2d.h4
-rw-r--r--scene/2d/position_2d.cpp2
-rw-r--r--scene/2d/position_2d.h2
-rw-r--r--scene/2d/ray_cast_2d.cpp2
-rw-r--r--scene/2d/ray_cast_2d.h2
-rw-r--r--scene/2d/remote_transform_2d.cpp2
-rw-r--r--scene/2d/remote_transform_2d.h2
-rw-r--r--scene/2d/sample_player_2d.cpp2
-rw-r--r--scene/2d/sample_player_2d.h2
-rw-r--r--scene/2d/screen_button.cpp10
-rw-r--r--scene/2d/screen_button.h2
-rw-r--r--scene/2d/sound_player_2d.cpp2
-rw-r--r--scene/2d/sound_player_2d.h2
-rw-r--r--scene/2d/sprite.cpp2
-rw-r--r--scene/2d/sprite.h2
-rw-r--r--scene/2d/tile_map.cpp93
-rw-r--r--scene/2d/tile_map.h10
-rw-r--r--scene/2d/visibility_notifier_2d.cpp2
-rw-r--r--scene/2d/visibility_notifier_2d.h2
54 files changed, 489 insertions, 127 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp
index 458246671c..1ed508aed3 100644
--- a/scene/2d/animated_sprite.cpp
+++ b/scene/2d/animated_sprite.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h
index 425f516b14..da4f1b99af 100644
--- a/scene/2d/animated_sprite.h
+++ b/scene/2d/animated_sprite.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index c44b46adbf..50a115174d 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -383,7 +383,11 @@ void Area2D::_clear_monitoring() {
Object *obj = ObjectDB::get_instance(E->key());
Node *node = obj ? obj->cast_to<Node>() : NULL;
- ERR_CONTINUE(!node);
+
+ if (!node) //node may have been deleted in previous frame, this should not be an error
+ continue;
+ //ERR_CONTINUE(!node);
+
if (!E->get().in_tree)
continue;
@@ -416,13 +420,13 @@ void Area2D::_notification(int p_what) {
void Area2D::set_enable_monitoring(bool p_enable) {
- if (locked) {
- ERR_EXPLAIN("This function can't be used during the in/out signal.");
- }
- ERR_FAIL_COND(locked);
if (p_enable==monitoring)
return;
+ if (locked) {
+ ERR_EXPLAIN("Function blocked during in/out signal. Use call_deferred(\"set_enable_monitoring\",true/false)");
+ }
+ ERR_FAIL_COND(locked);
monitoring=p_enable;
@@ -652,7 +656,7 @@ void Area2D::_bind_methods() {
ADD_SIGNAL( MethodInfo("area_exit",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D")));
- ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"space_override",PROPERTY_HINT_ENUM,"Disabled,Combine,Replace"),_SCS("set_space_override_mode"),_SCS("get_space_override_mode"));
+ ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"space_override",PROPERTY_HINT_ENUM,"Disabled,Combine,Combine-Replace,Replace,Replace-Combine"),_SCS("set_space_override_mode"),_SCS("get_space_override_mode"));
ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"gravity_point"),_SCS("set_gravity_is_point"),_SCS("is_gravity_a_point"));
ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"gravity_distance_scale", PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_gravity_distance_scale"),_SCS("get_gravity_distance_scale"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"gravity_vec"),_SCS("set_gravity_vector"),_SCS("get_gravity_vector"));
diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h
index f5a88390e7..7f3f9c93cf 100644
--- a/scene/2d/area_2d.h
+++ b/scene/2d/area_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -40,7 +40,9 @@ public:
enum SpaceOverride {
SPACE_OVERRIDE_DISABLED,
SPACE_OVERRIDE_COMBINE,
- SPACE_OVERRIDE_REPLACE
+ SPACE_OVERRIDE_COMBINE_REPLACE,
+ SPACE_OVERRIDE_REPLACE,
+ SPACE_OVERRIDE_REPLACE_COMBINE
};
private:
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index 52ae5d2954..67c1733759 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -118,10 +118,10 @@ Matrix32 Camera2D::get_camera_transform() {
- if (smoothing>0.0) {
+ if (smoothing_enabled) {
float c = smoothing*get_fixed_process_delta_time();
- smoothed_camera_pos = ((new_camera_pos-smoothed_camera_pos)*c)+smoothed_camera_pos;
+ smoothed_camera_pos = ((camera_pos-smoothed_camera_pos)*c)+smoothed_camera_pos;
ret_camera_pos=smoothed_camera_pos;
// camera_pos=camera_pos*(1.0-smoothing)+new_camera_pos*smoothing;
} else {
@@ -440,6 +440,27 @@ float Camera2D::get_h_offset() const{
}
+void Camera2D::_set_old_smoothing(float p_val) {
+ //compatibility
+ if (p_val>0) {
+ smoothing_enabled=true;
+ set_follow_smoothing(p_val);
+ }
+
+}
+
+void Camera2D::set_enable_follow_smoothing(bool p_enabled) {
+
+ smoothing_enabled=p_enabled;
+
+}
+
+bool Camera2D::is_follow_smoothing_enabled() const {
+
+ return smoothing_enabled;
+}
+
+
void Camera2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_offset","offset"),&Camera2D::set_offset);
@@ -482,21 +503,24 @@ void Camera2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_camera_pos"),&Camera2D::get_camera_pos);
ObjectTypeDB::bind_method(_MD("get_camera_screen_center"),&Camera2D::get_camera_screen_center);
- ObjectTypeDB::bind_method(_MD("set_zoom"),&Camera2D::set_zoom);
+ ObjectTypeDB::bind_method(_MD("set_zoom","zoom"),&Camera2D::set_zoom);
ObjectTypeDB::bind_method(_MD("get_zoom"),&Camera2D::get_zoom);
ObjectTypeDB::bind_method(_MD("set_follow_smoothing","follow_smoothing"),&Camera2D::set_follow_smoothing);
ObjectTypeDB::bind_method(_MD("get_follow_smoothing"),&Camera2D::get_follow_smoothing);
+ ObjectTypeDB::bind_method(_MD("set_enable_follow_smoothing","follow_smoothing"),&Camera2D::set_enable_follow_smoothing);
+ ObjectTypeDB::bind_method(_MD("is_follow_smoothing_enabled"),&Camera2D::is_follow_smoothing_enabled);
+
ObjectTypeDB::bind_method(_MD("force_update_scroll"),&Camera2D::force_update_scroll);
+ ObjectTypeDB::bind_method(_MD("_set_old_smoothing","follow_smoothing"),&Camera2D::_set_old_smoothing);
ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"anchor_mode",PROPERTY_HINT_ENUM,"Fixed TopLeft,Drag Center"),_SCS("set_anchor_mode"),_SCS("get_anchor_mode"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"rotating"),_SCS("set_rotating"),_SCS("is_rotating"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"current"),_SCS("_set_current"),_SCS("is_current"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing"),_SCS("set_follow_smoothing"),_SCS("get_follow_smoothing") );
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"zoom"),_SCS("set_zoom"),_SCS("get_zoom") );
ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit/left"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_LEFT);
@@ -507,6 +531,12 @@ void Camera2D::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin/h_enabled"),_SCS("set_h_drag_enabled"),_SCS("is_h_drag_enabled") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin/v_enabled"),_SCS("set_v_drag_enabled"),_SCS("is_v_drag_enabled") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"smoothing/enable"),_SCS("set_enable_follow_smoothing"),_SCS("is_follow_smoothing_enabled") );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing/speed"),_SCS("set_follow_smoothing"),_SCS("get_follow_smoothing") );
+
+ //compatibility
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing",PROPERTY_HINT_NONE,"",0),_SCS("_set_old_smoothing"),_SCS("get_follow_smoothing") );
+
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/left",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_LEFT);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/top",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_TOP);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/right",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_RIGHT);
@@ -535,8 +565,9 @@ Camera2D::Camera2D() {
drag_margin[MARGIN_BOTTOM]=0.2;
camera_pos=Vector2();
first=true;
+ smoothing_enabled=false;
- smoothing=0.0;
+ smoothing=5.0;
zoom = Vector2(1, 1);
h_drag_enabled=true;
diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h
index 79d84f48d0..3c51bbf220 100644
--- a/scene/2d/camera_2d.h
+++ b/scene/2d/camera_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -59,6 +59,7 @@ protected:
bool rotating;
bool current;
float smoothing;
+ bool smoothing_enabled;
int limit[4];
float drag_margin[4];
@@ -73,6 +74,8 @@ protected:
void _make_current(Object *p_which);
void _set_current(bool p_current);
+
+ void _set_old_smoothing(float p_enable);
protected:
virtual Matrix32 get_camera_transform();
@@ -108,6 +111,9 @@ public:
void set_h_offset(float p_offset);
float get_h_offset() const;
+ void set_enable_follow_smoothing(bool p_enabled);
+ bool is_follow_smoothing_enabled() const;
+
void set_follow_smoothing(float p_speed);
float get_follow_smoothing() const;
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 357aaa225b..316097fbcf 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -309,6 +309,15 @@ void CanvasItem::hide() {
_change_notify("visibility/visible");
}
+void CanvasItem::set_hidden(bool p_hidden) {
+
+ if (hidden == p_hidden) {
+ return;
+ }
+
+ _set_visible_(!p_hidden);
+}
+
Variant CanvasItem::edit_get_state() const {
@@ -380,8 +389,8 @@ Matrix32 CanvasItem::get_global_transform_with_canvas() const {
if (last_valid->canvas_layer)
return last_valid->canvas_layer->get_transform() * xform;
- else
- return xform;
+ else if (is_inside_tree())
+ return get_viewport()->get_canvas_transform() * xform;
}
Matrix32 CanvasItem::get_global_transform() const {
@@ -539,6 +548,7 @@ void CanvasItem::_notification(int p_what) {
get_parent()->cast_to<CanvasItem>()->children_items.erase(C);
C=NULL;
}
+ global_invalid=true;
} break;
case NOTIFICATION_DRAW: {
@@ -700,7 +710,7 @@ void CanvasItem::draw_circle(const Point2& p_pos, float p_radius, const Color& p
}
-void CanvasItem::draw_texture(const Ref<Texture>& p_texture,const Point2& p_pos) {
+void CanvasItem::draw_texture(const Ref<Texture>& p_texture,const Point2& p_pos,const Color& p_modulate) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
@@ -709,7 +719,7 @@ void CanvasItem::draw_texture(const Ref<Texture>& p_texture,const Point2& p_pos)
ERR_FAIL_COND(p_texture.is_null());
- p_texture->draw(canvas_item,p_pos);
+ p_texture->draw(canvas_item,p_pos,p_modulate);
}
void CanvasItem::draw_texture_rect(const Ref<Texture>& p_texture,const Rect2& p_rect, bool p_tile,const Color& p_modulate, bool p_transpose) {
@@ -764,7 +774,7 @@ void CanvasItem::draw_set_transform(const Point2& p_offset, float p_rot, const S
Matrix32 xform(p_rot,p_offset);
xform.scale_basis(p_scale);
- VisualServer::get_singleton()->canvas_item_set_transform(canvas_item,xform);
+ VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item,xform);
}
void CanvasItem::draw_polygon(const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, Ref<Texture> p_texture) {
@@ -1043,6 +1053,7 @@ void CanvasItem::_bind_methods() {
ObjectTypeDB::bind_method(_MD("is_hidden"),&CanvasItem::is_hidden);
ObjectTypeDB::bind_method(_MD("show"),&CanvasItem::show);
ObjectTypeDB::bind_method(_MD("hide"),&CanvasItem::hide);
+ ObjectTypeDB::bind_method(_MD("set_hidden","hidden"),&CanvasItem::set_hidden);
ObjectTypeDB::bind_method(_MD("update"),&CanvasItem::update);
@@ -1070,7 +1081,7 @@ void CanvasItem::_bind_methods() {
ObjectTypeDB::bind_method(_MD("draw_line","from","to","color","width"),&CanvasItem::draw_line,DEFVAL(1.0));
ObjectTypeDB::bind_method(_MD("draw_rect","rect","color"),&CanvasItem::draw_rect);
ObjectTypeDB::bind_method(_MD("draw_circle","pos","radius","color"),&CanvasItem::draw_circle);
- ObjectTypeDB::bind_method(_MD("draw_texture","texture:Texture","pos"),&CanvasItem::draw_texture);
+ ObjectTypeDB::bind_method(_MD("draw_texture","texture:Texture","pos","modulate"),&CanvasItem::draw_texture,DEFVAL(Color(1,1,1,1)));
ObjectTypeDB::bind_method(_MD("draw_texture_rect","texture:Texture","rect","tile","modulate","transpose"),&CanvasItem::draw_texture_rect,DEFVAL(Color(1,1,1)),DEFVAL(false));
ObjectTypeDB::bind_method(_MD("draw_texture_rect_region","texture:Texture","rect","src_rect","modulate","transpose"),&CanvasItem::draw_texture_rect_region,DEFVAL(Color(1,1,1)),DEFVAL(false));
ObjectTypeDB::bind_method(_MD("draw_style_box","style_box:StyleBox","rect"),&CanvasItem::draw_style_box);
@@ -1146,6 +1157,8 @@ Matrix32 CanvasItem::get_canvas_transform() const {
if (canvas_layer)
return canvas_layer->get_transform();
+ else if (get_parent()->cast_to<CanvasItem>())
+ return get_parent()->cast_to<CanvasItem>()->get_canvas_transform();
else
return get_viewport()->get_canvas_transform();
@@ -1180,6 +1193,14 @@ bool CanvasItem::is_local_transform_notification_enabled() const {
return notify_local_transform;
}
+int CanvasItem::get_canvas_layer() const {
+
+ if (canvas_layer)
+ return canvas_layer->get_layer();
+ else
+ return 0;
+}
+
CanvasItem::CanvasItem() : xform_change(this) {
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 4885256c64..05a2e725e9 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -190,13 +190,14 @@ public:
bool is_hidden() const;
void show();
void hide();
+ void set_hidden(bool p_hidden);
void update();
void set_blend_mode(BlendMode p_blend_mode);
BlendMode get_blend_mode() const;
- void set_light_mask(int p_light_mask);
+ virtual void set_light_mask(int p_light_mask);
int get_light_mask() const;
void set_opacity(float p_opacity);
@@ -210,7 +211,7 @@ public:
void draw_line(const Point2& p_from, const Point2& p_to,const Color& p_color,float p_width=1.0);
void draw_rect(const Rect2& p_rect, const Color& p_color);
void draw_circle(const Point2& p_pos, float p_radius, const Color& p_color);
- void draw_texture(const Ref<Texture>& p_texture,const Point2& p_pos);
+ void draw_texture(const Ref<Texture>& p_texture, const Point2& p_pos, const Color &p_modulate=Color(1,1,1,1));
void draw_texture_rect(const Ref<Texture>& p_texture, const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1), bool p_transpose=false);
void draw_texture_rect_region(const Ref<Texture>& p_texture,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1), bool p_transpose=false);
void draw_style_box(const Ref<StyleBox>& p_style_box,const Rect2& p_rect);
@@ -267,6 +268,7 @@ public:
void set_notify_local_transform(bool p_enable);
bool is_local_transform_notification_enabled() const;
+ int get_canvas_layer() const;
CanvasItem();
~CanvasItem();
diff --git a/scene/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp
index 82dd8012a5..77203a7110 100644
--- a/scene/2d/canvas_modulate.cpp
+++ b/scene/2d/canvas_modulate.cpp
@@ -5,10 +5,19 @@ void CanvasModulate::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_CANVAS) {
- VS::get_singleton()->canvas_set_modulate(get_canvas(),color);
+ if (is_visible())
+ VS::get_singleton()->canvas_set_modulate(get_canvas(),color);
} else if (p_what==NOTIFICATION_EXIT_CANVAS) {
- VS::get_singleton()->canvas_set_modulate(get_canvas(),Color(1,1,1,1));
+ if (is_visible())
+ VS::get_singleton()->canvas_set_modulate(get_canvas(),Color(1,1,1,1));
+ } else if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+
+ if (is_visible()) {
+ VS::get_singleton()->canvas_set_modulate(get_canvas(),color);
+ } else {
+ VS::get_singleton()->canvas_set_modulate(get_canvas(),Color(1,1,1,1));
+ }
}
}
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index 8b8caf13d3..3a45b0c84e 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,14 +32,14 @@
void CollisionObject2D::_update_shapes_from_children() {
- shapes.resize(0);
+ shapes.clear();
for(int i=0;i<get_child_count();i++) {
Node* n = get_child(i);
n->call("_add_to_collision_object",this);
}
-// _update_shapes();
+ _update_shapes();
}
void CollisionObject2D::_notification(int p_what) {
diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h
index 473f13d0ff..fc50c5c7cd 100644
--- a/scene/2d/collision_object_2d.h
+++ b/scene/2d/collision_object_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index 1479cb7881..2a40a6207d 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -30,7 +30,7 @@
#include "collision_object_2d.h"
#include "scene/resources/concave_polygon_shape_2d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
-
+#include "triangulator.h"
void CollisionPolygon2D::_add_to_collision_object(Object *p_obj) {
if (unparenting || !can_update_body)
@@ -48,7 +48,7 @@ void CollisionPolygon2D::_add_to_collision_object(Object *p_obj) {
//here comes the sun, lalalala
//decompose concave into multiple convex polygons and add them
- Vector< Vector<Vector2> > decomp = Geometry::decompose_polygon(polygon);
+ Vector< Vector<Vector2> > decomp = _decompose_in_convex();
shape_from=co->get_shape_count();
for(int i=0;i<decomp.size();i++) {
Ref<ConvexPolygonShape2D> convex = memnew( ConvexPolygonShape2D );
@@ -106,6 +106,51 @@ void CollisionPolygon2D::_update_parent() {
co->_update_shapes_from_children();
}
+Vector< Vector<Vector2> > CollisionPolygon2D::_decompose_in_convex() {
+
+ Vector< Vector<Vector2> > decomp;
+#if 0
+ //fast but imprecise triangulator, gave us problems
+ decomp = Geometry::decompose_polygon(polygon);
+#else
+
+ List<TriangulatorPoly> in_poly,out_poly;
+
+ TriangulatorPoly inp;
+ inp.Init(polygon.size());
+ for(int i=0;i<polygon.size();i++) {
+ inp.GetPoint(i)=polygon[i];
+ }
+ inp.SetOrientation(TRIANGULATOR_CCW);
+ in_poly.push_back(inp);
+ TriangulatorPartition tpart;
+ if (tpart.ConvexPartition_HM(&in_poly,&out_poly)==0) { //failed!
+ ERR_PRINT("Convex decomposing failed!");
+ return decomp;
+ }
+
+ decomp.resize(out_poly.size());
+ int idx=0;
+
+ for(List<TriangulatorPoly>::Element*I = out_poly.front();I;I=I->next()) {
+
+ TriangulatorPoly& tp = I->get();
+
+ decomp[idx].resize(tp.GetNumPoints());
+
+ for(int i=0;i<tp.GetNumPoints();i++) {
+
+ decomp[idx][i]=tp.GetPoint(i);
+ }
+
+ idx++;
+ }
+
+#endif
+
+ return decomp;
+}
+
void CollisionPolygon2D::_notification(int p_what) {
@@ -113,6 +158,12 @@ void CollisionPolygon2D::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
unparenting=false;
can_update_body=get_tree()->is_editor_hint();
+ if (!get_tree()->is_editor_hint()) {
+ //display above all else
+ set_z_as_relative(false);
+ set_z(VS::CANVAS_ITEM_Z_MAX-1);
+ }
+
} break;
case NOTIFICATION_EXIT_TREE: {
can_update_body=false;
@@ -146,10 +197,11 @@ void CollisionPolygon2D::_notification(int p_what) {
Vector2 n = polygon[(i+1)%polygon.size()];
draw_line(p,n,Color(0.9,0.2,0.0,0.8),3);
}
-//#define DEBUG_DECOMPOSE
+#define DEBUG_DECOMPOSE
#if defined(TOOLS_ENABLED) && defined (DEBUG_DECOMPOSE)
- Vector< Vector<Vector2> > decomp = Geometry::decompose_polygon(polygon);
+ Vector< Vector<Vector2> > decomp = _decompose_in_convex();
+
Color c(0.4,0.9,0.1);
for(int i=0;i<decomp.size();i++) {
@@ -251,10 +303,10 @@ void CollisionPolygon2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_polygon","polygon"),&CollisionPolygon2D::set_polygon);
ObjectTypeDB::bind_method(_MD("get_polygon"),&CollisionPolygon2D::get_polygon);
- ObjectTypeDB::bind_method(_MD("set_build_mode"),&CollisionPolygon2D::set_build_mode);
+ ObjectTypeDB::bind_method(_MD("set_build_mode","build_mode"),&CollisionPolygon2D::set_build_mode);
ObjectTypeDB::bind_method(_MD("get_build_mode"),&CollisionPolygon2D::get_build_mode);
- ObjectTypeDB::bind_method(_MD("set_trigger"),&CollisionPolygon2D::set_trigger);
+ ObjectTypeDB::bind_method(_MD("set_trigger","trigger"),&CollisionPolygon2D::set_trigger);
ObjectTypeDB::bind_method(_MD("is_trigger"),&CollisionPolygon2D::is_trigger);
ObjectTypeDB::bind_method(_MD("_set_shape_range","shape_range"),&CollisionPolygon2D::_set_shape_range);
diff --git a/scene/2d/collision_polygon_2d.h b/scene/2d/collision_polygon_2d.h
index 4bc9713c8a..b2bd4d189d 100644
--- a/scene/2d/collision_polygon_2d.h
+++ b/scene/2d/collision_polygon_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -63,6 +63,7 @@ protected:
void _set_shape_range(const Vector2& p_range);
Vector2 _get_shape_range() const;
+ Vector< Vector<Vector2> > _decompose_in_convex();
protected:
diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp
index 85751fc735..405310450b 100644
--- a/scene/2d/collision_shape_2d.cpp
+++ b/scene/2d/collision_shape_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -77,6 +77,11 @@ void CollisionShape2D::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
unparenting=false;
can_update_body=get_tree()->is_editor_hint();
+ if (!get_tree()->is_editor_hint()) {
+ //display above all else
+ set_z_as_relative(false);
+ set_z(VS::CANVAS_ITEM_Z_MAX-1);
+ }
} break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
@@ -120,6 +125,7 @@ void CollisionShape2D::_notification(int p_what) {
rect=Rect2();
+
Color draw_col=get_tree()->get_debug_collisions_color();
shape->draw(get_canvas_item(),draw_col);
diff --git a/scene/2d/collision_shape_2d.h b/scene/2d/collision_shape_2d.h
index 82e1137174..b14dad73ba 100644
--- a/scene/2d/collision_shape_2d.h
+++ b/scene/2d/collision_shape_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp
index 1df936535f..053fc2c9c2 100644
--- a/scene/2d/joints_2d.cpp
+++ b/scene/2d/joints_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -111,6 +111,19 @@ real_t Joint2D::get_bias() const{
return bias;
}
+void Joint2D::set_exclude_nodes_from_collision(bool p_enable) {
+
+ if (exclude_from_collision==p_enable)
+ return;
+ exclude_from_collision=p_enable;
+ _update_joint();
+}
+
+bool Joint2D::get_exclude_nodes_from_collision() const{
+
+ return exclude_from_collision;
+}
+
void Joint2D::_bind_methods() {
@@ -124,9 +137,14 @@ void Joint2D::_bind_methods() {
ObjectTypeDB::bind_method( _MD("set_bias","bias"), &Joint2D::set_bias );
ObjectTypeDB::bind_method( _MD("get_bias"), &Joint2D::get_bias );
+ ObjectTypeDB::bind_method( _MD("set_exclude_nodes_from_collision","enable"), &Joint2D::set_exclude_nodes_from_collision );
+ ObjectTypeDB::bind_method( _MD("get_exclude_nodes_from_collision"), &Joint2D::get_exclude_nodes_from_collision );
+
ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_a"), _SCS("set_node_a"),_SCS("get_node_a") );
ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_b"), _SCS("set_node_b"),_SCS("get_node_b") );
ADD_PROPERTY( PropertyInfo( Variant::REAL, "bias/bias",PROPERTY_HINT_RANGE,"0,0.9,0.001"), _SCS("set_bias"),_SCS("get_bias") );
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "collision/exclude_nodes"), _SCS("set_exclude_nodes_from_collision"),_SCS("get_exclude_nodes_from_collision") );
+
}
@@ -135,6 +153,7 @@ void Joint2D::_bind_methods() {
Joint2D::Joint2D() {
bias=0;
+ exclude_from_collision=true;
}
///////////////////////////////////////////////////////////////////////////////
@@ -145,11 +164,17 @@ void PinJoint2D::_notification(int p_what) {
switch(p_what) {
case NOTIFICATION_DRAW: {
- if (is_inside_tree() && get_tree()->is_editor_hint()) {
- draw_line(Point2(-10,0),Point2(+10,0),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(0,-10),Point2(0,+10),Color(0.7,0.6,0.0,0.5),3);
+ if (!is_inside_tree())
+ break;
+
+ if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
+ break;
}
+
+
+ draw_line(Point2(-10,0),Point2(+10,0),Color(0.7,0.6,0.0,0.5),3);
+ draw_line(Point2(0,-10),Point2(0,+10),Color(0.7,0.6,0.0,0.5),3);
} break;
}
@@ -173,7 +198,10 @@ RID PinJoint2D::_configure_joint() {
SWAP(body_a,body_b);
} else if (body_b) {
//add a collision exception between both
- Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid());
+ if (get_exclude_nodes_from_collision())
+ Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid());
+ else
+ Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid());
}
RID pj = Physics2DServer::get_singleton()->pin_joint_create(get_global_transform().get_origin(),body_a->get_rid(),body_b?body_b->get_rid():RID());
Physics2DServer::get_singleton()->pin_joint_set_param(pj, Physics2DServer::PIN_JOINT_SOFTNESS, softness);
@@ -219,13 +247,17 @@ void GrooveJoint2D::_notification(int p_what) {
switch(p_what) {
case NOTIFICATION_DRAW: {
- if (is_inside_tree() && get_tree()->is_editor_hint()) {
+ if (!is_inside_tree())
+ break;
- draw_line(Point2(-10,0),Point2(+10,0),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(-10,length),Point2(+10,length),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(0,0),Point2(0,length),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(-10,initial_offset),Point2(+10,initial_offset),Color(0.8,0.8,0.9,0.5),5);
+ if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
+ break;
}
+
+ draw_line(Point2(-10,0),Point2(+10,0),Color(0.7,0.6,0.0,0.5),3);
+ draw_line(Point2(-10,length),Point2(+10,length),Color(0.7,0.6,0.0,0.5),3);
+ draw_line(Point2(0,0),Point2(0,length),Color(0.7,0.6,0.0,0.5),3);
+ draw_line(Point2(-10,initial_offset),Point2(+10,initial_offset),Color(0.8,0.8,0.9,0.5),5);
} break;
}
}
@@ -245,7 +277,11 @@ RID GrooveJoint2D::_configure_joint(){
if (!body_a || !body_b)
return RID();
- Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid());
+
+ if (get_exclude_nodes_from_collision())
+ Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid());
+ else
+ Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid());
Matrix32 gt = get_global_transform();
Vector2 groove_A1 = gt.get_origin();
@@ -313,12 +349,17 @@ void DampedSpringJoint2D::_notification(int p_what) {
switch(p_what) {
case NOTIFICATION_DRAW: {
- if (is_inside_tree() && get_tree()->is_editor_hint()) {
- draw_line(Point2(-10,0),Point2(+10,0),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(-10,length),Point2(+10,length),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(0,0),Point2(0,length),Color(0.7,0.6,0.0,0.5),3);
+ if (!is_inside_tree())
+ break;
+
+ if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
+ break;
}
+
+ draw_line(Point2(-10,0),Point2(+10,0),Color(0.7,0.6,0.0,0.5),3);
+ draw_line(Point2(-10,length),Point2(+10,length),Color(0.7,0.6,0.0,0.5),3);
+ draw_line(Point2(0,0),Point2(0,length),Color(0.7,0.6,0.0,0.5),3);
} break;
}
}
@@ -338,7 +379,10 @@ RID DampedSpringJoint2D::_configure_joint(){
if (!body_a || !body_b)
return RID();
- Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid());
+ if (get_exclude_nodes_from_collision())
+ Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid());
+ else
+ Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid());
Matrix32 gt = get_global_transform();
Vector2 anchor_A = gt.get_origin();
diff --git a/scene/2d/joints_2d.h b/scene/2d/joints_2d.h
index 908e3a158e..52ffd86e7c 100644
--- a/scene/2d/joints_2d.h
+++ b/scene/2d/joints_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -42,6 +42,8 @@ class Joint2D : public Node2D {
NodePath b;
real_t bias;
+ bool exclude_from_collision;
+
protected:
@@ -62,6 +64,9 @@ public:
void set_bias(real_t p_bias);
real_t get_bias() const;
+ void set_exclude_nodes_from_collision(bool p_enable);
+ bool get_exclude_nodes_from_collision() const;
+
RID get_joint() const { return joint; }
Joint2D();
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index 852a6fb46b..9715afeaa4 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -34,10 +34,19 @@ Rect2 Light2D::get_item_rect() const {
}
+void Light2D::_update_light_visibility() {
+
+ if (!is_inside_tree())
+ return;
+
+ VS::get_singleton()->canvas_light_set_enabled(canvas_light,enabled && is_visible());
+}
+
void Light2D::set_enabled( bool p_enabled) {
- VS::get_singleton()->canvas_light_set_enabled(canvas_light,p_enabled);
+
enabled=p_enabled;
+ _update_light_visibility();
}
bool Light2D::is_enabled() const {
@@ -253,16 +262,22 @@ void Light2D::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
VS::get_singleton()->canvas_light_attach_to_canvas( canvas_light, get_canvas() );
+ _update_light_visibility();
}
if (p_what==NOTIFICATION_TRANSFORM_CHANGED) {
VS::get_singleton()->canvas_light_set_transform( canvas_light, get_global_transform());
}
+ if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+
+ _update_light_visibility();
+ }
if (p_what==NOTIFICATION_EXIT_TREE) {
VS::get_singleton()->canvas_light_attach_to_canvas( canvas_light, RID() );
+ _update_light_visibility();
}
}
@@ -333,7 +348,7 @@ void Light2D::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::REAL,"scale",PROPERTY_HINT_RANGE,"0.01,4096,0.01"),_SCS("set_texture_scale"),_SCS("get_texture_scale"));
ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"energy"),_SCS("set_energy"),_SCS("get_energy"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Add,Sub,Mix"),_SCS("set_mode"),_SCS("get_mode"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Add,Sub,Mix,Mask"),_SCS("set_mode"),_SCS("get_mode"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"range/height"),_SCS("set_height"),_SCS("get_height"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"range/z_min",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_min"),_SCS("get_z_range_min"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"range/z_max",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_max"),_SCS("get_z_range_max"));
@@ -349,6 +364,7 @@ void Light2D::_bind_methods() {
BIND_CONSTANT( MODE_ADD );
BIND_CONSTANT( MODE_SUB );
BIND_CONSTANT( MODE_MIX );
+ BIND_CONSTANT( MODE_MASK );
}
diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h
index bf61868bac..ca437769e7 100644
--- a/scene/2d/light_2d.h
+++ b/scene/2d/light_2d.h
@@ -11,6 +11,7 @@ public:
MODE_ADD,
MODE_SUB,
MODE_MIX,
+ MODE_MASK,
};
private:
@@ -34,6 +35,7 @@ private:
Ref<Texture> texture;
Vector2 texture_offset;
+ void _update_light_visibility();
protected:
void _notification(int p_what);
diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp
index 6ebd499f71..d98bed0ea3 100644
--- a/scene/2d/light_occluder_2d.cpp
+++ b/scene/2d/light_occluder_2d.cpp
@@ -93,12 +93,17 @@ void LightOccluder2D::_notification(int p_what) {
VS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder,get_canvas());
VS::get_singleton()->canvas_light_occluder_set_transform(occluder,get_global_transform());
+ VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible());
}
if (p_what==NOTIFICATION_TRANSFORM_CHANGED) {
VS::get_singleton()->canvas_light_occluder_set_transform(occluder,get_global_transform());
}
+ if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+
+ VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible());
+ }
if (p_what==NOTIFICATION_DRAW) {
diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp
index b7d51730a0..fe1760b84a 100644
--- a/scene/2d/navigation2d.cpp
+++ b/scene/2d/navigation2d.cpp
@@ -494,7 +494,29 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect
open_list.erase(least_cost_poly);
}
-
+#if 0
+debug path
+ {
+ Polygon *p=end_poly;
+ int idx=0;
+
+ while(true) {
+ int prev = p->prev_edge;
+ int prev_n = (p->prev_edge+1)%p->edges.size();
+ Vector2 point = (_get_vertex(p->edges[prev].point) + _get_vertex(p->edges[prev_n].point))*0.5;
+ String points;
+ for(int i=0;i<p->edges.size();i++) {
+ if (i>0)
+ points+=", ";
+ points+=_get_vertex(p->edges[i].point);
+ }
+ //print_line("poly "+itos(idx++)+" - "+points);
+ p = p->edges[prev].C;
+ if (p==begin_poly)
+ break;
+ }
+ }
+#endif
if (found_route) {
Vector<Vector2> path;
@@ -538,22 +560,29 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect
bool skip=false;
- /* print_line("-----\nAPEX: "+(apex_point-end_point));
+ /*
+ print_line("-----\nAPEX: "+(apex_point-end_point));
print_line("LEFT:");
print_line("\tPortal: "+(portal_left-end_point));
print_line("\tPoint: "+(left-end_point));
- print_line("\tFree: "+itos(CLOCK_TANGENT(apex_point,portal_left,left) >= 0));
+ print_line("\tLeft Tangent: "+rtos(CLOCK_TANGENT(apex_point,portal_left,left)));
+ print_line("\tLeft Distance: "+rtos(portal_left.distance_squared_to(apex_point)));
+ print_line("\tLeft Test: "+rtos(CLOCK_TANGENT(apex_point,left,portal_right)));
print_line("RIGHT:");
print_line("\tPortal: "+(portal_right-end_point));
print_line("\tPoint: "+(right-end_point));
- print_line("\tFree: "+itos(CLOCK_TANGENT(apex_point,portal_right,right) <= 0));
-*/
+ print_line("\tRight Tangent: "+rtos(CLOCK_TANGENT(apex_point,portal_right,right)));
+ print_line("\tRight Distance: "+rtos(portal_right.distance_squared_to(apex_point)));
+ print_line("\tRight Test: "+rtos(CLOCK_TANGENT(apex_point,right,portal_left)));
+ */
+
if (CLOCK_TANGENT(apex_point,portal_left,left) >= 0){
//process
if (portal_left.distance_squared_to(apex_point)<CMP_EPSILON || CLOCK_TANGENT(apex_point,left,portal_right) > 0) {
left_poly=p;
portal_left=left;
+ //print_line("***ADVANCE LEFT");
} else {
//_clip_path(path,apex_poly,portal_right,right_poly);
@@ -568,6 +597,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect
path.push_back(apex_point);
skip=true;
//print_line("addpoint left");
+ //print_line("***CLIP LEFT");
}
}
@@ -576,6 +606,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect
if (portal_right.distance_squared_to(apex_point)<CMP_EPSILON || CLOCK_TANGENT(apex_point,right,portal_left) < 0) {
right_poly=p;
portal_right=right;
+ //print_line("***ADVANCE RIGHT");
} else {
//_clip_path(path,apex_poly,portal_left,left_poly);
@@ -589,6 +620,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect
if (path[path.size()-1].distance_to(apex_point)>CMP_EPSILON)
path.push_back(apex_point);
//print_line("addpoint right");
+ //print_line("***CLIP RIGHT");
}
}
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 Ref<NavigationPolyg
}
if (navigation && navpoly.is_valid() && enabled) {
- nav_id = navigation->navpoly_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 52b112f090..7ef81306b6 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -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<Node2D>();
+
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();
}
@@ -394,9 +395,9 @@ void Node2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_z_as_relative","enable"),&Node2D::set_z_as_relative);
ObjectTypeDB::bind_method(_MD("is_z_relative"),&Node2D::is_z_relative);
- ObjectTypeDB::bind_method(_MD("edit_set_pivot"),&Node2D::edit_set_pivot);
+ ObjectTypeDB::bind_method(_MD("edit_set_pivot","pivot"),&Node2D::edit_set_pivot);
- ObjectTypeDB::bind_method(_MD("get_relative_transform"),&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..49d616fc1f 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -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/node_2d_singleton.cpp b/scene/2d/node_2d_singleton.cpp
index 361edf7587..b26804fedf 100644
--- a/scene/2d/node_2d_singleton.cpp
+++ b/scene/2d/node_2d_singleton.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/node_2d_singleton.h b/scene/2d/node_2d_singleton.h
index 6a21db2221..0aa6bbf992 100644
--- a/scene/2d/node_2d_singleton.h
+++ b/scene/2d/node_2d_singleton.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp
index 8bb4eb55ba..7f2e9efd96 100644
--- a/scene/2d/parallax_background.cpp
+++ b/scene/2d/parallax_background.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -193,7 +193,7 @@ void ParallaxBackground::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_limit_begin"),&ParallaxBackground::get_limit_begin);
ObjectTypeDB::bind_method(_MD("set_limit_end","ofs"),&ParallaxBackground::set_limit_end);
ObjectTypeDB::bind_method(_MD("get_limit_end"),&ParallaxBackground::get_limit_end);
- ObjectTypeDB::bind_method(_MD("set_ignore_camera_zoom"), &ParallaxBackground::set_ignore_camera_zoom);
+ ObjectTypeDB::bind_method(_MD("set_ignore_camera_zoom","ignore"), &ParallaxBackground::set_ignore_camera_zoom);
ObjectTypeDB::bind_method(_MD("is_ignore_camera_zoom"), &ParallaxBackground::is_ignore_camera_zoom);
diff --git a/scene/2d/parallax_background.h b/scene/2d/parallax_background.h
index 8dede07a16..bdaf7d241f 100644
--- a/scene/2d/parallax_background.h
+++ b/scene/2d/parallax_background.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp
index 70612d7c9a..7a898e43c9 100644
--- a/scene/2d/parallax_layer.cpp
+++ b/scene/2d/parallax_layer.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/parallax_layer.h b/scene/2d/parallax_layer.h
index 8fe2846897..6c24a9b9f7 100644
--- a/scene/2d/parallax_layer.h
+++ b/scene/2d/parallax_layer.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp
index 8f805ceba2..5b13c32d93 100644
--- a/scene/2d/particles_2d.cpp
+++ b/scene/2d/particles_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -697,7 +697,7 @@ bool Particles2D::is_emitting() const {
void Particles2D::set_amount(int p_amount) {
- ERR_FAIL_INDEX(p_amount,1024);
+ ERR_FAIL_INDEX(p_amount,1024+1);
particles.resize(p_amount);
}
@@ -719,7 +719,7 @@ float Particles2D::get_emit_timeout() const {
void Particles2D::set_lifetime(float p_lifetime) {
- ERR_FAIL_INDEX(p_lifetime,3600);
+ ERR_FAIL_INDEX(p_lifetime,3600+1);
lifetime=p_lifetime;
}
@@ -994,6 +994,15 @@ DVector<Vector2> Particles2D::get_emission_points() const{
return emission_points;
}
+void Particles2D::reset() {
+
+ for(int i=0;i<particles.size();i++) {
+ particles[i].active=false;
+ }
+ time=0;
+ active_count=0;
+}
+
void Particles2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_emitting","active"),&Particles2D::set_emitting);
@@ -1057,6 +1066,7 @@ void Particles2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_color_phase_pos","phase"),&Particles2D::get_color_phase_pos);
ObjectTypeDB::bind_method(_MD("pre_process","time"),&Particles2D::pre_process);
+ ObjectTypeDB::bind_method(_MD("reset"),&Particles2D::reset);
ObjectTypeDB::bind_method(_MD("set_use_local_space","enable"),&Particles2D::set_use_local_space);
ObjectTypeDB::bind_method(_MD("is_using_local_space"),&Particles2D::is_using_local_space);
diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h
index 4ee0fcf8da..101395589e 100644
--- a/scene/2d/particles_2d.h
+++ b/scene/2d/particles_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -248,6 +248,7 @@ public:
DVector<Vector2> get_emission_points() const;
void pre_process(float p_delta);
+ void reset();
Particles2D();
};
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index 8f110b3931..bd7415aa04 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,9 +31,13 @@
void Path2D::_notification(int p_what) {
- if (p_what==NOTIFICATION_DRAW && curve.is_valid() && is_inside_tree() && get_tree()->is_editor_hint()) {
+ if (p_what==NOTIFICATION_DRAW && curve.is_valid()) {
//draw the curve!!
+ if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_navigation_hint()) {
+ return;
+ }
+
for(int i=0;i<curve->get_point_count();i++) {
Vector2 prev_p=curve->get_point_pos(i);
@@ -70,6 +74,8 @@ void Path2D::set_curve(const Ref<Curve2D>& p_curve) {
curve->connect("changed",this,"_curve_changed");
}
+ _curve_changed();
+
}
Ref<Curve2D> Path2D::get_curve() const{
diff --git a/scene/2d/path_2d.h b/scene/2d/path_2d.h
index c9114c5d7d..486a8ac9ac 100644
--- a/scene/2d/path_2d.h
+++ b/scene/2d/path_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index c30921eb69..cc2e5c0d72 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -310,14 +310,20 @@ void RigidBody2D::_body_enter_tree(ObjectID p_id) {
ERR_FAIL_COND(!E);
ERR_FAIL_COND(E->get().in_scene);
+ contact_monitor->locked=true;
+
E->get().in_scene=true;
emit_signal(SceneStringNames::get_singleton()->body_enter,node);
+
for(int i=0;i<E->get().shapes.size();i++) {
emit_signal(SceneStringNames::get_singleton()->body_enter_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape);
}
+ contact_monitor->locked=false;
+
+
}
void RigidBody2D::_body_exit_tree(ObjectID p_id) {
@@ -329,11 +335,18 @@ void RigidBody2D::_body_exit_tree(ObjectID p_id) {
ERR_FAIL_COND(!E);
ERR_FAIL_COND(!E->get().in_scene);
E->get().in_scene=false;
+
+ contact_monitor->locked=true;
+
emit_signal(SceneStringNames::get_singleton()->body_exit,node);
+
for(int i=0;i<E->get().shapes.size();i++) {
emit_signal(SceneStringNames::get_singleton()->body_exit_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape);
}
+
+ contact_monitor->locked=false;
+
}
void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,int p_local_shape) {
@@ -439,6 +452,8 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
if (contact_monitor) {
+ contact_monitor->locked=true;
+
//untag all
int rc=0;
for( Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.front();E;E=E->next()) {
@@ -520,6 +535,8 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
_body_inout(1,toadd[i].id,toadd[i].shape,toadd[i].local_shape);
}
+ contact_monitor->locked=false;
+
}
set_block_transform_notify(true); // don't want notify (would feedback loop)
@@ -803,6 +820,11 @@ void RigidBody2D::set_contact_monitor(bool p_enabled) {
if (!p_enabled) {
+ if (contact_monitor->locked) {
+ ERR_EXPLAIN("Can't disable contact monitoring during in/out callback. Use call_deferred(\"set_contact_monitor\",false) instead");
+ }
+ ERR_FAIL_COND(contact_monitor->locked);
+
for(Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.front();E;E=E->next()) {
//clean up mess
@@ -813,6 +835,7 @@ void RigidBody2D::set_contact_monitor(bool p_enabled) {
} else {
contact_monitor = memnew( ContactMonitor );
+ contact_monitor->locked=false;
}
}
@@ -1250,7 +1273,7 @@ void KinematicBody2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_collider_velocity"),&KinematicBody2D::get_collider_velocity);
ObjectTypeDB::bind_method(_MD("get_collider:Object"),&KinematicBody2D::_get_collider);
ObjectTypeDB::bind_method(_MD("get_collider_shape"),&KinematicBody2D::get_collider_shape);
- ObjectTypeDB::bind_method(_MD("get_collider_metadata"),&KinematicBody2D::get_collider_metadata);
+ ObjectTypeDB::bind_method(_MD("get_collider_metadata:Variant"),&KinematicBody2D::get_collider_metadata);
ObjectTypeDB::bind_method(_MD("set_collision_margin","pixels"),&KinematicBody2D::set_collision_margin);
ObjectTypeDB::bind_method(_MD("get_collision_margin","pixels"),&KinematicBody2D::get_collision_margin);
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index b70fdd59cf..999e63dd5d 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -190,7 +190,7 @@ private:
struct ContactMonitor {
-
+ bool locked;
Map<ObjectID,BodyState> body_map;
};
diff --git a/scene/2d/position_2d.cpp b/scene/2d/position_2d.cpp
index f1591b5242..c293305cb2 100644
--- a/scene/2d/position_2d.cpp
+++ b/scene/2d/position_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/position_2d.h b/scene/2d/position_2d.h
index 16404e6ce8..23821e62d4 100644
--- a/scene/2d/position_2d.h
+++ b/scene/2d/position_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp
index 4a199e3418..4a774b0198 100644
--- a/scene/2d/ray_cast_2d.cpp
+++ b/scene/2d/ray_cast_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h
index 8c3ce8b3b3..54ec42c53e 100644
--- a/scene/2d/ray_cast_2d.h
+++ b/scene/2d/ray_cast_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp
index 0fbd140cfb..6dcd980822 100644
--- a/scene/2d/remote_transform_2d.cpp
+++ b/scene/2d/remote_transform_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/remote_transform_2d.h b/scene/2d/remote_transform_2d.h
index 506bde8cd8..4a5f5f72ea 100644
--- a/scene/2d/remote_transform_2d.h
+++ b/scene/2d/remote_transform_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/sample_player_2d.cpp b/scene/2d/sample_player_2d.cpp
index ec17ffc55e..bf09130238 100644
--- a/scene/2d/sample_player_2d.cpp
+++ b/scene/2d/sample_player_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/sample_player_2d.h b/scene/2d/sample_player_2d.h
index c0f2734ad1..eddf84f77b 100644
--- a/scene/2d/sample_player_2d.h
+++ b/scene/2d/sample_player_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp
index 0c3987e6b1..fac94f19dc 100644
--- a/scene/2d/screen_button.cpp
+++ b/scene/2d/screen_button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -102,6 +102,10 @@ void TouchScreenButton::_notification(int p_what) {
action_id=-1;
}
} break;
+ case NOTIFICATION_EXIT_TREE: {
+ if (is_pressed())
+ Input::get_singleton()->action_release(action);
+ } break;
}
}
@@ -161,7 +165,7 @@ void TouchScreenButton::_input(const InputEvent& p_event) {
if (finger_pressed==-1 || p_event.screen_touch.index==finger_pressed) {
- Point2 coord = (get_global_transform()).affine_inverse().xform(Point2(p_event.screen_touch.x,p_event.screen_touch.y));
+ Point2 coord = (get_global_transform_with_canvas()).affine_inverse().xform(Point2(p_event.screen_touch.x,p_event.screen_touch.y));
bool touched=false;
if (bitmask.is_valid()) {
@@ -238,7 +242,7 @@ void TouchScreenButton::_input(const InputEvent& p_event) {
if (finger_pressed!=-1)
return; //already fingering
- Point2 coord = (get_global_transform()).affine_inverse().xform(Point2(p_event.screen_touch.x,p_event.screen_touch.y));
+ Point2 coord = (get_global_transform_with_canvas()).affine_inverse().xform(Point2(p_event.screen_touch.x,p_event.screen_touch.y));
bool touched=false;
if (bitmask.is_valid()) {
diff --git a/scene/2d/screen_button.h b/scene/2d/screen_button.h
index 159b829079..ff3b50bf5e 100644
--- a/scene/2d/screen_button.h
+++ b/scene/2d/screen_button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/sound_player_2d.cpp b/scene/2d/sound_player_2d.cpp
index 0eb18866af..41ce87faf9 100644
--- a/scene/2d/sound_player_2d.cpp
+++ b/scene/2d/sound_player_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/sound_player_2d.h b/scene/2d/sound_player_2d.h
index a376cdbed7..0e75887235 100644
--- a/scene/2d/sound_player_2d.h
+++ b/scene/2d/sound_player_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index 89d9966958..001a1366a9 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/sprite.h b/scene/2d/sprite.h
index ad782e746b..cbcaec9aeb 100644
--- a/scene/2d/sprite.h
+++ b/scene/2d/sprite.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 167b637bdc..179d1f451a 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,6 +32,8 @@
#include "method_bind_ext.inc"
#include "os/os.h"
+
+
int TileMap::_get_quadrant_size() const {
if (y_sort_mode)
@@ -116,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<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
@@ -221,6 +223,14 @@ void TileMap::_fix_cell_transform(Matrix32& xform,const Cell& p_cell, const Vect
Size2 s=p_sc;
Vector2 offset = p_offset;
+ if (s.y > s.x) {
+ if ((p_cell.flip_h && (p_cell.flip_v || p_cell.transpose)) || (p_cell.flip_v && !p_cell.transpose))
+ offset.y += s.y - s.x;
+ } else if (s.y < s.x) {
+ if ((p_cell.flip_v && (p_cell.flip_h || p_cell.transpose)) || (p_cell.flip_h && !p_cell.transpose))
+ offset.x += s.x - s.y;
+ }
+
if (p_cell.transpose) {
SWAP(xform.elements[0].x, xform.elements[0].y);
SWAP(xform.elements[1].x, xform.elements[1].y);
@@ -259,7 +269,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;
@@ -299,6 +309,7 @@ void TileMap::_update_dirty_quadrants() {
q.occluder_instances.clear();
Ref<CanvasItemMaterial> prev_material;
RID prev_canvas_item;
+ RID prev_debug_canvas_item;
for(int i=0;i<q.cells.size();i++) {
@@ -319,6 +330,7 @@ void TileMap::_update_dirty_quadrants() {
Ref<CanvasItemMaterial> mat = tile_set->tile_get_material(c.id);
RID canvas_item;
+ RID debug_canvas_item;
if (prev_canvas_item==RID() || prev_material!=mat) {
@@ -329,13 +341,28 @@ void TileMap::_update_dirty_quadrants() {
Matrix32 xform;
xform.set_origin( q.pos );
vs->canvas_item_set_transform( canvas_item, xform );
+ vs->canvas_item_set_light_mask(canvas_item,get_light_mask());
+
q.canvas_items.push_back(canvas_item);
+ if (debug_shapes) {
+
+ debug_canvas_item=vs->canvas_item_create();
+ vs->canvas_item_set_parent( debug_canvas_item, canvas_item );
+ vs->canvas_item_set_z_as_relative_to_parent(debug_canvas_item,false);
+ vs->canvas_item_set_z(debug_canvas_item,VS::CANVAS_ITEM_Z_MAX-1);
+ q.canvas_items.push_back(debug_canvas_item);
+ prev_debug_canvas_item=debug_canvas_item;
+ }
+
prev_canvas_item=canvas_item;
prev_material=mat;
} else {
canvas_item=prev_canvas_item;
+ if (debug_shapes) {
+ debug_canvas_item=prev_debug_canvas_item;
+ }
}
@@ -357,13 +384,28 @@ void TileMap::_update_dirty_quadrants() {
rect.pos=offset.floor();
rect.size=s;
+ if (rect.size.y > rect.size.x) {
+ if ((c.flip_h && (c.flip_v || c.transpose)) || (c.flip_v && !c.transpose))
+ tile_ofs.y += rect.size.y - rect.size.x;
+ } else if (rect.size.y < rect.size.x) {
+ if ((c.flip_v && (c.flip_h || c.transpose)) || (c.flip_h && !c.transpose))
+ tile_ofs.x += rect.size.x - rect.size.y;
+ }
+
/* rect.size.x+=fp_adjust;
rect.size.y+=fp_adjust;*/
- if (c.flip_h)
+ if (c.transpose)
+ SWAP(tile_ofs.x, tile_ofs.y);
+
+ if (c.flip_h) {
rect.size.x=-rect.size.x;
- if (c.flip_v)
+ tile_ofs.x=-tile_ofs.x;
+ }
+ if (c.flip_v) {
rect.size.y=-rect.size.y;
+ tile_ofs.y=-tile_ofs.y;
+ }
Vector2 center_ofs;
@@ -407,9 +449,8 @@ void TileMap::_update_dirty_quadrants() {
_fix_cell_transform(xform,c,shape_ofs+center_ofs,s);
- if (debug_shapes) {
- vs->canvas_item_add_set_transform(canvas_item,xform);
- shape->draw(canvas_item,debug_collision_color);
+ if (debug_canvas_item) {
+ shape->draw(debug_canvas_item,debug_collision_color);
}
ps->body_add_shape(q.body,shape->get_rid(),xform);
@@ -417,9 +458,6 @@ void TileMap::_update_dirty_quadrants() {
}
}
- if (debug_shapes) {
- vs->canvas_item_add_set_transform(canvas_item,Matrix32());
- }
if (navigation) {
Ref<NavigationPolygon> navpoly = tile_set->tile_get_navigation_polygon(c.id);
@@ -452,6 +490,7 @@ void TileMap::_update_dirty_quadrants() {
VS::get_singleton()->canvas_light_occluder_set_transform(orid,get_global_transform() * xform);
VS::get_singleton()->canvas_light_occluder_set_polygon(orid,occluder->get_rid());
VS::get_singleton()->canvas_light_occluder_attach_to_canvas(orid,get_canvas());
+ VS::get_singleton()->canvas_light_occluder_set_light_mask(orid,occluder_light_mask);
Quadrant::Occluder oc;
oc.xform=xform;
oc.id=orid;
@@ -1075,6 +1114,33 @@ Array TileMap::get_used_cells() const {
return a;
}
+void TileMap::set_occluder_light_mask(int p_mask) {
+
+ occluder_light_mask=p_mask;
+ for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
+
+ for (Map<PosKey,Quadrant::Occluder>::Element *F=E->get().occluder_instances.front();F;F=F->next()) {
+ VisualServer::get_singleton()->canvas_light_occluder_set_light_mask(F->get().id,occluder_light_mask);
+ }
+ }
+}
+
+int TileMap::get_occluder_light_mask() const{
+
+ return occluder_light_mask;
+}
+
+void TileMap::set_light_mask(int p_light_mask) {
+
+ CanvasItem::set_light_mask(p_light_mask);
+ for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
+
+ for (List<RID>::Element *F=E->get().canvas_items.front();F;F=F->next()) {
+ VisualServer::get_singleton()->canvas_item_set_light_mask(F->get(),get_light_mask());
+ }
+ }
+}
+
void TileMap::_bind_methods() {
@@ -1126,6 +1192,9 @@ void TileMap::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_collision_bounce","value"),&TileMap::set_collision_bounce);
ObjectTypeDB::bind_method(_MD("get_collision_bounce"),&TileMap::get_collision_bounce);
+ ObjectTypeDB::bind_method(_MD("set_occluder_light_mask","mask"),&TileMap::set_occluder_light_mask);
+ ObjectTypeDB::bind_method(_MD("get_occluder_light_mask"),&TileMap::get_occluder_light_mask);
+
ObjectTypeDB::bind_method(_MD("set_cell","x","y","tile","flip_x","flip_y","transpose"),&TileMap::set_cell,DEFVAL(false),DEFVAL(false),DEFVAL(false));
ObjectTypeDB::bind_method(_MD("set_cellv","pos","tile","flip_x","flip_y","transpose"),&TileMap::set_cellv,DEFVAL(false),DEFVAL(false),DEFVAL(false));
ObjectTypeDB::bind_method(_MD("get_cell","x","y"),&TileMap::get_cell);
@@ -1160,6 +1229,7 @@ void TileMap::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_bounce"),_SCS("get_collision_bounce"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_layer"),_SCS("get_collision_layer"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"occluder/light_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_occluder_light_mask"),_SCS("get_occluder_light_mask"));
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"tile_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_tile_data"),_SCS("_get_tile_data"));
@@ -1197,6 +1267,7 @@ TileMap::TileMap() {
use_kinematic=false;
navigation=NULL;
y_sort_mode=false;
+ occluder_light_mask=1;
fp_adjust=0.00001;
tile_origin=TILE_ORIGIN_TOP_LEFT;
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index 60534cce15..14cb52b736 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -150,6 +150,8 @@ private:
TileOrigin tile_origin;
+ int occluder_light_mask;
+
void _fix_cell_transform(Matrix32& xform, const Cell& p_cell, const Vector2 &p_offset, const Size2 &p_sc);
Map<PosKey,Quadrant>::Element *_create_quadrant(const PosKey& p_qk);
@@ -187,6 +189,7 @@ public:
INVALID_CELL=-1
};
+
void set_tileset(const Ref<TileSet>& p_tileset);
Ref<TileSet> get_tileset() const;
@@ -247,6 +250,11 @@ public:
void set_y_sort_mode(bool p_enable);
bool is_y_sort_mode_enabled() const;
+ void set_occluder_light_mask(int p_mask);
+ int get_occluder_light_mask() const;
+
+ virtual void set_light_mask(int p_light_mask);
+
void clear();
TileMap();
diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp
index dc72c9a267..60fa7f69c8 100644
--- a/scene/2d/visibility_notifier_2d.cpp
+++ b/scene/2d/visibility_notifier_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/visibility_notifier_2d.h b/scene/2d/visibility_notifier_2d.h
index 1f7e4c6d45..6ec24fd4d0 100644
--- a/scene/2d/visibility_notifier_2d.h
+++ b/scene/2d/visibility_notifier_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */