summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/audio_stream_player_2d.cpp5
-rw-r--r--scene/2d/back_buffer_copy.cpp6
-rw-r--r--scene/2d/camera_2d.cpp24
-rw-r--r--scene/2d/canvas_item.cpp39
-rw-r--r--scene/2d/canvas_item.h6
-rw-r--r--scene/2d/collision_polygon_2d.cpp5
-rw-r--r--scene/2d/collision_shape_2d.cpp6
-rw-r--r--scene/2d/joints_2d.cpp8
-rw-r--r--scene/2d/joints_2d.h2
-rw-r--r--scene/2d/light_2d.cpp14
-rw-r--r--scene/2d/light_occluder_2d.cpp10
-rw-r--r--scene/2d/line_2d.cpp16
-rw-r--r--scene/2d/navigation2d.cpp3
-rw-r--r--scene/2d/navigation_polygon.cpp7
-rw-r--r--scene/2d/node_2d.h2
-rw-r--r--scene/2d/parallax_background.h2
-rw-r--r--scene/2d/parallax_layer.cpp4
-rw-r--r--scene/2d/parallax_layer.h4
-rw-r--r--scene/2d/particles_2d.cpp9
-rw-r--r--scene/2d/particles_2d.h2
-rw-r--r--scene/2d/path_2d.cpp6
-rw-r--r--scene/2d/path_2d.h2
-rw-r--r--scene/2d/physics_body_2d.cpp23
-rw-r--r--scene/2d/polygon_2d.cpp20
-rw-r--r--scene/2d/polygon_2d.h8
-rw-r--r--scene/2d/position_2d.cpp4
-rw-r--r--scene/2d/ray_cast_2d.cpp10
-rw-r--r--scene/2d/screen_button.cpp10
-rw-r--r--scene/2d/screen_button.h2
-rw-r--r--scene/2d/tile_map.cpp29
-rw-r--r--scene/2d/visibility_notifier_2d.cpp28
31 files changed, 184 insertions, 132 deletions
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp
index 1423a804ff..73782e1515 100644
--- a/scene/2d/audio_stream_player_2d.cpp
+++ b/scene/2d/audio_stream_player_2d.cpp
@@ -1,7 +1,10 @@
#include "audio_stream_player_2d.h"
+
+#include "engine.h"
#include "scene/2d/area_2d.h"
#include "scene/main/viewport.h"
+
void AudioStreamPlayer2D::_mix_audio() {
if (!stream_playback.is_valid()) {
@@ -120,7 +123,7 @@ void AudioStreamPlayer2D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
AudioServer::get_singleton()->add_callback(_mix_audios, this);
- if (autoplay && !get_tree()->is_editor_hint()) {
+ if (autoplay && !Engine::get_singleton()->is_editor_hint()) {
play();
}
}
diff --git a/scene/2d/back_buffer_copy.cpp b/scene/2d/back_buffer_copy.cpp
index 748a527ca0..44bee20d0a 100644
--- a/scene/2d/back_buffer_copy.cpp
+++ b/scene/2d/back_buffer_copy.cpp
@@ -85,9 +85,9 @@ void BackBufferCopy::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "copy_mode", PROPERTY_HINT_ENUM, "Disabled,Rect,Viewport"), "set_copy_mode", "get_copy_mode");
ADD_PROPERTY(PropertyInfo(Variant::RECT2, "rect"), "set_rect", "get_rect");
- BIND_CONSTANT(COPY_MODE_DISABLED);
- BIND_CONSTANT(COPY_MODE_RECT);
- BIND_CONSTANT(COPY_MODE_VIEWPORT);
+ BIND_ENUM_CONSTANT(COPY_MODE_DISABLED);
+ BIND_ENUM_CONSTANT(COPY_MODE_RECT);
+ BIND_ENUM_CONSTANT(COPY_MODE_VIEWPORT);
}
BackBufferCopy::BackBufferCopy() {
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index b11c1dd642..f309631715 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -38,7 +38,7 @@ void Camera2D::_update_scroll() {
if (!is_inside_tree())
return;
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
update(); //will just be drawn
return;
}
@@ -85,7 +85,7 @@ Transform2D Camera2D::get_camera_transform() {
if (anchor_mode == ANCHOR_MODE_DRAG_CENTER) {
- if (h_drag_enabled && !get_tree()->is_editor_hint()) {
+ if (h_drag_enabled && !Engine::get_singleton()->is_editor_hint()) {
camera_pos.x = MIN(camera_pos.x, (new_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_RIGHT]));
camera_pos.x = MAX(camera_pos.x, (new_camera_pos.x - screen_size.x * 0.5 * drag_margin[MARGIN_LEFT]));
} else {
@@ -97,7 +97,7 @@ Transform2D Camera2D::get_camera_transform() {
}
}
- if (v_drag_enabled && !get_tree()->is_editor_hint()) {
+ if (v_drag_enabled && !Engine::get_singleton()->is_editor_hint()) {
camera_pos.y = MIN(camera_pos.y, (new_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_BOTTOM]));
camera_pos.y = MAX(camera_pos.y, (new_camera_pos.y - screen_size.y * 0.5 * drag_margin[MARGIN_TOP]));
@@ -136,7 +136,7 @@ Transform2D Camera2D::get_camera_transform() {
camera_pos.y -= screen_rect.position.y - limit[MARGIN_TOP];
}
- if (smoothing_enabled && !get_tree()->is_editor_hint()) {
+ if (smoothing_enabled && !Engine::get_singleton()->is_editor_hint()) {
float c = smoothing * get_fixed_process_delta_time();
smoothed_camera_pos = ((camera_pos - smoothed_camera_pos) * c) + smoothed_camera_pos;
@@ -240,7 +240,7 @@ void Camera2D::_notification(int p_what) {
add_to_group(group_name);
add_to_group(canvas_group_name);
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
set_fixed_process(false);
}
@@ -262,7 +262,7 @@ void Camera2D::_notification(int p_what) {
} break;
case NOTIFICATION_DRAW: {
- if (!is_inside_tree() || !get_tree()->is_editor_hint())
+ if (!is_inside_tree() || !Engine::get_singleton()->is_editor_hint())
break;
if (screen_drawing_enabled) {
@@ -497,7 +497,7 @@ void Camera2D::align() {
void Camera2D::set_follow_smoothing(float p_speed) {
smoothing = p_speed;
- if (smoothing > 0 && !(is_inside_tree() && get_tree()->is_editor_hint()))
+ if (smoothing > 0 && !(is_inside_tree() && Engine::get_singleton()->is_editor_hint()))
set_fixed_process(true);
else
set_fixed_process(false);
@@ -552,11 +552,11 @@ float Camera2D::get_h_offset() const {
return h_ofs;
}
-void Camera2D::_set_old_smoothing(float p_val) {
+void Camera2D::_set_old_smoothing(float p_enable) {
//compatibility
- if (p_val > 0) {
+ if (p_enable > 0) {
smoothing_enabled = true;
- set_follow_smoothing(p_val);
+ set_follow_smoothing(p_enable);
}
}
@@ -735,8 +735,8 @@ void Camera2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_draw_limits"), "set_limit_drawing_enabled", "is_limit_drawing_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_draw_drag_margin"), "set_margin_drawing_enabled", "is_margin_drawing_enabled");
- BIND_CONSTANT(ANCHOR_MODE_DRAG_CENTER);
- BIND_CONSTANT(ANCHOR_MODE_FIXED_TOP_LEFT);
+ BIND_ENUM_CONSTANT(ANCHOR_MODE_DRAG_CENTER);
+ BIND_ENUM_CONSTANT(ANCHOR_MODE_FIXED_TOP_LEFT);
}
Camera2D::Camera2D() {
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 3d0b5047ae..5a519dee69 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -188,14 +188,15 @@ void CanvasItemMaterial::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "blend_mode", PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul,Premult Alpha"), "set_blend_mode", "get_blend_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "light_mode", PROPERTY_HINT_ENUM, "Normal,Unshaded,Light Only"), "set_light_mode", "get_light_mode");
- BIND_CONSTANT(BLEND_MODE_MIX);
- BIND_CONSTANT(BLEND_MODE_ADD);
- BIND_CONSTANT(BLEND_MODE_SUB);
- BIND_CONSTANT(BLEND_MODE_MUL);
- BIND_CONSTANT(BLEND_MODE_PREMULT_ALPHA);
- BIND_CONSTANT(LIGHT_MODE_NORMAL);
- BIND_CONSTANT(LIGHT_MODE_UNSHADED);
- BIND_CONSTANT(LIGHT_MODE_LIGHT_ONLY);
+ BIND_ENUM_CONSTANT(BLEND_MODE_MIX);
+ BIND_ENUM_CONSTANT(BLEND_MODE_ADD);
+ BIND_ENUM_CONSTANT(BLEND_MODE_SUB);
+ BIND_ENUM_CONSTANT(BLEND_MODE_MUL);
+ BIND_ENUM_CONSTANT(BLEND_MODE_PREMULT_ALPHA);
+
+ BIND_ENUM_CONSTANT(LIGHT_MODE_NORMAL);
+ BIND_ENUM_CONSTANT(LIGHT_MODE_UNSHADED);
+ BIND_ENUM_CONSTANT(LIGHT_MODE_LIGHT_ONLY);
}
CanvasItemMaterial::CanvasItemMaterial()
@@ -734,7 +735,7 @@ void CanvasItem::draw_set_transform_matrix(const Transform2D &p_matrix) {
VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item, p_matrix);
}
-void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, const Ref<Texture> &p_normal_map) {
+void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, const Ref<Texture> &p_normal_map, bool p_antialiased) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
@@ -744,10 +745,10 @@ void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
RID rid_normal = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, p_colors, p_uvs, rid, rid_normal);
+ VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, p_colors, p_uvs, rid, rid_normal, p_antialiased);
}
-void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, const Ref<Texture> &p_normal_map) {
+void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, const Ref<Texture> &p_normal_map, bool p_antialiased) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
@@ -759,7 +760,7 @@ void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Colo
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
RID rid_normal = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, colors, p_uvs, rid, rid_normal);
+ VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, colors, p_uvs, rid, rid_normal, p_antialiased);
}
void CanvasItem::draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, const Color &p_modulate, int p_clip_w) {
@@ -985,8 +986,8 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("draw_texture_rect_region", "texture", "rect", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &CanvasItem::draw_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(true));
ClassDB::bind_method(D_METHOD("draw_style_box", "style_box", "rect"), &CanvasItem::draw_style_box);
ClassDB::bind_method(D_METHOD("draw_primitive", "points", "colors", "uvs", "texture", "width", "normal_map"), &CanvasItem::draw_primitive, DEFVAL(Variant()), DEFVAL(1.0), DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("draw_polygon", "points", "colors", "uvs", "texture", "normal_map"), &CanvasItem::draw_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("draw_colored_polygon", "points", "color", "uvs", "texture", "normal_map"), &CanvasItem::draw_colored_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("draw_polygon", "points", "colors", "uvs", "texture", "normal_map", "antialiased"), &CanvasItem::draw_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("draw_colored_polygon", "points", "color", "uvs", "texture", "normal_map", "antialiased"), &CanvasItem::draw_colored_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("draw_string", "font", "pos", "text", "modulate", "clip_w"), &CanvasItem::draw_string, DEFVAL(Color(1, 1, 1)), DEFVAL(-1));
ClassDB::bind_method(D_METHOD("draw_char", "font", "pos", "char", "next", "modulate"), &CanvasItem::draw_char, DEFVAL(Color(1, 1, 1)));
@@ -1042,11 +1043,11 @@ void CanvasItem::_bind_methods() {
ADD_SIGNAL(MethodInfo("hide"));
ADD_SIGNAL(MethodInfo("item_rect_changed"));
- BIND_CONSTANT(BLEND_MODE_MIX);
- BIND_CONSTANT(BLEND_MODE_ADD);
- BIND_CONSTANT(BLEND_MODE_SUB);
- BIND_CONSTANT(BLEND_MODE_MUL);
- BIND_CONSTANT(BLEND_MODE_PREMULT_ALPHA);
+ BIND_ENUM_CONSTANT(BLEND_MODE_MIX);
+ BIND_ENUM_CONSTANT(BLEND_MODE_ADD);
+ BIND_ENUM_CONSTANT(BLEND_MODE_SUB);
+ BIND_ENUM_CONSTANT(BLEND_MODE_MUL);
+ BIND_ENUM_CONSTANT(BLEND_MODE_PREMULT_ALPHA);
BIND_CONSTANT(NOTIFICATION_DRAW);
BIND_CONSTANT(NOTIFICATION_VISIBILITY_CHANGED);
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 27842727ac..c6180e07b6 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -251,8 +251,8 @@ public:
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, const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = true);
void draw_style_box(const Ref<StyleBox> &p_style_box, const Rect2 &p_rect);
void draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture = Ref<Texture>(), float p_width = 1, const Ref<Texture> &p_normal_map = Ref<Texture>());
- void draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>());
- void draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>());
+ void draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_antialiased = false);
+ void draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_antialiased = false);
void draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, const Color &p_modulate = Color(1, 1, 1), int p_clip_w = -1);
float draw_char(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_char, const String &p_next = "", const Color &p_modulate = Color(1, 1, 1));
@@ -297,7 +297,7 @@ public:
void set_use_parent_material(bool p_use_parent_material);
bool get_use_parent_material() const;
- Ref<InputEvent> make_input_local(const Ref<InputEvent> &pevent) const;
+ Ref<InputEvent> make_input_local(const Ref<InputEvent> &p_event) const;
Vector2 make_canvas_pos_local(const Vector2 &screen_point) const;
Vector2 get_global_mouse_position() const;
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index bd669eb4c8..433661e393 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -30,6 +30,7 @@
#include "collision_polygon_2d.h"
#include "collision_object_2d.h"
+#include "engine.h"
#include "scene/resources/concave_polygon_shape_2d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
@@ -134,7 +135,7 @@ void CollisionPolygon2D::_notification(int p_what) {
parent->shape_owner_set_one_way_collision(owner_id, one_way_collision);
}
- /*if (get_tree()->is_editor_hint()) {
+ /*if (Engine::get_singleton()->is_editor_hint()) {
//display above all else
set_z_as_relative(false);
set_z(VS::CANVAS_ITEM_Z_MAX - 1);
@@ -158,7 +159,7 @@ void CollisionPolygon2D::_notification(int p_what) {
case NOTIFICATION_DRAW: {
- if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
break;
}
diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp
index ff4aa245ec..3fda4ab464 100644
--- a/scene/2d/collision_shape_2d.cpp
+++ b/scene/2d/collision_shape_2d.cpp
@@ -28,7 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "collision_shape_2d.h"
+
#include "collision_object_2d.h"
+#include "engine.h"
#include "scene/resources/capsule_shape_2d.h"
#include "scene/resources/circle_shape_2d.h"
#include "scene/resources/concave_polygon_shape_2d.h"
@@ -59,7 +61,7 @@ void CollisionShape2D::_notification(int p_what) {
parent->shape_owner_set_one_way_collision(owner_id, one_way_collision);
}
- /*if (get_tree()->is_editor_hint()) {
+ /*if (Engine::get_singleton()->is_editor_hint()) {
//display above all else
set_z_as_relative(false);
set_z(VS::CANVAS_ITEM_Z_MAX - 1);
@@ -90,7 +92,7 @@ void CollisionShape2D::_notification(int p_what) {
} break;*/
case NOTIFICATION_DRAW: {
- if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
break;
}
diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp
index 1bb40a28b5..ee41dca3a6 100644
--- a/scene/2d/joints_2d.cpp
+++ b/scene/2d/joints_2d.cpp
@@ -28,6 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "joints_2d.h"
+
+#include "engine.h"
#include "physics_body_2d.h"
#include "servers/physics_2d_server.h"
@@ -152,7 +154,7 @@ void PinJoint2D::_notification(int p_what) {
if (!is_inside_tree())
break;
- if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
break;
}
@@ -227,7 +229,7 @@ void GrooveJoint2D::_notification(int p_what) {
if (!is_inside_tree())
break;
- if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
break;
}
@@ -317,7 +319,7 @@ void DampedSpringJoint2D::_notification(int p_what) {
if (!is_inside_tree())
break;
- if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
break;
}
diff --git a/scene/2d/joints_2d.h b/scene/2d/joints_2d.h
index b52b0f4670..f854ce51ee 100644
--- a/scene/2d/joints_2d.h
+++ b/scene/2d/joints_2d.h
@@ -81,7 +81,7 @@ protected:
static void _bind_methods();
public:
- void set_softness(real_t p_stiffness);
+ void set_softness(real_t p_softness);
real_t get_softness() const;
PinJoint2D();
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index e8c2122bd1..219574cbfd 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -28,6 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "light_2d.h"
+
+#include "engine.h"
#include "servers/visual_server.h"
void Light2D::edit_set_pivot(const Point2 &p_pivot) {
@@ -70,7 +72,7 @@ void Light2D::_update_light_visibility() {
#ifdef TOOLS_ENABLED
if (editor_only) {
- if (!get_tree()->is_editor_hint()) {
+ if (!Engine::get_singleton()->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()));
@@ -416,7 +418,7 @@ void Light2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_only"), "set_editor_only", "is_editor_only");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_texture_offset", "get_texture_offset");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "scale", PROPERTY_HINT_RANGE, "0.01,50,0.01"), "set_texture_scale", "get_texture_scale");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture_scale", PROPERTY_HINT_RANGE, "0.01,50,0.01"), "set_texture_scale", "get_texture_scale");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "energy", PROPERTY_HINT_RANGE, "0.01,100,0.01"), "set_energy", "get_energy");
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Add,Sub,Mix,Mask"), "set_mode", "get_mode");
@@ -437,10 +439,10 @@ void Light2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "shadow_filter_smooth", PROPERTY_HINT_RANGE, "0,64,0.1"), "set_shadow_smooth", "get_shadow_smooth");
ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow_item_cull_mask", PROPERTY_HINT_LAYERS_2D_RENDER), "set_item_shadow_cull_mask", "get_item_shadow_cull_mask");
- BIND_CONSTANT(MODE_ADD);
- BIND_CONSTANT(MODE_SUB);
- BIND_CONSTANT(MODE_MIX);
- BIND_CONSTANT(MODE_MASK);
+ BIND_ENUM_CONSTANT(MODE_ADD);
+ BIND_ENUM_CONSTANT(MODE_SUB);
+ BIND_ENUM_CONSTANT(MODE_MIX);
+ BIND_ENUM_CONSTANT(MODE_MASK);
}
Light2D::Light2D() {
diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp
index a1a8e7d9c4..680adeea69 100644
--- a/scene/2d/light_occluder_2d.cpp
+++ b/scene/2d/light_occluder_2d.cpp
@@ -29,6 +29,8 @@
/*************************************************************************/
#include "light_occluder_2d.h"
+#include "engine.h"
+
void OccluderPolygon2D::set_polygon(const PoolVector<Vector2> &p_polygon) {
polygon = p_polygon;
@@ -87,9 +89,9 @@ void OccluderPolygon2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "cull_mode", PROPERTY_HINT_ENUM, "Disabled,ClockWise,CounterClockWise"), "set_cull_mode", "get_cull_mode");
ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR2_ARRAY, "polygon"), "set_polygon", "get_polygon");
- BIND_CONSTANT(CULL_DISABLED);
- BIND_CONSTANT(CULL_CLOCKWISE);
- BIND_CONSTANT(CULL_COUNTER_CLOCKWISE);
+ BIND_ENUM_CONSTANT(CULL_DISABLED);
+ BIND_ENUM_CONSTANT(CULL_CLOCKWISE);
+ BIND_ENUM_CONSTANT(CULL_COUNTER_CLOCKWISE);
}
OccluderPolygon2D::OccluderPolygon2D() {
@@ -130,7 +132,7 @@ void LightOccluder2D::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
if (occluder_polygon.is_valid()) {
diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp
index 5438557d0b..6e7bfe63c8 100644
--- a/scene/2d/line_2d.cpp
+++ b/scene/2d/line_2d.cpp
@@ -322,16 +322,16 @@ void Line2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "sharp_limit"), "set_sharp_limit", "get_sharp_limit");
ADD_PROPERTY(PropertyInfo(Variant::INT, "round_precision"), "set_round_precision", "get_round_precision");
- BIND_CONSTANT(LINE_JOINT_SHARP);
- BIND_CONSTANT(LINE_JOINT_BEVEL);
- BIND_CONSTANT(LINE_JOINT_ROUND);
+ BIND_ENUM_CONSTANT(LINE_JOINT_SHARP);
+ BIND_ENUM_CONSTANT(LINE_JOINT_BEVEL);
+ BIND_ENUM_CONSTANT(LINE_JOINT_ROUND);
- BIND_CONSTANT(LINE_CAP_NONE);
- BIND_CONSTANT(LINE_CAP_BOX);
- BIND_CONSTANT(LINE_CAP_ROUND);
+ BIND_ENUM_CONSTANT(LINE_CAP_NONE);
+ BIND_ENUM_CONSTANT(LINE_CAP_BOX);
+ BIND_ENUM_CONSTANT(LINE_CAP_ROUND);
- BIND_CONSTANT(LINE_TEXTURE_NONE);
- BIND_CONSTANT(LINE_TEXTURE_TILE);
+ BIND_ENUM_CONSTANT(LINE_TEXTURE_NONE);
+ BIND_ENUM_CONSTANT(LINE_TEXTURE_TILE);
ClassDB::bind_method(D_METHOD("_gradient_changed"), &Line2D::_gradient_changed);
}
diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp
index e579838903..383236b4ca 100644
--- a/scene/2d/navigation2d.cpp
+++ b/scene/2d/navigation2d.cpp
@@ -646,7 +646,8 @@ debug path
break;
}
- path.push_back(begin_point);
+ if (path[path.size() - 1].distance_to(begin_point) > CMP_EPSILON)
+ path.push_back(begin_point);
path.invert();
}
diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp
index 779751c1c5..7515d486c2 100644
--- a/scene/2d/navigation_polygon.cpp
+++ b/scene/2d/navigation_polygon.cpp
@@ -30,6 +30,7 @@
#include "navigation_polygon.h"
#include "core_string_names.h"
+#include "engine.h"
#include "navigation2d.h"
#include "thirdparty/misc/triangulator.h"
@@ -297,7 +298,7 @@ void NavigationPolygonInstance::set_enabled(bool p_enabled) {
}
}
- if (get_tree()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())
+ if (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())
update();
//update_gizmo();
@@ -352,7 +353,7 @@ void NavigationPolygonInstance::_notification(int p_what) {
} break;
case NOTIFICATION_DRAW: {
- if (is_inside_tree() && (get_tree()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()) && navpoly.is_valid()) {
+ if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()) && navpoly.is_valid()) {
PoolVector<Vector2> verts = navpoly->get_vertices();
int vsize = verts.size();
@@ -432,7 +433,7 @@ Ref<NavigationPolygon> NavigationPolygonInstance::get_navigation_polygon() const
void NavigationPolygonInstance::_navpoly_changed() {
- if (is_inside_tree() && (get_tree()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()))
+ if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()))
update();
}
diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h
index df9a05ff79..a6009851c7 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -49,7 +49,7 @@ class Node2D : public CanvasItem {
void _update_transform();
// Deprecated, should be removed in a future version.
- void _set_rotd(float p_angle);
+ void _set_rotd(float p_degrees);
float _get_rotd() const;
void _update_xform_values();
diff --git a/scene/2d/parallax_background.h b/scene/2d/parallax_background.h
index 99d8dd3811..fce1bbd928 100644
--- a/scene/2d/parallax_background.h
+++ b/scene/2d/parallax_background.h
@@ -60,7 +60,7 @@ public:
void set_scroll_offset(const Point2 &p_ofs);
Point2 get_scroll_offset() const;
- void set_scroll_scale(float p_ofs);
+ void set_scroll_scale(float p_scale);
float get_scroll_scale() const;
void set_scroll_base_offset(const Point2 &p_ofs);
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp
index 0e83b9aaae..a5a59252a9 100644
--- a/scene/2d/parallax_layer.cpp
+++ b/scene/2d/parallax_layer.cpp
@@ -28,6 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "parallax_layer.h"
+
+#include "engine.h"
#include "parallax_background.h"
void ParallaxLayer::set_motion_scale(const Size2 &p_scale) {
@@ -111,7 +113,7 @@ void ParallaxLayer::set_base_offset_and_scale(const Point2 &p_offset, float p_sc
if (!is_inside_tree())
return;
- if (get_tree()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint())
return;
Point2 new_ofs = ((orig_offset + p_offset) * motion_scale) * p_scale + motion_offset;
diff --git a/scene/2d/parallax_layer.h b/scene/2d/parallax_layer.h
index 85e70b0a51..f2d0053342 100644
--- a/scene/2d/parallax_layer.h
+++ b/scene/2d/parallax_layer.h
@@ -48,7 +48,7 @@ protected:
static void _bind_methods();
public:
- void set_motion_offset(const Size2 &p_scale);
+ void set_motion_offset(const Size2 &p_offset);
Size2 get_motion_offset() const;
void set_motion_scale(const Size2 &p_scale);
@@ -57,7 +57,7 @@ public:
void set_mirroring(const Size2 &p_mirroring);
Size2 get_mirroring() const;
- void set_base_offset_and_scale(const Point2 &p_offsetf, float p_scale);
+ void set_base_offset_and_scale(const Point2 &p_offset, float p_scale);
virtual String get_configuration_warning() const;
ParallaxLayer();
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp
index 4aa841131a..b0c00c4a64 100644
--- a/scene/2d/particles_2d.cpp
+++ b/scene/2d/particles_2d.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "particles_2d.h"
+#include "engine.h"
#include "scene/3d/particles.h"
#include "scene/scene_string_names.h"
@@ -55,6 +56,8 @@ void Particles2D::set_one_shot(bool p_enable) {
one_shot = p_enable;
VS::get_singleton()->particles_set_one_shot(particles, one_shot);
+ if (!one_shot && emitting)
+ VisualServer::get_singleton()->particles_restart(particles);
}
void Particles2D::set_pre_process_time(float p_time) {
@@ -293,7 +296,7 @@ void Particles2D::_notification(int p_what) {
VS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid, normal_rid, h_frames, v_frames);
#ifdef TOOLS_ENABLED
- if (get_tree()->is_editor_hint() && (this == get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
+ if (Engine::get_singleton()->is_editor_hint() && (this == get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
draw_rect(visibility_rect, Color(0, 0.7, 0.9, 0.4), false);
}
@@ -386,8 +389,8 @@ void Particles2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "h_frames", PROPERTY_HINT_RANGE, "1,1024,1"), "set_h_frames", "get_h_frames");
ADD_PROPERTY(PropertyInfo(Variant::INT, "v_frames", PROPERTY_HINT_RANGE, "1,1024,1"), "set_v_frames", "get_v_frames");
- BIND_CONSTANT(DRAW_ORDER_INDEX);
- BIND_CONSTANT(DRAW_ORDER_LIFETIME);
+ BIND_ENUM_CONSTANT(DRAW_ORDER_INDEX);
+ BIND_ENUM_CONSTANT(DRAW_ORDER_LIFETIME);
}
Particles2D::Particles2D() {
diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h
index 23278ce746..a6ac0c37d3 100644
--- a/scene/2d/particles_2d.h
+++ b/scene/2d/particles_2d.h
@@ -80,7 +80,7 @@ public:
void set_emitting(bool p_emitting);
void set_amount(int p_amount);
void set_lifetime(float p_lifetime);
- void set_one_shot(bool p_enabled);
+ void set_one_shot(bool p_enable);
void set_pre_process_time(float p_time);
void set_explosiveness_ratio(float p_ratio);
void set_randomness_ratio(float p_ratio);
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index 6b30e97de8..a79f60c96f 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -28,6 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "path_2d.h"
+
+#include "engine.h"
#include "scene/scene_string_names.h"
void Path2D::_notification(int p_what) {
@@ -35,7 +37,7 @@ void Path2D::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW && curve.is_valid()) {
//draw the curve!!
- if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_navigation_hint()) {
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_navigation_hint()) {
return;
}
@@ -56,7 +58,7 @@ void Path2D::_notification(int p_what) {
void Path2D::_curve_changed() {
- if (is_inside_tree() && get_tree()->is_editor_hint())
+ if (is_inside_tree() && Engine::get_singleton()->is_editor_hint())
update();
}
diff --git a/scene/2d/path_2d.h b/scene/2d/path_2d.h
index b2dae17735..e80817cd3c 100644
--- a/scene/2d/path_2d.h
+++ b/scene/2d/path_2d.h
@@ -96,7 +96,7 @@ public:
void set_loop(bool p_loop);
bool has_loop() const;
- void set_rotate(bool p_enabled);
+ void set_rotate(bool p_rotate);
bool is_rotating() const;
void set_cubic_interpolation(bool p_enable);
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 2f1e8925b8..aaba9da299 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -28,6 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "physics_body_2d.h"
+
+#include "engine.h"
#include "scene/scene_string_names.h"
void PhysicsBody2D::_notification(int p_what) {
@@ -802,13 +804,13 @@ void RigidBody2D::_notification(int p_what) {
#ifdef TOOLS_ENABLED
if (p_what == NOTIFICATION_ENTER_TREE) {
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
set_notify_local_transform(true); //used for warnings and only in editor
}
}
if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) {
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
update_configuration_warning();
}
}
@@ -931,14 +933,14 @@ void RigidBody2D::_bind_methods() {
ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body")));
ADD_SIGNAL(MethodInfo("sleeping_state_changed"));
- BIND_CONSTANT(MODE_STATIC);
- BIND_CONSTANT(MODE_KINEMATIC);
- BIND_CONSTANT(MODE_RIGID);
- BIND_CONSTANT(MODE_CHARACTER);
+ BIND_ENUM_CONSTANT(MODE_STATIC);
+ BIND_ENUM_CONSTANT(MODE_KINEMATIC);
+ BIND_ENUM_CONSTANT(MODE_RIGID);
+ BIND_ENUM_CONSTANT(MODE_CHARACTER);
- BIND_CONSTANT(CCD_MODE_DISABLED);
- BIND_CONSTANT(CCD_MODE_CAST_RAY);
- BIND_CONSTANT(CCD_MODE_CAST_SHAPE);
+ BIND_ENUM_CONSTANT(CCD_MODE_DISABLED);
+ BIND_ENUM_CONSTANT(CCD_MODE_CAST_RAY);
+ BIND_ENUM_CONSTANT(CCD_MODE_CAST_SHAPE);
}
RigidBody2D::RigidBody2D()
@@ -982,11 +984,12 @@ Dictionary KinematicBody2D::_move(const Vector2 &p_motion) {
if (move(p_motion, col)) {
Dictionary d;
d["position"] = col.collision;
- d["normal"] = col.collision;
+ d["normal"] = col.normal;
d["local_shape"] = col.local_shape;
d["travel"] = col.travel;
d["remainder"] = col.remainder;
d["collider_id"] = col.collider;
+ d["collider_velocity"] = col.collider_vel;
if (col.collider) {
d["collider"] = ObjectDB::get_instance(col.collider);
} else {
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index 5c1c953a37..7e2d6d1b5a 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -176,9 +176,10 @@ void Polygon2D::_notification(int p_what) {
}
}
- Vector<int> indices = Geometry::triangulate_polygon(points);
+ // Vector<int> indices = Geometry::triangulate_polygon(points);
+ // VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, texture.is_valid() ? texture->get_rid() : RID());
- VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, texture.is_valid() ? texture->get_rid() : RID());
+ VS::get_singleton()->canvas_item_add_polygon(get_canvas_item(), points, colors, uvs, texture.is_valid() ? texture->get_rid() : RID(), RID(), antialiased);
} break;
}
@@ -294,6 +295,16 @@ bool Polygon2D::get_invert() const {
return invert;
}
+void Polygon2D::set_antialiased(bool p_antialiased) {
+
+ antialiased = p_antialiased;
+ update();
+}
+bool Polygon2D::get_antialiased() const {
+
+ return antialiased;
+}
+
void Polygon2D::set_invert_border(float p_invert_border) {
invert_border = p_invert_border;
@@ -348,6 +359,9 @@ void Polygon2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_invert", "invert"), &Polygon2D::set_invert);
ClassDB::bind_method(D_METHOD("get_invert"), &Polygon2D::get_invert);
+ ClassDB::bind_method(D_METHOD("set_antialiased", "antialiased"), &Polygon2D::set_antialiased);
+ ClassDB::bind_method(D_METHOD("get_antialiased"), &Polygon2D::get_antialiased);
+
ClassDB::bind_method(D_METHOD("set_invert_border", "invert_border"), &Polygon2D::set_invert_border);
ClassDB::bind_method(D_METHOD("get_invert_border"), &Polygon2D::get_invert_border);
@@ -359,6 +373,7 @@ void Polygon2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
ADD_PROPERTY(PropertyInfo(Variant::POOL_COLOR_ARRAY, "vertex_colors"), "set_vertex_colors", "get_vertex_colors");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "antialiased"), "set_antialiased", "get_antialiased");
ADD_GROUP("Texture", "");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture");
ADD_GROUP("Texture", "texture_");
@@ -375,6 +390,7 @@ Polygon2D::Polygon2D() {
invert = 0;
invert_border = 100;
+ antialiased = false;
tex_rot = 0;
tex_tile = true;
tex_scale = Vector2(1, 1);
diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h
index f2cc9452b9..eb47f4d8d1 100644
--- a/scene/2d/polygon_2d.h
+++ b/scene/2d/polygon_2d.h
@@ -47,6 +47,7 @@ class Polygon2D : public Node2D {
float tex_rot;
bool invert;
float invert_border;
+ bool antialiased;
Vector2 offset;
mutable bool rect_cache_dirty;
@@ -84,10 +85,13 @@ public:
void set_texture_scale(const Size2 &p_scale);
Size2 get_texture_scale() const;
- void set_invert(bool p_rot);
+ void set_invert(bool p_invert);
bool get_invert() const;
- void set_invert_border(float p_border);
+ void set_antialiased(bool p_antialiased);
+ bool get_antialiased() const;
+
+ void set_invert_border(float p_invert_border);
float get_invert_border() const;
void set_offset(const Vector2 &p_offset);
diff --git a/scene/2d/position_2d.cpp b/scene/2d/position_2d.cpp
index 74ad9c17e2..7688faa23b 100644
--- a/scene/2d/position_2d.cpp
+++ b/scene/2d/position_2d.cpp
@@ -28,6 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "position_2d.h"
+
+#include "engine.h"
#include "scene/resources/texture.h"
void Position2D::_draw_cross() {
@@ -52,7 +54,7 @@ void Position2D::_notification(int p_what) {
case NOTIFICATION_DRAW: {
if (!is_inside_tree())
break;
- if (get_tree()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint())
_draw_cross();
} break;
diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp
index cfb4059714..fbec922a2d 100644
--- a/scene/2d/ray_cast_2d.cpp
+++ b/scene/2d/ray_cast_2d.cpp
@@ -28,14 +28,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "ray_cast_2d.h"
+
#include "collision_object_2d.h"
+#include "engine.h"
#include "physics_body_2d.h"
#include "servers/physics_2d_server.h"
void RayCast2D::set_cast_to(const Vector2 &p_point) {
cast_to = p_point;
- if (is_inside_tree() && (get_tree()->is_editor_hint() || get_tree()->is_debugging_collisions_hint()))
+ if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint()))
update();
}
@@ -92,7 +94,7 @@ Vector2 RayCast2D::get_collision_normal() const {
void RayCast2D::set_enabled(bool p_enabled) {
enabled = p_enabled;
- if (is_inside_tree() && !get_tree()->is_editor_hint())
+ if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint())
set_fixed_process(p_enabled);
if (!p_enabled)
collided = false;
@@ -132,7 +134,7 @@ void RayCast2D::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
- if (enabled && !get_tree()->is_editor_hint())
+ if (enabled && !Engine::get_singleton()->is_editor_hint())
set_fixed_process(true);
else
set_fixed_process(false);
@@ -153,7 +155,7 @@ void RayCast2D::_notification(int p_what) {
case NOTIFICATION_DRAW: {
- if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
break;
Transform2D xf;
xf.rotate(cast_to.angle());
diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp
index 37139b2b93..e8e5e9411f 100644
--- a/scene/2d/screen_button.cpp
+++ b/scene/2d/screen_button.cpp
@@ -112,7 +112,7 @@ void TouchScreenButton::_notification(int p_what) {
if (!is_inside_tree())
return;
- if (!get_tree()->is_editor_hint() && !OS::get_singleton()->has_touchscreen_ui_hint() && visibility == VISIBILITY_TOUCHSCREEN_ONLY)
+ if (!Engine::get_singleton()->is_editor_hint() && !OS::get_singleton()->has_touchscreen_ui_hint() && visibility == VISIBILITY_TOUCHSCREEN_ONLY)
return;
if (finger_pressed != -1) {
@@ -129,7 +129,7 @@ void TouchScreenButton::_notification(int p_what) {
if (!shape_visible)
return;
- if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
return;
if (shape.is_valid()) {
Color draw_col = get_tree()->get_debug_collisions_color();
@@ -141,11 +141,11 @@ void TouchScreenButton::_notification(int p_what) {
} break;
case NOTIFICATION_ENTER_TREE: {
- if (!get_tree()->is_editor_hint() && !OS::get_singleton()->has_touchscreen_ui_hint() && visibility == VISIBILITY_TOUCHSCREEN_ONLY)
+ if (!Engine::get_singleton()->is_editor_hint() && !OS::get_singleton()->has_touchscreen_ui_hint() && visibility == VISIBILITY_TOUCHSCREEN_ONLY)
return;
update();
- if (!get_tree()->is_editor_hint())
+ if (!Engine::get_singleton()->is_editor_hint())
set_process_input(is_visible_in_tree());
} break;
@@ -154,7 +154,7 @@ void TouchScreenButton::_notification(int p_what) {
_release(true);
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
- if (get_tree()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint())
break;
if (is_visible_in_tree()) {
set_process_input(true);
diff --git a/scene/2d/screen_button.h b/scene/2d/screen_button.h
index 8923da2ae4..2a5935aaf1 100644
--- a/scene/2d/screen_button.h
+++ b/scene/2d/screen_button.h
@@ -61,7 +61,7 @@ private:
VisibilityMode visibility;
- void _input(const Ref<InputEvent> &p_Event);
+ void _input(const Ref<InputEvent> &p_event);
bool _is_point_inside(const Point2 &p_point);
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index e4494742a1..5d246e331f 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -1068,20 +1068,20 @@ Transform2D TileMap::get_custom_transform() const {
return custom_transform;
}
-Vector2 TileMap::_map_to_world(int x, int y, bool p_ignore_ofs) const {
+Vector2 TileMap::_map_to_world(int p_x, int p_y, bool p_ignore_ofs) const {
- Vector2 ret = get_cell_transform().xform(Vector2(x, y));
+ Vector2 ret = get_cell_transform().xform(Vector2(p_x, p_y));
if (!p_ignore_ofs) {
switch (half_offset) {
case HALF_OFFSET_X: {
- if (ABS(y) & 1) {
+ if (ABS(p_y) & 1) {
ret += get_cell_transform()[0] * 0.5;
}
} break;
case HALF_OFFSET_Y: {
- if (ABS(x) & 1) {
+ if (ABS(p_x) & 1) {
ret += get_cell_transform()[1] * 0.5;
}
} break;
@@ -1315,15 +1315,18 @@ void TileMap::_bind_methods() {
ADD_SIGNAL(MethodInfo("settings_changed"));
BIND_CONSTANT(INVALID_CELL);
- BIND_CONSTANT(MODE_SQUARE);
- BIND_CONSTANT(MODE_ISOMETRIC);
- BIND_CONSTANT(MODE_CUSTOM);
- BIND_CONSTANT(HALF_OFFSET_X);
- BIND_CONSTANT(HALF_OFFSET_Y);
- BIND_CONSTANT(HALF_OFFSET_DISABLED);
- BIND_CONSTANT(TILE_ORIGIN_TOP_LEFT);
- BIND_CONSTANT(TILE_ORIGIN_CENTER);
- BIND_CONSTANT(TILE_ORIGIN_BOTTOM_LEFT);
+
+ BIND_ENUM_CONSTANT(MODE_SQUARE);
+ BIND_ENUM_CONSTANT(MODE_ISOMETRIC);
+ BIND_ENUM_CONSTANT(MODE_CUSTOM);
+
+ BIND_ENUM_CONSTANT(HALF_OFFSET_X);
+ BIND_ENUM_CONSTANT(HALF_OFFSET_Y);
+ BIND_ENUM_CONSTANT(HALF_OFFSET_DISABLED);
+
+ BIND_ENUM_CONSTANT(TILE_ORIGIN_TOP_LEFT);
+ BIND_ENUM_CONSTANT(TILE_ORIGIN_CENTER);
+ BIND_ENUM_CONSTANT(TILE_ORIGIN_BOTTOM_LEFT);
}
TileMap::TileMap() {
diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp
index fb71b61d45..2f2ad08f01 100644
--- a/scene/2d/visibility_notifier_2d.cpp
+++ b/scene/2d/visibility_notifier_2d.cpp
@@ -29,20 +29,20 @@
/*************************************************************************/
#include "visibility_notifier_2d.h"
+#include "engine.h"
#include "particles_2d.h"
#include "scene/2d/animated_sprite.h"
#include "scene/2d/physics_body_2d.h"
#include "scene/animation/animation_player.h"
#include "scene/main/viewport.h"
#include "scene/scene_string_names.h"
-#include "scene/scene_string_names.h"
void VisibilityNotifier2D::_enter_viewport(Viewport *p_viewport) {
ERR_FAIL_COND(viewports.has(p_viewport));
viewports.insert(p_viewport);
- if (is_inside_tree() && get_tree()->is_editor_hint())
+ if (is_inside_tree() && Engine::get_singleton()->is_editor_hint())
return;
if (viewports.size() == 1) {
@@ -58,7 +58,7 @@ void VisibilityNotifier2D::_exit_viewport(Viewport *p_viewport) {
ERR_FAIL_COND(!viewports.has(p_viewport));
viewports.erase(p_viewport);
- if (is_inside_tree() && get_tree()->is_editor_hint())
+ if (is_inside_tree() && Engine::get_singleton()->is_editor_hint())
return;
emit_signal(SceneStringNames::get_singleton()->viewport_exited, p_viewport);
@@ -74,7 +74,7 @@ void VisibilityNotifier2D::set_rect(const Rect2 &p_rect) {
rect = p_rect;
if (is_inside_tree()) {
get_world_2d()->_update_notifier(this, get_global_transform().xform(rect));
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
update();
item_rect_changed();
}
@@ -108,7 +108,7 @@ void VisibilityNotifier2D::_notification(int p_what) {
} break;
case NOTIFICATION_DRAW: {
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
draw_rect(rect, Color(1, 0.5, 1, 0.2));
}
@@ -236,7 +236,7 @@ void VisibilityEnabler2D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- if (get_tree()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint())
return;
Node *from = this;
@@ -254,7 +254,7 @@ void VisibilityEnabler2D::_notification(int p_what) {
if (p_what == NOTIFICATION_EXIT_TREE) {
- if (get_tree()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint())
return;
for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
@@ -341,13 +341,13 @@ void VisibilityEnabler2D::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "process_parent"), "set_enabler", "is_enabler_enabled", ENABLER_PARENT_PROCESS);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "fixed_process_parent"), "set_enabler", "is_enabler_enabled", ENABLER_PARENT_FIXED_PROCESS);
- BIND_CONSTANT(ENABLER_FREEZE_BODIES);
- BIND_CONSTANT(ENABLER_PAUSE_ANIMATIONS);
- BIND_CONSTANT(ENABLER_PAUSE_PARTICLES);
- BIND_CONSTANT(ENABLER_PAUSE_ANIMATED_SPRITES);
- BIND_CONSTANT(ENABLER_PARENT_PROCESS);
- BIND_CONSTANT(ENABLER_PARENT_FIXED_PROCESS);
- BIND_CONSTANT(ENABLER_MAX);
+ BIND_ENUM_CONSTANT(ENABLER_FREEZE_BODIES);
+ BIND_ENUM_CONSTANT(ENABLER_PAUSE_ANIMATIONS);
+ BIND_ENUM_CONSTANT(ENABLER_PAUSE_PARTICLES);
+ BIND_ENUM_CONSTANT(ENABLER_PAUSE_ANIMATED_SPRITES);
+ BIND_ENUM_CONSTANT(ENABLER_PARENT_PROCESS);
+ BIND_ENUM_CONSTANT(ENABLER_PARENT_FIXED_PROCESS);
+ BIND_ENUM_CONSTANT(ENABLER_MAX);
}
void VisibilityEnabler2D::set_enabler(Enabler p_enabler, bool p_enable) {