diff options
Diffstat (limited to 'scene/2d')
65 files changed, 221 insertions, 290 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index 366c3a8bd8..26241df660 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h index 80defac079..6c660d0381 100644 --- a/scene/2d/animated_sprite.h +++ b/scene/2d/animated_sprite.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index 02a0509449..1124904963 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -116,7 +116,7 @@ real_t Area2D::get_priority() const { void Area2D::_body_enter_tree(ObjectID p_id) { Object *obj = ObjectDB::get_instance(p_id); - Node *node = obj ? obj->cast_to<Node>() : NULL; + Node *node = Object::cast_to<Node>(obj); ERR_FAIL_COND(!node); Map<ObjectID, BodyState>::Element *E = body_map.find(p_id); @@ -134,7 +134,7 @@ void Area2D::_body_enter_tree(ObjectID p_id) { void Area2D::_body_exit_tree(ObjectID p_id) { Object *obj = ObjectDB::get_instance(p_id); - Node *node = obj ? obj->cast_to<Node>() : NULL; + Node *node = Object::cast_to<Node>(obj); ERR_FAIL_COND(!node); Map<ObjectID, BodyState>::Element *E = body_map.find(p_id); ERR_FAIL_COND(!E); @@ -153,7 +153,7 @@ void Area2D::_body_inout(int p_status, const RID &p_body, int p_instance, int p_ ObjectID objid = p_instance; Object *obj = ObjectDB::get_instance(objid); - Node *node = obj ? obj->cast_to<Node>() : NULL; + Node *node = Object::cast_to<Node>(obj); Map<ObjectID, BodyState>::Element *E = body_map.find(objid); @@ -217,7 +217,7 @@ void Area2D::_body_inout(int p_status, const RID &p_body, int p_instance, int p_ void Area2D::_area_enter_tree(ObjectID p_id) { Object *obj = ObjectDB::get_instance(p_id); - Node *node = obj ? obj->cast_to<Node>() : NULL; + Node *node = Object::cast_to<Node>(obj); ERR_FAIL_COND(!node); Map<ObjectID, AreaState>::Element *E = area_map.find(p_id); @@ -235,7 +235,7 @@ void Area2D::_area_enter_tree(ObjectID p_id) { void Area2D::_area_exit_tree(ObjectID p_id) { Object *obj = ObjectDB::get_instance(p_id); - Node *node = obj ? obj->cast_to<Node>() : NULL; + Node *node = Object::cast_to<Node>(obj); ERR_FAIL_COND(!node); Map<ObjectID, AreaState>::Element *E = area_map.find(p_id); ERR_FAIL_COND(!E); @@ -254,7 +254,7 @@ void Area2D::_area_inout(int p_status, const RID &p_area, int p_instance, int p_ ObjectID objid = p_instance; Object *obj = ObjectDB::get_instance(objid); - Node *node = obj ? obj->cast_to<Node>() : NULL; + Node *node = Object::cast_to<Node>(obj); Map<ObjectID, AreaState>::Element *E = area_map.find(objid); @@ -330,7 +330,7 @@ void Area2D::_clear_monitoring() { for (Map<ObjectID, BodyState>::Element *E = bmcopy.front(); E; E = E->next()) { Object *obj = ObjectDB::get_instance(E->key()); - Node *node = obj ? obj->cast_to<Node>() : NULL; + Node *node = Object::cast_to<Node>(obj); if (!node) //node may have been deleted in previous frame or at other legiminate point continue; @@ -360,7 +360,7 @@ void Area2D::_clear_monitoring() { for (Map<ObjectID, AreaState>::Element *E = bmcopy.front(); E; E = E->next()) { Object *obj = ObjectDB::get_instance(E->key()); - Node *node = obj ? obj->cast_to<Node>() : NULL; + Node *node = Object::cast_to<Node>(obj); if (!node) //node may have been deleted in previous frame or at other legiminate point continue; diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h index 12d71f3911..c56cf651a1 100644 --- a/scene/2d/area_2d.h +++ b/scene/2d/area_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index 73782e1515..ea2e77fc47 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -157,10 +157,8 @@ void AudioStreamPlayer2D::_notification(int p_what) { int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask, Physics2DDirectSpaceState::TYPE_MASK_AREA); for (int i = 0; i < areas; i++) { - if (!sr[i].collider) - continue; - Area2D *area2d = sr[i].collider->cast_to<Area2D>(); + Area2D *area2d = Object::cast_to<Area2D>(sr[i].collider); if (!area2d) continue; @@ -219,13 +217,16 @@ void AudioStreamPlayer2D::_notification(int p_what) { setseek = setplay; active = true; setplay = -1; - _change_notify("playing"); //update property in editor + //do not update, this makes it easier to animate (will shut off otherise) + //_change_notify("playing"); //update property in editor } //stop playing if no longer active if (!active) { set_fixed_process_internal(false); - _change_notify("playing"); //update property in editor + //do not update, this makes it easier to animate (will shut off otherise) + //_change_notify("playing"); //update property in editor + emit_signal("finished"); } } } @@ -247,12 +248,14 @@ void AudioStreamPlayer2D::set_stream(Ref<AudioStream> p_stream) { stream = p_stream; stream_playback = p_stream->instance_playback(); + AudioServer::get_singleton()->unlock(); + if (stream_playback.is_null()) { stream.unref(); ERR_FAIL_COND(stream_playback.is_null()); } - AudioServer::get_singleton()->unlock(); + } Ref<AudioStream> AudioStreamPlayer2D::get_stream() const { @@ -438,12 +441,15 @@ void AudioStreamPlayer2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), "set_stream", "get_stream"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE, "-80,24"), "set_volume_db", "get_volume_db"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "play", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_distance", PROPERTY_HINT_RANGE, "1,65536,1"), "set_max_distance", "get_max_distance"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "attenuation", PROPERTY_HINT_EXP_EASING), "set_attenuation", "get_attenuation"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus"); ADD_PROPERTY(PropertyInfo(Variant::INT, "area_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_area_mask", "get_area_mask"); + + ADD_SIGNAL(MethodInfo("finished")); + } AudioStreamPlayer2D::AudioStreamPlayer2D() { diff --git a/scene/2d/back_buffer_copy.cpp b/scene/2d/back_buffer_copy.cpp index 44bee20d0a..2858ddaad5 100644 --- a/scene/2d/back_buffer_copy.cpp +++ b/scene/2d/back_buffer_copy.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/back_buffer_copy.h b/scene/2d/back_buffer_copy.h index 4080f50696..2424dd7b19 100644 --- a/scene/2d/back_buffer_copy.h +++ b/scene/2d/back_buffer_copy.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index f309631715..e39e6fc6da 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -577,7 +577,7 @@ void Camera2D::set_custom_viewport(Node *p_viewport) { remove_from_group(canvas_group_name); } - custom_viewport = p_viewport->cast_to<Viewport>(); + custom_viewport = Object::cast_to<Viewport>(p_viewport); if (custom_viewport) { custom_viewport_id = custom_viewport->get_instance_id(); diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h index 8d9e76be85..dfcadf65a6 100644 --- a/scene/2d/camera_2d.h +++ b/scene/2d/camera_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 5a519dee69..a7c5d1adbb 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -37,6 +37,7 @@ #include "scene/resources/style_box.h" #include "scene/resources/texture.h" #include "scene/scene_string_names.h" +#include "servers/visual/visual_server_raster.h" #include "servers/visual_server.h" Mutex *CanvasItemMaterial::material_mutex = NULL; @@ -260,7 +261,7 @@ void CanvasItem::_propagate_visibility_changed(bool p_visible) { for (int i = 0; i < get_child_count(); i++) { - CanvasItem *c = get_child(i)->cast_to<CanvasItem>(); + CanvasItem *c = Object::cast_to<CanvasItem>(get_child(i)); if (c && c->visible) //should the toplevels stop propagation? i think so but.. c->_propagate_visibility_changed(p_visible); @@ -398,7 +399,7 @@ void CanvasItem::_toplevel_raise_self() { void CanvasItem::_enter_canvas() { - if ((!get_parent() || !get_parent()->cast_to<CanvasItem>()) || toplevel) { + if ((!Object::cast_to<CanvasItem>(get_parent())) || toplevel) { Node *n = this; @@ -406,7 +407,7 @@ void CanvasItem::_enter_canvas() { while (n) { - canvas_layer = n->cast_to<CanvasLayer>(); + canvas_layer = Object::cast_to<CanvasLayer>(n); if (canvas_layer) { break; } @@ -460,7 +461,7 @@ void CanvasItem::_notification(int p_what) { first_draw = true; if (get_parent()) { - CanvasItem *ci = get_parent()->cast_to<CanvasItem>(); + CanvasItem *ci = Object::cast_to<CanvasItem>(get_parent()); if (ci) C = ci->children_items.push_back(this); } @@ -488,7 +489,7 @@ void CanvasItem::_notification(int p_what) { get_tree()->xform_change_list.remove(&xform_change); _exit_canvas(); if (C) { - get_parent()->cast_to<CanvasItem>()->children_items.erase(C); + Object::cast_to<CanvasItem>(get_parent())->children_items.erase(C); C = NULL; } global_invalid = true; @@ -565,11 +566,7 @@ CanvasItem *CanvasItem::get_parent_item() const { if (toplevel) return NULL; - Node *parent = get_parent(); - if (!parent) - return NULL; - - return parent->cast_to<CanvasItem>(); + return Object::cast_to<CanvasItem>(get_parent()); } void CanvasItem::set_self_modulate(const Color &p_self_modulate) { @@ -830,8 +827,8 @@ RID CanvasItem::get_canvas() const { CanvasItem *CanvasItem::get_toplevel() const { CanvasItem *ci = const_cast<CanvasItem *>(this); - while (!ci->toplevel && ci->get_parent() && ci->get_parent()->cast_to<CanvasItem>()) { - ci = ci->get_parent()->cast_to<CanvasItem>(); + while (!ci->toplevel && Object::cast_to<CanvasItem>(ci->get_parent())) { + ci = Object::cast_to<CanvasItem>(ci->get_parent()); } return ci; @@ -1062,8 +1059,8 @@ Transform2D 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 if (Object::cast_to<CanvasItem>(get_parent())) + return Object::cast_to<CanvasItem>(get_parent())->get_canvas_transform(); else return get_viewport()->get_canvas_transform(); } @@ -1122,7 +1119,7 @@ Rect2 CanvasItem::get_item_and_children_rect() const { Rect2 rect = get_item_rect(); for (int i = 0; i < get_child_count(); i++) { - CanvasItem *c = get_child(i)->cast_to<CanvasItem>(); + CanvasItem *c = Object::cast_to<CanvasItem>(get_child(i)); if (c) { Rect2 sir = c->get_transform().xform(c->get_item_and_children_rect()); rect = rect.merge(sir); diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index c6180e07b6..5a0a9c6e6a 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -291,10 +291,10 @@ public: RID get_canvas() const; Ref<World2D> get_world_2d() const; - void set_material(const Ref<Material> &p_material); + virtual void set_material(const Ref<Material> &p_material); Ref<Material> get_material() const; - void set_use_parent_material(bool p_use_parent_material); + virtual void set_use_parent_material(bool p_use_parent_material); bool get_use_parent_material() const; Ref<InputEvent> make_input_local(const Ref<InputEvent> &p_event) const; diff --git a/scene/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp index a132c5e18c..05831609fc 100644 --- a/scene/2d/canvas_modulate.cpp +++ b/scene/2d/canvas_modulate.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/canvas_modulate.h b/scene/2d/canvas_modulate.h index 37d9d47ba5..4195c1386c 100644 --- a/scene/2d/canvas_modulate.h +++ b/scene/2d/canvas_modulate.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index d3bb5a8d4e..ce56b85a9e 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h index 36bf39ff4e..a828d8d8ea 100644 --- a/scene/2d/collision_object_2d.h +++ b/scene/2d/collision_object_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index 433661e393..e2764a6e8d 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -79,11 +79,6 @@ void CollisionPolygon2D::_build_polygon() { 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; @@ -116,8 +111,6 @@ Vector<Vector<Vector2> > CollisionPolygon2D::_decompose_in_convex() { idx++; } -#endif - return decomp; } @@ -126,7 +119,7 @@ void CollisionPolygon2D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_PARENTED: { - parent = get_parent()->cast_to<CollisionObject2D>(); + parent = Object::cast_to<CollisionObject2D>(get_parent()); if (parent) { owner_id = parent->create_shape_owner(this); _build_polygon(); @@ -257,7 +250,7 @@ Rect2 CollisionPolygon2D::get_item_rect() const { String CollisionPolygon2D::get_configuration_warning() const { - if (!get_parent()->cast_to<CollisionObject2D>()) { + if (!Object::cast_to<CollisionObject2D>(get_parent())) { return TTR("CollisionPolygon2D only serves to provide a collision shape to a CollisionObject2D derived node. Please only use it as a child of Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape."); } diff --git a/scene/2d/collision_polygon_2d.h b/scene/2d/collision_polygon_2d.h index f0666ba9de..c9ec860e36 100644 --- a/scene/2d/collision_polygon_2d.h +++ b/scene/2d/collision_polygon_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp index 3fda4ab464..0758f4a9bf 100644 --- a/scene/2d/collision_shape_2d.cpp +++ b/scene/2d/collision_shape_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -50,7 +50,7 @@ void CollisionShape2D::_notification(int p_what) { case NOTIFICATION_PARENTED: { - parent = get_parent()->cast_to<CollisionObject2D>(); + parent = Object::cast_to<CollisionObject2D>(get_parent()); if (parent) { owner_id = parent->create_shape_owner(this); if (shape.is_valid()) { @@ -165,7 +165,7 @@ Rect2 CollisionShape2D::get_item_rect() const { String CollisionShape2D::get_configuration_warning() const { - if (!get_parent()->cast_to<CollisionObject2D>()) { + if (!Object::cast_to<CollisionObject2D>(get_parent())) { return TTR("CollisionShape2D only serves to provide a collision shape to a CollisionObject2D derived node. Please only use it as a child of Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape."); } diff --git a/scene/2d/collision_shape_2d.h b/scene/2d/collision_shape_2d.h index 1f2b96b91f..04203a75b4 100644 --- a/scene/2d/collision_shape_2d.h +++ b/scene/2d/collision_shape_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp index ee41dca3a6..69bad1623f 100644 --- a/scene/2d/joints_2d.cpp +++ b/scene/2d/joints_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -172,8 +172,8 @@ RID PinJoint2D::_configure_joint() { if (!node_a && !node_b) return RID(); - PhysicsBody2D *body_a = node_a ? node_a->cast_to<PhysicsBody2D>() : (PhysicsBody2D *)NULL; - PhysicsBody2D *body_b = node_b ? node_b->cast_to<PhysicsBody2D>() : (PhysicsBody2D *)NULL; + PhysicsBody2D *body_a = Object::cast_to<PhysicsBody2D>(node_a); + PhysicsBody2D *body_b = Object::cast_to<PhysicsBody2D>(node_b); if (!body_a && !body_b) return RID(); @@ -249,8 +249,8 @@ RID GrooveJoint2D::_configure_joint() { if (!node_a || !node_b) return RID(); - PhysicsBody2D *body_a = node_a->cast_to<PhysicsBody2D>(); - PhysicsBody2D *body_b = node_b->cast_to<PhysicsBody2D>(); + PhysicsBody2D *body_a = Object::cast_to<PhysicsBody2D>(node_a); + PhysicsBody2D *body_b = Object::cast_to<PhysicsBody2D>(node_b); if (!body_a || !body_b) return RID(); @@ -338,8 +338,8 @@ RID DampedSpringJoint2D::_configure_joint() { if (!node_a || !node_b) return RID(); - PhysicsBody2D *body_a = node_a->cast_to<PhysicsBody2D>(); - PhysicsBody2D *body_b = node_b->cast_to<PhysicsBody2D>(); + PhysicsBody2D *body_a = Object::cast_to<PhysicsBody2D>(node_a); + PhysicsBody2D *body_b = Object::cast_to<PhysicsBody2D>(node_b); if (!body_a || !body_b) return RID(); diff --git a/scene/2d/joints_2d.h b/scene/2d/joints_2d.h index f854ce51ee..685299abc6 100644 --- a/scene/2d/joints_2d.h +++ b/scene/2d/joints_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp index 219574cbfd..1bca2c6f37 100644 --- a/scene/2d/light_2d.cpp +++ b/scene/2d/light_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -434,8 +434,8 @@ void Light2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shadow_enabled"), "set_shadow_enabled", "is_shadow_enabled"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "shadow_color"), "set_shadow_color", "get_shadow_color"); ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow_buffer_size", PROPERTY_HINT_RANGE, "32,16384,1"), "set_shadow_buffer_size", "get_shadow_buffer_size"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "shadow_gradient_length", PROPERTY_HINT_RANGE, "1,4096,0.1"), "set_shadow_gradient_length", "get_shadow_gradient_length"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "shadow_filter", PROPERTY_HINT_ENUM, "None,PCF3,PCF5,PCF9,PCF13"), "set_shadow_filter", "get_shadow_filter"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "shadow_gradient_length", PROPERTY_HINT_RANGE, "0,4096,0.1"), "set_shadow_gradient_length", "get_shadow_gradient_length"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "shadow_filter", PROPERTY_HINT_ENUM, "None,PCF3,PCF5,PCF7,PCF9,PCF13"), "set_shadow_filter", "get_shadow_filter"); 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"); diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h index 90e55aeda4..f6bc943adb 100644 --- a/scene/2d/light_2d.h +++ b/scene/2d/light_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -48,6 +48,7 @@ public: SHADOW_FILTER_NONE, SHADOW_FILTER_PCF3, SHADOW_FILTER_PCF5, + SHADOW_FILTER_PCF7, SHADOW_FILTER_PCF9, SHADOW_FILTER_PCF13, }; diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp index 680adeea69..92e0d8a2f6 100644 --- a/scene/2d/light_occluder_2d.cpp +++ b/scene/2d/light_occluder_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/light_occluder_2d.h b/scene/2d/light_occluder_2d.h index 30c30b1a47..cca7bfecd6 100644 --- a/scene/2d/light_occluder_2d.h +++ b/scene/2d/light_occluder_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp index 6e7bfe63c8..c87a9a5b1e 100644 --- a/scene/2d/line_2d.cpp +++ b/scene/2d/line_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/line_2d.h b/scene/2d/line_2d.h index e8ca5e6e7c..017ccf13ff 100644 --- a/scene/2d/line_2d.h +++ b/scene/2d/line_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/line_builder.cpp b/scene/2d/line_builder.cpp index 3c1410edbb..1235013af4 100644 --- a/scene/2d/line_builder.cpp +++ b/scene/2d/line_builder.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -139,7 +139,7 @@ void LineBuilder::build() { float current_distance0 = 0.f; float current_distance1 = 0.f; - float total_distance; + float total_distance = 0.f; _interpolate_color = gradient != NULL; bool distance_required = _interpolate_color || texture_mode == LINE_TEXTURE_TILE; if (distance_required) diff --git a/scene/2d/line_builder.h b/scene/2d/line_builder.h index 0e1a2aaf50..227e0abd08 100644 --- a/scene/2d/line_builder.h +++ b/scene/2d/line_builder.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp index 383236b4ca..74d835dfb2 100644 --- a/scene/2d/navigation2d.cpp +++ b/scene/2d/navigation2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -236,42 +236,6 @@ void Navigation2D::navpoly_remove(int p_id) { _navpoly_unlink(p_id); navpoly_map.erase(p_id); } -#if 0 -void Navigation2D::_clip_path(Vector<Vector2>& path, Polygon *from_poly, const Vector2& p_to_point, Polygon* p_to_poly) { - - Vector2 from = path[path.size()-1]; - - if (from.distance_to(p_to_point)<CMP_EPSILON) - return; - Plane cut_plane; - cut_plane.normal = (from-p_to_point).cross(up); - if (cut_plane.normal==Vector2()) - return; - cut_plane.normal.normalize(); - cut_plane.d = cut_plane.normal.dot(from); - - - while(from_poly!=p_to_poly) { - - int pe = from_poly->prev_edge; - Vector2 a = _get_vertex(from_poly->edges[pe].point); - Vector2 b = _get_vertex(from_poly->edges[(pe+1)%from_poly->edges.size()].point); - - from_poly=from_poly->edges[pe].C; - ERR_FAIL_COND(!from_poly); - - if (a.distance_to(b)>CMP_EPSILON) { - - Vector2 inters; - if (cut_plane.intersects_segment(a,b,&inters)) { - if (inters.distance_to(p_to_point)>CMP_EPSILON && inters.distance_to(path[path.size()-1])>CMP_EPSILON) { - path.push_back(inters); - } - } - } - } -} -#endif Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vector2 &p_end, bool p_optimize) { @@ -498,29 +462,7 @@ 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; @@ -534,7 +476,6 @@ debug path Polygon *left_poly = end_poly; Polygon *right_poly = end_poly; Polygon *p = end_poly; - path.push_back(end_point); while (p) { @@ -592,7 +533,7 @@ debug path left_poly = p; portal_left = apex_point; portal_right = apex_point; - if (path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON) + if (!path.size() || path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON) path.push_back(apex_point); skip = true; //print_line("addpoint left"); @@ -613,7 +554,7 @@ debug path right_poly = p; portal_right = apex_point; portal_left = apex_point; - if (path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON) + if (!path.size() || path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON) path.push_back(apex_point); //print_line("addpoint right"); //print_line("***CLIP RIGHT"); @@ -626,16 +567,10 @@ debug path p = NULL; } - if (path[path.size() - 1].distance_to(begin_point) > CMP_EPSILON) - path.push_back(begin_point); - - path.invert(); - } else { //midpoints Polygon *p = end_poly; - path.push_back(end_point); while (true) { int prev = p->prev_edge; int prev_n = (p->prev_edge + 1) % p->edges.size(); @@ -645,11 +580,20 @@ debug path if (p == begin_poly) break; } + } + + if (!path.size() || path[path.size() - 1].distance_squared_to(begin_point) > CMP_EPSILON) { + path.push_back(begin_point); // Add the begin point + } else { + path[path.size() - 1] = begin_point; // Replace first midpoint by the exact begin point + } - if (path[path.size() - 1].distance_to(begin_point) > CMP_EPSILON) - path.push_back(begin_point); + path.invert(); - path.invert(); + if (path.size() <= 1 || path[path.size() - 1].distance_squared_to(end_point) > CMP_EPSILON) { + path.push_back(end_point); // Add the end point + } else { + path[path.size() - 1] = end_point; // Replace last midpoint by the exact end point } return path; diff --git a/scene/2d/navigation2d.h b/scene/2d/navigation2d.h index 54e89de9e2..e87b01f7c5 100644 --- a/scene/2d/navigation2d.h +++ b/scene/2d/navigation2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -153,9 +153,7 @@ class Navigation2D : public Node2D { float cell_size; Map<int, NavMesh> navpoly_map; int last_id; -#if 0 - void _clip_path(Vector<Vector2>& path,Polygon *from_poly, const Vector2& p_to_point, Polygon* p_to_poly); -#endif + protected: static void _bind_methods(); diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp index 7515d486c2..352ec3b300 100644 --- a/scene/2d/navigation_polygon.cpp +++ b/scene/2d/navigation_polygon.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -319,7 +319,7 @@ void NavigationPolygonInstance::_notification(int p_what) { Node2D *c = this; while (c) { - navigation = c->cast_to<Navigation2D>(); + navigation = Object::cast_to<Navigation2D>(c); if (navigation) { if (enabled && navpoly.is_valid()) { @@ -329,7 +329,7 @@ void NavigationPolygonInstance::_notification(int p_what) { break; } - c = c->get_parent()->cast_to<Node2D>(); + c = Object::cast_to<Node2D>(get_parent()); } } break; @@ -448,11 +448,11 @@ String NavigationPolygonInstance::get_configuration_warning() const { const Node2D *c = this; while (c) { - if (c->cast_to<Navigation2D>()) { + if (Object::cast_to<Navigation2D>(c)) { return String(); } - c = c->get_parent()->cast_to<Node2D>(); + c = Object::cast_to<Node2D>(get_parent()); } return TTR("NavigationPolygonInstance must be a child or grandchild to a Navigation2D node. It only provides navigation data."); diff --git a/scene/2d/navigation_polygon.h b/scene/2d/navigation_polygon.h index f6e6ed210a..5576a3abd2 100644 --- a/scene/2d/navigation_polygon.h +++ b/scene/2d/navigation_polygon.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index 98d6a467b1..0c7685a858 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -379,7 +379,7 @@ Transform2D Node2D::get_relative_transform_to_parent(const Node *p_parent) const if (p_parent == this) return Transform2D(); - Node2D *parent_2d = get_parent()->cast_to<Node2D>(); + Node2D *parent_2d = Object::cast_to<Node2D>(get_parent()); ERR_FAIL_COND_V(!parent_2d, Transform2D()); if (p_parent == parent_2d) diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h index a6009851c7..19aafc81ff 100644 --- a/scene/2d/node_2d.h +++ b/scene/2d/node_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp index 433ab5ff8d..0ddcb7b51b 100644 --- a/scene/2d/parallax_background.cpp +++ b/scene/2d/parallax_background.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -101,7 +101,7 @@ void ParallaxBackground::_update_scroll() { for (int i = 0; i < get_child_count(); i++) { - ParallaxLayer *l = get_child(i)->cast_to<ParallaxLayer>(); + ParallaxLayer *l = Object::cast_to<ParallaxLayer>(get_child(i)); if (!l) continue; diff --git a/scene/2d/parallax_background.h b/scene/2d/parallax_background.h index fce1bbd928..0dad1daeab 100644 --- a/scene/2d/parallax_background.h +++ b/scene/2d/parallax_background.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp index debdc22b65..8fe651cb5f 100644 --- a/scene/2d/parallax_layer.cpp +++ b/scene/2d/parallax_layer.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -36,11 +36,8 @@ void ParallaxLayer::set_motion_scale(const Size2 &p_scale) { motion_scale = p_scale; - if (!get_parent()) - return; - - ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>(); - if (is_inside_tree() && pb) { + ParallaxBackground *pb = Object::cast_to<ParallaxBackground>(get_parent()); + if (pb && is_inside_tree()) { Vector2 ofs = pb->get_final_offset(); float scale = pb->get_scroll_scale(); set_base_offset_and_scale(ofs, scale); @@ -56,11 +53,8 @@ void ParallaxLayer::set_motion_offset(const Size2 &p_offset) { motion_offset = p_offset; - if (!get_parent()) - return; - - ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>(); - if (is_inside_tree() && pb) { + ParallaxBackground *pb = Object::cast_to<ParallaxBackground>(get_parent()); + if (pb && is_inside_tree()) { Vector2 ofs = pb->get_final_offset(); float scale = pb->get_scroll_scale(); set_base_offset_and_scale(ofs, scale); @@ -74,10 +68,7 @@ Size2 ParallaxLayer::get_motion_offset() const { void ParallaxLayer::_update_mirroring() { - if (!get_parent()) - return; - - ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>(); + ParallaxBackground *pb = Object::cast_to<ParallaxBackground>(get_parent()); if (pb) { RID c = pb->get_world_2d()->get_canvas(); @@ -139,7 +130,7 @@ void ParallaxLayer::set_base_offset_and_scale(const Point2 &p_offset, float p_sc String ParallaxLayer::get_configuration_warning() const { - if (!get_parent() || !get_parent()->cast_to<ParallaxBackground>()) { + if (!Object::cast_to<ParallaxBackground>(get_parent())) { return TTR("ParallaxLayer node only works when set as child of a ParallaxBackground node."); } diff --git a/scene/2d/parallax_layer.h b/scene/2d/parallax_layer.h index f2d0053342..95ca27c41a 100644 --- a/scene/2d/parallax_layer.h +++ b/scene/2d/parallax_layer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index b0c00c4a64..c146ac08c2 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h index a6ac0c37d3..6946f2a799 100644 --- a/scene/2d/particles_2d.h +++ b/scene/2d/particles_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index a79f60c96f..1d7bd8fc2a 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -137,13 +137,8 @@ void PathFollow2D::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { - Node *parent = get_parent(); - if (parent) { - - path = parent->cast_to<Path2D>(); - if (path) { - _update_transform(); - } + if ((path = Object::cast_to<Path2D>(get_parent()))) { + _update_transform(); } } break; @@ -231,7 +226,7 @@ String PathFollow2D::get_configuration_warning() const { if (!is_visible_in_tree() || !is_inside_tree()) return String(); - if (!get_parent() || !get_parent()->cast_to<Path2D>()) { + if (!Object::cast_to<Path2D>(get_parent())) { return TTR("PathFollow2D only works when set as a child of a Path2D node."); } diff --git a/scene/2d/path_2d.h b/scene/2d/path_2d.h index e80817cd3c..88a0abdea9 100644 --- a/scene/2d/path_2d.h +++ b/scene/2d/path_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/path_texture.cpp b/scene/2d/path_texture.cpp index e06c79dabd..13644f71cf 100644 --- a/scene/2d/path_texture.cpp +++ b/scene/2d/path_texture.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/path_texture.h b/scene/2d/path_texture.h index 163e914e4a..4639a6072b 100644 --- a/scene/2d/path_texture.h +++ b/scene/2d/path_texture.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index aaba9da299..b1eb2ba267 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -143,7 +143,7 @@ PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) void PhysicsBody2D::add_collision_exception_with(Node *p_node) { ERR_FAIL_NULL(p_node); - PhysicsBody2D *physics_body = p_node->cast_to<PhysicsBody2D>(); + PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(p_node); if (!physics_body) { ERR_EXPLAIN("Collision exception only works between two objects of PhysicsBody type"); } @@ -154,7 +154,7 @@ void PhysicsBody2D::add_collision_exception_with(Node *p_node) { void PhysicsBody2D::remove_collision_exception_with(Node *p_node) { ERR_FAIL_NULL(p_node); - PhysicsBody2D *physics_body = p_node->cast_to<PhysicsBody2D>(); + PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(p_node); if (!physics_body) { ERR_EXPLAIN("Collision exception only works between two objects of PhysicsBody type"); } @@ -182,29 +182,6 @@ real_t StaticBody2D::get_constant_angular_velocity() const { return constant_angular_velocity; } -#if 0 -void StaticBody2D::_update_xform() { - - if (!pre_xform || !pending) - return; - - setting=true; - - - Transform2D new_xform = get_global_transform(); //obtain the new one - - set_block_transform_notify(true); - Physics2DServer::get_singleton()->body_set_state(get_rid(),Physics2DServer::BODY_STATE_TRANSFORM,*pre_xform); //then simulate motion! - set_global_transform(*pre_xform); //but restore state to previous one in both visual and physics - set_block_transform_notify(false); - - Physics2DServer::get_singleton()->body_static_simulate_motion(get_rid(),new_xform); //then simulate motion! - - setting=false; - pending=false; - -} -#endif void StaticBody2D::set_friction(real_t p_friction) { @@ -262,7 +239,7 @@ StaticBody2D::~StaticBody2D() { void RigidBody2D::_body_enter_tree(ObjectID p_id) { Object *obj = ObjectDB::get_instance(p_id); - Node *node = obj ? obj->cast_to<Node>() : NULL; + Node *node = Object::cast_to<Node>(obj); ERR_FAIL_COND(!node); Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(p_id); @@ -285,7 +262,7 @@ void RigidBody2D::_body_enter_tree(ObjectID p_id) { void RigidBody2D::_body_exit_tree(ObjectID p_id) { Object *obj = ObjectDB::get_instance(p_id); - Node *node = obj ? obj->cast_to<Node>() : NULL; + Node *node = Object::cast_to<Node>(obj); ERR_FAIL_COND(!node); Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(p_id); ERR_FAIL_COND(!E); @@ -310,7 +287,7 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap ObjectID objid = p_instance; Object *obj = ObjectDB::get_instance(objid); - Node *node = obj ? obj->cast_to<Node>() : NULL; + Node *node = Object::cast_to<Node>(obj); Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(objid); @@ -393,7 +370,7 @@ void RigidBody2D::_direct_state_changed(Object *p_state) { //eh.. fuck #ifdef DEBUG_ENABLED - state = p_state->cast_to<Physics2DDirectBodyState>(); + state = Object::cast_to<Physics2DDirectBodyState>(p_state); #else state = (Physics2DDirectBodyState *)p_state; //trust it #endif @@ -906,7 +883,7 @@ void RigidBody2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_colliding_bodies"), &RigidBody2D::get_colliding_bodies); - BIND_VMETHOD(MethodInfo("_integrate_forces", PropertyInfo(Variant::OBJECT, "state:Physics2DDirectBodyState"))); + BIND_VMETHOD(MethodInfo("_integrate_forces", PropertyInfo(Variant::OBJECT, "state", PROPERTY_HINT_RESOURCE_TYPE, "Physics2DDirectBodyState"))); ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Rigid,Static,Character,Kinematic"), "set_mode", "get_mode"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "mass", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01"), "set_mass", "get_mass"); @@ -1171,12 +1148,10 @@ ObjectID KinematicBody2D::get_collision_collider_id(int p_collision) const { Object *KinematicBody2D::get_collision_collider_shape(int p_collision) const { ERR_FAIL_INDEX_V(p_collision, colliders.size(), NULL); Object *collider = get_collision_collider(p_collision); - if (collider) { - CollisionObject2D *obj2d = collider->cast_to<CollisionObject2D>(); - if (obj2d) { - uint32_t owner = shape_find_owner(colliders[p_collision].collider_shape); - return obj2d->shape_owner_get_owner(owner); - } + CollisionObject2D *obj2d = Object::cast_to<CollisionObject2D>(collider); + if (obj2d) { + uint32_t owner = shape_find_owner(colliders[p_collision].collider_shape); + return obj2d->shape_owner_get_owner(owner); } return NULL; diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index 54bd263b15..1a4b0c0f5c 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index cde5724069..197c74352e 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h index eb47f4d8d1..20c3324a50 100644 --- a/scene/2d/polygon_2d.h +++ b/scene/2d/polygon_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/position_2d.cpp b/scene/2d/position_2d.cpp index 7688faa23b..cde665d422 100644 --- a/scene/2d/position_2d.cpp +++ b/scene/2d/position_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/position_2d.h b/scene/2d/position_2d.h index 67ff2c610d..af54fb919a 100644 --- a/scene/2d/position_2d.h +++ b/scene/2d/position_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp index fbec922a2d..f90331c411 100644 --- a/scene/2d/ray_cast_2d.cpp +++ b/scene/2d/ray_cast_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -115,11 +115,11 @@ void RayCast2D::set_exclude_parent_body(bool p_exclude_parent_body) { if (!is_inside_tree()) return; - if (get_parent()->cast_to<PhysicsBody2D>()) { + if (Object::cast_to<PhysicsBody2D>(get_parent())) { if (exclude_parent_body) - exclude.insert(get_parent()->cast_to<PhysicsBody2D>()->get_rid()); + exclude.insert(Object::cast_to<PhysicsBody2D>(get_parent())->get_rid()); else - exclude.erase(get_parent()->cast_to<PhysicsBody2D>()->get_rid()); + exclude.erase(Object::cast_to<PhysicsBody2D>(get_parent())->get_rid()); } } @@ -139,11 +139,11 @@ void RayCast2D::_notification(int p_what) { else set_fixed_process(false); - if (get_parent()->cast_to<PhysicsBody2D>()) { + if (Object::cast_to<PhysicsBody2D>(get_parent())) { if (exclude_parent_body) - exclude.insert(get_parent()->cast_to<PhysicsBody2D>()->get_rid()); + exclude.insert(Object::cast_to<PhysicsBody2D>(get_parent())->get_rid()); else - exclude.erase(get_parent()->cast_to<PhysicsBody2D>()->get_rid()); + exclude.erase(Object::cast_to<PhysicsBody2D>(get_parent())->get_rid()); } } break; case NOTIFICATION_EXIT_TREE: { @@ -227,7 +227,7 @@ void RayCast2D::add_exception_rid(const RID &p_rid) { void RayCast2D::add_exception(const Object *p_object) { ERR_FAIL_NULL(p_object); - CollisionObject2D *co = ((Object *)p_object)->cast_to<CollisionObject2D>(); + const CollisionObject2D *co = Object::cast_to<CollisionObject2D>(p_object); if (!co) return; add_exception_rid(co->get_rid()); @@ -241,7 +241,7 @@ void RayCast2D::remove_exception_rid(const RID &p_rid) { void RayCast2D::remove_exception(const Object *p_object) { ERR_FAIL_NULL(p_object); - CollisionObject2D *co = ((Object *)p_object)->cast_to<CollisionObject2D>(); + const CollisionObject2D *co = Object::cast_to<CollisionObject2D>(p_object); if (!co) return; remove_exception_rid(co->get_rid()); diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h index 244f4302ad..338de814d2 100644 --- a/scene/2d/ray_cast_2d.h +++ b/scene/2d/ray_cast_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp index cbd7ac06f5..c139573853 100644 --- a/scene/2d/remote_transform_2d.cpp +++ b/scene/2d/remote_transform_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -51,11 +51,7 @@ void RemoteTransform2D::_update_remote() { if (!cache) return; - Object *obj = ObjectDB::get_instance(cache); - if (!obj) - return; - - Node2D *n = obj->cast_to<Node2D>(); + Node2D *n = Object::cast_to<Node2D>(ObjectDB::get_instance(cache)); if (!n) return; @@ -182,7 +178,7 @@ bool RemoteTransform2D::get_update_scale() const { String RemoteTransform2D::get_configuration_warning() const { - if (!has_node(remote_node) || !get_node(remote_node) || !get_node(remote_node)->cast_to<Node2D>()) { + if (!has_node(remote_node) || !Object::cast_to<Node2D>(get_node(remote_node))) { return TTR("Path property must point to a valid Node2D node to work."); } diff --git a/scene/2d/remote_transform_2d.h b/scene/2d/remote_transform_2d.h index d58ec14a95..30d5fd1e7c 100644 --- a/scene/2d/remote_transform_2d.h +++ b/scene/2d/remote_transform_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp index e8e5e9411f..c9bf6675d2 100644 --- a/scene/2d/screen_button.cpp +++ b/scene/2d/screen_button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -196,11 +196,11 @@ void TouchScreenButton::_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(!is_visible_in_tree()); - const InputEventScreenTouch *st = p_event->cast_to<InputEventScreenTouch>(); + const InputEventScreenTouch *st = Object::cast_to<InputEventScreenTouch>(*p_event); if (passby_press) { - const InputEventScreenDrag *sd = p_event->cast_to<InputEventScreenDrag>(); + const InputEventScreenDrag *sd = Object::cast_to<InputEventScreenDrag>(*p_event); if (st && !st->is_pressed() && finger_pressed == st->get_index()) { diff --git a/scene/2d/screen_button.h b/scene/2d/screen_button.h index 2a5935aaf1..7647070b26 100644 --- a/scene/2d/screen_button.h +++ b/scene/2d/screen_button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp index 2ec529a166..c53faab5f9 100644 --- a/scene/2d/sprite.cpp +++ b/scene/2d/sprite.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -399,7 +399,7 @@ void ViewportSprite::_notification(int p_what) { Node *n = get_node(viewport_path); ERR_FAIL_COND(!n); - Viewport *vp=n->cast_to<Viewport>(); + Viewport *vp=Object::cast_to<Viewport>(n); ERR_FAIL_COND(!vp); Ref<RenderTargetTexture> rtt = vp->get_render_target_texture(); @@ -467,7 +467,7 @@ void ViewportSprite::set_viewport_path(const NodePath& p_viewport) { Node *n = get_node(viewport_path); ERR_FAIL_COND(!n); - Viewport *vp=n->cast_to<Viewport>(); + Viewport *vp=Object::cast_to<Viewport>(n); ERR_FAIL_COND(!vp); Ref<RenderTargetTexture> rtt = vp->get_render_target_texture(); @@ -544,13 +544,13 @@ Rect2 ViewportSprite::get_item_rect() const { String ViewportSprite::get_configuration_warning() const { - if (!has_node(viewport_path) || !get_node(viewport_path) || !get_node(viewport_path)->cast_to<Viewport>()) { + if (!has_node(viewport_path) || !Object::cast_to<Viewport>(get_node(viewport_path))) { return TTR("Path property must point to a valid Viewport node to work. Such Viewport must be set to 'render target' mode."); } else { Node *n = get_node(viewport_path); if (n) { - Viewport *vp = n->cast_to<Viewport>(); + Viewport *vp = Object::cast_to<Viewport>(n); if (!vp->is_set_as_render_target()) { return TTR("The Viewport set in the path property must be set as 'render target' in order for this sprite to work."); diff --git a/scene/2d/sprite.h b/scene/2d/sprite.h index d3f9a5f032..64d30325f2 100644 --- a/scene/2d/sprite.h +++ b/scene/2d/sprite.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 5d246e331f..b1cc8c226a 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -50,12 +50,12 @@ void TileMap::_notification(int p_what) { Node2D *c = this; while (c) { - navigation = c->cast_to<Navigation2D>(); + navigation = Object::cast_to<Navigation2D>(c); if (navigation) { break; } - c = c->get_parent()->cast_to<Node2D>(); + c = Object::cast_to<Node2D>(c->get_parent()); } pending_update = true; @@ -336,6 +336,7 @@ void TileMap::_update_dirty_quadrants() { if (mat.is_valid()) vs->canvas_item_set_material(canvas_item, mat->get_rid()); vs->canvas_item_set_parent(canvas_item, get_canvas_item()); + _update_item_material_state(canvas_item); Transform2D xform; xform.set_origin(q.pos); vs->canvas_item_set_transform(canvas_item, xform); @@ -370,15 +371,13 @@ void TileMap::_update_dirty_quadrants() { s = tex->get_size(); else { s = r.size; - r.position.x += fp_adjust; - r.position.y += fp_adjust; - r.size.x -= fp_adjust * 2.0; - r.size.y -= fp_adjust * 2.0; } Rect2 rect; rect.position = offset.floor(); rect.size = s; + rect.size.x += fp_adjust; + rect.size.y += fp_adjust; if (rect.size.y > rect.size.x) { if ((c.flip_h && (c.flip_v || c.transpose)) || (c.flip_v && !c.transpose)) @@ -782,6 +781,35 @@ void TileMap::_clear_quadrants() { } } +void TileMap::set_material(const Ref<Material> &p_material) { + + CanvasItem::set_material(p_material); + _update_all_items_material_state(); +} + +void TileMap::set_use_parent_material(bool p_use_parent_material) { + + CanvasItem::set_use_parent_material(p_use_parent_material); + _update_all_items_material_state(); +} + +void TileMap::_update_all_items_material_state() { + + for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { + + Quadrant &q = E->get(); + for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) { + + _update_item_material_state(E->get()); + } + } +} + +void TileMap::_update_item_material_state(const RID &p_canvas_item) { + + VS::get_singleton()->canvas_item_set_use_parent_material(p_canvas_item, get_use_parent_material() || get_material().is_valid()); +} + void TileMap::clear() { _clear_quadrants(); diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index 082e9d1018..c9d14e09d1 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -183,6 +183,9 @@ private: void _update_quadrant_transform(); void _recompute_rect_cache(); + void _update_all_items_material_state(); + _FORCE_INLINE_ void _update_item_material_state(const RID &p_canvas_item); + _FORCE_INLINE_ int _get_quadrant_size() const; void _set_tile_data(const PoolVector<int> &p_data); @@ -278,6 +281,10 @@ public: virtual void set_light_mask(int p_light_mask); + virtual void set_material(const Ref<Material> &p_material); + + virtual void set_use_parent_material(bool p_use_parent_material); + void clear(); TileMap(); diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp index 2f2ad08f01..8fc8b65217 100644 --- a/scene/2d/visibility_notifier_2d.cpp +++ b/scene/2d/visibility_notifier_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -184,7 +184,7 @@ void VisibilityEnabler2D::_find_nodes(Node *p_node) { if (enabler[ENABLER_FREEZE_BODIES]) { - RigidBody2D *rb2d = p_node->cast_to<RigidBody2D>(); + RigidBody2D *rb2d = Object::cast_to<RigidBody2D>(p_node); if (rb2d && ((rb2d->get_mode() == RigidBody2D::MODE_CHARACTER || (rb2d->get_mode() == RigidBody2D::MODE_RIGID && !rb2d->is_able_to_sleep())))) { add = true; @@ -194,7 +194,7 @@ void VisibilityEnabler2D::_find_nodes(Node *p_node) { if (enabler[ENABLER_PAUSE_ANIMATIONS]) { - AnimationPlayer *ap = p_node->cast_to<AnimationPlayer>(); + AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node); if (ap) { add = true; } @@ -202,7 +202,7 @@ void VisibilityEnabler2D::_find_nodes(Node *p_node) { if (enabler[ENABLER_PAUSE_ANIMATED_SPRITES]) { - AnimatedSprite *as = p_node->cast_to<AnimatedSprite>(); + AnimatedSprite *as = Object::cast_to<AnimatedSprite>(p_node); if (as) { add = true; } @@ -210,7 +210,7 @@ void VisibilityEnabler2D::_find_nodes(Node *p_node) { if (enabler[ENABLER_PAUSE_PARTICLES]) { - Particles2D *ps = p_node->cast_to<Particles2D>(); + Particles2D *ps = Object::cast_to<Particles2D>(p_node); if (ps) { add = true; } @@ -273,7 +273,7 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) { ERR_FAIL_COND(!nodes.has(p_node)); { - RigidBody2D *rb = p_node->cast_to<RigidBody2D>(); + RigidBody2D *rb = Object::cast_to<RigidBody2D>(p_node); if (rb) { rb->set_sleeping(!p_enabled); @@ -281,7 +281,7 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) { } { - AnimationPlayer *ap = p_node->cast_to<AnimationPlayer>(); + AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node); if (ap) { @@ -289,7 +289,7 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) { } } { - AnimatedSprite *as = p_node->cast_to<AnimatedSprite>(); + AnimatedSprite *as = Object::cast_to<AnimatedSprite>(p_node); if (as) { @@ -301,7 +301,7 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) { } { - Particles2D *ps = p_node->cast_to<Particles2D>(); + Particles2D *ps = Object::cast_to<Particles2D>(p_node); if (ps) { diff --git a/scene/2d/visibility_notifier_2d.h b/scene/2d/visibility_notifier_2d.h index 38da69faef..ef0e1affd3 100644 --- a/scene/2d/visibility_notifier_2d.h +++ b/scene/2d/visibility_notifier_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/y_sort.cpp b/scene/2d/y_sort.cpp index f258b7e2e0..e0fb3f0645 100644 --- a/scene/2d/y_sort.cpp +++ b/scene/2d/y_sort.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/y_sort.h b/scene/2d/y_sort.h index 3564cfc151..de7aa3a317 100644 --- a/scene/2d/y_sort.h +++ b/scene/2d/y_sort.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ |