diff options
36 files changed, 218 insertions, 62 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index c7039353ae..32b94b9b02 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -2585,7 +2585,7 @@ void _Engine::set_target_fps(int p_fps) { Engine::get_singleton()->set_target_fps(p_fps); } -float _Engine::get_target_fps() const { +int _Engine::get_target_fps() const { return Engine::get_singleton()->get_target_fps(); } diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index bc5b8ea04c..2353b6d09f 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -656,7 +656,7 @@ public: int get_iterations_per_second() const; void set_target_fps(int p_fps); - float get_target_fps() const; + int get_target_fps() const; float get_frames_per_second() const; diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index 0a54a84c8c..bd851ebb6d 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -155,7 +155,7 @@ void PacketPeerStream::_set_stream_peer(REF p_peer) { void PacketPeerStream::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_stream_peer", "peer"), &PacketPeerStream::_set_stream_peer); + ClassDB::bind_method(D_METHOD("set_stream_peer", "peer"), &PacketPeerStream::set_stream_peer); ClassDB::bind_method(D_METHOD("get_stream_peer"), &PacketPeerStream::get_stream_peer); ClassDB::bind_method(D_METHOD("set_input_buffer_max_size", "max_size_bytes"), &PacketPeerStream::set_input_buffer_max_size); ClassDB::bind_method(D_METHOD("set_output_buffer_max_size", "max_size_bytes"), &PacketPeerStream::set_output_buffer_max_size); diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index d16a128034..d0c948e599 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -32,8 +32,8 @@ <return type="void"> </return> <description> - Called when the node leaves the [SceneTree] (e.g. upon freeing, scene changing, or after calling [method remove_child] in a script). If the node has children, its [method _exit_tree] callback will be called last, after all its children have left the tree. - Corresponds to the NOTIFICATION_EXIT_TREE notification in [method Object._notification]. + Called when the node is about to leave the [SceneTree] (e.g. upon freeing, scene changing, or after calling [method remove_child] in a script). If the node has children, its [method _exit_tree] callback will be called last, after all its children have left the tree. + Corresponds to the NOTIFICATION_EXIT_TREE notification in [method Object._notification] and signal [signal tree_exiting]. To get notified when the node has already left the active tree, connect to the [signal tree_exited] </description> </method> <method name="_input" qualifiers="virtual"> @@ -744,9 +744,14 @@ Emitted when the node enters the tree. </description> </signal> + <signal name="tree_exiting"> + <description> + Emitted when the node is still active but about to exit the tree. This is the right place for de-initialization. + </description> + </signal> <signal name="tree_exited"> <description> - Emitted when the node exits the tree. + Emitted after the node exits the tree and is no longer active. </description> </signal> </signals> @@ -755,7 +760,7 @@ Notification received when the node enters a [SceneTree]. </constant> <constant name="NOTIFICATION_EXIT_TREE" value="11"> - Notification received when the node exits a [SceneTree]. + Notification received when the node is about to exit a [SceneTree]. </constant> <constant name="NOTIFICATION_MOVED_IN_PARENT" value="12"> Notification received when the node is moved in the parent. diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 3255726c1f..8452afb045 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -6950,6 +6950,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) { memdelete(cls); } else if (particles_owner.owns(p_rid)) { Particles *particles = particles_owner.get(p_rid); + particles->instance_remove_deps(); particles_owner.free(p_rid); memdelete(particles); } else { diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp index 7e49d1300c..91aa189c8f 100644 --- a/editor/animation_editor.cpp +++ b/editor/animation_editor.cpp @@ -3119,12 +3119,12 @@ void AnimationKeyEditor::set_animation(const Ref<Animation> &p_anim) { void AnimationKeyEditor::set_root(Node *p_root) { if (root) - root->disconnect("tree_exited", this, "_root_removed"); + root->disconnect("tree_exiting", this, "_root_removed"); root = p_root; if (root) - root->connect("tree_exited", this, "_root_removed", make_binds(), CONNECT_ONESHOT); + root->connect("tree_exiting", this, "_root_removed", make_binds(), CONNECT_ONESHOT); } Node *AnimationKeyEditor::get_root() const { diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 374688f2db..95ed40d889 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -829,7 +829,7 @@ void EditorSelection::add_node(Node *p_node) { } selection[p_node] = meta; - p_node->connect("tree_exited", this, "_node_removed", varray(p_node), CONNECT_ONESHOT); + p_node->connect("tree_exiting", this, "_node_removed", varray(p_node), CONNECT_ONESHOT); //emit_signal("selection_changed"); } @@ -847,7 +847,7 @@ void EditorSelection::remove_node(Node *p_node) { if (meta) memdelete(meta); selection.erase(p_node); - p_node->disconnect("tree_exited", this, "_node_removed"); + p_node->disconnect("tree_exiting", this, "_node_removed"); //emit_signal("selection_changed"); } bool EditorSelection::is_selected(Node *p_node) const { diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 9fda9d2ff6..9f031b5a80 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1053,7 +1053,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Color word_highlighted_color = alpha1; const Color number_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3); const Color function_color = main_color; - const Color member_variable_color = mono_color; + const Color member_variable_color = main_color.linear_interpolate(mono_color, 0.6); const Color mark_color = Color(error_color.r, error_color.g, error_color.b, 0.3); const Color breakpoint_color = error_color; const Color code_folding_color = alpha4; diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index f1ed984fee..2a6b4ee173 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -63,6 +63,7 @@ void ScriptTextEditor::apply_code() { //print_line("applying code"); script->set_source_code(code_editor->get_text_edit()->get_text()); script->update_exports(); + _update_member_keywords(); } Ref<Script> ScriptTextEditor::get_edited_script() const { @@ -70,6 +71,37 @@ Ref<Script> ScriptTextEditor::get_edited_script() const { return script; } +void ScriptTextEditor::_update_member_keywords() { + member_keywords.clear(); + code_editor->get_text_edit()->clear_member_keywords(); + Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color"); + + StringName instance_base = script->get_instance_base_type(); + + if (instance_base == StringName()) + return; + List<PropertyInfo> plist; + ClassDB::get_property_list(instance_base, &plist); + + for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { + String name = E->get().name; + if (E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_GROUP) + continue; + if (name.find("/") != -1) + continue; + + code_editor->get_text_edit()->add_member_keyword(name, member_variable_color); + } + + List<String> clist; + ClassDB::get_integer_constant_list(instance_base, &clist); + + for (List<String>::Element *E = clist.front(); E; E = E->next()) { + + code_editor->get_text_edit()->add_member_keyword(E->get(), member_variable_color); + } +} + void ScriptTextEditor::_load_theme_settings() { TextEdit *text_edit = code_editor->get_text_edit(); @@ -563,6 +595,7 @@ void ScriptTextEditor::_validate_script() { if (!script->is_tool()) { script->set_source_code(text); script->update_exports(); + _update_member_keywords(); //script->reload(); //will update all the variables in property editors } diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index ebbe865cee..22e8fbce25 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -44,6 +44,8 @@ class ScriptTextEditor : public ScriptEditorBase { Vector<String> functions; + Vector<String> member_keywords; + HBoxContainer *edit_hb; MenuButton *edit_menu; @@ -58,6 +60,8 @@ class ScriptTextEditor : public ScriptEditorBase { int color_line; String color_args; + void _update_member_keywords(); + struct ColorsCache { Color symbol_color; Color keyword_color; diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index b677017371..cef1da1d06 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -2689,7 +2689,7 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) { if (!p_activate) { - previewing->disconnect("tree_exited", this, "_preview_exited_scene"); + previewing->disconnect("tree_exiting", this, "_preview_exited_scene"); previewing = NULL; VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore if (!preview) @@ -2700,7 +2700,7 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) { } else { previewing = preview; - previewing->connect("tree_exited", this, "_preview_exited_scene"); + previewing->connect("tree_exiting", this, "_preview_exited_scene"); VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), preview->get_camera()); //replace view_menu->hide(); surface->update(); @@ -2851,7 +2851,7 @@ void SpatialEditorViewport::set_state(const Dictionary &p_state) { Node *pv = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["previewing"]); if (Object::cast_to<Camera>(pv)) { previewing = Object::cast_to<Camera>(pv); - previewing->connect("tree_exited", this, "_preview_exited_scene"); + previewing->connect("tree_exiting", this, "_preview_exited_scene"); VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), previewing->get_camera()); //replace view_menu->hide(); surface->update(); diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp index e56ec774dd..8a674bc8c1 100644 --- a/modules/etc/image_etc.cpp +++ b/modules/etc/image_etc.cpp @@ -118,7 +118,6 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f } uint32_t imgw = p_img->get_width(), imgh = p_img->get_height(); - ERR_FAIL_COND(next_power_of_2(imgw) != imgw || next_power_of_2(imgh) != imgh); Image::Format etc_format = force_etc1_format ? Image::FORMAT_ETC : _get_etc2_mode(detected_channels); @@ -127,6 +126,25 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f if (img->get_format() != Image::FORMAT_RGBA8) img->convert(Image::FORMAT_RGBA8); //still uses RGBA to convert + if (img->has_mipmaps()) { + if (next_power_of_2(imgw) != imgw || next_power_of_2(imgh) != imgh) { + img->resize_to_po2(); + imgw = img->get_width(); + imgh = img->get_height(); + } + } else { + if (imgw % 4 != 0 || imgh % 4 != 0) { + if (imgw % 4) { + imgw += 4 - imgw % 4; + } + if (imgh % 4) { + imgh += 4 - imgh % 4; + } + + img->resize(imgw, imgh); + } + } + PoolVector<uint8_t>::Read r = img->get_data().read(); int target_size = Image::get_image_data_size(imgw, imgh, etc_format, p_img->has_mipmaps() ? -1 : 0); diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index 6ecf661efd..6fff7ac0a4 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -170,7 +170,7 @@ void Area2D::_body_inout(int p_status, const RID &p_body, int p_instance, int p_ E->get().in_tree = node && node->is_inside_tree(); if (node) { node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree, make_binds(objid)); - node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid)); + node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid)); if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->body_entered, node); } @@ -197,7 +197,7 @@ void Area2D::_body_inout(int p_status, const RID &p_body, int p_instance, int p_ if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree); - node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree); if (E->get().in_tree) emit_signal(SceneStringNames::get_singleton()->body_exited, obj); } @@ -271,7 +271,7 @@ void Area2D::_area_inout(int p_status, const RID &p_area, int p_instance, int p_ E->get().in_tree = node && node->is_inside_tree(); if (node) { node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree, make_binds(objid)); - node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_area_exit_tree, make_binds(objid)); + node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree, make_binds(objid)); if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->area_entered, node); } @@ -298,7 +298,7 @@ void Area2D::_area_inout(int p_status, const RID &p_area, int p_instance, int p_ if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree); - node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_area_exit_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree); if (E->get().in_tree) emit_signal(SceneStringNames::get_singleton()->area_exited, obj); } @@ -338,7 +338,7 @@ void Area2D::_clear_monitoring() { //ERR_CONTINUE(!node); node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree); - node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree); if (!E->get().in_tree) continue; @@ -368,7 +368,7 @@ void Area2D::_clear_monitoring() { //ERR_CONTINUE(!node); node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree); - node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_area_exit_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree); if (!E->get().in_tree) continue; diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index 965507e385..978fb379ac 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -115,6 +115,15 @@ Vector<Vector<Vector2> > CollisionPolygon2D::_decompose_in_convex() { return decomp; } +void CollisionPolygon2D::_update_in_shape_owner(bool p_xform_only) { + + parent->shape_owner_set_transform(owner_id, get_transform()); + if (p_xform_only) + return; + parent->shape_owner_set_disabled(owner_id, disabled); + parent->shape_owner_set_one_way_collision(owner_id, one_way_collision); +} + void CollisionPolygon2D::_notification(int p_what) { switch (p_what) { @@ -124,9 +133,7 @@ void CollisionPolygon2D::_notification(int p_what) { if (parent) { owner_id = parent->create_shape_owner(this); _build_polygon(); - parent->shape_owner_set_transform(owner_id, get_transform()); - parent->shape_owner_set_disabled(owner_id, disabled); - parent->shape_owner_set_one_way_collision(owner_id, one_way_collision); + _update_in_shape_owner(); } /*if (Engine::get_singleton()->is_editor_hint()) { @@ -136,10 +143,17 @@ void CollisionPolygon2D::_notification(int p_what) { }*/ } break; + case NOTIFICATION_ENTER_TREE: { + + if (parent) { + _update_in_shape_owner(); + } + + } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { if (parent) { - parent->shape_owner_set_transform(owner_id, get_transform()); + _update_in_shape_owner(true); } } break; diff --git a/scene/2d/collision_polygon_2d.h b/scene/2d/collision_polygon_2d.h index 83451f3f1a..4dafe7d1da 100644 --- a/scene/2d/collision_polygon_2d.h +++ b/scene/2d/collision_polygon_2d.h @@ -59,6 +59,8 @@ protected: void _build_polygon(); + void _update_in_shape_owner(bool p_xform_only = false); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp index bf213614ed..0eeb6dafe5 100644 --- a/scene/2d/collision_shape_2d.cpp +++ b/scene/2d/collision_shape_2d.cpp @@ -45,6 +45,15 @@ void CollisionShape2D::_shape_changed() { update(); } +void CollisionShape2D::_update_in_shape_owner(bool p_xform_only) { + + parent->shape_owner_set_transform(owner_id, get_transform()); + if (p_xform_only) + return; + parent->shape_owner_set_disabled(owner_id, disabled); + parent->shape_owner_set_one_way_collision(owner_id, one_way_collision); +} + void CollisionShape2D::_notification(int p_what) { switch (p_what) { @@ -57,9 +66,7 @@ void CollisionShape2D::_notification(int p_what) { if (shape.is_valid()) { parent->shape_owner_add_shape(owner_id, shape); } - parent->shape_owner_set_transform(owner_id, get_transform()); - parent->shape_owner_set_disabled(owner_id, disabled); - parent->shape_owner_set_one_way_collision(owner_id, one_way_collision); + _update_in_shape_owner(); } /*if (Engine::get_singleton()->is_editor_hint()) { @@ -69,10 +76,17 @@ void CollisionShape2D::_notification(int p_what) { }*/ } break; + case NOTIFICATION_ENTER_TREE: { + + if (parent) { + _update_in_shape_owner(); + } + + } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { if (parent) { - parent->shape_owner_set_transform(owner_id, get_transform()); + _update_in_shape_owner(true); } } break; diff --git a/scene/2d/collision_shape_2d.h b/scene/2d/collision_shape_2d.h index b3f7d3f02a..cdff595828 100644 --- a/scene/2d/collision_shape_2d.h +++ b/scene/2d/collision_shape_2d.h @@ -47,6 +47,8 @@ class CollisionShape2D : public Node2D { bool disabled; bool one_way_collision; + void _update_in_shape_owner(bool p_xform_only = false); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 7f96a258e0..1b25b3588a 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -310,7 +310,7 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap E->get().in_scene = node && node->is_inside_tree(); if (node) { node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree, make_binds(objid)); - node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid)); + node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid)); if (E->get().in_scene) { emit_signal(SceneStringNames::get_singleton()->body_entered, node); } @@ -339,7 +339,7 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree); - node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree); if (in_scene) emit_signal(SceneStringNames::get_singleton()->body_exited, obj); } diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp index c2227d9964..4b38534d97 100644 --- a/scene/2d/visibility_notifier_2d.cpp +++ b/scene/2d/visibility_notifier_2d.cpp @@ -219,7 +219,7 @@ void VisibilityEnabler2D::_find_nodes(Node *p_node) { if (add) { - p_node->connect(SceneStringNames::get_singleton()->tree_exited, this, "_node_removed", varray(p_node), CONNECT_ONESHOT); + p_node->connect(SceneStringNames::get_singleton()->tree_exiting, this, "_node_removed", varray(p_node), CONNECT_ONESHOT); nodes[p_node] = meta; _change_node_state(p_node, false); } @@ -262,7 +262,7 @@ void VisibilityEnabler2D::_notification(int p_what) { if (!visible) _change_node_state(E->key(), true); - E->key()->disconnect(SceneStringNames::get_singleton()->tree_exited, this, "_node_removed"); + E->key()->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, "_node_removed"); } nodes.clear(); diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index 4089d80d4e..21f471039f 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -169,7 +169,7 @@ void Area::_body_inout(int p_status, const RID &p_body, int p_instance, int p_bo E->get().in_tree = node && node->is_inside_tree(); if (node) { node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree, make_binds(objid)); - node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid)); + node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid)); if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->body_entered, node); } @@ -196,7 +196,7 @@ void Area::_body_inout(int p_status, const RID &p_body, int p_instance, int p_bo if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree); - node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree); if (E->get().in_tree) emit_signal(SceneStringNames::get_singleton()->body_exited, obj); } @@ -246,7 +246,7 @@ void Area::_clear_monitoring() { emit_signal(SceneStringNames::get_singleton()->body_exited, obj); node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree); - node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree); } } @@ -276,7 +276,7 @@ void Area::_clear_monitoring() { emit_signal(SceneStringNames::get_singleton()->area_exited, obj); node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree); - node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_area_exit_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree); } } } @@ -366,7 +366,7 @@ void Area::_area_inout(int p_status, const RID &p_area, int p_instance, int p_ar E->get().in_tree = node && node->is_inside_tree(); if (node) { node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree, make_binds(objid)); - node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_area_exit_tree, make_binds(objid)); + node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree, make_binds(objid)); if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->area_entered, node); } @@ -393,7 +393,7 @@ void Area::_area_inout(int p_status, const RID &p_area, int p_instance, int p_ar if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree); - node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_area_exit_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree); if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->area_exited, obj); } diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp index ef1b33a4e2..3a77360bc2 100644 --- a/scene/3d/collision_polygon.cpp +++ b/scene/3d/collision_polygon.cpp @@ -73,6 +73,14 @@ void CollisionPolygon::_build_polygon() { } } +void CollisionPolygon::_update_in_shape_owner(bool p_xform_only) { + + parent->shape_owner_set_transform(owner_id, get_transform()); + if (p_xform_only) + return; + parent->shape_owner_set_disabled(owner_id, disabled); +} + void CollisionPolygon::_notification(int p_what) { switch (p_what) { @@ -82,14 +90,20 @@ void CollisionPolygon::_notification(int p_what) { if (parent) { owner_id = parent->create_shape_owner(this); _build_polygon(); - parent->shape_owner_set_transform(owner_id, get_transform()); - parent->shape_owner_set_disabled(owner_id, disabled); + _update_in_shape_owner(); } } break; + case NOTIFICATION_ENTER_TREE: { + + if (parent) { + _update_in_shape_owner(); + } + + } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { if (parent) { - parent->shape_owner_set_transform(owner_id, get_transform()); + _update_in_shape_owner(true); } } break; diff --git a/scene/3d/collision_polygon.h b/scene/3d/collision_polygon.h index 6643cfa044..971c67f1ad 100644 --- a/scene/3d/collision_polygon.h +++ b/scene/3d/collision_polygon.h @@ -51,6 +51,8 @@ protected: void _build_polygon(); + void _update_in_shape_owner(bool p_xform_only = false); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/scene/3d/collision_shape.cpp b/scene/3d/collision_shape.cpp index d6d49a197c..943f4158f7 100644 --- a/scene/3d/collision_shape.cpp +++ b/scene/3d/collision_shape.cpp @@ -64,6 +64,14 @@ void CollisionShape::make_convex_from_brothers() { } } +void CollisionShape::_update_in_shape_owner(bool p_xform_only) { + + parent->shape_owner_set_transform(owner_id, get_transform()); + if (p_xform_only) + return; + parent->shape_owner_set_disabled(owner_id, disabled); +} + void CollisionShape::_notification(int p_what) { switch (p_what) { @@ -75,19 +83,20 @@ void CollisionShape::_notification(int p_what) { if (shape.is_valid()) { parent->shape_owner_add_shape(owner_id, shape); } - parent->shape_owner_set_transform(owner_id, get_transform()); - parent->shape_owner_set_disabled(owner_id, disabled); + _update_in_shape_owner(); } } break; case NOTIFICATION_ENTER_TREE: { + if (parent) { + _update_in_shape_owner(); + } if (get_tree()->is_debugging_collisions_hint()) { _create_debug_shape(); } - } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { if (parent) { - parent->shape_owner_set_transform(owner_id, get_transform()); + _update_in_shape_owner(true); } } break; case NOTIFICATION_UNPARENTED: { diff --git a/scene/3d/collision_shape.h b/scene/3d/collision_shape.h index 724a025165..c9c91a5824 100644 --- a/scene/3d/collision_shape.h +++ b/scene/3d/collision_shape.h @@ -51,6 +51,8 @@ class CollisionShape : public Spatial { void _create_debug_shape(); + void _update_in_shape_owner(bool p_xform_only = false); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index 7d638d8737..a15a7dcead 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -318,7 +318,7 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, E->get().in_tree = node && node->is_inside_tree(); if (node) { node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree, make_binds(objid)); - node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid)); + node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid)); if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->body_entered, node); } @@ -345,7 +345,7 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree); - node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree); if (in_tree) emit_signal(SceneStringNames::get_singleton()->body_exited, obj); } diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp index 556774a0d1..dd5ae8a999 100644 --- a/scene/3d/ray_cast.cpp +++ b/scene/3d/ray_cast.cpp @@ -217,6 +217,8 @@ void RayCast::_update_raycast_state() { against_shape = rr.shape; } else { collided = false; + against = 0; + against_shape = 0; } } diff --git a/scene/3d/visibility_notifier.cpp b/scene/3d/visibility_notifier.cpp index a8818a06c3..9d6e4941f3 100644 --- a/scene/3d/visibility_notifier.cpp +++ b/scene/3d/visibility_notifier.cpp @@ -170,7 +170,7 @@ void VisibilityEnabler::_find_nodes(Node *p_node) { if (add) { - p_node->connect(SceneStringNames::get_singleton()->tree_exited, this, "_node_removed", varray(p_node), CONNECT_ONESHOT); + p_node->connect(SceneStringNames::get_singleton()->tree_exiting, this, "_node_removed", varray(p_node), CONNECT_ONESHOT); nodes[p_node] = meta; _change_node_state(p_node, false); } @@ -208,7 +208,7 @@ void VisibilityEnabler::_notification(int p_what) { if (!visible) _change_node_state(E->key(), true); - E->key()->disconnect(SceneStringNames::get_singleton()->tree_exited, this, "_node_removed"); + E->key()->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, "_node_removed"); } nodes.clear(); @@ -240,7 +240,7 @@ void VisibilityEnabler::_node_removed(Node *p_node) { if (!visible) _change_node_state(p_node, true); - p_node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, "_node_removed"); + p_node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, "_node_removed"); nodes.erase(p_node); } diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp index df83be6d50..949a0be3bc 100644 --- a/scene/animation/animation_cache.cpp +++ b/scene/animation/animation_cache.cpp @@ -56,7 +56,7 @@ void AnimationCache::_clear_cache() { while (connected_nodes.size()) { - connected_nodes.front()->get()->disconnect("tree_exited", this, "_node_exit_tree"); + connected_nodes.front()->get()->disconnect("tree_exiting", this, "_node_exit_tree"); connected_nodes.erase(connected_nodes.front()); } path_cache.clear(); @@ -181,7 +181,7 @@ void AnimationCache::_update_cache() { if (!connected_nodes.has(path.node)) { connected_nodes.insert(path.node); - path.node->connect("tree_exited", this, "_node_exit_tree", Node::make_binds(path.node), CONNECT_ONESHOT); + path.node->connect("tree_exiting", this, "_node_exit_tree", Node::make_binds(path.node), CONNECT_ONESHOT); } } diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 2a276981db..0a051cdb9b 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -261,8 +261,8 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) { } { - if (!child->is_connected("tree_exited", this, "_node_removed")) - child->connect("tree_exited", this, "_node_removed", make_binds(child), CONNECT_ONESHOT); + if (!child->is_connected("tree_exiting", this, "_node_removed")) + child->connect("tree_exiting", this, "_node_removed", make_binds(child), CONNECT_ONESHOT); } TrackNodeCacheKey key; diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index d54500bc51..95fcda2db3 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -323,14 +323,14 @@ void ScrollBar::_notification(int p_what) { if (drag_slave) { drag_slave->connect("gui_input", this, "_drag_slave_input"); - drag_slave->connect("tree_exited", this, "_drag_slave_exit", varray(), CONNECT_ONESHOT); + drag_slave->connect("tree_exiting", this, "_drag_slave_exit", varray(), CONNECT_ONESHOT); } } if (p_what == NOTIFICATION_EXIT_TREE) { if (drag_slave) { drag_slave->disconnect("gui_input", this, "_drag_slave_input"); - drag_slave->disconnect("tree_exited", this, "_drag_slave_exit"); + drag_slave->disconnect("tree_exiting", this, "_drag_slave_exit"); } drag_slave = NULL; @@ -655,7 +655,7 @@ void ScrollBar::set_drag_slave(const NodePath &p_path) { if (drag_slave) { drag_slave->disconnect("gui_input", this, "_drag_slave_input"); - drag_slave->disconnect("tree_exited", this, "_drag_slave_exit"); + drag_slave->disconnect("tree_exiting", this, "_drag_slave_exit"); } } @@ -671,7 +671,7 @@ void ScrollBar::set_drag_slave(const NodePath &p_path) { if (drag_slave) { drag_slave->connect("gui_input", this, "_drag_slave_input"); - drag_slave->connect("tree_exited", this, "_drag_slave_exit", varray(), CONNECT_ONESHOT); + drag_slave->connect("tree_exiting", this, "_drag_slave_exit", varray(), CONNECT_ONESHOT); } } } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 8f37628c33..d673f21077 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1025,6 +1025,21 @@ void TextEdit::_notification(int p_what) { const Color *col = keywords.custom_getptr(range, hash); + if (!col) { + col = member_keywords.custom_getptr(range, hash); + + if (col) { + for (int k = j - 1; k >= 0; k--) { + if (str[k] == '.') { + col = NULL; //member indexing not allowed + break; + } else if (str[k] > 32) { + break; + } + } + } + } + if (col) { in_keyword = true; @@ -4138,6 +4153,16 @@ void TextEdit::add_color_region(const String &p_begin_key, const String &p_end_k update(); } +void TextEdit::add_member_keyword(const String &p_keyword, const Color &p_color) { + member_keywords[p_keyword] = p_color; + update(); +} + +void TextEdit::clear_member_keywords() { + member_keywords.clear(); + update(); +} + void TextEdit::set_syntax_coloring(bool p_enabled) { syntax_coloring = p_enabled; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 5ce751faa8..acbf41aa81 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -210,6 +210,7 @@ class TextEdit : public Control { //syntax coloring HashMap<String, Color> keywords; + HashMap<String, Color> member_keywords; Vector<ColorRegion> color_regions; @@ -546,6 +547,9 @@ public: void add_color_region(const String &p_begin_key = String(), const String &p_end_key = String(), const Color &p_color = Color(), bool p_line_only = false); void clear_colors(); + void add_member_keyword(const String &p_keyword, const Color &p_color); + void clear_member_keywords(); + int get_v_scroll() const; void set_v_scroll(int p_scroll); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 5f39c6285f..148cdaf526 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -275,7 +275,7 @@ void Node::_propagate_exit_tree() { get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_tree, NULL, 0); } - emit_signal(SceneStringNames::get_singleton()->tree_exited); + emit_signal(SceneStringNames::get_singleton()->tree_exiting); notification(NOTIFICATION_EXIT_TREE, true); if (data.tree) @@ -297,6 +297,8 @@ void Node::_propagate_exit_tree() { data.ready_notified = false; data.tree = NULL; data.depth = -1; + + emit_signal(SceneStringNames::get_singleton()->tree_exited); } void Node::move_child(Node *p_child, int p_pos) { @@ -2952,6 +2954,7 @@ void Node::_bind_methods() { ADD_SIGNAL(MethodInfo("renamed")); ADD_SIGNAL(MethodInfo("tree_entered")); + ADD_SIGNAL(MethodInfo("tree_exiting")); ADD_SIGNAL(MethodInfo("tree_exited")); //ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/process" ),"set_process","is_processing") ; diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index d9ae912208..e7329f5183 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -2127,7 +2127,7 @@ SpatialMaterial::SpatialMaterial() : for (int i = 0; i < FLAG_MAX; i++) { flags[i] = 0; } - diffuse_mode = DIFFUSE_LAMBERT; + diffuse_mode = DIFFUSE_BURLEY; specular_mode = SPECULAR_SCHLICK_GGX; for (int i = 0; i < FEATURE_MAX; i++) { diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp index 7d8dfea2bc..fdce0eb2b6 100644 --- a/scene/scene_string_names.cpp +++ b/scene/scene_string_names.cpp @@ -49,6 +49,7 @@ SceneStringNames::SceneStringNames() { shader_unshaded = StaticCString::create("shader/unshaded"); shading_mode = StaticCString::create("shader/shading_mode"); tree_entered = StaticCString::create("tree_entered"); + tree_exiting = StaticCString::create("tree_exiting"); tree_exited = StaticCString::create("tree_exited"); item_rect_changed = StaticCString::create("item_rect_changed"); size_flags_changed = StaticCString::create("size_flags_changed"); diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h index 1b30d7c1bf..63a9a5db4d 100644 --- a/scene/scene_string_names.h +++ b/scene/scene_string_names.h @@ -69,6 +69,7 @@ public: StringName shader_unshaded; StringName shading_mode; StringName tree_entered; + StringName tree_exiting; StringName tree_exited; StringName size_flags_changed; StringName minimum_size_changed; |