diff options
Diffstat (limited to 'scene')
50 files changed, 208 insertions, 173 deletions
diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h index 37d093e3d8..e5d015b07c 100644 --- a/scene/2d/animated_sprite.h +++ b/scene/2d/animated_sprite.h @@ -42,7 +42,7 @@ class SpriteFrames : public Resource { float speed; bool loop; - Vector<Ref<Texture2D> > frames; + Vector<Ref<Texture2D>> frames; Anim() { loop = true; diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index 4edf92197e..e9dfb94cb2 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -50,7 +50,7 @@ void CollisionPolygon2D::_build_polygon() { //here comes the sun, lalalala //decompose concave into multiple convex polygons and add them - Vector<Vector<Vector2> > decomp = _decompose_in_convex(); + Vector<Vector<Vector2>> decomp = _decompose_in_convex(); for (int i = 0; i < decomp.size(); i++) { Ref<ConvexPolygonShape2D> convex = memnew(ConvexPolygonShape2D); convex->set_points(decomp[i]); @@ -76,8 +76,8 @@ void CollisionPolygon2D::_build_polygon() { } } -Vector<Vector<Vector2> > CollisionPolygon2D::_decompose_in_convex() { - Vector<Vector<Vector2> > decomp = Geometry::decompose_polygon_in_convex(polygon); +Vector<Vector<Vector2>> CollisionPolygon2D::_decompose_in_convex() { + Vector<Vector<Vector2>> decomp = Geometry::decompose_polygon_in_convex(polygon); return decomp; } @@ -148,7 +148,7 @@ void CollisionPolygon2D::_notification(int p_what) { #define DEBUG_DECOMPOSE #if defined(TOOLS_ENABLED) && defined(DEBUG_DECOMPOSE) - Vector<Vector<Vector2> > decomp = _decompose_in_convex(); + Vector<Vector<Vector2>> decomp = _decompose_in_convex(); Color c(0.4, 0.9, 0.1); for (int i = 0; i < decomp.size(); i++) { diff --git a/scene/2d/collision_polygon_2d.h b/scene/2d/collision_polygon_2d.h index d8dfec8fd2..92a2758813 100644 --- a/scene/2d/collision_polygon_2d.h +++ b/scene/2d/collision_polygon_2d.h @@ -56,7 +56,7 @@ protected: bool one_way_collision; float one_way_collision_margin; - Vector<Vector<Vector2> > _decompose_in_convex(); + Vector<Vector<Vector2>> _decompose_in_convex(); void _build_polygon(); diff --git a/scene/2d/navigation_polygon.h b/scene/2d/navigation_polygon.h index 579d6b0e0e..3d096ec91b 100644 --- a/scene/2d/navigation_polygon.h +++ b/scene/2d/navigation_polygon.h @@ -43,7 +43,7 @@ class NavigationPolygon : public Resource { Vector<int> indices; }; Vector<Polygon> polygons; - Vector<Vector<Vector2> > outlines; + Vector<Vector<Vector2>> outlines; mutable Rect2 item_rect; mutable bool rect_cache_dirty; diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index 20e9f3ffcf..eb7aefb495 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -300,7 +300,7 @@ private: bool sync_to_physics; Vector<Collision> colliders; - Vector<Ref<KinematicCollision2D> > slide_colliders; + Vector<Ref<KinematicCollision2D>> slide_colliders; Ref<KinematicCollision2D> motion_cache; _FORCE_INLINE_ bool _ignores_mode(Physics2DServer::BodyMode) const; diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp index 636b859477..24c3a9eb41 100644 --- a/scene/3d/collision_polygon.cpp +++ b/scene/3d/collision_polygon.cpp @@ -44,7 +44,7 @@ void CollisionPolygon::_build_polygon() { if (polygon.size() == 0) return; - Vector<Vector<Vector2> > decomp = Geometry::decompose_polygon_in_convex(polygon); + Vector<Vector<Vector2>> decomp = Geometry::decompose_polygon_in_convex(polygon); if (decomp.size() == 0) return; diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h index 354eaad7c0..f991843883 100644 --- a/scene/3d/gi_probe.h +++ b/scene/3d/gi_probe.h @@ -135,7 +135,7 @@ private: struct PlotMesh { Ref<Material> override_material; - Vector<Ref<Material> > instance_materials; + Vector<Ref<Material>> instance_materials; Ref<Mesh> mesh; Transform local_xform; }; diff --git a/scene/3d/immediate_geometry.h b/scene/3d/immediate_geometry.h index 77a20e8d4d..f9222c75fa 100644 --- a/scene/3d/immediate_geometry.h +++ b/scene/3d/immediate_geometry.h @@ -41,7 +41,7 @@ class ImmediateGeometry : public GeometryInstance { RID im; //a list of textures drawn need to be kept, to avoid references // in VisualServer from becoming invalid if the texture is no longer used - List<Ref<Texture2D> > cached_textures; + List<Ref<Texture2D>> cached_textures; bool empty; AABB aabb; diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance.h index d49d9ed98f..a6190e7660 100644 --- a/scene/3d/mesh_instance.h +++ b/scene/3d/mesh_instance.h @@ -58,7 +58,7 @@ protected: }; Map<StringName, BlendShapeTrack> blend_shape_tracks; - Vector<Ref<Material> > materials; + Vector<Ref<Material>> materials; void _mesh_changed(); void _resolve_skeleton_path(); diff --git a/scene/3d/navigation_region.cpp b/scene/3d/navigation_region.cpp index d96d095797..53b707a29a 100644 --- a/scene/3d/navigation_region.cpp +++ b/scene/3d/navigation_region.cpp @@ -162,22 +162,22 @@ Ref<NavigationMesh> NavigationRegion::get_navigation_mesh() const { } struct BakeThreadsArgs { - NavigationRegion *nav_mesh_instance; + NavigationRegion *nav_region; }; void _bake_navigation_mesh(void *p_user_data) { BakeThreadsArgs *args = static_cast<BakeThreadsArgs *>(p_user_data); - if (args->nav_mesh_instance->get_navigation_mesh().is_valid()) { - Ref<NavigationMesh> nav_mesh = args->nav_mesh_instance->get_navigation_mesh()->duplicate(); + if (args->nav_region->get_navigation_mesh().is_valid()) { + Ref<NavigationMesh> nav_mesh = args->nav_region->get_navigation_mesh()->duplicate(); - NavigationServer::get_singleton()->region_bake_navmesh(nav_mesh, args->nav_mesh_instance); - args->nav_mesh_instance->call_deferred("_bake_finished", nav_mesh); + NavigationServer::get_singleton()->region_bake_navmesh(nav_mesh, args->nav_region); + args->nav_region->call_deferred("_bake_finished", nav_mesh); memdelete(args); } else { ERR_PRINT("Can't bake the navigation mesh if the `NavigationMesh` resource doesn't exist"); - args->nav_mesh_instance->call_deferred("_bake_finished", Ref<NavigationMesh>()); + args->nav_region->call_deferred("_bake_finished", Ref<NavigationMesh>()); memdelete(args); } } @@ -186,7 +186,7 @@ void NavigationRegion::bake_navigation_mesh() { ERR_FAIL_COND(bake_thread != NULL); BakeThreadsArgs *args = memnew(BakeThreadsArgs); - args->nav_mesh_instance = this; + args->nav_region = this; bake_thread = Thread::create(_bake_navigation_mesh, args); ERR_FAIL_COND(bake_thread == NULL); diff --git a/scene/3d/particles.h b/scene/3d/particles.h index 95c6de15ec..cf461f25e9 100644 --- a/scene/3d/particles.h +++ b/scene/3d/particles.h @@ -69,7 +69,7 @@ private: DrawOrder draw_order; - Vector<Ref<Mesh> > draw_passes; + Vector<Ref<Mesh>> draw_passes; protected: static void _bind_methods(); diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h index 5362baf8ee..90de1ffce6 100644 --- a/scene/3d/physics_body.h +++ b/scene/3d/physics_body.h @@ -293,7 +293,7 @@ private: bool on_ceiling; bool on_wall; Vector<Collision> colliders; - Vector<Ref<KinematicCollision> > slide_colliders; + Vector<Ref<KinematicCollision>> slide_colliders; Ref<KinematicCollision> motion_cache; _FORCE_INLINE_ bool _ignores_mode(PhysicsServer::BodyMode) const; diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp index be1426f13c..f6eb3d954a 100644 --- a/scene/3d/ray_cast.cpp +++ b/scene/3d/ray_cast.cpp @@ -186,7 +186,7 @@ void RayCast::_notification(int p_what) { _update_raycast_state(); if (prev_collision_state != collided && get_tree()->is_debugging_collisions_hint()) { if (debug_material.is_valid()) { - Ref<StandardMaterial3D> line_material = static_cast<Ref<StandardMaterial3D> >(debug_material); + Ref<StandardMaterial3D> line_material = static_cast<Ref<StandardMaterial3D>>(debug_material); line_material->set_albedo(collided ? Color(1.0, 0, 0) : Color(1.0, 0.8, 0.6)); } } @@ -335,7 +335,7 @@ void RayCast::_create_debug_shape() { if (!debug_material.is_valid()) { debug_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); - Ref<StandardMaterial3D> line_material = static_cast<Ref<StandardMaterial3D> >(debug_material); + Ref<StandardMaterial3D> line_material = static_cast<Ref<StandardMaterial3D>>(debug_material); line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); line_material->set_albedo(Color(1.0, 0.8, 0.6)); } diff --git a/scene/3d/soft_body.cpp b/scene/3d/soft_body.cpp index 3859a278ef..65f868aed4 100644 --- a/scene/3d/soft_body.cpp +++ b/scene/3d/soft_body.cpp @@ -479,7 +479,7 @@ void SoftBody::become_mesh_owner() { if (!mesh_owner) { mesh_owner = true; - Vector<Ref<Material> > copy_materials; + Vector<Ref<Material>> copy_materials; copy_materials.append_array(materials); ERR_FAIL_COND(!mesh->get_surface_count()); diff --git a/scene/3d/voxelizer.cpp b/scene/3d/voxelizer.cpp index 0257e6e83d..203c3cd812 100644 --- a/scene/3d/voxelizer.cpp +++ b/scene/3d/voxelizer.cpp @@ -569,7 +569,7 @@ Voxelizer::MaterialCache Voxelizer::_get_material_cache(Ref<Material> p_material return mc; } -void Voxelizer::plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, const Vector<Ref<Material> > &p_materials, const Ref<Material> &p_override_material) { +void Voxelizer::plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, const Vector<Ref<Material>> &p_materials, const Ref<Material> &p_override_material) { for (int i = 0; i < p_mesh->get_surface_count(); i++) { diff --git a/scene/3d/voxelizer.h b/scene/3d/voxelizer.h index 1d50f1cd18..af9237ae7b 100644 --- a/scene/3d/voxelizer.h +++ b/scene/3d/voxelizer.h @@ -125,7 +125,7 @@ private: public: void begin_bake(int p_subdiv, const AABB &p_bounds); - void plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, const Vector<Ref<Material> > &p_materials, const Ref<Material> &p_override_material); + void plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, const Vector<Ref<Material>> &p_materials, const Ref<Material> &p_override_material); void end_bake(); int get_gi_probe_octree_depth() const; diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index fbd9a2aa7d..ce1e75a61d 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -565,6 +565,27 @@ void AnimationNodeStateMachine::add_node(const StringName &p_name, Ref<Animation p_node->connect("tree_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed), varray(), CONNECT_REFERENCE_COUNTED); } +void AnimationNodeStateMachine::replace_node(const StringName &p_name, Ref<AnimationNode> p_node) { + + ERR_FAIL_COND(states.has(p_name) == false); + ERR_FAIL_COND(p_node.is_null()); + ERR_FAIL_COND(String(p_name).find("/") != -1); + + { + Ref<AnimationNode> node = states[p_name].node; + if (node.is_valid()) { + node->disconnect_compat("tree_changed", this, "_tree_changed"); + } + } + + states[p_name].node = p_node; + + emit_changed(); + emit_signal("tree_changed"); + + p_node->connect_compat("tree_changed", this, "_tree_changed", varray(), CONNECT_REFERENCE_COUNTED); +} + Ref<AnimationNode> AnimationNodeStateMachine::get_node(const StringName &p_name) const { ERR_FAIL_COND_V(!states.has(p_name), Ref<AnimationNode>()); @@ -949,6 +970,7 @@ void AnimationNodeStateMachine::_tree_changed() { void AnimationNodeStateMachine::_bind_methods() { ClassDB::bind_method(D_METHOD("add_node", "name", "node", "position"), &AnimationNodeStateMachine::add_node, DEFVAL(Vector2())); + ClassDB::bind_method(D_METHOD("replace_node", "name", "node"), &AnimationNodeStateMachine::replace_node); ClassDB::bind_method(D_METHOD("get_node", "name"), &AnimationNodeStateMachine::get_node); ClassDB::bind_method(D_METHOD("remove_node", "name"), &AnimationNodeStateMachine::remove_node); ClassDB::bind_method(D_METHOD("rename_node", "name", "new_name"), &AnimationNodeStateMachine::rename_node); diff --git a/scene/animation/animation_node_state_machine.h b/scene/animation/animation_node_state_machine.h index 55c9c3f00e..27a4451f08 100644 --- a/scene/animation/animation_node_state_machine.h +++ b/scene/animation/animation_node_state_machine.h @@ -178,6 +178,7 @@ public: virtual Variant get_parameter_default_value(const StringName &p_parameter) const; void add_node(const StringName &p_name, Ref<AnimationNode> p_node, const Vector2 &p_position = Vector2()); + void replace_node(const StringName &p_name, Ref<AnimationNode> p_node); Ref<AnimationNode> get_node(const StringName &p_name) const; void remove_node(const StringName &p_name); void rename_node(const StringName &p_name, const StringName &p_new_name); diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h index 8769e2c61d..742942fcda 100644 --- a/scene/animation/animation_tree.h +++ b/scene/animation/animation_tree.h @@ -285,7 +285,7 @@ private: void _tree_changed(); void _update_properties(); List<PropertyInfo> properties; - HashMap<StringName, HashMap<StringName, StringName> > property_parent_map; + HashMap<StringName, HashMap<StringName, StringName>> property_parent_map; HashMap<StringName, Variant> property_map; struct Activity { @@ -293,7 +293,7 @@ private: float activity; }; - HashMap<StringName, Vector<Activity> > input_activity_map; + HashMap<StringName, Vector<Activity>> input_activity_map; HashMap<StringName, Vector<Activity> *> input_activity_map_get; void _update_properties_for_node(const String &p_base_path, Ref<AnimationNode> node); diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp index 22ff0611a7..7a184adc55 100644 --- a/scene/debugger/scene_debugger.cpp +++ b/scene/debugger/scene_debugger.cpp @@ -30,8 +30,9 @@ #include "scene_debugger.h" +#include "core/debugger/engine_debugger.h" #include "core/io/marshalls.h" -#include "core/script_debugger_remote.h" +#include "core/script_language.h" #include "scene/main/scene_tree.h" #include "scene/main/viewport.h" #include "scene/resources/packed_scene.h" @@ -39,13 +40,16 @@ void SceneDebugger::initialize() { #ifdef DEBUG_ENABLED LiveEditor::singleton = memnew(LiveEditor); - ScriptDebuggerRemote::scene_tree_parse_func = SceneDebugger::parse_message; + EngineDebugger::register_message_capture("scene", EngineDebugger::Capture(NULL, SceneDebugger::parse_message)); #endif } void SceneDebugger::deinitialize() { #ifdef DEBUG_ENABLED if (LiveEditor::singleton) { + // Should be removed automatically when deiniting debugger, but just in case + if (EngineDebugger::has_capture("scene")) + EngineDebugger::unregister_message_capture("scene"); memdelete(LiveEditor::singleton); LiveEditor::singleton = NULL; } @@ -53,13 +57,15 @@ void SceneDebugger::deinitialize() { } #ifdef DEBUG_ENABLED -Error SceneDebugger::parse_message(const String &p_msg, const Array &p_args) { +Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Array &p_args, bool &r_captured) { SceneTree *scene_tree = SceneTree::get_singleton(); if (!scene_tree) return ERR_UNCONFIGURED; LiveEditor *live_editor = LiveEditor::get_singleton(); if (!live_editor) return ERR_UNCONFIGURED; + + r_captured = true; if (p_msg == "request_scene_tree") { // Scene tree live_editor->_send_tree(); @@ -171,7 +177,7 @@ Error SceneDebugger::parse_message(const String &p_msg, const Array &p_args) { ERR_FAIL_COND_V(p_args.size() < 4, ERR_INVALID_DATA); live_editor->_reparent_node_func(p_args[0], p_args[1], p_args[2], p_args[3]); } else { - return ERR_SKIP; + r_captured = false; } return OK; } @@ -180,7 +186,6 @@ void SceneDebugger::_save_node(ObjectID id, const String &p_path) { Node *node = Object::cast_to<Node>(ObjectDB::get_instance(id)); ERR_FAIL_COND(!node); - WARN_PRINT("SAVING " + itos(id) + " TO " + p_path); Ref<PackedScene> ps = memnew(PackedScene); ps->pack(node); ResourceSaver::save(p_path, ps); @@ -193,7 +198,7 @@ void SceneDebugger::_send_object_id(ObjectID p_id, int p_max_size) { Array arr; obj.serialize(arr); - ScriptDebugger::get_singleton()->send_message("inspect_object", arr); + EngineDebugger::get_singleton()->send_message("scene:inspect_object", arr); } void SceneDebugger::_set_object_property(ObjectID p_id, const String &p_property, const Variant &p_value) { @@ -216,7 +221,7 @@ void SceneDebugger::add_to_cache(const String &p_filename, Node *p_node) { if (!debugger) return; - if (ScriptDebugger::get_singleton() && p_filename != String()) { + if (EngineDebugger::get_script_debugger() && p_filename != String()) { debugger->live_scene_edit_cache[p_filename].insert(p_node); } } @@ -225,8 +230,8 @@ void SceneDebugger::remove_from_cache(const String &p_filename, Node *p_node) { if (!debugger) return; - Map<String, Set<Node *> > &edit_cache = debugger->live_scene_edit_cache; - Map<String, Set<Node *> >::Element *E = edit_cache.find(p_filename); + Map<String, Set<Node *>> &edit_cache = debugger->live_scene_edit_cache; + Map<String, Set<Node *>>::Element *E = edit_cache.find(p_filename); if (E) { E->get().erase(p_node); if (E->get().size() == 0) { @@ -234,8 +239,8 @@ void SceneDebugger::remove_from_cache(const String &p_filename, Node *p_node) { } } - Map<Node *, Map<ObjectID, Node *> > &remove_list = debugger->live_edit_remove_list; - Map<Node *, Map<ObjectID, Node *> >::Element *F = remove_list.find(p_node); + Map<Node *, Map<ObjectID, Node *>> &remove_list = debugger->live_edit_remove_list; + Map<Node *, Map<ObjectID, Node *>>::Element *F = remove_list.find(p_node); if (F) { for (Map<ObjectID, Node *>::Element *G = F->get().front(); G; G = G->next()) { @@ -288,8 +293,8 @@ SceneDebuggerObject::SceneDebuggerObject(ObjectID p_id) { } void SceneDebuggerObject::_parse_script_properties(Script *p_script, ScriptInstance *p_instance) { - typedef Map<const Script *, Set<StringName> > ScriptMemberMap; - typedef Map<const Script *, Map<StringName, Variant> > ScriptConstantsMap; + typedef Map<const Script *, Set<StringName>> ScriptMemberMap; + typedef Map<const Script *, Map<StringName, Variant>> ScriptConstantsMap; ScriptMemberMap members; if (p_instance) { @@ -487,7 +492,7 @@ void LiveEditor::_send_tree() { // Encoded as a flat list depth fist. SceneDebuggerTree tree(scene_tree->root); tree.serialize(arr); - ScriptDebugger::get_singleton()->send_message("scene_tree", arr); + EngineDebugger::get_singleton()->send_message("scene:scene_tree", arr); } void LiveEditor::_node_path_func(const NodePath &p_path, int p_id) { @@ -514,7 +519,7 @@ void LiveEditor::_node_set_func(int p_id, const StringName &p_prop, const Varian if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); - Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene); + Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene); if (!E) return; //scene not editable @@ -552,7 +557,7 @@ void LiveEditor::_node_call_func(int p_id, const StringName &p_method, VARIANT_A if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); - Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene); + Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene); if (!E) return; //scene not editable @@ -625,7 +630,7 @@ void LiveEditor::_create_node_func(const NodePath &p_parent, const String &p_typ if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); - Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene); + Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene); if (!E) return; //scene not editable @@ -663,7 +668,7 @@ void LiveEditor::_instance_node_func(const NodePath &p_parent, const String &p_p if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); - Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene); + Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene); if (!E) return; //scene not editable @@ -696,7 +701,7 @@ void LiveEditor::_remove_node_func(const NodePath &p_at) { if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); - Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene); + Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene); if (!E) return; //scene not editable @@ -727,7 +732,7 @@ void LiveEditor::_remove_and_keep_node_func(const NodePath &p_at, ObjectID p_kee if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); - Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene); + Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene); if (!E) return; //scene not editable @@ -761,7 +766,7 @@ void LiveEditor::_restore_node_func(ObjectID p_id, const NodePath &p_at, int p_a if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); - Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene); + Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene); if (!E) return; //scene not editable @@ -778,7 +783,7 @@ void LiveEditor::_restore_node_func(ObjectID p_id, const NodePath &p_at, int p_a continue; Node *n2 = n->get_node(p_at); - Map<Node *, Map<ObjectID, Node *> >::Element *EN = live_edit_remove_list.find(n); + Map<Node *, Map<ObjectID, Node *>>::Element *EN = live_edit_remove_list.find(n); if (!EN) continue; @@ -807,7 +812,7 @@ void LiveEditor::_duplicate_node_func(const NodePath &p_at, const String &p_new_ if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); - Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene); + Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene); if (!E) return; //scene not editable @@ -840,7 +845,7 @@ void LiveEditor::_reparent_node_func(const NodePath &p_at, const NodePath &p_new if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); - Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene); + Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene); if (!E) return; //scene not editable diff --git a/scene/debugger/scene_debugger.h b/scene/debugger/scene_debugger.h index d22f8e8e18..e295510960 100644 --- a/scene/debugger/scene_debugger.h +++ b/scene/debugger/scene_debugger.h @@ -34,9 +34,10 @@ #include "core/array.h" #include "core/object.h" #include "core/pair.h" -#include "core/script_language.h" #include "core/ustring.h" +class Script; + class SceneDebugger { public: @@ -50,7 +51,7 @@ private: static void _send_object_id(ObjectID p_id, int p_max_size = 1 << 20); public: - static Error parse_message(const String &p_msg, const Array &p_args); + static Error parse_message(void *p_user, const String &p_msg, const Array &p_args, bool &r_captured); static void add_to_cache(const String &p_filename, Node *p_node); static void remove_from_cache(const String &p_filename, Node *p_node); #endif @@ -112,8 +113,8 @@ private: NodePath live_edit_root; String live_edit_scene; - Map<String, Set<Node *> > live_scene_edit_cache; - Map<Node *, Map<ObjectID, Node *> > live_edit_remove_list; + Map<String, Set<Node *>> live_scene_edit_cache; + Map<Node *, Map<ObjectID, Node *>> live_edit_remove_list; void _send_tree(); diff --git a/scene/gui/control.h b/scene/gui/control.h index 67e8ed0d27..15a32b8f67 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -198,10 +198,10 @@ private: NodePath focus_next; NodePath focus_prev; - HashMap<StringName, Ref<Texture2D> > icon_override; - HashMap<StringName, Ref<Shader> > shader_override; - HashMap<StringName, Ref<StyleBox> > style_override; - HashMap<StringName, Ref<Font> > font_override; + HashMap<StringName, Ref<Texture2D>> icon_override; + HashMap<StringName, Ref<Shader>> shader_override; + HashMap<StringName, Ref<StyleBox>> style_override; + HashMap<StringName, Ref<Font>> font_override; HashMap<StringName, Color> color_override; HashMap<StringName, int> constant_override; diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 409aec0ca6..dd439208af 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -330,7 +330,7 @@ private: ItemMeta *meta_hovering; Variant current_meta; - Vector<Ref<RichTextEffect> > custom_effects; + Vector<Ref<RichTextEffect>> custom_effects; void _invalidate_current_line(ItemFrame *p_frame); void _validate_line_caches(ItemFrame *p_frame); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 5e925bf37f..06691d09be 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1856,6 +1856,7 @@ void TextEdit::_consume_pair_symbol(CharType ch) { bool in_single_quote = false; bool in_double_quote = false; + bool found_comment = false; int c = 0; while (c < line.length()) { @@ -1865,6 +1866,9 @@ void TextEdit::_consume_pair_symbol(CharType ch) { if (cursor.column == c) { break; } + } else if (!in_single_quote && !in_double_quote && line[c] == '#') { + found_comment = true; + break; } else { if (line[c] == '\'' && !in_double_quote) { in_single_quote = !in_single_quote; @@ -1880,7 +1884,15 @@ void TextEdit::_consume_pair_symbol(CharType ch) { } } - // Disallow inserting duplicated quotes while already in string + // Do not need to duplicate quotes while in comments + if (found_comment) { + insert_text_at_cursor(ch_single); + cursor_set_column(cursor_position_to_move); + + return; + } + + // Disallow inserting duplicated quotes while already in string if ((in_single_quote || in_double_quote) && (ch == '"' || ch == '\'')) { insert_text_at_cursor(ch_single); cursor_set_column(cursor_position_to_move); @@ -2517,13 +2529,11 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { String new_word = get_word_at_pos(mm->get_position()); if (new_word != highlighted_word) { - highlighted_word = new_word; - update(); + emit_signal("symbol_validate", new_word); } } else { if (highlighted_word != String()) { - highlighted_word = String(); - update(); + set_highlighted_word(String()); } } } @@ -2572,13 +2582,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (select_identifiers_enabled) { if (k->is_pressed() && !dragging_minimap && !dragging_selection) { - - highlighted_word = get_word_at_pos(get_local_mouse_position()); - update(); - + emit_signal("symbol_validate", get_word_at_pos(get_local_mouse_position())); } else { - highlighted_word = String(); - update(); + set_highlighted_word(String()); } } } @@ -6996,6 +7002,11 @@ void TextEdit::menu_option(int p_option) { } } +void TextEdit::set_highlighted_word(const String &new_word) { + highlighted_word = new_word; + update(); +} + void TextEdit::set_select_identifiers_on_hover(bool p_enable) { select_identifiers_enabled = p_enable; @@ -7213,6 +7224,7 @@ void TextEdit::_bind_methods() { ADD_SIGNAL(MethodInfo("breakpoint_toggled", PropertyInfo(Variant::INT, "row"))); ADD_SIGNAL(MethodInfo("symbol_lookup", PropertyInfo(Variant::STRING, "symbol"), PropertyInfo(Variant::INT, "row"), PropertyInfo(Variant::INT, "column"))); ADD_SIGNAL(MethodInfo("info_clicked", PropertyInfo(Variant::INT, "row"), PropertyInfo(Variant::STRING, "info"))); + ADD_SIGNAL(MethodInfo("symbol_validate", PropertyInfo(Variant::STRING, "symbol"))); BIND_ENUM_CONSTANT(MENU_CUT); BIND_ENUM_CONSTANT(MENU_COPY); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 6e267f5a47..7d096f7897 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -268,7 +268,7 @@ private: } cache; Map<int, int> color_region_cache; - Map<int, Map<int, HighlighterInfo> > syntax_highlighting_cache; + Map<int, Map<int, HighlighterInfo>> syntax_highlighting_cache; struct TextOperation { @@ -585,6 +585,7 @@ public: bool is_insert_text_operation(); + void set_highlighted_word(const String &new_word); void set_text(String p_text); void insert_text_at_cursor(const String &p_text); void insert_at(const String &p_text, int at); diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 370cf6a2a4..f472de220b 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -30,6 +30,7 @@ #include "scene_tree.h" +#include "core/debugger/engine_debugger.h" #include "core/io/marshalls.h" #include "core/io/resource_loader.h" #include "core/message_queue.h" @@ -38,7 +39,6 @@ #include "core/os/os.h" #include "core/print_string.h" #include "core/project_settings.h" -#include "core/script_debugger_remote.h" #include "main/input_default.h" #include "node.h" #include "scene/debugger/scene_debugger.h" @@ -172,7 +172,7 @@ void SceneTree::_flush_ugc() { while (unique_group_calls.size()) { - Map<UGCall, Vector<Variant> >::Element *E = unique_group_calls.front(); + Map<UGCall, Vector<Variant>>::Element *E = unique_group_calls.front(); Variant v[VARIANT_ARG_MAX]; for (int i = 0; i < E->get().size(); i++) @@ -432,11 +432,11 @@ void SceneTree::input_event(const Ref<InputEvent> &p_event) { call_group_flags(GROUP_CALL_REALTIME, "_viewports", "_vp_input", ev); //special one for GUI, as controls use their own process check - if (ScriptDebugger::get_singleton() && ScriptDebugger::get_singleton()->is_remote()) { + if (EngineDebugger::is_active()) { //quit from game window using F8 Ref<InputEventKey> k = ev; if (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_keycode() == KEY_F8) { - ScriptDebugger::get_singleton()->request_quit(); + EngineDebugger::get_singleton()->send_message("request_quit", Array()); } } @@ -546,11 +546,11 @@ bool SceneTree::idle(float p_time) { //go through timers - List<Ref<SceneTreeTimer> >::Element *L = timers.back(); //last element + List<Ref<SceneTreeTimer>>::Element *L = timers.back(); //last element - for (List<Ref<SceneTreeTimer> >::Element *E = timers.front(); E;) { + for (List<Ref<SceneTreeTimer>>::Element *E = timers.front(); E;) { - List<Ref<SceneTreeTimer> >::Element *N = E->next(); + List<Ref<SceneTreeTimer>>::Element *N = E->next(); if (pause && !E->get()->is_pause_mode_process()) { if (E == L) { break; //break on last, so if new timers were added during list traversal, ignore them. @@ -625,7 +625,7 @@ void SceneTree::finish() { } // cleanup timers - for (List<Ref<SceneTreeTimer> >::Element *E = timers.front(); E; E = E->next()) { + for (List<Ref<SceneTreeTimer>>::Element *E = timers.front(); E; E = E->next()) { E->get()->release_connections(); } timers.clear(); @@ -1737,10 +1737,6 @@ SceneTree::SceneTree() { last_screen_size = Size2(OS::get_singleton()->get_window_size().width, OS::get_singleton()->get_window_size().height); _update_root_rect(); - if (ScriptDebugger::get_singleton()) { - ScriptDebugger::get_singleton()->set_multiplayer(multiplayer); - } - root->set_physics_object_picking(GLOBAL_DEF("physics/common/enable_object_picking", true)); #ifdef TOOLS_ENABLED diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h index 1bef0d3131..2f805d074f 100644 --- a/scene/main/scene_tree.h +++ b/scene/main/scene_tree.h @@ -157,7 +157,7 @@ private: List<ObjectID> delete_queue; - Map<UGCall, Vector<Variant> > unique_group_calls; + Map<UGCall, Vector<Variant>> unique_group_calls; bool ugc_locked; void _flush_ugc(); @@ -181,7 +181,7 @@ private: void _change_scene(Node *p_to); //void _call_group(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,const Variant& p_arg1,const Variant& p_arg2); - List<Ref<SceneTreeTimer> > timers; + List<Ref<SceneTreeTimer>> timers; ///network/// diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index e027ec9b4b..dfd55e2577 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -31,6 +31,7 @@ #include "viewport.h" #include "core/core_string_names.h" +#include "core/debugger/engine_debugger.h" #include "core/os/input.h" #include "core/os/os.h" #include "core/project_settings.h" @@ -421,7 +422,7 @@ void Viewport::_notification(int p_what) { // if no mouse event exists, create a motion one. This is necessary because objects or camera may have moved. // while this extra event is sent, it is checked if both camera and last object and last ID did not move. If nothing changed, the event is discarded to avoid flooding with unnecessary motion events every frame bool has_mouse_event = false; - for (List<Ref<InputEvent> >::Element *E = physics_picking_events.front(); E; E = E->next()) { + for (List<Ref<InputEvent>>::Element *E = physics_picking_events.front(); E; E = E->next()) { Ref<InputEventMouse> m = E->get(); if (m.is_valid()) { has_mouse_event = true; @@ -1927,12 +1928,12 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { mb->set_position(pos); #ifdef DEBUG_ENABLED - if (ScriptDebugger::get_singleton() && gui.mouse_focus) { + if (EngineDebugger::get_singleton() && gui.mouse_focus) { Array arr; arr.push_back(gui.mouse_focus->get_path()); arr.push_back(gui.mouse_focus->get_class()); - ScriptDebugger::get_singleton()->send_message("click_ctrl", arr); + EngineDebugger::get_singleton()->send_message("scene:click_ctrl", arr); } #endif diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 30c872b6ed..e511ce1b17 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -235,7 +235,7 @@ private: bool snap_controls_to_pixels; bool physics_object_picking; - List<Ref<InputEvent> > physics_picking_events; + List<Ref<InputEvent>> physics_picking_events; ObjectID physics_object_capture; ObjectID physics_object_over; Transform physics_last_object_transform; diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index ba1f738115..aa4c9bf225 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -1705,7 +1705,7 @@ float Animation::_cubic_interpolate(const float &p_pre_a, const float &p_a, cons } template <class T> -T Animation::_interpolate(const Vector<TKey<T> > &p_keys, float p_time, InterpolationType p_interp, bool p_loop_wrap, bool *p_ok) const { +T Animation::_interpolate(const Vector<TKey<T>> &p_keys, float p_time, InterpolationType p_interp, bool p_loop_wrap, bool *p_ok) const { int len = _find(p_keys, length) + 1; // try to find last key (there may be more past the end) diff --git a/scene/resources/animation.h b/scene/resources/animation.h index ea4f92878d..36d5df52df 100644 --- a/scene/resources/animation.h +++ b/scene/resources/animation.h @@ -105,7 +105,7 @@ private: struct TransformTrack : public Track { - Vector<TKey<TransformKey> > transforms; + Vector<TKey<TransformKey>> transforms; TransformTrack() { type = TYPE_TRANSFORM; } }; @@ -116,7 +116,7 @@ private: UpdateMode update_mode; bool update_on_seek; - Vector<TKey<Variant> > values; + Vector<TKey<Variant>> values; ValueTrack() { type = TYPE_VALUE; @@ -148,7 +148,7 @@ private: struct BezierTrack : public Track { - Vector<TKey<BezierKey> > values; + Vector<TKey<BezierKey>> values; BezierTrack() { type = TYPE_BEZIER; @@ -169,7 +169,7 @@ private: struct AudioTrack : public Track { - Vector<TKey<AudioKey> > values; + Vector<TKey<AudioKey>> values; AudioTrack() { type = TYPE_AUDIO; @@ -180,7 +180,7 @@ private: struct AnimationTrack : public Track { - Vector<TKey<StringName> > values; + Vector<TKey<StringName>> values; AnimationTrack() { type = TYPE_ANIMATION; @@ -216,7 +216,7 @@ private: _FORCE_INLINE_ float _cubic_interpolate(const float &p_pre_a, const float &p_a, const float &p_b, const float &p_post_b, float p_c) const; template <class T> - _FORCE_INLINE_ T _interpolate(const Vector<TKey<T> > &p_keys, float p_time, InterpolationType p_interp, bool p_loop_wrap, bool *p_ok) const; + _FORCE_INLINE_ T _interpolate(const Vector<TKey<T>> &p_keys, float p_time, InterpolationType p_interp, bool p_loop_wrap, bool *p_ok) const; template <class T> _FORCE_INLINE_ void _track_get_key_indices_in_range(const Vector<T> &p_array, float from_time, float to_time, List<int> *p_indices) const; diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index ed25729c40..a68b750b31 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -258,7 +258,7 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in float srate = base->mix_rate; srate *= p_rate_scale; float fincrement = srate / base_rate; - int32_t increment = int32_t(fincrement * MIX_FRAC_LEN); + int32_t increment = int32_t(MAX(fincrement * MIX_FRAC_LEN, 1)); increment *= sign; //looping diff --git a/scene/resources/bit_map.cpp b/scene/resources/bit_map.cpp index 6730f86e0c..d45f36dfd1 100644 --- a/scene/resources/bit_map.cpp +++ b/scene/resources/bit_map.cpp @@ -493,7 +493,7 @@ static void fill_bits(const BitMap *p_src, Ref<BitMap> &p_map, const Point2i &p_ print_verbose("BitMap: Max stack size: " + itos(stack.size())); } -Vector<Vector<Vector2> > BitMap::clip_opaque_to_polygons(const Rect2 &p_rect, float p_epsilon) const { +Vector<Vector<Vector2>> BitMap::clip_opaque_to_polygons(const Rect2 &p_rect, float p_epsilon) const { Rect2i r = Rect2i(0, 0, width, height).clip(p_rect); print_verbose("BitMap: Rect: " + r); @@ -503,7 +503,7 @@ Vector<Vector<Vector2> > BitMap::clip_opaque_to_polygons(const Rect2 &p_rect, fl fill.instance(); fill->create(get_size()); - Vector<Vector<Vector2> > polygons; + Vector<Vector<Vector2>> polygons; for (int i = r.position.y; i < r.position.y + r.size.height; i++) { for (int j = r.position.x; j < r.position.x + r.size.width; j++) { if (!fill->get_bit(Point2(j, i)) && get_bit(Point2(j, i))) { @@ -591,7 +591,7 @@ void BitMap::shrink_mask(int p_pixels, const Rect2 &p_rect) { Array BitMap::_opaque_to_polygons_bind(const Rect2 &p_rect, float p_epsilon) const { - Vector<Vector<Vector2> > result = clip_opaque_to_polygons(p_rect, p_epsilon); + Vector<Vector<Vector2>> result = clip_opaque_to_polygons(p_rect, p_epsilon); // Convert result to bindable types diff --git a/scene/resources/bit_map.h b/scene/resources/bit_map.h index ed332dffa4..05313a0cff 100644 --- a/scene/resources/bit_map.h +++ b/scene/resources/bit_map.h @@ -72,7 +72,7 @@ public: void blit(const Vector2 &p_pos, const Ref<BitMap> &p_bitmap); Ref<Image> convert_to_image() const; - Vector<Vector<Vector2> > clip_opaque_to_polygons(const Rect2 &p_rect, float p_epsilon = 2.0) const; + Vector<Vector<Vector2>> clip_opaque_to_polygons(const Rect2 &p_rect, float p_epsilon = 2.0) const; BitMap(); }; diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp index a68eb77378..d19eae0d4f 100644 --- a/scene/resources/curve.cpp +++ b/scene/resources/curve.cpp @@ -941,7 +941,7 @@ PackedVector2Array Curve2D::tessellate(int p_max_stages, float p_tolerance) cons if (points.size() == 0) { return tess; } - Vector<Map<float, Vector2> > midpoints; + Vector<Map<float, Vector2>> midpoints; midpoints.resize(points.size() - 1); @@ -1615,7 +1615,7 @@ PackedVector3Array Curve3D::tessellate(int p_max_stages, float p_tolerance) cons if (points.size() == 0) { return tess; } - Vector<Map<float, Vector3> > midpoints; + Vector<Map<float, Vector3>> midpoints; midpoints.resize(points.size() - 1); diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 04bc95ade6..9f5b49c4c3 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -38,7 +38,7 @@ #include "font_hidpi.inc" #include "font_lodpi.inc" -typedef Map<const void *, Ref<ImageTexture> > TexCacheMap; +typedef Map<const void *, Ref<ImageTexture>> TexCacheMap; static TexCacheMap *tex_cache; static float scale = 1; diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index ebd5b02dbc..410c4990a2 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -115,7 +115,7 @@ DynamicFontData::~DynamicFontData() { } //////////////////// -HashMap<String, Vector<uint8_t> > DynamicFontAtSize::_fontdata; +HashMap<String, Vector<uint8_t>> DynamicFontAtSize::_fontdata; Error DynamicFontAtSize::_load() { @@ -243,7 +243,7 @@ float DynamicFontAtSize::get_descent() const { return descent; } -const Pair<const DynamicFontAtSize::Character *, DynamicFontAtSize *> DynamicFontAtSize::_find_char_with_font(CharType p_char, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks) const { +const Pair<const DynamicFontAtSize::Character *, DynamicFontAtSize *> DynamicFontAtSize::_find_char_with_font(CharType p_char, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks) const { const Character *chr = char_map.getptr(p_char); ERR_FAIL_COND_V(!chr, (Pair<const Character *, DynamicFontAtSize *>(NULL, NULL))); @@ -275,7 +275,7 @@ const Pair<const DynamicFontAtSize::Character *, DynamicFontAtSize *> DynamicFon return Pair<const Character *, DynamicFontAtSize *>(chr, const_cast<DynamicFontAtSize *>(this)); } -Size2 DynamicFontAtSize::get_char_size(CharType p_char, CharType p_next, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks) const { +Size2 DynamicFontAtSize::get_char_size(CharType p_char, CharType p_next, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks) const { if (!valid) return Size2(1, 1); @@ -294,7 +294,7 @@ Size2 DynamicFontAtSize::get_char_size(CharType p_char, CharType p_next, const V return ret; } -float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks, bool p_advance_only, bool p_outline) const { +float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks, bool p_advance_only, bool p_outline) const { if (!valid) return 0; @@ -850,7 +850,7 @@ float DynamicFont::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_ if (!font_at_size.is_valid()) return 0; - const Vector<Ref<DynamicFontAtSize> > &fallbacks = p_outline && outline_cache_id.outline_size > 0 ? fallback_outline_data_at_size : fallback_data_at_size; + const Vector<Ref<DynamicFontAtSize>> &fallbacks = p_outline && outline_cache_id.outline_size > 0 ? fallback_outline_data_at_size : fallback_data_at_size; Color color = p_outline && outline_cache_id.outline_size > 0 ? p_modulate * outline_color : p_modulate; // If requested outline draw, but no outline is present, simply return advance without drawing anything @@ -1025,7 +1025,7 @@ void DynamicFont::finish_dynamic_fonts() { void DynamicFont::update_oversampling() { - Vector<Ref<DynamicFont> > changed; + Vector<Ref<DynamicFont>> changed; { MutexLock lock(dynamic_font_mutex); diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h index c10f1e6681..88b1df039e 100644 --- a/scene/resources/dynamic_font.h +++ b/scene/resources/dynamic_font.h @@ -161,7 +161,7 @@ class DynamicFontAtSize : public Reference { int y; }; - const Pair<const Character *, DynamicFontAtSize *> _find_char_with_font(CharType p_char, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks) const; + const Pair<const Character *, DynamicFontAtSize *> _find_char_with_font(CharType p_char, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks) const; Character _make_outline_char(CharType p_char); TexturePosition _find_texture_pos_for_glyph(int p_color_size, Image::Format p_image_format, int p_width, int p_height); Character _bitmap_to_character(FT_Bitmap bitmap, int yofs, int xofs, float advance); @@ -177,7 +177,7 @@ class DynamicFontAtSize : public Reference { Ref<DynamicFontData> font; DynamicFontData::CacheID id; - static HashMap<String, Vector<uint8_t> > _fontdata; + static HashMap<String, Vector<uint8_t>> _fontdata; Error _load(); public: @@ -188,9 +188,9 @@ public: float get_ascent() const; float get_descent() const; - Size2 get_char_size(CharType p_char, CharType p_next, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks) const; + Size2 get_char_size(CharType p_char, CharType p_next, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks) const; - float draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks, bool p_advance_only = false, bool p_outline = false) const; + float draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks, bool p_advance_only = false, bool p_outline = false) const; void set_texture_flags(uint32_t p_flags); void update_oversampling(); @@ -218,9 +218,9 @@ private: Ref<DynamicFontAtSize> data_at_size; Ref<DynamicFontAtSize> outline_data_at_size; - Vector<Ref<DynamicFontData> > fallbacks; - Vector<Ref<DynamicFontAtSize> > fallback_data_at_size; - Vector<Ref<DynamicFontAtSize> > fallback_outline_data_at_size; + Vector<Ref<DynamicFontData>> fallbacks; + Vector<Ref<DynamicFontAtSize>> fallback_data_at_size; + Vector<Ref<DynamicFontAtSize>> fallback_outline_data_at_size; DynamicFontData::CacheID cache_id; DynamicFontData::CacheID outline_cache_id; diff --git a/scene/resources/font.h b/scene/resources/font.h index 85b295b5f8..076532f390 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -108,7 +108,7 @@ class BitmapFont : public Font { GDCLASS(BitmapFont, Font); RES_BASE_EXTENSION("font"); - Vector<Ref<Texture2D> > textures; + Vector<Ref<Texture2D>> textures; public: struct Character { diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index a063b7f74f..f93b7ced98 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -252,10 +252,12 @@ Ref<Shape> Mesh::create_trimesh_shape() const { Vector<Vector3> face_points; face_points.resize(faces.size() * 3); - for (int i = 0; i < face_points.size(); i++) { + for (int i = 0; i < face_points.size(); i += 3) { Face3 f = faces.get(i / 3); - face_points.set(i, f.vertex[i % 3]); + face_points.set(i, f.vertex[0]); + face_points.set(i + 1, f.vertex[1]); + face_points.set(i + 2, f.vertex[2]); } Ref<ConcavePolygonShape> shape = memnew(ConcavePolygonShape); @@ -539,21 +541,15 @@ void Mesh::clear_cache() const { debug_lines.clear(); } -Vector<Ref<Shape> > Mesh::convex_decompose() const { +Vector<Ref<Shape>> Mesh::convex_decompose() const { - ERR_FAIL_COND_V(!convex_composition_function, Vector<Ref<Shape> >()); + ERR_FAIL_COND_V(!convex_composition_function, Vector<Ref<Shape>>()); - Vector<Face3> faces = get_faces(); - Vector<Face3> f3; - f3.resize(faces.size()); - const Face3 *f = faces.ptr(); - for (int i = 0; i < f3.size(); i++) { - f3.write[i] = f[i]; - } + const Vector<Face3> faces = get_faces(); - Vector<Vector<Face3> > decomposed = convex_composition_function(f3); + Vector<Vector<Face3>> decomposed = convex_composition_function(faces); - Vector<Ref<Shape> > ret; + Vector<Ref<Shape>> ret; for (int i = 0; i < decomposed.size(); i++) { Set<Vector3> points; @@ -792,7 +788,7 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) { if (d.has("index_count")) index_count = d["index_count"]; - Vector<Vector<uint8_t> > blend_shapes; + Vector<Vector<uint8_t>> blend_shapes; if (d.has("blend_shape_data")) { Array blend_shape_data = d["blend_shape_data"]; @@ -914,7 +910,7 @@ void ArrayMesh::_create_if_empty() const { void ArrayMesh::_set_surfaces(const Array &p_surfaces) { Vector<VS::SurfaceData> surface_data; - Vector<Ref<Material> > surface_materials; + Vector<Ref<Material>> surface_materials; Vector<String> surface_names; Vector<bool> surface_2d; @@ -1106,7 +1102,7 @@ void ArrayMesh::_recompute_aabb() { #ifndef _MSC_VER #warning need to add binding to add_surface using future MeshSurfaceData object #endif -void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t> > &p_blend_shapes, const Vector<AABB> &p_bone_aabb, const Vector<VS::SurfaceData::LOD> &p_lods) { +void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes, const Vector<AABB> &p_bone_aabb, const Vector<VS::SurfaceData::LOD> &p_lods) { _create_if_empty(); @@ -1345,7 +1341,7 @@ void ArrayMesh::regen_normalmaps() { if (surfaces.size() == 0) { return; } - Vector<Ref<SurfaceTool> > surfs; + Vector<Ref<SurfaceTool>> surfs; for (int i = 0; i < get_surface_count(); i++) { Ref<SurfaceTool> st = memnew(SurfaceTool); @@ -1383,7 +1379,7 @@ Error ArrayMesh::lightmap_unwrap(const Transform &p_base_transform, float p_texe Vector<int> indices; Vector<int> face_materials; Vector<float> uv; - Vector<Pair<int, int> > uv_index; + Vector<Pair<int, int>> uv_index; Vector<ArrayMeshLightmapSurface> surfaces; for (int i = 0; i < get_surface_count(); i++) { @@ -1476,7 +1472,7 @@ Error ArrayMesh::lightmap_unwrap(const Transform &p_base_transform, float p_texe clear_surfaces(); //create surfacetools for each surface.. - Vector<Ref<SurfaceTool> > surfaces_tools; + Vector<Ref<SurfaceTool>> surfaces_tools; for (int i = 0; i < surfaces.size(); i++) { Ref<SurfaceTool> st; diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h index 0e356c16a6..e0cc214301 100644 --- a/scene/resources/mesh.h +++ b/scene/resources/mesh.h @@ -142,11 +142,11 @@ public: Size2 get_lightmap_size_hint() const; void clear_cache() const; - typedef Vector<Vector<Face3> > (*ConvexDecompositionFunc)(const Vector<Face3> &); + typedef Vector<Vector<Face3>> (*ConvexDecompositionFunc)(const Vector<Face3> &); static ConvexDecompositionFunc convex_composition_function; - Vector<Ref<Shape> > convex_decompose() const; + Vector<Ref<Shape>> convex_decompose() const; Mesh(); }; @@ -193,7 +193,7 @@ protected: public: void add_surface_from_arrays(PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), const Dictionary &p_lods = Dictionary(), uint32_t p_flags = ARRAY_COMPRESS_DEFAULT); - void add_surface(uint32_t p_format, PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t> > &p_blend_shapes = Vector<Vector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>(), const Vector<VS::SurfaceData::LOD> &p_lods = Vector<VS::SurfaceData::LOD>()); + void add_surface(uint32_t p_format, PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes = Vector<Vector<uint8_t>>(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>(), const Vector<VS::SurfaceData::LOD> &p_lods = Vector<VS::SurfaceData::LOD>()); Array surface_get_arrays(int p_surface) const; Array surface_get_blend_shape_arrays(int p_surface) const; diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 0538f679cc..7059682904 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -82,7 +82,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const { bool gen_node_path_cache = p_edit_state != GEN_EDIT_STATE_DISABLED && node_path_cache.empty(); - Map<Ref<Resource>, Ref<Resource> > resources_local_to_scene; + Map<Ref<Resource>, Ref<Resource>> resources_local_to_scene; for (int i = 0; i < nc; i++) { @@ -201,7 +201,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const { //https://github.com/godotengine/godot/issues/2958 //store old state - List<Pair<StringName, Variant> > old_state; + List<Pair<StringName, Variant>> old_state; if (node->get_script_instance()) { node->get_script_instance()->get_property_state(old_state); } @@ -209,7 +209,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const { node->set(snames[nprops[j].name], props[nprops[j].value], &valid); //restore old state for new script, if exists - for (List<Pair<StringName, Variant> >::Element *E = old_state.front(); E; E = E->next()) { + for (List<Pair<StringName, Variant>>::Element *E = old_state.front(); E; E = E->next()) { node->set(E->get().first, E->get().second); } } else { @@ -222,7 +222,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const { if (res.is_valid()) { if (res->is_local_to_scene()) { - Map<Ref<Resource>, Ref<Resource> >::Element *E = resources_local_to_scene.find(res); + Map<Ref<Resource>, Ref<Resource>>::Element *E = resources_local_to_scene.find(res); if (E) { value = E->get(); @@ -302,7 +302,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const { } } - for (Map<Ref<Resource>, Ref<Resource> >::Element *E = resources_local_to_scene.front(); E; E = E->next()) { + for (Map<Ref<Resource>, Ref<Resource>>::Element *E = resources_local_to_scene.front(); E; E = E->next()) { E->get()->setup_local_to_scene(); } diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index 00fc016ca1..959ee214a2 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -150,7 +150,7 @@ Array PrimitiveMesh::surface_get_blend_shape_arrays(int p_surface) const { uint32_t PrimitiveMesh::surface_get_format(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, 1, 0); - return VS::ARRAY_COMPRESS_DEFAULT; + return VS::ARRAY_FORMAT_VERTEX | VS::ARRAY_FORMAT_NORMAL | VS::ARRAY_FORMAT_TANGENT | VS::ARRAY_FORMAT_TEX_UV | VS::ARRAY_FORMAT_INDEX | VS::ARRAY_COMPRESS_DEFAULT; } Mesh::PrimitiveType PrimitiveMesh::surface_get_primitive_type(int p_idx) const { diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp index 8f76c0165f..e61a1e6880 100644 --- a/scene/resources/shader.cpp +++ b/scene/resources/shader.cpp @@ -121,7 +121,7 @@ Ref<Texture2D> Shader::get_default_texture_param(const StringName &p_param) cons void Shader::get_default_texture_param_list(List<StringName> *r_textures) const { - for (const Map<StringName, Ref<Texture2D> >::Element *E = default_textures.front(); E; E = E->next()) { + for (const Map<StringName, Ref<Texture2D>>::Element *E = default_textures.front(); E; E = E->next()) { r_textures->push_back(E->key()); } diff --git a/scene/resources/shader.h b/scene/resources/shader.h index 5050632dd5..84908852da 100644 --- a/scene/resources/shader.h +++ b/scene/resources/shader.h @@ -59,7 +59,7 @@ private: // conversion fast and save memory. mutable bool params_cache_dirty; mutable Map<StringName, StringName> params_cache; //map a shader param to a material param.. - Map<StringName, Ref<Texture2D> > default_textures; + Map<StringName, Ref<Texture2D>> default_textures; virtual void _update_shader() const; //used for visual shader protected: diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index cb827c4b0b..1c5b2abad2 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -370,7 +370,7 @@ Ref<Image> StreamTexture::load_image_from_file(FileAccess *f, int p_size_limit) int sh = h; //mipmaps need to be read independently, they will be later combined - Vector<Ref<Image> > mipmap_images; + Vector<Ref<Image>> mipmap_images; int total_size = 0; bool first = true; @@ -1899,7 +1899,7 @@ uint32_t TextureLayered::get_layers() const { } Error TextureLayered::_create_from_images(const Array &p_images) { - Vector<Ref<Image> > images; + Vector<Ref<Image>> images; for (int i = 0; i < p_images.size(); i++) { Ref<Image> img = p_images[i]; ERR_FAIL_COND_V(img.is_null(), ERR_INVALID_PARAMETER); @@ -1917,7 +1917,7 @@ Array TextureLayered::_get_images() const { return images; } -Error TextureLayered::create_from_images(Vector<Ref<Image> > p_images) { +Error TextureLayered::create_from_images(Vector<Ref<Image>> p_images) { int new_layers = p_images.size(); ERR_FAIL_COND_V(new_layers == 0, ERR_INVALID_PARAMETER); @@ -2077,7 +2077,7 @@ RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String Image::Format format = Image::Format(f->get_32()); uint32_t compression = f->get_32(); // 0 - lossless (PNG), 1 - vram, 2 - uncompressed - Vector<Ref<Image> > images; + Vector<Ref<Image>> images; for (int layer = 0; layer < td; layer++) { Ref<Image> image; @@ -2087,7 +2087,7 @@ RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String //look for a PNG file inside int mipmaps = f->get_32(); - Vector<Ref<Image> > mipmap_images; + Vector<Ref<Image>> mipmap_images; for (int i = 0; i < mipmaps; i++) { uint32_t size = f->get_32(); diff --git a/scene/resources/texture.h b/scene/resources/texture.h index 237c02a8cd..1fb8742cec 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -376,7 +376,7 @@ public: uint32_t get_layers() const; bool has_mipmaps() const; - Error create_from_images(Vector<Ref<Image> > p_images); + Error create_from_images(Vector<Ref<Image>> p_images); void update_layer(const Ref<Image> &p_image, int p_layer); Ref<Image> get_layer_data(int p_layer) const; diff --git a/scene/resources/theme.h b/scene/resources/theme.h index 3d01f71ea0..d6d724e3f7 100644 --- a/scene/resources/theme.h +++ b/scene/resources/theme.h @@ -45,12 +45,12 @@ class Theme : public Resource { void _emit_theme_changed(); - HashMap<StringName, HashMap<StringName, Ref<Texture2D> > > icon_map; - HashMap<StringName, HashMap<StringName, Ref<StyleBox> > > style_map; - HashMap<StringName, HashMap<StringName, Ref<Font> > > font_map; - HashMap<StringName, HashMap<StringName, Ref<Shader> > > shader_map; - HashMap<StringName, HashMap<StringName, Color> > color_map; - HashMap<StringName, HashMap<StringName, int> > constant_map; + HashMap<StringName, HashMap<StringName, Ref<Texture2D>>> icon_map; + HashMap<StringName, HashMap<StringName, Ref<StyleBox>>> style_map; + HashMap<StringName, HashMap<StringName, Ref<Font>>> font_map; + HashMap<StringName, HashMap<StringName, Ref<Shader>>> shader_map; + HashMap<StringName, HashMap<StringName, Color>> color_map; + HashMap<StringName, HashMap<StringName, int>> constant_map; Vector<String> _get_icon_list(const String &p_type) const; Vector<String> _get_stylebox_list(const String &p_type) const; diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index f42b56bc83..b312aa054c 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -252,14 +252,14 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const { r_ret = p; } else if (what == "occluder_map") { Array p; - for (Map<Vector2, Ref<OccluderPolygon2D> >::Element *E = tile_map[id].autotile_data.occluder_map.front(); E; E = E->next()) { + for (Map<Vector2, Ref<OccluderPolygon2D>>::Element *E = tile_map[id].autotile_data.occluder_map.front(); E; E = E->next()) { p.push_back(E->key()); p.push_back(E->value()); } r_ret = p; } else if (what == "navpoly_map") { Array p; - for (Map<Vector2, Ref<NavigationPolygon> >::Element *E = tile_map[id].autotile_data.navpoly_map.front(); E; E = E->next()) { + for (Map<Vector2, Ref<NavigationPolygon>>::Element *E = tile_map[id].autotile_data.navpoly_map.front(); E; E = E->next()) { p.push_back(E->key()); p.push_back(E->value()); } @@ -903,9 +903,9 @@ Ref<NavigationPolygon> TileSet::tile_get_navigation_polygon(int p_id) const { return tile_map[p_id].navigation_polygon; } -const Map<Vector2, Ref<OccluderPolygon2D> > &TileSet::autotile_get_light_oclusion_map(int p_id) const { +const Map<Vector2, Ref<OccluderPolygon2D>> &TileSet::autotile_get_light_oclusion_map(int p_id) const { - static Map<Vector2, Ref<OccluderPolygon2D> > dummy; + static Map<Vector2, Ref<OccluderPolygon2D>> dummy; ERR_FAIL_COND_V(!tile_map.has(p_id), dummy); return tile_map[p_id].autotile_data.occluder_map; } @@ -932,9 +932,9 @@ Ref<NavigationPolygon> TileSet::autotile_get_navigation_polygon(int p_id, const } } -const Map<Vector2, Ref<NavigationPolygon> > &TileSet::autotile_get_navigation_map(int p_id) const { +const Map<Vector2, Ref<NavigationPolygon>> &TileSet::autotile_get_navigation_map(int p_id) const { - static Map<Vector2, Ref<NavigationPolygon> > dummy; + static Map<Vector2, Ref<NavigationPolygon>> dummy; ERR_FAIL_COND_V(!tile_map.has(p_id), dummy); return tile_map[p_id].autotile_data.navpoly_map; } @@ -1077,7 +1077,7 @@ void TileSet::_decompose_convex_shape(Ref<Shape2D> p_shape) { Ref<ConvexPolygonShape2D> convex = p_shape; if (!convex.is_valid()) return; - Vector<Vector<Vector2> > decomp = Geometry::decompose_polygon_in_convex(convex->get_points()); + Vector<Vector<Vector2>> decomp = Geometry::decompose_polygon_in_convex(convex->get_points()); if (decomp.size() > 1) { Array sub_shapes; for (int i = 0; i < decomp.size(); i++) { diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h index 8b540982a4..3c964ec667 100644 --- a/scene/resources/tile_set.h +++ b/scene/resources/tile_set.h @@ -97,8 +97,8 @@ public: int spacing; Vector2 icon_coord; Map<Vector2, uint32_t> flags; - Map<Vector2, Ref<OccluderPolygon2D> > occluder_map; - Map<Vector2, Ref<NavigationPolygon> > navpoly_map; + Map<Vector2, Ref<OccluderPolygon2D>> occluder_map; + Map<Vector2, Ref<NavigationPolygon>> navpoly_map; Map<Vector2, int> priority_map; Map<Vector2, int> z_index_map; @@ -233,7 +233,7 @@ public: void autotile_set_light_occluder(int p_id, const Ref<OccluderPolygon2D> &p_light_occluder, const Vector2 &p_coord); Ref<OccluderPolygon2D> autotile_get_light_occluder(int p_id, const Vector2 &p_coord) const; - const Map<Vector2, Ref<OccluderPolygon2D> > &autotile_get_light_oclusion_map(int p_id) const; + const Map<Vector2, Ref<OccluderPolygon2D>> &autotile_get_light_oclusion_map(int p_id) const; void tile_set_navigation_polygon_offset(int p_id, const Vector2 &p_offset); Vector2 tile_get_navigation_polygon_offset(int p_id) const; @@ -243,7 +243,7 @@ public: void autotile_set_navigation_polygon(int p_id, const Ref<NavigationPolygon> &p_navigation_polygon, const Vector2 &p_coord); Ref<NavigationPolygon> autotile_get_navigation_polygon(int p_id, const Vector2 &p_coord) const; - const Map<Vector2, Ref<NavigationPolygon> > &autotile_get_navigation_map(int p_id) const; + const Map<Vector2, Ref<NavigationPolygon>> &autotile_get_navigation_map(int p_id) const; void tile_set_z_index(int p_id, int p_z_index); int tile_get_z_index(int p_id) const; |