diff options
217 files changed, 2369 insertions, 2619 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 810284d5d0..bb4b49d9cd 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -2291,8 +2291,8 @@ void Engine::register_singleton(const StringName &p_name, Object *p_object) { s.ptr = p_object; s.user_created = true; ::Engine::get_singleton()->add_singleton(s); - ; } + void Engine::unregister_singleton(const StringName &p_name) { ERR_FAIL_COND_MSG(!has_singleton(p_name), "Attempt to remove unregistered singleton: " + String(p_name)); ERR_FAIL_COND_MSG(!::Engine::get_singleton()->is_singleton_user_created(p_name), "Attempt to remove non-user created singleton: " + String(p_name)); diff --git a/core/input/input.cpp b/core/input/input.cpp index d36d0f4da0..656bb92203 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -1145,7 +1145,6 @@ Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, J // It doesn't make sense for a full axis to map to a button, // but keeping as a default for a trigger with a positive half-axis. event.value = (shifted_positive_value * 2) - 1; - ; break; } return event; diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 5c39b2fa1b..12de2f582e 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -1417,19 +1417,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo d.get_key_list(&keys); for (const Variant &E : keys) { - /* - CharString utf8 = E->->utf8(); - - if (buf) { - encode_uint32(utf8.length()+1,buf); - buf+=4; - memcpy(buf,utf8.get_data(),utf8.length()+1); - } - - r_len+=4+utf8.length()+1; - while (r_len%4) - r_len++; //pad - */ int len; Error err = encode_variant(E, buf, len, p_full_objects, p_depth + 1); ERR_FAIL_COND_V(err, err); diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index ed58b4be7b..611f371229 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1607,11 +1607,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia d.get_key_list(&keys); for (const Variant &E : keys) { - /* - if (!_check_type(dict[E])) - continue; - */ - write_variant(f, E, resource_map, external_resources, string_map); write_variant(f, d[E], resource_map, external_resources, string_map); } diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 21bf566b1b..2419c76dd3 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -672,10 +672,6 @@ int ResourceLoader::get_import_order(const String &p_path) { if (!loader[i]->recognize_path(local_path)) { continue; } - /* - if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) - continue; - */ return loader[i]->get_import_order(p_path); } @@ -690,10 +686,6 @@ String ResourceLoader::get_import_group_file(const String &p_path) { if (!loader[i]->recognize_path(local_path)) { continue; } - /* - if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) - continue; - */ return loader[i]->get_import_group_file(p_path); } @@ -708,10 +700,6 @@ bool ResourceLoader::is_import_valid(const String &p_path) { if (!loader[i]->recognize_path(local_path)) { continue; } - /* - if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) - continue; - */ return loader[i]->is_import_valid(p_path); } @@ -726,10 +714,6 @@ bool ResourceLoader::is_imported(const String &p_path) { if (!loader[i]->recognize_path(local_path)) { continue; } - /* - if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) - continue; - */ return loader[i]->is_imported(p_path); } @@ -744,10 +728,6 @@ void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_depe if (!loader[i]->recognize_path(local_path)) { continue; } - /* - if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) - continue; - */ loader[i]->get_dependencies(local_path, p_dependencies, p_add_types); } @@ -760,10 +740,6 @@ Error ResourceLoader::rename_dependencies(const String &p_path, const Map<String if (!loader[i]->recognize_path(local_path)) { continue; } - /* - if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) - continue; - */ return loader[i]->rename_dependencies(local_path, p_map); } diff --git a/core/math/bvh_cull.inc b/core/math/bvh_cull.inc index d7edc8a884..ab468bfd29 100644 --- a/core/math/bvh_cull.inc +++ b/core/math/bvh_cull.inc @@ -508,8 +508,9 @@ bool _cull_convex_iterative(uint32_t p_node_id, CullParams &r_params, bool p_ful uint32_t child_id = leaf.get_item_ref_id(n); // full up with results? exit early, no point in further testing - if (!_cull_hit(child_id, r_params)) + if (!_cull_hit(child_id, r_params)) { return false; + } } } #endif // BVH_CONVEX_CULL_OPTIMIZED diff --git a/core/math/bvh_debug.inc b/core/math/bvh_debug.inc index 55db794ee3..896c36ecf1 100644 --- a/core/math/bvh_debug.inc +++ b/core/math/bvh_debug.inc @@ -1,8 +1,9 @@ public: #ifdef BVH_VERBOSE void _debug_recursive_print_tree(int p_tree_id) const { - if (_root_node_id[p_tree_id] != BVHCommon::INVALID) + if (_root_node_id[p_tree_id] != BVHCommon::INVALID) { _debug_recursive_print_tree_node(_root_node_id[p_tree_id]); + } } String _debug_aabb_to_string(const BVHABB_CLASS &aabb) const { @@ -42,8 +43,9 @@ void _debug_recursive_print_tree_node(uint32_t p_node_id, int depth = 0) const { sz += "["; for (int n = 0; n < leaf.num_items; n++) { - if (n) + if (n) { sz += ", "; + } sz += "r"; sz += itos(leaf.get_item_ref_id(n)); } diff --git a/core/math/octree.h b/core/math/octree.h index 23ba4c1aa3..e73f8213b3 100644 --- a/core/math/octree.h +++ b/core/math/octree.h @@ -211,11 +211,6 @@ private: E = pair_map.insert(key, pdata); E->get().eA = p_A->pair_list.push_back(&E->get()); E->get().eB = p_B->pair_list.push_back(&E->get()); - - /* - if (pair_callback) - pair_callback(pair_callback_userdata,p_A->userdata,p_B->userdata); - */ } else { E->get().refcount++; } @@ -854,11 +849,6 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) { Octant *o = F->get().octant; typename List<typename Element::OctantOwner, AL>::Element *N = F->next(); - /* - if (!use_pairs) - o->elements.erase( F->get().E ); - */ - if (use_pairs && e.pairable) { o->pairable_elements.erase(F->get().E); } else { diff --git a/core/object/object.cpp b/core/object/object.cpp index f966607e03..a8a49bd22e 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -402,13 +402,9 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid #endif } - //try built-in setgetter + // Try built-in setter. { if (ClassDB::set_property(this, p_name, p_value, r_valid)) { - /* - if (r_valid) - *r_valid=true; - */ return; } } @@ -421,7 +417,6 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid return; } else if (p_name == CoreStringNames::get_singleton()->_meta) { - //set_meta(p_name,p_value); metadata = p_value.duplicate(); if (r_valid) { *r_valid = true; @@ -429,7 +424,7 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid return; } - //something inside the object... :| + // Something inside the object... :| bool success = _setv(p_name, p_value); if (success) { if (r_valid) { @@ -485,7 +480,7 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const { #endif } - //try built-in setgetter + // Try built-in getter. { if (ClassDB::get_property(const_cast<Object *>(this), p_name, ret)) { if (r_valid) { @@ -510,7 +505,7 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const { return ret; } else { - //something inside the object... :| + // Something inside the object... :| bool success = _getv(p_name, ret); if (success) { if (r_valid) { diff --git a/core/object/object.h b/core/object/object.h index be360703bc..b5be1cf0e7 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -245,13 +245,7 @@ struct MethodInfo { MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5); }; -// old cast_to -//if ( is_type(T::get_class_static()) ) -//return static_cast<T*>(this); -////else -//return nullptr; - -// API used to extend in GDNative and other C compatible compiled languages +// API used to extend in GDNative and other C compatible compiled languages. class MethodBind; struct ObjectNativeExtension { @@ -297,8 +291,10 @@ struct ObjectNativeExtension { #define GDVIRTUAL_IS_OVERRIDDEN_PTR(m_obj, m_name) m_obj->_gdvirtual_##m_name##_overridden() /* - the following is an incomprehensible blob of hacks and workarounds to compensate for many of the fallencies in C++. As a plus, this macro pretty much alone defines the object model. -*/ + * The following is an incomprehensible blob of hacks and workarounds to + * compensate for many of the fallacies in C++. As a plus, this macro pretty + * much alone defines the object model. + */ #define REVERSE_GET_PROPERTY_LIST \ public: \ @@ -534,7 +530,7 @@ private: Set<String> editor_section_folding; #endif ScriptInstance *script_instance = nullptr; - Variant script; //reference does not yet exist, store it in a + Variant script; // Reference does not exist yet, store it in a Variant. Dictionary metadata; mutable StringName _class_name; mutable const StringName *_class_ptr = nullptr; @@ -583,6 +579,7 @@ protected: } return can_die; } + friend class NativeExtensionMethodBind; _ALWAYS_INLINE_ const ObjectNativeExtension *_get_extension() const { return _extension; } _ALWAYS_INLINE_ GDExtensionClassInstancePtr _get_extension_instance() const { return _extension_instance; } @@ -617,9 +614,6 @@ protected: static void get_valid_parents_static(List<String> *p_parents); static void _get_valid_parents_static(List<String> *p_parents); - //Variant _call_bind(const StringName& p_name, const Variant& p_arg1 = Variant(), const Variant& p_arg2 = Variant(), const Variant& p_arg3 = Variant(), const Variant& p_arg4 = Variant()); - //void _call_deferred_bind(const StringName& p_name, const Variant& p_arg1 = Variant(), const Variant& p_arg2 = Variant(), const Variant& p_arg3 = Variant(), const Variant& p_arg4 = Variant()); - Variant _call_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error); Variant _call_deferred_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error); @@ -641,7 +635,7 @@ protected: void _disconnect(const StringName &p_signal, const Callable &p_callable, bool p_force = false); -public: //should be protected, but bug in clang++ +public: // Should be protected, but bug in clang++. static void initialize_class(); _FORCE_INLINE_ static void register_custom_data_to_otdb() {} @@ -729,8 +723,6 @@ public: } /* IAPI */ - //void set(const String& p_name, const Variant& p_value); - //Variant get(const String& p_name) const; void set(const StringName &p_name, const Variant &p_value, bool *r_valid = nullptr); Variant get(const StringName &p_name, bool *r_valid = nullptr) const; @@ -748,7 +740,7 @@ public: void notification(int p_notification, bool p_reversed = false); virtual String to_string(); - //used mainly by script, get and set all INCLUDING string + // Used mainly by script, get and set all INCLUDING string. virtual Variant getvar(const Variant &p_key, bool *r_valid = nullptr) const; virtual void setvar(const Variant &p_key, const Variant &p_value, bool *r_valid = nullptr); @@ -757,8 +749,6 @@ public: void set_script(const Variant &p_script); Variant get_script() const; - /* SCRIPT */ - bool has_meta(const StringName &p_name) const; void set_meta(const StringName &p_name, const Variant &p_value); void remove_meta(const StringName &p_name); @@ -768,13 +758,15 @@ public: #ifdef TOOLS_ENABLED void set_edited(bool p_edited); bool is_edited() const; - uint32_t get_edited_version() const; //this function is used to check when something changed beyond a point, it's used mainly for generating previews + // This function is used to check when something changed beyond a point, it's used mainly for generating previews. + uint32_t get_edited_version() const; #endif void set_script_instance(ScriptInstance *p_instance); _FORCE_INLINE_ ScriptInstance *get_script_instance() const { return script_instance; } - void set_script_and_instance(const Variant &p_script, ScriptInstance *p_instance); //some script languages can't control instance creation, so this function eases the process + // Some script languages can't control instance creation, so this function eases the process. + void set_script_and_instance(const Variant &p_script, ScriptInstance *p_instance); void add_user_signal(const MethodInfo &p_signal); Error emit_signal(const StringName &p_name, VARIANT_ARG_LIST); @@ -803,10 +795,11 @@ public: virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; - String tr(const StringName &p_message, const StringName &p_context = "") const; // translate message (internationalization) + // Translate message (internationalization). + String tr(const StringName &p_message, const StringName &p_context = "") const; String tr_n(const StringName &p_message, const StringName &p_message_plural, int p_n, const StringName &p_context = "") const; - bool _is_queued_for_deletion = false; // set to true by SceneTree::queue_delete() + bool _is_queued_for_deletion = false; // Set to true by SceneTree::queue_delete(). bool is_queued_for_deletion() const; _FORCE_INLINE_ void set_message_translation(bool p_enable) { _can_translate = p_enable; } @@ -838,14 +831,14 @@ bool predelete_handler(Object *p_object); void postinitialize_handler(Object *p_object); class ObjectDB { -//this needs to add up to 63, 1 bit is for reference +// This needs to add up to 63, 1 bit is for reference. #define OBJECTDB_VALIDATOR_BITS 39 #define OBJECTDB_VALIDATOR_MASK ((uint64_t(1) << OBJECTDB_VALIDATOR_BITS) - 1) #define OBJECTDB_SLOT_MAX_COUNT_BITS 24 #define OBJECTDB_SLOT_MAX_COUNT_MASK ((uint64_t(1) << OBJECTDB_SLOT_MAX_COUNT_BITS) - 1) #define OBJECTDB_REFERENCE_BIT (uint64_t(1) << (OBJECTDB_SLOT_MAX_COUNT_BITS + OBJECTDB_VALIDATOR_BITS)) - struct ObjectSlot { //128 bits per slot + struct ObjectSlot { // 128 bits per slot. uint64_t validator : OBJECTDB_VALIDATOR_BITS; uint64_t next_free : OBJECTDB_SLOT_MAX_COUNT_BITS; uint64_t is_ref_counted : 1; @@ -875,7 +868,7 @@ public: uint64_t id = p_instance_id; uint32_t slot = id & OBJECTDB_SLOT_MAX_COUNT_MASK; - ERR_FAIL_COND_V(slot >= slot_max, nullptr); //this should never happen unless RID is corrupted + ERR_FAIL_COND_V(slot >= slot_max, nullptr); // This should never happen unless RID is corrupted. spin_lock.lock(); diff --git a/core/os/os.cpp b/core/os/os.cpp index 9558a6978e..9837b6e0aa 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -391,16 +391,18 @@ bool OS::has_feature(const String &p_feature) { return true; } #else - if (p_feature == "release") + if (p_feature == "release") { return true; + } #endif #ifdef TOOLS_ENABLED if (p_feature == "editor") { return true; } #else - if (p_feature == "standalone") + if (p_feature == "standalone") { return true; + } #endif if (sizeof(void *) == 8 && p_feature == "64") { diff --git a/core/os/spin_lock.h b/core/os/spin_lock.h index 27d915e0ae..6e8d7f46d5 100644 --- a/core/os/spin_lock.h +++ b/core/os/spin_lock.h @@ -41,7 +41,7 @@ class SpinLock { public: _ALWAYS_INLINE_ void lock() { while (locked.test_and_set(std::memory_order_acquire)) { - ; + // Continue. } } _ALWAYS_INLINE_ void unlock() { diff --git a/core/variant/type_info.h b/core/variant/type_info.h index 5ae35c92d3..ee050cff4f 100644 --- a/core/variant/type_info.h +++ b/core/variant/type_info.h @@ -245,8 +245,9 @@ namespace godot { namespace details { inline String enum_qualified_name_to_class_info_name(const String &p_qualified_name) { Vector<String> parts = p_qualified_name.split("::", false); - if (parts.size() <= 2) + if (parts.size() <= 2) { return String(".").join(parts); + } // Contains namespace. We only want the class and enum names. return parts[parts.size() - 2] + "." + parts[parts.size() - 1]; } diff --git a/doc/classes/Line2D.xml b/doc/classes/Line2D.xml index 41c9ea5df5..88574c0028 100644 --- a/doc/classes/Line2D.xml +++ b/doc/classes/Line2D.xml @@ -79,7 +79,8 @@ The points that form the lines. The line is drawn between every point set in this array. Points are interpreted as local vectors. </member> <member name="round_precision" type="int" setter="set_round_precision" getter="get_round_precision" default="8"> - The smoothness of the rounded joints and caps. This is only used if a cap or joint is set as round. + The smoothness of the rounded joints and caps. Higher values result in smoother corners, but are more demanding to render and update. This is only used if a cap or joint is set as round. + [b]Note:[/b] The default value is tuned for lines with the default [member width]. For thin lines, this value should be reduced to a number between [code]2[/code] and [code]4[/code] to improve performance. </member> <member name="sharp_limit" type="float" setter="set_sharp_limit" getter="get_sharp_limit" default="2.0"> The direction difference in radians between vector points. This value is only used if [member joint_mode] is set to [constant LINE_JOINT_SHARP]. diff --git a/doc/classes/SpriteBase3D.xml b/doc/classes/SpriteBase3D.xml index 298f5bc8c2..405fff0ce8 100644 --- a/doc/classes/SpriteBase3D.xml +++ b/doc/classes/SpriteBase3D.xml @@ -61,7 +61,7 @@ </member> <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color(1, 1, 1, 1)"> A color value used to [i]multiply[/i] the texture's colors. Can be used for mood-coloring or to simulate the color of light. - [b]Note:[/b] If a [member GeometryInstance3D.material_override] is defined on the [SpriteBase3D], the material override must be configured to take vertex colors into account for albedo. Otherwise, the color defined in [member modulate] will be ignored. For a [BaseMaterial3D], [member BaseMaterial3D.vertex_color_use_as_albedo] must be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/color] must be inserted in the shader's [code]fragment()[/code] function. + [b]Note:[/b] If a [member GeometryInstance3D.material_override] is defined on the [SpriteBase3D], the material override must be configured to take vertex colors into account for albedo. Otherwise, the color defined in [member modulate] will be ignored. For a [BaseMaterial3D], [member BaseMaterial3D.vertex_color_use_as_albedo] must be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. </member> <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)"> The texture's drawing offset. diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml index b6a2909ce7..c909a35ab5 100644 --- a/doc/classes/TreeItem.xml +++ b/doc/classes/TreeItem.xml @@ -18,7 +18,7 @@ <argument index="3" name="disabled" type="bool" default="false" /> <argument index="4" name="tooltip" type="String" default="""" /> <description> - Adds a button with [Texture2D] [code]button[/code] at column [code]column[/code]. The [code]id[/code] is used to identify the button. If not specified, the next available index is used, which may be retrieved by calling [method get_button_count] immediately after this method. Optionally, the button can be [code]disabled[/code] and have a [code]tooltip[/code]. + Adds a button with [Texture2D] [code]button[/code] at column [code]column[/code]. The [code]id[/code] is used to identify the button. If not specified, the next available index is used, which may be retrieved by calling [method get_button_count] immediately before this method. Optionally, the button can be [code]disabled[/code] and have a [code]tooltip[/code]. </description> </method> <method name="call_recursive" qualifiers="vararg"> @@ -92,7 +92,7 @@ <return type="int" /> <argument index="0" name="column" type="int" /> <description> - Returns the number of buttons in column [code]column[/code]. May be used to get the most recently added button's index, if no index was specified. + Returns the number of buttons in column [code]column[/code]. </description> </method> <method name="get_button_id" qualifiers="const"> diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp index e37a53fede..e2b195350f 100644 --- a/drivers/coreaudio/audio_driver_coreaudio.cpp +++ b/drivers/coreaudio/audio_driver_coreaudio.cpp @@ -174,9 +174,9 @@ OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon, for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) { AudioBuffer *abuf = &ioData->mBuffers[i]; memset(abuf->mData, 0, abuf->mDataByteSize); - }; + } return 0; - }; + } ad->start_counting_ticks(); @@ -195,14 +195,14 @@ OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon, frames_left -= frames; out += frames * ad->channels; - }; - }; + } + } ad->stop_counting_ticks(); ad->unlock(); return 0; -}; +} OSStatus AudioDriverCoreAudio::input_callback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, @@ -251,7 +251,7 @@ void AudioDriverCoreAudio::start() { active = true; } } -}; +} void AudioDriverCoreAudio::stop() { if (active) { @@ -266,19 +266,19 @@ void AudioDriverCoreAudio::stop() { int AudioDriverCoreAudio::get_mix_rate() const { return mix_rate; -}; +} AudioDriver::SpeakerMode AudioDriverCoreAudio::get_speaker_mode() const { return get_speaker_mode_by_total_channels(channels); -}; +} void AudioDriverCoreAudio::lock() { mutex.lock(); -}; +} void AudioDriverCoreAudio::unlock() { mutex.unlock(); -}; +} bool AudioDriverCoreAudio::try_lock() { return mutex.try_lock() == OK; @@ -521,8 +521,9 @@ Array AudioDriverCoreAudio::_get_device_list(bool capture) { AudioObjectGetPropertyData(audioDevices[i], &prop, 0, nullptr, &size, bufferList); UInt32 channelCount = 0; - for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++) + for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++) { channelCount += bufferList->mBuffers[j].mNumberChannels; + } memfree(bufferList); @@ -579,8 +580,9 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) { AudioObjectGetPropertyData(audioDevices[i], &prop, 0, nullptr, &size, bufferList); UInt32 channelCount = 0; - for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++) + for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++) { channelCount += bufferList->mBuffers[j].mNumberChannels; + } memfree(bufferList); diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 121dc86fb2..1382573461 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "rasterizer_scene_gles3.h" + #ifdef GLES3_ENABLED // TODO: 3D support not implemented yet. diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index a7638b49ec..abbba13ee6 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "rasterizer_storage_gles3.h" + #ifdef GLES3_ENABLED #include "core/config/project_settings.h" @@ -3716,10 +3717,11 @@ void RasterizerStorageGLES3::canvas_light_occluder_set_polylines(RID p_occluder, co->lines = p_lines; if (p_lines.size() != co->len) { - if (co->index_id) + if (co->index_id) { glDeleteBuffers(1, &co->index_id); - if (co->vertex_id) + } if (co->vertex_id) { glDeleteBuffers(1, &co->vertex_id); + } co->index_id = 0; co->vertex_id = 0; @@ -4014,10 +4016,12 @@ bool RasterizerStorageGLES3::free(RID p_rid) { } else if (canvas_occluder_owner.owns(p_rid)) { CanvasOccluder *co = canvas_occluder_owner.get_or_null(p_rid); - if (co->index_id) + if (co->index_id) { glDeleteBuffers(1, &co->index_id); - if (co->vertex_id) + } + if (co->vertex_id) { glDeleteBuffers(1, &co->vertex_id); + } canvas_occluder_owner.free(p_rid); memdelete(co); diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index 7ae8b4e3bf..9349722625 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "shader_gles3.h" + #ifdef GLES3_ENABLED #include "core/io/compression.h" diff --git a/drivers/gles3/texture_loader_gles3.cpp b/drivers/gles3/texture_loader_gles3.cpp index 1cbda02121..f8d4cfdc61 100644 --- a/drivers/gles3/texture_loader_gles3.cpp +++ b/drivers/gles3/texture_loader_gles3.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "texture_loader_gles3.h" + #ifdef GLES3_ENABLED #include "core/io/file_access.h" diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp index 77390a5915..ca84fb6be9 100644 --- a/drivers/png/resource_saver_png.cpp +++ b/drivers/png/resource_saver_png.cpp @@ -46,7 +46,7 @@ Error ResourceSaverPNG::save(const String &p_path, const RES &p_resource, uint32 Error err = save_image(p_path, img); return err; -}; +} Error ResourceSaverPNG::save_image(const String &p_path, const Ref<Image> &p_img) { Vector<uint8_t> buffer; @@ -89,4 +89,4 @@ void ResourceSaverPNG::get_recognized_extensions(const RES &p_resource, List<Str ResourceSaverPNG::ResourceSaverPNG() { Image::save_png_func = &save_image; Image::save_png_buffer_func = &save_image_to_buffer; -}; +} diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index 5fdfde4913..af47173b41 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -138,9 +138,9 @@ uint64_t DirAccessUnix::get_modified_time(String p_file) { return flags.st_mtime; } else { ERR_FAIL_V(0); - }; + } return 0; -}; +} String DirAccessUnix::get_next() { if (!dir_stream) { @@ -320,11 +320,11 @@ Error DirAccessUnix::make_dir(String p_dir) { if (success) { return OK; - }; + } if (err == EEXIST) { return ERR_ALREADY_EXISTS; - }; + } return ERR_CANT_CREATE; } @@ -474,14 +474,14 @@ uint64_t DirAccessUnix::get_space_left() { struct statvfs vfs; if (statvfs(current_dir.utf8().get_data(), &vfs) != 0) { return 0; - }; + } return (uint64_t)vfs.f_bavail * (uint64_t)vfs.f_frsize; #else // FIXME: Implement this. return 0; #endif -}; +} String DirAccessUnix::get_filesystem_type() const { return ""; //TODO this should be implemented diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index 80ae999ac9..ea442ad8bf 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -246,7 +246,7 @@ uint64_t FileAccessUnix::get_buffer(uint8_t *p_dst, uint64_t p_length) const { uint64_t read = fread(p_dst, 1, p_length, f); check_errors(); return read; -}; +} Error FileAccessUnix::get_error() const { return last_error; @@ -285,8 +285,9 @@ bool FileAccessUnix::file_exists(const String &p_path) { return false; } #else - if (_access(filename.utf8().get_data(), 4) == -1) + if (_access(filename.utf8().get_data(), 4) == -1) { return false; + } #endif // See if this is a regular file @@ -309,7 +310,7 @@ uint64_t FileAccessUnix::_get_modified_time(const String &p_file) { } else { print_verbose("Failed to get modified time for: " + p_file + ""); return 0; - }; + } } uint32_t FileAccessUnix::_get_unix_permissions(const String &p_file) { @@ -321,7 +322,7 @@ uint32_t FileAccessUnix::_get_unix_permissions(const String &p_file) { return flags.st_mode & 0x7FF; //only permissions } else { ERR_FAIL_V_MSG(0, "Failed to get unix permissions for: " + p_file + "."); - }; + } } Error FileAccessUnix::_set_unix_permissions(const String &p_file, uint32_t p_permissions) { diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp index d82dcb8a8d..d442e521bf 100644 --- a/drivers/unix/ip_unix.cpp +++ b/drivers/unix/ip_unix.cpp @@ -72,10 +72,10 @@ static IPAddress _sockaddr2ip(struct sockaddr *p_addr) { } else if (p_addr->sa_family == AF_INET6) { struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)p_addr; ip.set_ipv6(addr6->sin6_addr.s6_addr); - }; + } return ip; -}; +} void IPUnix::_resolve_hostname(List<IPAddress> &r_addresses, const String &p_hostname, Type p_type) const { struct addrinfo hints; @@ -90,14 +90,14 @@ void IPUnix::_resolve_hostname(List<IPAddress> &r_addresses, const String &p_hos } else { hints.ai_family = AF_UNSPEC; hints.ai_flags = AI_ADDRCONFIG; - }; + } hints.ai_flags &= ~AI_NUMERICHOST; int s = getaddrinfo(p_hostname.utf8().get_data(), nullptr, &hints, &result); if (s != 0) { ERR_PRINT("getaddrinfo failed! Cannot resolve hostname."); return; - }; + } if (result == nullptr || result->ai_addr == nullptr) { ERR_PRINT("Invalid response from getaddrinfo"); @@ -105,7 +105,7 @@ void IPUnix::_resolve_hostname(List<IPAddress> &r_addresses, const String &p_hos freeaddrinfo(result); } return; - }; + } struct addrinfo *next = result; @@ -138,8 +138,9 @@ void IPUnix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) con for (int i = 0; i < hostnames->Size; i++) { auto hostname = hostnames->GetAt(i); - if (hostname->Type != HostNameType::Ipv4 && hostname->Type != HostNameType::Ipv6) + if (hostname->Type != HostNameType::Ipv4 && hostname->Type != HostNameType::Ipv6) { continue; + } String name = hostname->RawName->Data(); Map<String, Interface_Info>::Element *E = r_interfaces->find(name); @@ -171,14 +172,14 @@ void IPUnix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) con nullptr, addrs, &buf_size); if (err == NO_ERROR) { break; - }; + } memfree(addrs); if (err == ERROR_BUFFER_OVERFLOW) { continue; // will go back and alloc the right size - }; + } ERR_FAIL_MSG("Call to GetAdaptersAddresses failed with error " + itos(err) + "."); - }; + } IP_ADAPTER_ADDRESSES *adapter = addrs; @@ -191,19 +192,21 @@ void IPUnix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) con IP_ADAPTER_UNICAST_ADDRESS *address = adapter->FirstUnicastAddress; while (address != nullptr) { int family = address->Address.lpSockaddr->sa_family; - if (family != AF_INET && family != AF_INET6) + if (family != AF_INET && family != AF_INET6) { continue; + } info.ip_addresses.push_front(_sockaddr2ip(address->Address.lpSockaddr)); address = address->Next; } adapter = adapter->Next; // Only add interface if it has at least one IP - if (info.ip_addresses.size() > 0) + if (info.ip_addresses.size() > 0) { r_interfaces->insert(info.name, info); - }; + } + } memfree(addrs); -}; +} #endif diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp index bdfd264a0c..3130d5cae2 100644 --- a/drivers/unix/net_socket_posix.cpp +++ b/drivers/unix/net_socket_posix.cpp @@ -147,7 +147,7 @@ void NetSocketPosix::_set_ip_port(struct sockaddr_storage *p_addr, IPAddress *r_ if (r_port) { *r_port = ntohs(addr6->sin6_port); } - }; + } } NetSocket *NetSocketPosix::_create_func() { @@ -325,8 +325,9 @@ Error NetSocketPosix::open(Type p_sock_type, IP::Type &ip_type) { #if defined(__OpenBSD__) // OpenBSD does not support dual stacking, fallback to IPv4 only. - if (ip_type == IP::TYPE_ANY) + if (ip_type == IP::TYPE_ANY) { ip_type = IP::TYPE_IPV4; + } #endif int family = ip_type == IP::TYPE_IPV4 ? AF_INET : AF_INET6; @@ -420,7 +421,7 @@ Error NetSocketPosix::listen(int p_max_pending) { print_verbose("Failed to listen from socket."); close(); return FAILED; - }; + } return OK; } @@ -494,8 +495,9 @@ Error NetSocketPosix::poll(PollType p_type, int p_timeout) const { return FAILED; } - if (ret == 0) + if (ret == 0) { return ERR_BUSY; + } if (FD_ISSET(_sock, &ex)) { _get_socket_error(); @@ -503,10 +505,12 @@ Error NetSocketPosix::poll(PollType p_type, int p_timeout) const { return FAILED; } - if (rdp && FD_ISSET(_sock, rdp)) + if (rdp && FD_ISSET(_sock, rdp)) { ready = true; - if (wrp && FD_ISSET(_sock, wrp)) + } + if (wrp && FD_ISSET(_sock, wrp)) { ready = true; + } return ready ? OK : ERR_BUSY; #else diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 7d57926757..088525647c 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -106,7 +106,7 @@ static void _setup_clock() { void OS_Unix::debug_break() { assert(false); -}; +} static void handle_interrupt(int sig) { if (!EngineDebugger::is_active()) { @@ -198,7 +198,7 @@ double OS_Unix::get_unix_time() const { struct timeval tv_now; gettimeofday(&tv_now, nullptr); return (double)tv_now.tv_sec + double(tv_now.tv_usec) / 1000000; -}; +} OS::Date OS_Unix::get_date(bool p_utc) const { time_t t = time(nullptr); @@ -410,7 +410,7 @@ Error OS_Unix::kill(const ProcessID &p_pid) { int OS_Unix::get_process_id() const { return getpid(); -}; +} bool OS_Unix::has_environment(const String &p_var) const { return getenv(p_var.utf8().get_data()) != nullptr; @@ -555,8 +555,9 @@ String OS_Unix::get_executable_path() const { char *resolved_path = new char[buff_size + 1]; - if (_NSGetExecutablePath(resolved_path, &buff_size) == 1) + if (_NSGetExecutablePath(resolved_path, &buff_size) == 1) { WARN_PRINT("MAXPATHLEN is too small"); + } String path(resolved_path); delete[] resolved_path; diff --git a/drivers/unix/syslog_logger.cpp b/drivers/unix/syslog_logger.cpp index 0e1a1a89a3..6189d645c6 100644 --- a/drivers/unix/syslog_logger.cpp +++ b/drivers/unix/syslog_logger.cpp @@ -31,7 +31,9 @@ #ifdef UNIX_ENABLED #include "syslog_logger.h" + #include "core/string/print_string.h" + #include <syslog.h> void SyslogLogger::logv(const char *p_format, va_list p_list, bool p_err) { diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 1d6d9d56e8..247961b358 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -1200,7 +1200,7 @@ uint32_t RenderingDeviceVulkan::get_image_required_mipmaps(uint32_t p_width, uin d = MAX(1, d >> 1); mipmaps++; - }; + } return mipmaps; } @@ -3679,7 +3679,7 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF // Set view masks for each subpass for (uint32_t i = 0; i < subpasses.size(); i++) { view_masks.push_back(view_mask); - }; + } render_pass_multiview_create_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO; render_pass_multiview_create_info.pNext = nullptr; @@ -6326,7 +6326,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma attachment_states.push_back(state); idx++; - }; + } } ERR_FAIL_COND_V(attachment_states.size() != p_blend_state.attachments.size(), RID()); @@ -9013,49 +9013,49 @@ uint64_t RenderingDeviceVulkan::get_driver_resource(DriverResource p_resource, R switch (p_resource) { case DRIVER_RESOURCE_VULKAN_DEVICE: { return (uint64_t)context->get_device(); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_PHYSICAL_DEVICE: { return (uint64_t)context->get_physical_device(); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_INSTANCE: { return (uint64_t)context->get_instance(); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_QUEUE: { return (uint64_t)context->get_graphics_queue(); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_QUEUE_FAMILY_INDEX: { return context->get_graphics_queue_family_index(); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_IMAGE: { Texture *tex = texture_owner.get_or_null(p_rid); ERR_FAIL_NULL_V(tex, 0); return (uint64_t)tex->image; - }; break; + } break; case DRIVER_RESOURCE_VULKAN_IMAGE_VIEW: { Texture *tex = texture_owner.get_or_null(p_rid); ERR_FAIL_NULL_V(tex, 0); return (uint64_t)tex->view; - }; break; + } break; case DRIVER_RESOURCE_VULKAN_IMAGE_NATIVE_TEXTURE_FORMAT: { Texture *tex = texture_owner.get_or_null(p_rid); ERR_FAIL_NULL_V(tex, 0); return vulkan_formats[tex->format]; - }; break; + } break; case DRIVER_RESOURCE_VULKAN_SAMPLER: { VkSampler *sampler = sampler_owner.get_or_null(p_rid); ERR_FAIL_NULL_V(sampler, 0); return uint64_t(*sampler); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_DESCRIPTOR_SET: { UniformSet *uniform_set = uniform_set_owner.get_or_null(p_rid); ERR_FAIL_NULL_V(uniform_set, 0); return uint64_t(uniform_set->descriptor_set); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_BUFFER: { Buffer *buffer = nullptr; if (vertex_buffer_owner.owns(p_rid)) { @@ -9073,23 +9073,23 @@ uint64_t RenderingDeviceVulkan::get_driver_resource(DriverResource p_resource, R ERR_FAIL_NULL_V(buffer, 0); return uint64_t(buffer->buffer); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_COMPUTE_PIPELINE: { ComputePipeline *compute_pipeline = compute_pipeline_owner.get_or_null(p_rid); ERR_FAIL_NULL_V(compute_pipeline, 0); return uint64_t(compute_pipeline->pipeline); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_RENDER_PIPELINE: { RenderPipeline *render_pipeline = render_pipeline_owner.get_or_null(p_rid); ERR_FAIL_NULL_V(render_pipeline, 0); return uint64_t(render_pipeline->pipeline); - }; break; + } break; default: { // not supported for this driver return 0; - }; break; + } break; } } diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp index c7a2d04436..c9609b469a 100644 --- a/drivers/wasapi/audio_driver_wasapi.cpp +++ b/drivers/wasapi/audio_driver_wasapi.cpp @@ -454,8 +454,9 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c Error AudioDriverWASAPI::init_render_device(bool reinit) { Error err = audio_device_init(&audio_output, false, reinit); - if (err != OK) + if (err != OK) { return err; + } switch (audio_output.channels) { case 2: // Stereo @@ -485,8 +486,9 @@ Error AudioDriverWASAPI::init_render_device(bool reinit) { Error AudioDriverWASAPI::init_capture_device(bool reinit) { Error err = audio_device_init(&audio_input, true, reinit); - if (err != OK) + if (err != OK) { return err; + } // Get the max frames UINT32 max_frames; diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index cfd5d65f60..59dc1d8e77 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -87,7 +87,7 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) { if (!S_ISREG(st.st_mode)) { return ERR_FILE_CANT_OPEN; } - }; + } #ifdef TOOLS_ENABLED // Windows is case insensitive, but all other platforms are sensitive to it @@ -269,7 +269,7 @@ uint64_t FileAccessWindows::get_buffer(uint8_t *p_dst, uint64_t p_length) const uint64_t read = fread(p_dst, 1, p_length, f); check_errors(); return read; -}; +} Error FileAccessWindows::get_error() const { return last_error; @@ -326,8 +326,9 @@ bool FileAccessWindows::file_exists(const String &p_name) { uint64_t FileAccessWindows::_get_modified_time(const String &p_file) { String file = fix_path(p_file); - if (file.ends_with("/") && file != "/") + if (file.ends_with("/") && file != "/") { file = file.substr(0, file.length() - 1); + } struct _stat st; int rv = _wstat((LPCWSTR)(file.utf16().get_data()), &st); diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 6e97151465..c8c8c7d891 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -1289,10 +1289,6 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { // 3-move the keys (re insert them) for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { float newpos = editor->snap_time(animation->track_get_key_time(E->get().first, E->get().second) + moving_selection_offset.x); - /* - if (newpos<0) - continue; //no add at the beginning - */ Array key = animation->track_get_key_value(E->get().first, E->get().second); float h = key[0]; h += moving_selection_offset.y; @@ -1303,10 +1299,6 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { // 4-(undo) remove inserted keys for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { float newpos = editor->snap_time(animation->track_get_key_time(E->get().first, E->get().second) + moving_selection_offset.x); - /* - if (newpos<0) - continue; //no remove what no inserted - */ undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", E->get().first, newpos); } diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index c137740bda..2a1b0029d4 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -41,7 +41,6 @@ void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) { } frame_metrics.write[last_metric] = p_metric; - // _make_metric_ptrs(frame_metrics.write[last_metric]); List<String> stack; for (int i = 0; i < frame_metrics[last_metric].areas.size(); i++) { @@ -482,19 +481,6 @@ void EditorVisualProfiler::_graph_tex_draw() { graph->draw_string(font, Vector2(font->get_string_size("X", font_size).x, font->get_ascent(font_size) + 2), "CPU:", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1, 0.8)); graph->draw_string(font, Vector2(font->get_string_size("X", font_size).x + graph->get_size().width / 2, font->get_ascent(font_size) + 2), "GPU:", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1, 0.8)); - - /* - if (hover_metric != -1 && frame_metrics[hover_metric].valid) { - int max_frames = frame_metrics.size(); - int frame = frame_metrics[hover_metric].frame_number - (frame_metrics[last_metric].frame_number - max_frames + 1); - if (frame < 0) - frame = 0; - - int cur_x = frame * graph->get_size().x / max_frames; - - graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), Color(1, 1, 1, 0.4)); - } -*/ } void EditorVisualProfiler::_graph_tex_mouse_exit() { diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index 36ae19cb23..250182b8fc 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -1375,7 +1375,7 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str _write_string(f, 1, "<tutorials>"); for (int i = 0; i < c.tutorials.size(); i++) { DocData::TutorialDoc tutorial = c.tutorials.get(i); - String title_attribute = (!tutorial.title.is_empty()) ? " title=\"" + tutorial.title.xml_escape() + "\"" : ""; + String title_attribute = (!tutorial.title.is_empty()) ? " title=\"" + _translate_doc_string(tutorial.title).xml_escape() + "\"" : ""; _write_string(f, 2, "<link" + title_attribute + ">" + tutorial.link.xml_escape() + "</link>"); } _write_string(f, 1, "</tutorials>"); diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 91bd89b201..69c7e9d52c 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -589,11 +589,6 @@ void EditorData::remove_scene(int p_idx) { } bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String> &checked_paths) { - /* - if (p_root!=p_node && p_node->get_owner()!=p_root && !p_root->is_editable_instance(p_node->get_owner())) - return false; - */ - Ref<SceneState> ss; if (p_node == p_root) { diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index cbdfc4c65a..675ef808e1 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -1867,7 +1867,6 @@ int EditorInspectorArray::_drop_position() const { void EditorInspectorArray::_new_size_line_edit_text_changed(String p_text) { bool valid = false; - ; if (p_text.is_valid_int()) { int val = p_text.to_int(); if (val > 0 && val != count) { @@ -1879,7 +1878,6 @@ void EditorInspectorArray::_new_size_line_edit_text_changed(String p_text) { void EditorInspectorArray::_new_size_line_edit_text_submitted(String p_text) { bool valid = false; - ; if (p_text.is_valid_int()) { int val = p_text.to_int(); if (val > 0 && val != count) { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 208640a2e3..a10eecbca1 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3916,8 +3916,9 @@ Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) cons if (script.is_valid()) { // Uncommenting would break things! Consider adding a parameter if you need it. // StringName name = EditorNode::get_editor_data().script_class_get_name(base_script->get_path()); - // if (name != StringName()) + // if (name != StringName()) { // return name; + // } // should probably be deprecated in 4.x StringName base = script->get_instance_base_type(); @@ -5745,7 +5746,6 @@ static void _execute_thread(void *p_ud) { } eta->done.set(); - ; } int EditorNode::execute_and_show_output(const String &p_title, const String &p_path, const List<String> &p_arguments, bool p_close_on_ok, bool p_close_on_errors) { diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp index 605f385de2..fe32399fc6 100644 --- a/editor/import/collada.cpp +++ b/editor/import/collada.cpp @@ -1009,11 +1009,6 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name String source = _uri_to_id(parser.get_attribute_value("source")); if (semantic == "TEXCOORD") { - /* - if (parser.has_attribute("set"))// a texcoord - semantic+=parser.get_attribute_value("set"); - else - semantic="TEXCOORD0";*/ semantic = "TEXCOORD" + itos(last_ref++); } int offset = parser.get_attribute_value("offset").to_int(); @@ -1194,11 +1189,6 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { skindata.weights = weights; } - /* - else if (!parser.is_empty()) - parser.skip_section(); - */ - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "skin") { break; } @@ -1258,19 +1248,8 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) { } } else if (section == "Name_array" || section == "IDREF_array") { // create a new array and read it. - - /* - if (section=="IDREF_array") - morphdata.use_idrefs=true; - */ if (morphdata.sources.has(current_source)) { morphdata.sources[current_source].sarray = _read_string_array(parser); - /* - if (section=="IDREF_array") { - Vector<String> sa = morphdata.sources[current_source].sarray; - for(int i=0;i<sa.size();i++) - state.idref_joints.insert(sa[i]); - }*/ COLLADA_PRINT("section: " + current_source + " read " + itos(morphdata.sources[current_source].array.size()) + " values."); } } else if (section == "technique_common") { @@ -1303,11 +1282,6 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) { } } } - /* - else if (!parser.is_empty()) - parser.skip_section(); - */ - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "morph") { break; } diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp index 864e69a16e..8486d170a7 100644 --- a/editor/import/dynamic_font_import_settings.cpp +++ b/editor/import/dynamic_font_import_settings.cpp @@ -900,13 +900,18 @@ String DynamicFontImportSettings::_pad_zeros(const String &p_hex) const { } void DynamicFontImportSettings::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - connect("confirmed", callable_mp(this, &DynamicFontImportSettings::_re_import)); - } else if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - add_lang->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - add_script->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - add_var->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - add_ot->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + switch (p_what) { + case NOTIFICATION_READY: { + connect("confirmed", callable_mp(this, &DynamicFontImportSettings::_re_import)); + } break; + + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + add_lang->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + add_script->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + add_var->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + add_ot->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + } break; } } diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 96645665aa..9042f1e32c 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -317,8 +317,6 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ ERR_FAIL_INDEX_V(vtx, vertices.size(), ERR_FILE_CORRUPT); Vector3 vertex = vertices[vtx]; - //if (weld_vertices) - // vertex.snap(Vector3(weld_tolerance, weld_tolerance, weld_tolerance)); if (!smoothing) { smooth_group++; } diff --git a/editor/import/resource_importer_wav.h b/editor/import/resource_importer_wav.h index a5b576ceb9..2316ce80e5 100644 --- a/editor/import/resource_importer_wav.h +++ b/editor/import/resource_importer_wav.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef RESOURCEIMPORTWAV_H -#define RESOURCEIMPORTWAV_H +#ifndef RESOURCE_IMPORTER_WAV_H +#define RESOURCE_IMPORTER_WAV_H #include "core/io/resource_importer.h" @@ -50,9 +50,6 @@ public: virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override; static void _compress_ima_adpcm(const Vector<float> &p_data, Vector<uint8_t> &dst_data) { - /*p_sample_data->data = (void*)malloc(len); - xm_s8 *dataptr=(xm_s8*)p_sample_data->data;*/ - static const int16_t _ima_adpcm_step_table[89] = { 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, @@ -81,15 +78,14 @@ public: int i, step_idx = 0, prev = 0; uint8_t *out = w; - //int16_t xm_prev=0; const float *in = p_data.ptr(); - /* initial value is zero */ + // Initial value is zero. *(out++) = 0; *(out++) = 0; - /* Table index initial value */ + // Table index initial value. *(out++) = 0; - /* unused */ + // Unused. *(out++) = 0; for (i = 0; i < datalen; i++) { @@ -101,15 +97,8 @@ public: xm_sample = 0; } else { xm_sample = CLAMP(in[i] * 32767.0, -32768, 32767); - /* - if (xm_sample==32767 || xm_sample==-32768) - printf("clippy!\n",xm_sample); - */ } - //xm_sample=xm_sample+xm_prev; - //xm_prev=xm_sample; - diff = (int)xm_sample - prev; nibble = 0; @@ -129,7 +118,7 @@ public: step >>= 1; mask >>= 1; - }; + } if (nibble & 8) { prev -= vpdiff; @@ -137,20 +126,10 @@ public: prev += vpdiff; } - if (prev > 32767) { - //printf("%i,xms %i, prev %i,diff %i, vpdiff %i, clip up %i\n",i,xm_sample,prev,diff,vpdiff,prev); - prev = 32767; - } else if (prev < -32768) { - //printf("%i,xms %i, prev %i,diff %i, vpdiff %i, clip down %i\n",i,xm_sample,prev,diff,vpdiff,prev); - prev = -32768; - } + prev = CLAMP(prev, -32768, 32767); step_idx += _ima_adpcm_index_table[nibble]; - if (step_idx < 0) { - step_idx = 0; - } else if (step_idx > 88) { - step_idx = 88; - } + step_idx = CLAMP(step_idx, 0, 88); if (i & 1) { *out |= nibble << 4; @@ -158,7 +137,6 @@ public: } else { *out = nibble; } - /*dataptr[i]=prev>>8;*/ } } @@ -167,4 +145,4 @@ public: ResourceImporterWAV(); }; -#endif // RESOURCEIMPORTWAV_H +#endif // RESOURCE_IMPORTER_WAV_H diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index a3fb753d7f..488bd02de4 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -837,8 +837,10 @@ void SceneImportSettings::_re_import() { } void SceneImportSettings::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - connect("confirmed", callable_mp(this, &SceneImportSettings::_re_import)); + switch (p_what) { + case NOTIFICATION_READY: { + connect("confirmed", callable_mp(this, &SceneImportSettings::_re_import)); + } break; } } diff --git a/editor/import_defaults_editor.cpp b/editor/import_defaults_editor.cpp index 767e2a7fad..ca979c094f 100644 --- a/editor/import_defaults_editor.cpp +++ b/editor/import_defaults_editor.cpp @@ -80,8 +80,10 @@ protected: }; void ImportDefaultsEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_PREDELETE) { - inspector->edit(nullptr); + switch (p_what) { + case NOTIFICATION_PREDELETE: { + inspector->edit(nullptr); + } break; } } diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp index 401ba02099..cd9986d527 100644 --- a/editor/localization_editor.cpp +++ b/editor/localization_editor.cpp @@ -40,25 +40,27 @@ #include "scene/gui/control.h" void LocalizationEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - translation_list->connect("button_pressed", callable_mp(this, &LocalizationEditor::_translation_delete)); - translation_pot_list->connect("button_pressed", callable_mp(this, &LocalizationEditor::_pot_delete)); - - List<String> tfn; - ResourceLoader::get_recognized_extensions_for_type("Translation", &tfn); - for (const String &E : tfn) { - translation_file_open->add_filter("*." + E); - } + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + translation_list->connect("button_pressed", callable_mp(this, &LocalizationEditor::_translation_delete)); + translation_pot_list->connect("button_pressed", callable_mp(this, &LocalizationEditor::_pot_delete)); + + List<String> tfn; + ResourceLoader::get_recognized_extensions_for_type("Translation", &tfn); + for (const String &E : tfn) { + translation_file_open->add_filter("*." + E); + } - List<String> rfn; - ResourceLoader::get_recognized_extensions_for_type("Resource", &rfn); - for (const String &E : rfn) { - translation_res_file_open_dialog->add_filter("*." + E); - translation_res_option_file_open_dialog->add_filter("*." + E); - } + List<String> rfn; + ResourceLoader::get_recognized_extensions_for_type("Resource", &rfn); + for (const String &E : rfn) { + translation_res_file_open_dialog->add_filter("*." + E); + translation_res_option_file_open_dialog->add_filter("*." + E); + } - _update_pot_file_extensions(); - pot_generate_dialog->add_filter("*.pot"); + _update_pot_file_extensions(); + pot_generate_dialog->add_filter("*.pot"); + } break; } } diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp index 9b06435648..18545d3c9a 100644 --- a/editor/node_dock.cpp +++ b/editor/node_dock.cpp @@ -52,9 +52,12 @@ void NodeDock::_bind_methods() { } void NodeDock::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - connections_button->set_icon(get_theme_icon(SNAME("Signals"), SNAME("EditorIcons"))); - groups_button->set_icon(get_theme_icon(SNAME("Groups"), SNAME("EditorIcons"))); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + connections_button->set_icon(get_theme_icon(SNAME("Signals"), SNAME("EditorIcons"))); + groups_button->set_icon(get_theme_icon(SNAME("Groups"), SNAME("EditorIcons"))); + } break; } } diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index 5786d24d23..48ea3013f7 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -160,6 +160,7 @@ void PluginConfigDialog::_notification(int p_what) { name_edit->grab_focus(); } } break; + case NOTIFICATION_READY: { connect("confirmed", callable_mp(this, &PluginConfigDialog::_on_confirmed)); get_cancel_button()->connect("pressed", callable_mp(this, &PluginConfigDialog::_on_cancelled)); diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index 8f6ac149aa..5a2696fff1 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -154,6 +154,7 @@ void AbstractPolygon2DEditor::_notification(int p_what) { button_edit->set_icon(get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons"))); button_delete->set_icon(get_theme_icon(SNAME("CurveDelete"), SNAME("EditorIcons"))); } break; + case NOTIFICATION_READY: { disable_polygon_editing(false, String()); diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index 4156c14a7e..fe8b462084 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -531,39 +531,42 @@ void AnimationNodeBlendSpace1DEditor::_open_editor() { } void AnimationNodeBlendSpace1DEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); - error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); - panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); - tool_blend->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons"))); - tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); - tool_create->set_icon(get_theme_icon(SNAME("EditKey"), SNAME("EditorIcons"))); - tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); - snap->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); - open_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); - } - - if (p_what == NOTIFICATION_PROCESS) { - String error; - - if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) { - error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails."); - } else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { - error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason(); - } + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + tool_blend->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons"))); + tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + tool_create->set_icon(get_theme_icon(SNAME("EditKey"), SNAME("EditorIcons"))); + tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + snap->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); + open_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + } break; + + case NOTIFICATION_PROCESS: { + String error; + + if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) { + error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails."); + } else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { + error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason(); + } - if (error != error_label->get_text()) { - error_label->set_text(error); - if (!error.is_empty()) { - error_panel->show(); - } else { - error_panel->hide(); + if (error != error_label->get_text()) { + error_label->set_text(error); + if (!error.is_empty()) { + error_panel->show(); + } else { + error_panel->hide(); + } } - } - } + } break; - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - set_process(is_visible_in_tree()); + case NOTIFICATION_VISIBILITY_CHANGED: { + set_process(is_visible_in_tree()); + } break; } } diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 6d876aba44..506a709728 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -731,49 +731,52 @@ void AnimationNodeBlendSpace2DEditor::_edit_point_pos(double) { } void AnimationNodeBlendSpace2DEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); - error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); - panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); - tool_blend->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons"))); - tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); - tool_create->set_icon(get_theme_icon(SNAME("EditKey"), SNAME("EditorIcons"))); - tool_triangle->set_icon(get_theme_icon(SNAME("ToolTriangle"), SNAME("EditorIcons"))); - tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); - snap->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); - open_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); - auto_triangles->set_icon(get_theme_icon(SNAME("AutoTriangle"), SNAME("EditorIcons"))); - interpolation->clear(); - interpolation->add_icon_item(get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), "", 0); - interpolation->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), "", 1); - interpolation->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), "", 2); - } - - if (p_what == NOTIFICATION_PROCESS) { - String error; - - if (!AnimationTreeEditor::get_singleton()->get_tree()) { - error = TTR("BlendSpace2D does not belong to an AnimationTree node."); - } else if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) { - error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails."); - } else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { - error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason(); - } else if (blend_space->get_triangle_count() == 0) { - error = TTR("No triangles exist, so no blending can take place."); - } + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + tool_blend->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons"))); + tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + tool_create->set_icon(get_theme_icon(SNAME("EditKey"), SNAME("EditorIcons"))); + tool_triangle->set_icon(get_theme_icon(SNAME("ToolTriangle"), SNAME("EditorIcons"))); + tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + snap->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); + open_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + auto_triangles->set_icon(get_theme_icon(SNAME("AutoTriangle"), SNAME("EditorIcons"))); + interpolation->clear(); + interpolation->add_icon_item(get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), "", 0); + interpolation->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), "", 1); + interpolation->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), "", 2); + } break; + + case NOTIFICATION_PROCESS: { + String error; + + if (!AnimationTreeEditor::get_singleton()->get_tree()) { + error = TTR("BlendSpace2D does not belong to an AnimationTree node."); + } else if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) { + error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails."); + } else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { + error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason(); + } else if (blend_space->get_triangle_count() == 0) { + error = TTR("No triangles exist, so no blending can take place."); + } - if (error != error_label->get_text()) { - error_label->set_text(error); - if (!error.is_empty()) { - error_panel->show(); - } else { - error_panel->hide(); + if (error != error_label->get_text()) { + error_label->set_text(error); + if (!error.is_empty()) { + error_panel->show(); + } else { + error_panel->hide(); + } } - } - } + } break; - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - set_process(is_visible_in_tree()); + case NOTIFICATION_VISIBILITY_CHANGED: { + set_process(is_visible_in_tree()); + } break; } } diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 14dd782b73..0b3164aada 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -734,80 +734,95 @@ void AnimationNodeBlendTreeEditor::_removed_from_graph() { } } +void AnimationNodeBlendTreeEditor::_update_editor_settings() { + graph->get_panner()->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning"))); + graph->set_warped_panning(bool(EditorSettings::get_singleton()->get("editors/panning/warped_mouse_panning"))); +} + +void AnimationNodeBlendTreeEditor::_update_theme() { + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); +} + void AnimationNodeBlendTreeEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - graph->get_panner()->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning"))); - graph->set_warped_panning(bool(EditorSettings::get_singleton()->get("editors/panning/warped_mouse_panning"))); - } + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + _update_editor_settings(); + _update_theme(); + } break; - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); - error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { + _update_editor_settings(); + } break; - if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree()) { - _update_graph(); - } - } + case NOTIFICATION_THEME_CHANGED: { + _update_theme(); - if (p_what == NOTIFICATION_PROCESS) { - String error; + if (is_visible_in_tree()) { + _update_graph(); + } + } break; - if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) { - error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails."); - } else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { - error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason(); - } + case NOTIFICATION_PROCESS: { + String error; - if (error != error_label->get_text()) { - error_label->set_text(error); - if (!error.is_empty()) { - error_panel->show(); - } else { - error_panel->hide(); + if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) { + error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails."); + } else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { + error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason(); } - } - List<AnimationNodeBlendTree::NodeConnection> conns; - blend_tree->get_node_connections(&conns); - for (const AnimationNodeBlendTree::NodeConnection &E : conns) { - float activity = 0; - StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node; - if (AnimationTreeEditor::get_singleton()->get_tree() && !AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { - activity = AnimationTreeEditor::get_singleton()->get_tree()->get_connection_activity(path, E.input_index); + if (error != error_label->get_text()) { + error_label->set_text(error); + if (!error.is_empty()) { + error_panel->show(); + } else { + error_panel->hide(); + } } - graph->set_connection_activity(E.output_node, 0, E.input_node, E.input_index, activity); - } - AnimationTree *graph_player = AnimationTreeEditor::get_singleton()->get_tree(); - AnimationPlayer *player = nullptr; - if (graph_player->has_node(graph_player->get_animation_player())) { - player = Object::cast_to<AnimationPlayer>(graph_player->get_node(graph_player->get_animation_player())); - } + List<AnimationNodeBlendTree::NodeConnection> conns; + blend_tree->get_node_connections(&conns); + for (const AnimationNodeBlendTree::NodeConnection &E : conns) { + float activity = 0; + StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node; + if (AnimationTreeEditor::get_singleton()->get_tree() && !AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { + activity = AnimationTreeEditor::get_singleton()->get_tree()->get_connection_activity(path, E.input_index); + } + graph->set_connection_activity(E.output_node, 0, E.input_node, E.input_index, activity); + } - if (player) { - for (const KeyValue<StringName, ProgressBar *> &E : animations) { - Ref<AnimationNodeAnimation> an = blend_tree->get_node(E.key); - if (an.is_valid()) { - if (player->has_animation(an->get_animation())) { - Ref<Animation> anim = player->get_animation(an->get_animation()); - if (anim.is_valid()) { - E.value->set_max(anim->get_length()); - //StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node; - StringName time_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E.key) + "/time"; - E.value->set_value(AnimationTreeEditor::get_singleton()->get_tree()->get(time_path)); + AnimationTree *graph_player = AnimationTreeEditor::get_singleton()->get_tree(); + AnimationPlayer *player = nullptr; + if (graph_player->has_node(graph_player->get_animation_player())) { + player = Object::cast_to<AnimationPlayer>(graph_player->get_node(graph_player->get_animation_player())); + } + + if (player) { + for (const KeyValue<StringName, ProgressBar *> &E : animations) { + Ref<AnimationNodeAnimation> an = blend_tree->get_node(E.key); + if (an.is_valid()) { + if (player->has_animation(an->get_animation())) { + Ref<Animation> anim = player->get_animation(an->get_animation()); + if (anim.is_valid()) { + E.value->set_max(anim->get_length()); + //StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node; + StringName time_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E.key) + "/time"; + E.value->set_value(AnimationTreeEditor::get_singleton()->get_tree()->get(time_path)); + } } } } } - } - for (int i = 0; i < visible_properties.size(); i++) { - visible_properties[i]->update_property(); - } - } + for (int i = 0; i < visible_properties.size(); i++) { + visible_properties[i]->update_property(); + } + } break; - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - set_process(is_visible_in_tree()); + case NOTIFICATION_VISIBILITY_CHANGED: { + set_process(is_visible_in_tree()); + } break; } } diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h index b1b905a3f5..c111f9245e 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.h +++ b/editor/plugins/animation_blend_tree_editor_plugin.h @@ -119,6 +119,9 @@ class AnimationNodeBlendTreeEditor : public AnimationTreeNodeEditorPlugin { void _property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing); void _removed_from_graph(); + void _update_editor_settings(); + void _update_theme(); + EditorFileDialog *open_file; Ref<AnimationNode> file_loaded; void _file_opened(const String &p_file); diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 28b1126102..ad126d28f6 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -94,6 +94,7 @@ void AnimationPlayerEditor::_notification(int p_what) { last_active = player->is_playing(); updating = false; } break; + case NOTIFICATION_ENTER_TREE: { tool_anim->get_popup()->connect("id_pressed", callable_mp(this, &AnimationPlayerEditor::_animation_tool_menu)); @@ -105,9 +106,11 @@ void AnimationPlayerEditor::_notification(int p_what) { add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel"))); } break; + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel"))); } break; + case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_THEME_CHANGED: { diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 5e32c77511..6c284f2268 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -884,169 +884,174 @@ void AnimationNodeStateMachineEditor::_update_graph() { } void AnimationNodeStateMachineEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) { - error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); - error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); - panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); - - tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); - tool_create->set_icon(get_theme_icon(SNAME("ToolAddNode"), SNAME("EditorIcons"))); - tool_connect->set_icon(get_theme_icon(SNAME("ToolConnect"), SNAME("EditorIcons"))); - - transition_mode->clear(); - transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionImmediate"), SNAME("EditorIcons")), TTR("Immediate")); - transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionSync"), SNAME("EditorIcons")), TTR("Sync")); - transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionEnd"), SNAME("EditorIcons")), TTR("At End")); - - tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); - tool_autoplay->set_icon(get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons"))); - tool_end->set_icon(get_theme_icon(SNAME("AutoEnd"), SNAME("EditorIcons"))); - - play_mode->clear(); - play_mode->add_icon_item(get_theme_icon(SNAME("PlayTravel"), SNAME("EditorIcons")), TTR("Travel")); - play_mode->add_icon_item(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")), TTR("Immediate")); - } - - if (p_what == NOTIFICATION_PROCESS) { - String error; - - Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback"); - - if (error_time > 0) { - error = error_text; - error_time -= get_process_delta_time(); - } else if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) { - error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails."); - } else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { - error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason(); - /*} else if (state_machine->get_parent().is_valid() && state_machine->get_parent()->is_class("AnimationNodeStateMachine")) { - if (state_machine->get_start_node() == StringName() || state_machine->get_end_node() == StringName()) { - error = TTR("Start and end nodes are needed for a sub-transition."); - }*/ - } else if (playback.is_null()) { - error = vformat(TTR("No playback resource set at path: %s."), AnimationTreeEditor::get_singleton()->get_base_path() + "playback"); - } - - if (error != error_label->get_text()) { - error_label->set_text(error); - if (!error.is_empty()) { - error_panel->show(); - } else { - error_panel->hide(); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: + case NOTIFICATION_TRANSLATION_CHANGED: { + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + + tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + tool_create->set_icon(get_theme_icon(SNAME("ToolAddNode"), SNAME("EditorIcons"))); + tool_connect->set_icon(get_theme_icon(SNAME("ToolConnect"), SNAME("EditorIcons"))); + + transition_mode->clear(); + transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionImmediate"), SNAME("EditorIcons")), TTR("Immediate")); + transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionSync"), SNAME("EditorIcons")), TTR("Sync")); + transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionEnd"), SNAME("EditorIcons")), TTR("At End")); + + tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + tool_autoplay->set_icon(get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons"))); + tool_end->set_icon(get_theme_icon(SNAME("AutoEnd"), SNAME("EditorIcons"))); + + play_mode->clear(); + play_mode->add_icon_item(get_theme_icon(SNAME("PlayTravel"), SNAME("EditorIcons")), TTR("Travel")); + play_mode->add_icon_item(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")), TTR("Immediate")); + } break; + + case NOTIFICATION_PROCESS: { + String error; + + Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback"); + + if (error_time > 0) { + error = error_text; + error_time -= get_process_delta_time(); + } else if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) { + error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails."); + } else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { + error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason(); + /*} else if (state_machine->get_parent().is_valid() && state_machine->get_parent()->is_class("AnimationNodeStateMachine")) { + if (state_machine->get_start_node() == StringName() || state_machine->get_end_node() == StringName()) { + error = TTR("Start and end nodes are needed for a sub-transition."); + }*/ + } else if (playback.is_null()) { + error = vformat(TTR("No playback resource set at path: %s."), AnimationTreeEditor::get_singleton()->get_base_path() + "playback"); } - } - for (int i = 0; i < transition_lines.size(); i++) { - int tidx = -1; - for (int j = 0; j < state_machine->get_transition_count(); j++) { - if (transition_lines[i].from_node == state_machine->get_transition_from(j) && transition_lines[i].to_node == state_machine->get_transition_to(j)) { - tidx = j; - break; + if (error != error_label->get_text()) { + error_label->set_text(error); + if (!error.is_empty()) { + error_panel->show(); + } else { + error_panel->hide(); } } - if (tidx == -1) { //missing transition, should redraw - state_machine_draw->update(); - break; - } + for (int i = 0; i < transition_lines.size(); i++) { + int tidx = -1; + for (int j = 0; j < state_machine->get_transition_count(); j++) { + if (transition_lines[i].from_node == state_machine->get_transition_from(j) && transition_lines[i].to_node == state_machine->get_transition_to(j)) { + tidx = j; + break; + } + } - if (transition_lines[i].disabled != state_machine->get_transition(tidx)->is_disabled()) { - state_machine_draw->update(); - break; - } + if (tidx == -1) { //missing transition, should redraw + state_machine_draw->update(); + break; + } - if (transition_lines[i].auto_advance != state_machine->get_transition(tidx)->has_auto_advance()) { - state_machine_draw->update(); - break; - } + if (transition_lines[i].disabled != state_machine->get_transition(tidx)->is_disabled()) { + state_machine_draw->update(); + break; + } - if (transition_lines[i].advance_condition_name != state_machine->get_transition(tidx)->get_advance_condition_name()) { - state_machine_draw->update(); - break; - } + if (transition_lines[i].auto_advance != state_machine->get_transition(tidx)->has_auto_advance()) { + state_machine_draw->update(); + break; + } - if (transition_lines[i].mode != state_machine->get_transition(tidx)->get_switch_mode()) { - state_machine_draw->update(); - break; - } + if (transition_lines[i].advance_condition_name != state_machine->get_transition(tidx)->get_advance_condition_name()) { + state_machine_draw->update(); + break; + } - bool acstate = transition_lines[i].advance_condition_name != StringName() && bool(AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + String(transition_lines[i].advance_condition_name))); + if (transition_lines[i].mode != state_machine->get_transition(tidx)->get_switch_mode()) { + state_machine_draw->update(); + break; + } - if (transition_lines[i].advance_condition_state != acstate) { - state_machine_draw->update(); - break; + bool acstate = transition_lines[i].advance_condition_name != StringName() && bool(AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + String(transition_lines[i].advance_condition_name))); + + if (transition_lines[i].advance_condition_state != acstate) { + state_machine_draw->update(); + break; + } } - } - bool same_travel_path = true; - Vector<StringName> tp; - bool is_playing = false; - StringName current_node; - StringName blend_from_node; - play_pos = 0; - current_length = 0; - - if (playback.is_valid()) { - tp = playback->get_travel_path(); - is_playing = playback->is_playing(); - current_node = playback->get_current_node(); - blend_from_node = playback->get_blend_from_node(); - play_pos = playback->get_current_play_pos(); - current_length = playback->get_current_length(); - } + bool same_travel_path = true; + Vector<StringName> tp; + bool is_playing = false; + StringName current_node; + StringName blend_from_node; + play_pos = 0; + current_length = 0; + + if (playback.is_valid()) { + tp = playback->get_travel_path(); + is_playing = playback->is_playing(); + current_node = playback->get_current_node(); + blend_from_node = playback->get_blend_from_node(); + play_pos = playback->get_current_play_pos(); + current_length = playback->get_current_length(); + } - { - if (last_travel_path.size() != tp.size()) { - same_travel_path = false; - } else { - for (int i = 0; i < last_travel_path.size(); i++) { - if (last_travel_path[i] != tp[i]) { - same_travel_path = false; - break; + { + if (last_travel_path.size() != tp.size()) { + same_travel_path = false; + } else { + for (int i = 0; i < last_travel_path.size(); i++) { + if (last_travel_path[i] != tp[i]) { + same_travel_path = false; + break; + } } } } - } - //update if travel state changed - if (!same_travel_path || last_active != is_playing || last_current_node != current_node || last_blend_from_node != blend_from_node) { - state_machine_draw->update(); - last_travel_path = tp; - last_current_node = current_node; - last_active = is_playing; - last_blend_from_node = blend_from_node; - state_machine_play_pos->update(); - } + //update if travel state changed + if (!same_travel_path || last_active != is_playing || last_current_node != current_node || last_blend_from_node != blend_from_node) { + state_machine_draw->update(); + last_travel_path = tp; + last_current_node = current_node; + last_active = is_playing; + last_blend_from_node = blend_from_node; + state_machine_play_pos->update(); + } - { - if (current_node != StringName() && state_machine->has_node(current_node)) { - String next = current_node; - Ref<AnimationNodeStateMachine> anodesm = state_machine->get_node(next); - Ref<AnimationNodeStateMachinePlayback> current_node_playback; - - while (anodesm.is_valid()) { - current_node_playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + next + "/playback"); - next += "/" + current_node_playback->get_current_node(); - anodesm = anodesm->get_node(current_node_playback->get_current_node()); - } + { + if (current_node != StringName() && state_machine->has_node(current_node)) { + String next = current_node; + Ref<AnimationNodeStateMachine> anodesm = state_machine->get_node(next); + Ref<AnimationNodeStateMachinePlayback> current_node_playback; - // when current_node is a state machine, use playback of current_node to set play_pos - if (current_node_playback.is_valid()) { - play_pos = current_node_playback->get_current_play_pos(); - current_length = current_node_playback->get_current_length(); + while (anodesm.is_valid()) { + current_node_playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + next + "/playback"); + next += "/" + current_node_playback->get_current_node(); + anodesm = anodesm->get_node(current_node_playback->get_current_node()); + } + + // when current_node is a state machine, use playback of current_node to set play_pos + if (current_node_playback.is_valid()) { + play_pos = current_node_playback->get_current_play_pos(); + current_length = current_node_playback->get_current_length(); + } } } - } - if (last_play_pos != play_pos) { - last_play_pos = play_pos; - state_machine_play_pos->update(); - } - } + if (last_play_pos != play_pos) { + last_play_pos = play_pos; + state_machine_play_pos->update(); + } + } break; - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - over_node = StringName(); - set_process(is_visible_in_tree()); + case NOTIFICATION_VISIBILITY_CHANGED: { + over_node = StringName(); + set_process(is_visible_in_tree()); + } break; } } diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index f7057f375e..7ea6906d72 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -145,19 +145,21 @@ void AnimationTreeEditor::enter_editor(const String &p_path) { } void AnimationTreeEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_PROCESS) { - ObjectID root; - if (tree && tree->get_tree_root().is_valid()) { - root = tree->get_tree_root()->get_instance_id(); - } + switch (p_what) { + case NOTIFICATION_PROCESS: { + ObjectID root; + if (tree && tree->get_tree_root().is_valid()) { + root = tree->get_tree_root()->get_instance_id(); + } - if (root != current_root) { - edit_path(Vector<String>()); - } + if (root != current_root) { + edit_path(Vector<String>()); + } - if (button_path.size() != edited_path.size()) { - edit_path(edited_path); - } + if (button_path.size() != edited_path.size()) { + edit_path(edited_path); + } + } break; } } diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 7ab9fa05f7..9e9915cfa4 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -68,11 +68,13 @@ void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Textur } void EditorAssetLibraryItem::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - icon->set_normal_texture(get_theme_icon(SNAME("ProjectIconLoading"), SNAME("EditorIcons"))); - category->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5)); - author->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5)); - price->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5)); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + icon->set_normal_texture(get_theme_icon(SNAME("ProjectIconLoading"), SNAME("EditorIcons"))); + category->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5)); + author->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5)); + price->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5)); + } break; } } @@ -406,6 +408,7 @@ void EditorAssetLibraryItemDownload::_notification(int p_what) { status->add_theme_color_override("font_color", get_theme_color(SNAME("status_color"), SNAME("AssetLib"))); dismiss_button->set_normal_texture(get_theme_icon(SNAME("dismiss"), SNAME("AssetLib"))); } break; + case NOTIFICATION_PROCESS: { // Make the progress bar visible again when retrying the download. progress->set_modulate(Color(1, 1, 1, 1)); @@ -576,6 +579,7 @@ void EditorAssetLibrary::_notification(int p_what) { case NOTIFICATION_READY: { error_label->raise(); } break; + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { error_tr->set_texture(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); @@ -584,6 +588,7 @@ void EditorAssetLibrary::_notification(int p_what) { downloads_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); error_label->add_theme_color_override("color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); } break; + case NOTIFICATION_VISIBILITY_CHANGED: { if (is_visible()) { // Focus the search box automatically when switching to the Templates tab (in the Project Manager) @@ -596,6 +601,7 @@ void EditorAssetLibrary::_notification(int p_what) { } } } break; + case NOTIFICATION_PROCESS: { HTTPClient::Status s = request->get_http_client_status(); const bool loading = s != HTTPClient::STATUS_DISCONNECTED; @@ -612,6 +618,7 @@ void EditorAssetLibrary::_notification(int p_what) { } } break; + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { _update_repository_options(); setup_http_request(request); diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp index c77ff5778a..a60e49ca9d 100644 --- a/editor/plugins/audio_stream_editor_plugin.cpp +++ b/editor/plugins/audio_stream_editor_plugin.cpp @@ -39,29 +39,32 @@ #include "editor/editor_settings.h" void AudioStreamEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - AudioStreamPreviewGenerator::get_singleton()->connect("preview_updated", callable_mp(this, &AudioStreamEditor::_preview_changed)); - } - - if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { - _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); - _stop_button->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); - _preview->set_color(get_theme_color(SNAME("dark_color_2"), SNAME("Editor"))); - set_color(get_theme_color(SNAME("dark_color_1"), SNAME("Editor"))); - - _indicator->update(); - _preview->update(); - } - - if (p_what == NOTIFICATION_PROCESS) { - _current = _player->get_playback_position(); - _indicator->update(); - } - - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - if (!is_visible_in_tree()) { - _stop(); - } + switch (p_what) { + case NOTIFICATION_READY: { + AudioStreamPreviewGenerator::get_singleton()->connect("preview_updated", callable_mp(this, &AudioStreamEditor::_preview_changed)); + } break; + + case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_ENTER_TREE: { + _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + _stop_button->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); + _preview->set_color(get_theme_color(SNAME("dark_color_2"), SNAME("Editor"))); + set_color(get_theme_color(SNAME("dark_color_1"), SNAME("Editor"))); + + _indicator->update(); + _preview->update(); + } break; + + case NOTIFICATION_PROCESS: { + _current = _player->get_playback_position(); + _indicator->update(); + } break; + + case NOTIFICATION_VISIBILITY_CHANGED: { + if (!is_visible_in_tree()) { + _stop(); + } + } break; } } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 06ca89da51..76558eb946 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3694,149 +3694,154 @@ void CanvasItemEditor::set_current_tool(Tool p_tool) { _button_tool_select(p_tool); } +void CanvasItemEditor::_update_editor_settings() { + select_button->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + list_select_button->set_icon(get_theme_icon(SNAME("ListSelect"), SNAME("EditorIcons"))); + move_button->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons"))); + scale_button->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons"))); + rotate_button->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons"))); + smart_snap_button->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); + grid_snap_button->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); + snap_config_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + skeleton_menu->set_icon(get_theme_icon(SNAME("Bone"), SNAME("EditorIcons"))); + override_camera_button->set_icon(get_theme_icon(SNAME("Camera2D"), SNAME("EditorIcons"))); + pan_button->set_icon(get_theme_icon(SNAME("ToolPan"), SNAME("EditorIcons"))); + ruler_button->set_icon(get_theme_icon(SNAME("Ruler"), SNAME("EditorIcons"))); + pivot_button->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons"))); + select_handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); + anchor_handle = get_theme_icon(SNAME("EditorControlAnchor"), SNAME("EditorIcons")); + lock_button->set_icon(get_theme_icon(SNAME("Lock"), SNAME("EditorIcons"))); + unlock_button->set_icon(get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons"))); + group_button->set_icon(get_theme_icon(SNAME("Group"), SNAME("EditorIcons"))); + ungroup_button->set_icon(get_theme_icon(SNAME("Ungroup"), SNAME("EditorIcons"))); + key_loc_button->set_icon(get_theme_icon(SNAME("KeyPosition"), SNAME("EditorIcons"))); + key_rot_button->set_icon(get_theme_icon(SNAME("KeyRotation"), SNAME("EditorIcons"))); + key_scale_button->set_icon(get_theme_icon(SNAME("KeyScale"), SNAME("EditorIcons"))); + key_insert_button->set_icon(get_theme_icon(SNAME("Key"), SNAME("EditorIcons"))); + key_auto_insert_button->set_icon(get_theme_icon(SNAME("AutoKey"), SNAME("EditorIcons"))); + // Use a different color for the active autokey icon to make them easier + // to distinguish from the other key icons at the top. On a light theme, + // the icon will be dark, so we need to lighten it before blending it + // with the red color. + const Color key_auto_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25); + key_auto_insert_button->add_theme_color_override("icon_pressed_color", key_auto_color.lerp(Color(1, 0, 0), 0.55)); + animation_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + + _update_context_menu_stylebox(); + + panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/2d_editor_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning"))); + pan_speed = int(EditorSettings::get_singleton()->get("editors/panning/2d_editor_pan_speed")); + warped_panning = bool(EditorSettings::get_singleton()->get("editors/panning/warped_mouse_panning")); +} + void CanvasItemEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_PHYSICS_PROCESS) { - EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET("gui/common/snap_controls_to_pixels")); + switch (p_what) { + case NOTIFICATION_PHYSICS_PROCESS: { + EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET("gui/common/snap_controls_to_pixels")); - int nb_having_pivot = 0; + int nb_having_pivot = 0; - // Update the viewport if the canvas_item changes - List<CanvasItem *> selection = _get_edited_canvas_items(true); - for (CanvasItem *canvas_item : selection) { - CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); + // Update the viewport if the canvas_item changes + List<CanvasItem *> selection = _get_edited_canvas_items(true); + for (CanvasItem *canvas_item : selection) { + CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); - Rect2 rect; - if (canvas_item->_edit_use_rect()) { - rect = canvas_item->_edit_get_rect(); - } else { - rect = Rect2(); - } - Transform2D xform = canvas_item->get_transform(); + Rect2 rect; + if (canvas_item->_edit_use_rect()) { + rect = canvas_item->_edit_get_rect(); + } else { + rect = Rect2(); + } + Transform2D xform = canvas_item->get_transform(); - if (rect != se->prev_rect || xform != se->prev_xform) { - viewport->update(); - se->prev_rect = rect; - se->prev_xform = xform; + if (rect != se->prev_rect || xform != se->prev_xform) { + viewport->update(); + se->prev_rect = rect; + se->prev_xform = xform; + } + + Control *control = Object::cast_to<Control>(canvas_item); + if (control) { + real_t anchors[4]; + Vector2 pivot; + + pivot = control->get_pivot_offset(); + anchors[SIDE_LEFT] = control->get_anchor(SIDE_LEFT); + anchors[SIDE_RIGHT] = control->get_anchor(SIDE_RIGHT); + anchors[SIDE_TOP] = control->get_anchor(SIDE_TOP); + anchors[SIDE_BOTTOM] = control->get_anchor(SIDE_BOTTOM); + + if (pivot != se->prev_pivot || anchors[SIDE_LEFT] != se->prev_anchors[SIDE_LEFT] || anchors[SIDE_RIGHT] != se->prev_anchors[SIDE_RIGHT] || anchors[SIDE_TOP] != se->prev_anchors[SIDE_TOP] || anchors[SIDE_BOTTOM] != se->prev_anchors[SIDE_BOTTOM]) { + se->prev_pivot = pivot; + se->prev_anchors[SIDE_LEFT] = anchors[SIDE_LEFT]; + se->prev_anchors[SIDE_RIGHT] = anchors[SIDE_RIGHT]; + se->prev_anchors[SIDE_TOP] = anchors[SIDE_TOP]; + se->prev_anchors[SIDE_BOTTOM] = anchors[SIDE_BOTTOM]; + viewport->update(); + } + } + + if (canvas_item->_edit_use_pivot()) { + nb_having_pivot++; + } } - Control *control = Object::cast_to<Control>(canvas_item); - if (control) { - real_t anchors[4]; - Vector2 pivot; - - pivot = control->get_pivot_offset(); - anchors[SIDE_LEFT] = control->get_anchor(SIDE_LEFT); - anchors[SIDE_RIGHT] = control->get_anchor(SIDE_RIGHT); - anchors[SIDE_TOP] = control->get_anchor(SIDE_TOP); - anchors[SIDE_BOTTOM] = control->get_anchor(SIDE_BOTTOM); - - if (pivot != se->prev_pivot || anchors[SIDE_LEFT] != se->prev_anchors[SIDE_LEFT] || anchors[SIDE_RIGHT] != se->prev_anchors[SIDE_RIGHT] || anchors[SIDE_TOP] != se->prev_anchors[SIDE_TOP] || anchors[SIDE_BOTTOM] != se->prev_anchors[SIDE_BOTTOM]) { - se->prev_pivot = pivot; - se->prev_anchors[SIDE_LEFT] = anchors[SIDE_LEFT]; - se->prev_anchors[SIDE_RIGHT] = anchors[SIDE_RIGHT]; - se->prev_anchors[SIDE_TOP] = anchors[SIDE_TOP]; - se->prev_anchors[SIDE_BOTTOM] = anchors[SIDE_BOTTOM]; + // Activate / Deactivate the pivot tool + pivot_button->set_disabled(nb_having_pivot == 0); + + // Update the viewport if bones changes + for (KeyValue<BoneKey, BoneList> &E : bone_list) { + Object *b = ObjectDB::get_instance(E.key.from); + if (!b) { viewport->update(); + break; } - } - if (canvas_item->_edit_use_pivot()) { - nb_having_pivot++; - } - } + Node2D *b2 = Object::cast_to<Node2D>(b); + if (!b2 || !b2->is_inside_tree()) { + continue; + } - // Activate / Deactivate the pivot tool - pivot_button->set_disabled(nb_having_pivot == 0); + Transform2D global_xform = b2->get_global_transform(); - // Update the viewport if bones changes - for (KeyValue<BoneKey, BoneList> &E : bone_list) { - Object *b = ObjectDB::get_instance(E.key.from); - if (!b) { - viewport->update(); - break; + if (global_xform != E.value.xform) { + E.value.xform = global_xform; + viewport->update(); + } + + Bone2D *bone = Object::cast_to<Bone2D>(b); + if (bone && bone->get_length() != E.value.length) { + E.value.length = bone->get_length(); + viewport->update(); + } } + } break; - Node2D *b2 = Object::cast_to<Node2D>(b); - if (!b2 || !b2->is_inside_tree()) { - continue; + case NOTIFICATION_ENTER_TREE: { + select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons"))); + for (int i = 0; i < 4; i++) { + select_sb->set_margin_size(Side(i), 4); + select_sb->set_default_margin(Side(i), 4); } - Transform2D global_xform = b2->get_global_transform(); + AnimationPlayerEditor::get_singleton()->get_track_editor()->connect("visibility_changed", callable_mp(this, &CanvasItemEditor::_keying_changed)); + _keying_changed(); + _update_editor_settings(); + } break; - if (global_xform != E.value.xform) { - E.value.xform = global_xform; - viewport->update(); - } + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { + select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons"))); + _update_editor_settings(); + } break; - Bone2D *bone = Object::cast_to<Bone2D>(b); - if (bone && bone->get_length() != E.value.length) { - E.value.length = bone->get_length(); - viewport->update(); - } - } - } + case NOTIFICATION_VISIBILITY_CHANGED: { + if (!is_visible() && override_camera_button->is_pressed()) { + EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton(); - if (p_what == NOTIFICATION_ENTER_TREE) { - select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons"))); - for (int i = 0; i < 4; i++) { - select_sb->set_margin_size(Side(i), 4); - select_sb->set_default_margin(Side(i), 4); - } - - AnimationPlayerEditor::get_singleton()->get_track_editor()->connect("visibility_changed", callable_mp(this, &CanvasItemEditor::_keying_changed)); - _keying_changed(); - - } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons"))); - } - - if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - select_button->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); - list_select_button->set_icon(get_theme_icon(SNAME("ListSelect"), SNAME("EditorIcons"))); - move_button->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons"))); - scale_button->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons"))); - rotate_button->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons"))); - smart_snap_button->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); - grid_snap_button->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); - snap_config_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - skeleton_menu->set_icon(get_theme_icon(SNAME("Bone"), SNAME("EditorIcons"))); - override_camera_button->set_icon(get_theme_icon(SNAME("Camera2D"), SNAME("EditorIcons"))); - pan_button->set_icon(get_theme_icon(SNAME("ToolPan"), SNAME("EditorIcons"))); - ruler_button->set_icon(get_theme_icon(SNAME("Ruler"), SNAME("EditorIcons"))); - pivot_button->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons"))); - select_handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); - anchor_handle = get_theme_icon(SNAME("EditorControlAnchor"), SNAME("EditorIcons")); - lock_button->set_icon(get_theme_icon(SNAME("Lock"), SNAME("EditorIcons"))); - unlock_button->set_icon(get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons"))); - group_button->set_icon(get_theme_icon(SNAME("Group"), SNAME("EditorIcons"))); - ungroup_button->set_icon(get_theme_icon(SNAME("Ungroup"), SNAME("EditorIcons"))); - key_loc_button->set_icon(get_theme_icon(SNAME("KeyPosition"), SNAME("EditorIcons"))); - key_rot_button->set_icon(get_theme_icon(SNAME("KeyRotation"), SNAME("EditorIcons"))); - key_scale_button->set_icon(get_theme_icon(SNAME("KeyScale"), SNAME("EditorIcons"))); - key_insert_button->set_icon(get_theme_icon(SNAME("Key"), SNAME("EditorIcons"))); - key_auto_insert_button->set_icon(get_theme_icon(SNAME("AutoKey"), SNAME("EditorIcons"))); - // Use a different color for the active autokey icon to make them easier - // to distinguish from the other key icons at the top. On a light theme, - // the icon will be dark, so we need to lighten it before blending it - // with the red color. - const Color key_auto_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25); - key_auto_insert_button->add_theme_color_override("icon_pressed_color", key_auto_color.lerp(Color(1, 0, 0), 0.55)); - animation_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - - _update_context_menu_stylebox(); - - panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/2d_editor_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning"))); - pan_speed = int(EditorSettings::get_singleton()->get("editors/panning/2d_editor_pan_speed")); - warped_panning = bool(EditorSettings::get_singleton()->get("editors/panning/warped_mouse_panning")); - } - - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - if (!is_visible() && override_camera_button->is_pressed()) { - EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton(); - - debugger->set_camera_override(EditorDebuggerNode::OVERRIDE_NONE); - override_camera_button->set_pressed(false); - } + debugger->set_camera_override(EditorDebuggerNode::OVERRIDE_NONE); + override_camera_button->set_pressed(false); + } + } break; } } @@ -5702,29 +5707,32 @@ Node *CanvasItemEditorViewport::_make_texture_node_type(String texture_node_type return node; } -void CanvasItemEditorViewport::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - List<BaseButton *> btn_list; - button_group->get_buttons(&btn_list); - - for (int i = 0; i < btn_list.size(); i++) { - CheckBox *check = Object::cast_to<CheckBox>(btn_list[i]); - check->set_icon(get_theme_icon(check->get_text(), SNAME("EditorIcons"))); - } +void CanvasItemEditorViewport::_update_theme() { + List<BaseButton *> btn_list; + button_group->get_buttons(&btn_list); - label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + for (int i = 0; i < btn_list.size(); i++) { + CheckBox *check = Object::cast_to<CheckBox>(btn_list[i]); + check->set_icon(get_theme_icon(check->get_text(), SNAME("EditorIcons"))); } + label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); +} + +void CanvasItemEditorViewport::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_THEME_CHANGED: { + _update_theme(); + } break; + case NOTIFICATION_ENTER_TREE: { + _update_theme(); connect("mouse_exited", callable_mp(this, &CanvasItemEditorViewport::_on_mouse_exit)); } break; + case NOTIFICATION_EXIT_TREE: { disconnect("mouse_exited", callable_mp(this, &CanvasItemEditorViewport::_on_mouse_exit)); } break; - - default: - break; } } diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 6c1b18acf4..57760475a1 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -389,6 +389,7 @@ private: void _add_node_pressed(int p_result); void _node_created(Node *p_node); void _reset_create_position(); + void _update_editor_settings(); UndoRedo *undo_redo; @@ -607,6 +608,7 @@ class CanvasItemEditorViewport : public Control { bool _create_instance(Node *parent, String &path, const Point2 &p_point); void _perform_drop_data(); void _show_resource_type_selector(); + void _update_theme(); static void _bind_methods(); diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp index 786c0e002d..79025041d3 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp @@ -224,10 +224,12 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() { } void CPUParticles2DEditorPlugin::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - menu->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticles2DEditorPlugin::_menu_callback)); - menu->set_icon(epoints->get_theme_icon(SNAME("CPUParticles2D"), SNAME("EditorIcons"))); - file->connect("file_selected", callable_mp(this, &CPUParticles2DEditorPlugin::_file_selected)); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + menu->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticles2DEditorPlugin::_menu_callback)); + menu->set_icon(epoints->get_theme_icon(SNAME("CPUParticles2D"), SNAME("EditorIcons"))); + file->connect("file_selected", callable_mp(this, &CPUParticles2DEditorPlugin::_file_selected)); + } break; } } diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.cpp b/editor/plugins/cpu_particles_3d_editor_plugin.cpp index 046a48337a..775c2dbb2a 100644 --- a/editor/plugins/cpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_3d_editor_plugin.cpp @@ -43,8 +43,10 @@ void CPUParticles3DEditor::_node_removed(Node *p_node) { } void CPUParticles3DEditor::_notification(int p_notification) { - if (p_notification == NOTIFICATION_ENTER_TREE) { - options->set_icon(get_theme_icon(SNAME("CPUParticles3D"), SNAME("EditorIcons"))); + switch (p_notification) { + case NOTIFICATION_ENTER_TREE: { + options->set_icon(get_theme_icon(SNAME("CPUParticles3D"), SNAME("EditorIcons"))); + } break; } } diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index d221d8aeaf..6d1a86765a 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -97,8 +97,10 @@ Size2 CurveEditor::get_minimum_size() const { } void CurveEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAW) { - _draw(); + switch (p_what) { + case NOTIFICATION_DRAW: { + _draw(); + } break; } } diff --git a/editor/plugins/debugger_editor_plugin.cpp b/editor/plugins/debugger_editor_plugin.cpp index 32f58c6931..501becac57 100644 --- a/editor/plugins/debugger_editor_plugin.cpp +++ b/editor/plugins/debugger_editor_plugin.cpp @@ -177,8 +177,10 @@ void DebuggerEditorPlugin::_menu_option(int p_option) { } void DebuggerEditorPlugin::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - _update_debug_options(); + switch (p_what) { + case NOTIFICATION_READY: { + _update_debug_options(); + } break; } } diff --git a/editor/plugins/font_editor_plugin.cpp b/editor/plugins/font_editor_plugin.cpp index e14304a2c8..b9de621bcb 100644 --- a/editor/plugins/font_editor_plugin.cpp +++ b/editor/plugins/font_editor_plugin.cpp @@ -33,14 +33,16 @@ #include "editor/editor_scale.h" void FontDataPreview::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAW) { - Color text_color = get_theme_color(SNAME("font_color"), SNAME("Label")); - Color line_color = text_color; - line_color.a *= 0.6; - Vector2 pos = (get_size() - line->get_size()) / 2; - line->draw(get_canvas_item(), pos, text_color); - draw_line(Vector2(0, pos.y + line->get_line_ascent()), Vector2(pos.x - 5, pos.y + line->get_line_ascent()), line_color); - draw_line(Vector2(pos.x + line->get_size().x + 5, pos.y + line->get_line_ascent()), Vector2(get_size().x, pos.y + line->get_line_ascent()), line_color); + switch (p_what) { + case NOTIFICATION_DRAW: { + Color text_color = get_theme_color(SNAME("font_color"), SNAME("Label")); + Color line_color = text_color; + line_color.a *= 0.6; + Vector2 pos = (get_size() - line->get_size()) / 2; + line->draw(get_canvas_item(), pos, text_color); + draw_line(Vector2(0, pos.y + line->get_line_ascent()), Vector2(pos.x - 5, pos.y + line->get_line_ascent()), line_color); + draw_line(Vector2(pos.x + line->get_size().x + 5, pos.y + line->get_line_ascent()), Vector2(get_size().x, pos.y + line->get_line_ascent()), line_color); + } break; } } diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp index fdfd4b5832..b15aec87d9 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp @@ -354,11 +354,13 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() { } void GPUParticles2DEditorPlugin::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - menu->get_popup()->connect("id_pressed", callable_mp(this, &GPUParticles2DEditorPlugin::_menu_callback)); - menu->set_icon(menu->get_theme_icon(SNAME("GPUParticles2D"), SNAME("EditorIcons"))); - file->connect("file_selected", callable_mp(this, &GPUParticles2DEditorPlugin::_file_selected)); - EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", callable_mp(this, &GPUParticles2DEditorPlugin::_selection_changed)); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + menu->get_popup()->connect("id_pressed", callable_mp(this, &GPUParticles2DEditorPlugin::_menu_callback)); + menu->set_icon(menu->get_theme_icon(SNAME("GPUParticles2D"), SNAME("EditorIcons"))); + file->connect("file_selected", callable_mp(this, &GPUParticles2DEditorPlugin::_file_selected)); + EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", callable_mp(this, &GPUParticles2DEditorPlugin::_selection_changed)); + } break; } } diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp index ec61c01705..293d1c3913 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp @@ -231,9 +231,11 @@ void GPUParticles3DEditor::_node_removed(Node *p_node) { } void GPUParticles3DEditor::_notification(int p_notification) { - if (p_notification == NOTIFICATION_ENTER_TREE) { - options->set_icon(options->get_popup()->get_theme_icon(SNAME("GPUParticles3D"), SNAME("EditorIcons"))); - get_tree()->connect("node_removed", callable_mp(this, &GPUParticles3DEditor::_node_removed)); + switch (p_notification) { + case NOTIFICATION_ENTER_TREE: { + options->set_icon(options->get_popup()->get_theme_icon(SNAME("GPUParticles3D"), SNAME("EditorIcons"))); + get_tree()->connect("node_removed", callable_mp(this, &GPUParticles3DEditor::_node_removed)); + } break; } } diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp index f63a31e869..affe10a01d 100644 --- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp @@ -66,41 +66,43 @@ bool GPUParticlesCollisionSDF3DEditorPlugin::handles(Object *p_object) const { } void GPUParticlesCollisionSDF3DEditorPlugin::_notification(int p_what) { - if (p_what == NOTIFICATION_PROCESS) { - if (!col_sdf) { - return; - } + switch (p_what) { + case NOTIFICATION_PROCESS: { + if (!col_sdf) { + return; + } - // Set information tooltip on the Bake button. This information is useful - // to optimize performance (video RAM size) and reduce collision tunneling (individual cell size). + // Set information tooltip on the Bake button. This information is useful + // to optimize performance (video RAM size) and reduce collision tunneling (individual cell size). - const Vector3i size = col_sdf->get_estimated_cell_size(); + const Vector3i size = col_sdf->get_estimated_cell_size(); - const Vector3 extents = col_sdf->get_extents(); + const Vector3 extents = col_sdf->get_extents(); - int data_size = 2; - const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0); - // Add a qualitative measurement to help the user assess whether a GPUParticlesCollisionSDF3D node is using a lot of VRAM. - String size_quality; - if (size_mb < 8.0) { - size_quality = TTR("Low"); - } else if (size_mb < 32.0) { - size_quality = TTR("Moderate"); - } else { - size_quality = TTR("High"); - } + int data_size = 2; + const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0); + // Add a qualitative measurement to help the user assess whether a GPUParticlesCollisionSDF3D node is using a lot of VRAM. + String size_quality; + if (size_mb < 8.0) { + size_quality = TTR("Low"); + } else if (size_mb < 32.0) { + size_quality = TTR("Moderate"); + } else { + size_quality = TTR("High"); + } - String text; - text += vformat(TTR("Subdivisions: %s"), vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z)) + "\n"; - text += vformat(TTR("Cell size: %s"), vformat(String::utf8("%.3f × %.3f × %.3f"), extents.x / size.x, extents.y / size.y, extents.z / size.z)) + "\n"; - text += vformat(TTR("Video RAM size: %s MB (%s)"), String::num(size_mb, 2), size_quality); + String text; + text += vformat(TTR("Subdivisions: %s"), vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z)) + "\n"; + text += vformat(TTR("Cell size: %s"), vformat(String::utf8("%.3f × %.3f × %.3f"), extents.x / size.x, extents.y / size.y, extents.z / size.z)) + "\n"; + text += vformat(TTR("Video RAM size: %s MB (%s)"), String::num(size_mb, 2), size_quality); - // Only update the tooltip when needed to avoid constant redrawing. - if (bake->get_tooltip(Point2()) == text) { - return; - } + // Only update the tooltip when needed to avoid constant redrawing. + if (bake->get_tooltip(Point2()) == text) { + return; + } - bake->set_tooltip(text); + bake->set_tooltip(text); + } break; } } diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp index 3f5b687430..e9d7808684 100644 --- a/editor/plugins/gradient_editor_plugin.cpp +++ b/editor/plugins/gradient_editor_plugin.cpp @@ -91,13 +91,15 @@ GradientEditor::GradientEditor() { /////////////////////// void GradientReverseButton::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> icon = get_theme_icon(SNAME("ReverseGradient"), SNAME("EditorIcons")); - if (is_pressed()) { - draw_texture_rect(icon, Rect2(margin, margin, icon->get_width(), icon->get_height()), false, get_theme_color(SNAME("icon_pressed_color"), SNAME("Button"))); - } else { - draw_texture_rect(icon, Rect2(margin, margin, icon->get_width(), icon->get_height())); - } + switch (p_what) { + case NOTIFICATION_DRAW: { + Ref<Texture2D> icon = get_theme_icon(SNAME("ReverseGradient"), SNAME("EditorIcons")); + if (is_pressed()) { + draw_texture_rect(icon, Rect2(margin, margin, icon->get_width(), icon->get_height()), false, get_theme_color(SNAME("icon_pressed_color"), SNAME("Button"))); + } else { + draw_texture_rect(icon, Rect2(margin, margin, icon->get_width(), icon->get_height())); + } + } break; } } diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index f3759da47f..daa864cfa1 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -38,31 +38,33 @@ #include "scene/resources/sky_material.h" void MaterialEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - //get_scene()->connect("node_removed",this,"_node_removed"); + switch (p_what) { + case NOTIFICATION_READY: { + //get_scene()->connect("node_removed",this,"_node_removed"); - if (first_enter) { - //it's in propertyeditor so.. could be moved around + if (first_enter) { + //it's in propertyeditor so.. could be moved around - light_1_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons"))); - light_1_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight1Off"), SNAME("EditorIcons"))); - light_2_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons"))); - light_2_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight2Off"), SNAME("EditorIcons"))); + light_1_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons"))); + light_1_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight1Off"), SNAME("EditorIcons"))); + light_2_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons"))); + light_2_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight2Off"), SNAME("EditorIcons"))); - sphere_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewSphereOff"), SNAME("EditorIcons"))); - sphere_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewSphere"), SNAME("EditorIcons"))); - box_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewCubeOff"), SNAME("EditorIcons"))); - box_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewCube"), SNAME("EditorIcons"))); + sphere_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewSphereOff"), SNAME("EditorIcons"))); + sphere_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewSphere"), SNAME("EditorIcons"))); + box_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewCubeOff"), SNAME("EditorIcons"))); + box_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewCube"), SNAME("EditorIcons"))); - first_enter = false; - } - } + first_enter = false; + } + } break; - if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); - Size2 size = get_size(); + case NOTIFICATION_DRAW: { + Ref<Texture2D> checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); + Size2 size = get_size(); - draw_texture_rect(checkerboard, Rect2(Point2(), size), true); + draw_texture_rect(checkerboard, Rect2(Point2(), size), true); + } break; } } diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index 8711559dbf..4760b61dc8 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -49,18 +49,20 @@ void MeshEditor::gui_input(const Ref<InputEvent> &p_event) { } void MeshEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - //get_scene()->connect("node_removed",this,"_node_removed"); - - if (first_enter) { - //it's in propertyeditor so. could be moved around - - light_1_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons"))); - light_1_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight1Off"), SNAME("EditorIcons"))); - light_2_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons"))); - light_2_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight2Off"), SNAME("EditorIcons"))); - first_enter = false; - } + switch (p_what) { + case NOTIFICATION_READY: { + //get_scene()->connect("node_removed",this,"_node_removed"); + + if (first_enter) { + //it's in propertyeditor so. could be moved around + + light_1_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons"))); + light_1_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight1Off"), SNAME("EditorIcons"))); + light_2_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons"))); + light_2_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight2Off"), SNAME("EditorIcons"))); + first_enter = false; + } + } break; } } diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 9f432a1fc7..46b33f62fe 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -1069,7 +1069,6 @@ void EditorNode3DGizmoPlugin::_bind_methods() { GDVIRTUAL_BIND(_get_subgizmo_transform, "gizmo", "subgizmo_id"); GDVIRTUAL_BIND(_set_subgizmo_transform, "gizmo", "subgizmo_id", "transform"); GDVIRTUAL_BIND(_commit_subgizmos, "gizmo", "ids", "restores", "cancel"); - ; } bool EditorNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 52671f224e..3d3738ad47 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -82,28 +82,32 @@ #define MAX_FOV 179 void ViewportRotationControl::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - axis_menu_options.clear(); - axis_menu_options.push_back(Node3DEditorViewport::VIEW_RIGHT); - axis_menu_options.push_back(Node3DEditorViewport::VIEW_TOP); - axis_menu_options.push_back(Node3DEditorViewport::VIEW_REAR); - axis_menu_options.push_back(Node3DEditorViewport::VIEW_LEFT); - axis_menu_options.push_back(Node3DEditorViewport::VIEW_BOTTOM); - axis_menu_options.push_back(Node3DEditorViewport::VIEW_FRONT); - - axis_colors.clear(); - axis_colors.push_back(get_theme_color(SNAME("axis_x_color"), SNAME("Editor"))); - axis_colors.push_back(get_theme_color(SNAME("axis_y_color"), SNAME("Editor"))); - axis_colors.push_back(get_theme_color(SNAME("axis_z_color"), SNAME("Editor"))); - update(); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + axis_menu_options.clear(); + axis_menu_options.push_back(Node3DEditorViewport::VIEW_RIGHT); + axis_menu_options.push_back(Node3DEditorViewport::VIEW_TOP); + axis_menu_options.push_back(Node3DEditorViewport::VIEW_REAR); + axis_menu_options.push_back(Node3DEditorViewport::VIEW_LEFT); + axis_menu_options.push_back(Node3DEditorViewport::VIEW_BOTTOM); + axis_menu_options.push_back(Node3DEditorViewport::VIEW_FRONT); + + axis_colors.clear(); + axis_colors.push_back(get_theme_color(SNAME("axis_x_color"), SNAME("Editor"))); + axis_colors.push_back(get_theme_color(SNAME("axis_y_color"), SNAME("Editor"))); + axis_colors.push_back(get_theme_color(SNAME("axis_z_color"), SNAME("Editor"))); + update(); - if (!is_connected("mouse_exited", callable_mp(this, &ViewportRotationControl::_on_mouse_exited))) { - connect("mouse_exited", callable_mp(this, &ViewportRotationControl::_on_mouse_exited)); - } - } + if (!is_connected("mouse_exited", callable_mp(this, &ViewportRotationControl::_on_mouse_exited))) { + connect("mouse_exited", callable_mp(this, &ViewportRotationControl::_on_mouse_exited)); + } + } break; - if (p_what == NOTIFICATION_DRAW && viewport != nullptr) { - _draw(); + case NOTIFICATION_DRAW: { + if (viewport != nullptr) { + _draw(); + } + } break; } } @@ -2422,279 +2426,281 @@ void Node3DEditorViewport::_project_settings_changed() { } void Node3DEditorViewport::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - EditorNode::get_singleton()->connect("project_settings_changed", callable_mp(this, &Node3DEditorViewport::_project_settings_changed)); - } + switch (p_what) { + case NOTIFICATION_READY: { + EditorNode::get_singleton()->connect("project_settings_changed", callable_mp(this, &Node3DEditorViewport::_project_settings_changed)); + } break; - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - bool visible = is_visible_in_tree(); + case NOTIFICATION_VISIBILITY_CHANGED: { + bool visible = is_visible_in_tree(); - set_process(visible); + set_process(visible); - if (visible) { - orthogonal = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL)); - _update_name(); - _update_camera(0); - } else { - set_freelook_active(false); - } - call_deferred(SNAME("update_transform_gizmo_view")); - rotation_control->set_visible(EditorSettings::get_singleton()->get("editors/3d/navigation/show_viewport_rotation_gizmo")); - } + if (visible) { + orthogonal = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL)); + _update_name(); + _update_camera(0); + } else { + set_freelook_active(false); + } + call_deferred(SNAME("update_transform_gizmo_view")); + rotation_control->set_visible(EditorSettings::get_singleton()->get("editors/3d/navigation/show_viewport_rotation_gizmo")); + } break; - if (p_what == NOTIFICATION_RESIZED) { - call_deferred(SNAME("update_transform_gizmo_view")); - } + case NOTIFICATION_RESIZED: { + call_deferred(SNAME("update_transform_gizmo_view")); + } break; - if (p_what == NOTIFICATION_PROCESS) { - real_t delta = get_process_delta_time(); + case NOTIFICATION_PROCESS: { + real_t delta = get_process_delta_time(); - if (zoom_indicator_delay > 0) { - zoom_indicator_delay -= delta; - if (zoom_indicator_delay <= 0) { - surface->update(); - zoom_limit_label->hide(); + if (zoom_indicator_delay > 0) { + zoom_indicator_delay -= delta; + if (zoom_indicator_delay <= 0) { + surface->update(); + zoom_limit_label->hide(); + } } - } - _update_freelook(delta); + _update_freelook(delta); - Node *scene_root = SceneTreeDock::get_singleton()->get_editor_data()->get_edited_scene_root(); - if (previewing_cinema && scene_root != nullptr) { - Camera3D *cam = scene_root->get_viewport()->get_camera_3d(); - if (cam != nullptr && cam != previewing) { - //then switch the viewport's camera to the scene's viewport camera - if (previewing != nullptr) { - previewing->disconnect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); + Node *scene_root = SceneTreeDock::get_singleton()->get_editor_data()->get_edited_scene_root(); + if (previewing_cinema && scene_root != nullptr) { + Camera3D *cam = scene_root->get_viewport()->get_camera_3d(); + if (cam != nullptr && cam != previewing) { + //then switch the viewport's camera to the scene's viewport camera + if (previewing != nullptr) { + previewing->disconnect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); + } + previewing = cam; + previewing->connect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); + RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), cam->get_camera()); + surface->update(); } - previewing = cam; - previewing->connect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); - RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), cam->get_camera()); - surface->update(); } - } - _update_camera(delta); + _update_camera(delta); - Map<Node *, Object *> &selection = editor_selection->get_selection(); + Map<Node *, Object *> &selection = editor_selection->get_selection(); - bool changed = false; - bool exist = false; + bool changed = false; + bool exist = false; - for (const KeyValue<Node *, Object *> &E : selection) { - Node3D *sp = Object::cast_to<Node3D>(E.key); - if (!sp) { - continue; - } + for (const KeyValue<Node *, Object *> &E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E.key); + if (!sp) { + continue; + } - Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); - if (!se) { - continue; - } + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); + if (!se) { + continue; + } - Transform3D t = sp->get_global_gizmo_transform(); - VisualInstance3D *vi = Object::cast_to<VisualInstance3D>(sp); - AABB new_aabb = vi ? vi->get_aabb() : _calculate_spatial_bounds(sp); + Transform3D t = sp->get_global_gizmo_transform(); + VisualInstance3D *vi = Object::cast_to<VisualInstance3D>(sp); + AABB new_aabb = vi ? vi->get_aabb() : _calculate_spatial_bounds(sp); - exist = true; - if (se->last_xform == t && se->aabb == new_aabb && !se->last_xform_dirty) { - continue; - } - changed = true; - se->last_xform_dirty = false; - se->last_xform = t; + exist = true; + if (se->last_xform == t && se->aabb == new_aabb && !se->last_xform_dirty) { + continue; + } + changed = true; + se->last_xform_dirty = false; + se->last_xform = t; - se->aabb = new_aabb; + se->aabb = new_aabb; - Transform3D t_offset = t; + Transform3D t_offset = t; - // apply AABB scaling before item's global transform - { - const Vector3 offset(0.005, 0.005, 0.005); - Basis aabb_s; - aabb_s.scale(se->aabb.size + offset); - t.translate(se->aabb.position - offset / 2); - t.basis = t.basis * aabb_s; - } - { - const Vector3 offset(0.01, 0.01, 0.01); - Basis aabb_s; - aabb_s.scale(se->aabb.size + offset); - t_offset.translate(se->aabb.position - offset / 2); - t_offset.basis = t_offset.basis * aabb_s; + // apply AABB scaling before item's global transform + { + const Vector3 offset(0.005, 0.005, 0.005); + Basis aabb_s; + aabb_s.scale(se->aabb.size + offset); + t.translate(se->aabb.position - offset / 2); + t.basis = t.basis * aabb_s; + } + { + const Vector3 offset(0.01, 0.01, 0.01); + Basis aabb_s; + aabb_s.scale(se->aabb.size + offset); + t_offset.translate(se->aabb.position - offset / 2); + t_offset.basis = t_offset.basis * aabb_s; + } + + RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance, t); + RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance_offset, t_offset); + RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance_xray, t); + RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance_xray_offset, t_offset); } - RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance, t); - RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance_offset, t_offset); - RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance_xray, t); - RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance_xray_offset, t_offset); - } + if (changed || (spatial_editor->is_gizmo_visible() && !exist)) { + spatial_editor->update_transform_gizmo(); + } - if (changed || (spatial_editor->is_gizmo_visible() && !exist)) { - spatial_editor->update_transform_gizmo(); - } + if (message_time > 0) { + if (message != last_message) { + surface->update(); + last_message = message; + } - if (message_time > 0) { - if (message != last_message) { - surface->update(); - last_message = message; + message_time -= get_physics_process_delta_time(); + if (message_time < 0) { + surface->update(); + } } - message_time -= get_physics_process_delta_time(); - if (message_time < 0) { - surface->update(); + bool show_info = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION)); + if (show_info != info_label->is_visible()) { + info_label->set_visible(show_info); } - } - bool show_info = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION)); - if (show_info != info_label->is_visible()) { - info_label->set_visible(show_info); - } + Camera3D *current_camera; - Camera3D *current_camera; + if (previewing) { + current_camera = previewing; + } else { + current_camera = camera; + } + + if (show_info) { + const String viewport_size = vformat(String::utf8("%d × %d"), viewport->get_size().x, viewport->get_size().y); + String text; + text += vformat(TTR("X: %s\n"), rtos(current_camera->get_position().x).pad_decimals(1)); + text += vformat(TTR("Y: %s\n"), rtos(current_camera->get_position().y).pad_decimals(1)); + text += vformat(TTR("Z: %s\n"), rtos(current_camera->get_position().z).pad_decimals(1)); + text += "\n"; + text += vformat( + TTR("Size: %s (%.1fMP)\n"), + viewport_size, + viewport->get_size().x * viewport->get_size().y * 0.000001); + + text += "\n"; + text += vformat(TTR("Objects: %d\n"), viewport->get_render_info(Viewport::RENDER_INFO_TYPE_VISIBLE, Viewport::RENDER_INFO_OBJECTS_IN_FRAME)); + text += vformat(TTR("Primitives: %d\n"), viewport->get_render_info(Viewport::RENDER_INFO_TYPE_VISIBLE, Viewport::RENDER_INFO_PRIMITIVES_IN_FRAME)); + text += vformat(TTR("Draw Calls: %d"), viewport->get_render_info(Viewport::RENDER_INFO_TYPE_VISIBLE, Viewport::RENDER_INFO_DRAW_CALLS_IN_FRAME)); + + info_label->set_text(text); + } + + // FPS Counter. + bool show_fps = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_FRAME_TIME)); + + if (show_fps != fps_label->is_visible()) { + cpu_time_label->set_visible(show_fps); + gpu_time_label->set_visible(show_fps); + fps_label->set_visible(show_fps); + RS::get_singleton()->viewport_set_measure_render_time(viewport->get_viewport_rid(), show_fps); + for (int i = 0; i < FRAME_TIME_HISTORY; i++) { + cpu_time_history[i] = 0; + gpu_time_history[i] = 0; + } + cpu_time_history_index = 0; + gpu_time_history_index = 0; + } + if (show_fps) { + cpu_time_history[cpu_time_history_index] = RS::get_singleton()->viewport_get_measured_render_time_cpu(viewport->get_viewport_rid()); + cpu_time_history_index = (cpu_time_history_index + 1) % FRAME_TIME_HISTORY; + double cpu_time = 0.0; + for (int i = 0; i < FRAME_TIME_HISTORY; i++) { + cpu_time += cpu_time_history[i]; + } + cpu_time /= FRAME_TIME_HISTORY; + // Prevent unrealistically low values. + cpu_time = MAX(0.01, cpu_time); + + gpu_time_history[gpu_time_history_index] = RS::get_singleton()->viewport_get_measured_render_time_gpu(viewport->get_viewport_rid()); + gpu_time_history_index = (gpu_time_history_index + 1) % FRAME_TIME_HISTORY; + double gpu_time = 0.0; + for (int i = 0; i < FRAME_TIME_HISTORY; i++) { + gpu_time += gpu_time_history[i]; + } + gpu_time /= FRAME_TIME_HISTORY; + // Prevent division by zero for the FPS counter (and unrealistically low values). + // This limits the reported FPS to 100000. + gpu_time = MAX(0.01, gpu_time); + + // Color labels depending on performance level ("good" = green, "OK" = yellow, "bad" = red). + // Middle point is at 15 ms. + cpu_time_label->set_text(vformat(TTR("CPU Time: %s ms"), rtos(cpu_time).pad_decimals(2))); + cpu_time_label->add_theme_color_override( + "font_color", + frame_time_gradient->get_color_at_offset( + Math::range_lerp(cpu_time, 0, 30, 0, 1))); + + gpu_time_label->set_text(vformat(TTR("GPU Time: %s ms"), rtos(gpu_time).pad_decimals(2))); + // Middle point is at 15 ms. + gpu_time_label->add_theme_color_override( + "font_color", + frame_time_gradient->get_color_at_offset( + Math::range_lerp(gpu_time, 0, 30, 0, 1))); + + const double fps = 1000.0 / gpu_time; + fps_label->set_text(vformat(TTR("FPS: %d"), fps)); + // Middle point is at 60 FPS. + fps_label->add_theme_color_override( + "font_color", + frame_time_gradient->get_color_at_offset( + Math::range_lerp(fps, 110, 10, 0, 1))); + } + + bool show_cinema = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_CINEMATIC_PREVIEW)); + cinema_label->set_visible(show_cinema); + if (show_cinema) { + float cinema_half_width = cinema_label->get_size().width / 2.0f; + cinema_label->set_anchor_and_offset(SIDE_LEFT, 0.5f, -cinema_half_width); + } - if (previewing) { - current_camera = previewing; - } else { - current_camera = camera; - } - - if (show_info) { - const String viewport_size = vformat(String::utf8("%d × %d"), viewport->get_size().x, viewport->get_size().y); - String text; - text += vformat(TTR("X: %s\n"), rtos(current_camera->get_position().x).pad_decimals(1)); - text += vformat(TTR("Y: %s\n"), rtos(current_camera->get_position().y).pad_decimals(1)); - text += vformat(TTR("Z: %s\n"), rtos(current_camera->get_position().z).pad_decimals(1)); - text += "\n"; - text += vformat( - TTR("Size: %s (%.1fMP)\n"), - viewport_size, - viewport->get_size().x * viewport->get_size().y * 0.000001); - - text += "\n"; - text += vformat(TTR("Objects: %d\n"), viewport->get_render_info(Viewport::RENDER_INFO_TYPE_VISIBLE, Viewport::RENDER_INFO_OBJECTS_IN_FRAME)); - text += vformat(TTR("Primitives: %d\n"), viewport->get_render_info(Viewport::RENDER_INFO_TYPE_VISIBLE, Viewport::RENDER_INFO_PRIMITIVES_IN_FRAME)); - text += vformat(TTR("Draw Calls: %d"), viewport->get_render_info(Viewport::RENDER_INFO_TYPE_VISIBLE, Viewport::RENDER_INFO_DRAW_CALLS_IN_FRAME)); - - info_label->set_text(text); - } - - // FPS Counter. - bool show_fps = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_FRAME_TIME)); - - if (show_fps != fps_label->is_visible()) { - cpu_time_label->set_visible(show_fps); - gpu_time_label->set_visible(show_fps); - fps_label->set_visible(show_fps); - RS::get_singleton()->viewport_set_measure_render_time(viewport->get_viewport_rid(), show_fps); - for (int i = 0; i < FRAME_TIME_HISTORY; i++) { - cpu_time_history[i] = 0; - gpu_time_history[i] = 0; - } - cpu_time_history_index = 0; - gpu_time_history_index = 0; - } - if (show_fps) { - cpu_time_history[cpu_time_history_index] = RS::get_singleton()->viewport_get_measured_render_time_cpu(viewport->get_viewport_rid()); - cpu_time_history_index = (cpu_time_history_index + 1) % FRAME_TIME_HISTORY; - double cpu_time = 0.0; - for (int i = 0; i < FRAME_TIME_HISTORY; i++) { - cpu_time += cpu_time_history[i]; - } - cpu_time /= FRAME_TIME_HISTORY; - // Prevent unrealistically low values. - cpu_time = MAX(0.01, cpu_time); - - gpu_time_history[gpu_time_history_index] = RS::get_singleton()->viewport_get_measured_render_time_gpu(viewport->get_viewport_rid()); - gpu_time_history_index = (gpu_time_history_index + 1) % FRAME_TIME_HISTORY; - double gpu_time = 0.0; - for (int i = 0; i < FRAME_TIME_HISTORY; i++) { - gpu_time += gpu_time_history[i]; - } - gpu_time /= FRAME_TIME_HISTORY; - // Prevent division by zero for the FPS counter (and unrealistically low values). - // This limits the reported FPS to 100000. - gpu_time = MAX(0.01, gpu_time); - - // Color labels depending on performance level ("good" = green, "OK" = yellow, "bad" = red). - // Middle point is at 15 ms. - cpu_time_label->set_text(vformat(TTR("CPU Time: %s ms"), rtos(cpu_time).pad_decimals(2))); - cpu_time_label->add_theme_color_override( - "font_color", - frame_time_gradient->get_color_at_offset( - Math::range_lerp(cpu_time, 0, 30, 0, 1))); - - gpu_time_label->set_text(vformat(TTR("GPU Time: %s ms"), rtos(gpu_time).pad_decimals(2))); - // Middle point is at 15 ms. - gpu_time_label->add_theme_color_override( - "font_color", - frame_time_gradient->get_color_at_offset( - Math::range_lerp(gpu_time, 0, 30, 0, 1))); - - const double fps = 1000.0 / gpu_time; - fps_label->set_text(vformat(TTR("FPS: %d"), fps)); - // Middle point is at 60 FPS. - fps_label->add_theme_color_override( - "font_color", - frame_time_gradient->get_color_at_offset( - Math::range_lerp(fps, 110, 10, 0, 1))); - } - - bool show_cinema = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_CINEMATIC_PREVIEW)); - cinema_label->set_visible(show_cinema); - if (show_cinema) { - float cinema_half_width = cinema_label->get_size().width / 2.0f; - cinema_label->set_anchor_and_offset(SIDE_LEFT, 0.5f, -cinema_half_width); - } - - if (lock_rotation) { - float locked_half_width = locked_label->get_size().width / 2.0f; - locked_label->set_anchor_and_offset(SIDE_LEFT, 0.5f, -locked_half_width); - } - } - - if (p_what == NOTIFICATION_ENTER_TREE) { - surface->connect("draw", callable_mp(this, &Node3DEditorViewport::_draw)); - surface->connect("gui_input", callable_mp(this, &Node3DEditorViewport::_sinput)); - surface->connect("mouse_entered", callable_mp(this, &Node3DEditorViewport::_surface_mouse_enter)); - surface->connect("mouse_exited", callable_mp(this, &Node3DEditorViewport::_surface_mouse_exit)); - surface->connect("focus_entered", callable_mp(this, &Node3DEditorViewport::_surface_focus_enter)); - surface->connect("focus_exited", callable_mp(this, &Node3DEditorViewport::_surface_focus_exit)); - - _init_gizmo_instance(index); - } - - if (p_what == NOTIFICATION_EXIT_TREE) { - _finish_gizmo_instances(); - } + if (lock_rotation) { + float locked_half_width = locked_label->get_size().width / 2.0f; + locked_label->set_anchor_and_offset(SIDE_LEFT, 0.5f, -locked_half_width); + } + } break; - if (p_what == NOTIFICATION_THEME_CHANGED) { - view_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - preview_camera->set_icon(get_theme_icon(SNAME("Camera3D"), SNAME("EditorIcons"))); - Control *gui_base = EditorNode::get_singleton()->get_gui_base(); + case NOTIFICATION_ENTER_TREE: { + surface->connect("draw", callable_mp(this, &Node3DEditorViewport::_draw)); + surface->connect("gui_input", callable_mp(this, &Node3DEditorViewport::_sinput)); + surface->connect("mouse_entered", callable_mp(this, &Node3DEditorViewport::_surface_mouse_enter)); + surface->connect("mouse_exited", callable_mp(this, &Node3DEditorViewport::_surface_mouse_exit)); + surface->connect("focus_entered", callable_mp(this, &Node3DEditorViewport::_surface_focus_enter)); + surface->connect("focus_exited", callable_mp(this, &Node3DEditorViewport::_surface_focus_exit)); + + _init_gizmo_instance(index); + } break; - view_menu->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - view_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - view_menu->add_theme_style_override("pressed", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - view_menu->add_theme_style_override("focus", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - view_menu->add_theme_style_override("disabled", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - - preview_camera->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - preview_camera->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - preview_camera->add_theme_style_override("pressed", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - preview_camera->add_theme_style_override("focus", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - preview_camera->add_theme_style_override("disabled", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - - frame_time_gradient->set_color(0, get_theme_color(SNAME("success_color"), SNAME("Editor"))); - frame_time_gradient->set_color(1, get_theme_color(SNAME("warning_color"), SNAME("Editor"))); - frame_time_gradient->set_color(2, get_theme_color(SNAME("error_color"), SNAME("Editor"))); + case NOTIFICATION_EXIT_TREE: { + _finish_gizmo_instances(); + } break; - info_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - cpu_time_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - gpu_time_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - fps_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - cinema_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - locked_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + case NOTIFICATION_THEME_CHANGED: { + view_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + preview_camera->set_icon(get_theme_icon(SNAME("Camera3D"), SNAME("EditorIcons"))); + Control *gui_base = EditorNode::get_singleton()->get_gui_base(); + + view_menu->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + view_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + view_menu->add_theme_style_override("pressed", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + view_menu->add_theme_style_override("focus", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + view_menu->add_theme_style_override("disabled", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + + preview_camera->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + preview_camera->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + preview_camera->add_theme_style_override("pressed", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + preview_camera->add_theme_style_override("focus", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + preview_camera->add_theme_style_override("disabled", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + + frame_time_gradient->set_color(0, get_theme_color(SNAME("success_color"), SNAME("Editor"))); + frame_time_gradient->set_color(1, get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + frame_time_gradient->set_color(2, get_theme_color(SNAME("error_color"), SNAME("Editor"))); + + info_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + cpu_time_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + gpu_time_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + fps_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + cinema_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + locked_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + } break; } } @@ -4799,197 +4805,202 @@ void Node3DEditorViewportContainer::gui_input(const Ref<InputEvent> &p_event) { } void Node3DEditorViewportContainer::_notification(int p_what) { - if (p_what == NOTIFICATION_MOUSE_ENTER || p_what == NOTIFICATION_MOUSE_EXIT) { - mouseover = (p_what == NOTIFICATION_MOUSE_ENTER); - update(); - } + switch (p_what) { + case NOTIFICATION_MOUSE_ENTER: + case NOTIFICATION_MOUSE_EXIT: { + mouseover = (p_what == NOTIFICATION_MOUSE_ENTER); + update(); + } break; - if (p_what == NOTIFICATION_DRAW && mouseover) { - Ref<Texture2D> h_grabber = get_theme_icon(SNAME("grabber"), SNAME("HSplitContainer")); - Ref<Texture2D> v_grabber = get_theme_icon(SNAME("grabber"), SNAME("VSplitContainer")); + case NOTIFICATION_DRAW: { + if (mouseover) { + Ref<Texture2D> h_grabber = get_theme_icon(SNAME("grabber"), SNAME("HSplitContainer")); + Ref<Texture2D> v_grabber = get_theme_icon(SNAME("grabber"), SNAME("VSplitContainer")); - Ref<Texture2D> hdiag_grabber = get_theme_icon(SNAME("GuiViewportHdiagsplitter"), SNAME("EditorIcons")); - Ref<Texture2D> vdiag_grabber = get_theme_icon(SNAME("GuiViewportVdiagsplitter"), SNAME("EditorIcons")); - Ref<Texture2D> vh_grabber = get_theme_icon(SNAME("GuiViewportVhsplitter"), SNAME("EditorIcons")); + Ref<Texture2D> hdiag_grabber = get_theme_icon(SNAME("GuiViewportHdiagsplitter"), SNAME("EditorIcons")); + Ref<Texture2D> vdiag_grabber = get_theme_icon(SNAME("GuiViewportVdiagsplitter"), SNAME("EditorIcons")); + Ref<Texture2D> vh_grabber = get_theme_icon(SNAME("GuiViewportVhsplitter"), SNAME("EditorIcons")); - Vector2 size = get_size(); + Vector2 size = get_size(); - int h_sep = get_theme_constant(SNAME("separation"), SNAME("HSplitContainer")); + int h_sep = get_theme_constant(SNAME("separation"), SNAME("HSplitContainer")); - int v_sep = get_theme_constant(SNAME("separation"), SNAME("VSplitContainer")); + int v_sep = get_theme_constant(SNAME("separation"), SNAME("VSplitContainer")); - int mid_w = size.width * ratio_h; - int mid_h = size.height * ratio_v; + int mid_w = size.width * ratio_h; + int mid_h = size.height * ratio_v; - int size_left = mid_w - h_sep / 2; - int size_bottom = size.height - mid_h - v_sep / 2; + int size_left = mid_w - h_sep / 2; + int size_bottom = size.height - mid_h - v_sep / 2; - switch (view) { - case VIEW_USE_1_VIEWPORT: { - // Nothing to show. + switch (view) { + case VIEW_USE_1_VIEWPORT: { + // Nothing to show. - } break; - case VIEW_USE_2_VIEWPORTS: { - draw_texture(v_grabber, Vector2((size.width - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2)); - set_default_cursor_shape(CURSOR_VSPLIT); + } break; + case VIEW_USE_2_VIEWPORTS: { + draw_texture(v_grabber, Vector2((size.width - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2)); + set_default_cursor_shape(CURSOR_VSPLIT); - } break; - case VIEW_USE_2_VIEWPORTS_ALT: { - draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, (size.height - h_grabber->get_height()) / 2)); - set_default_cursor_shape(CURSOR_HSPLIT); + } break; + case VIEW_USE_2_VIEWPORTS_ALT: { + draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, (size.height - h_grabber->get_height()) / 2)); + set_default_cursor_shape(CURSOR_HSPLIT); - } break; - case VIEW_USE_3_VIEWPORTS: { - if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) { - draw_texture(hdiag_grabber, Vector2(mid_w - hdiag_grabber->get_width() / 2, mid_h - v_grabber->get_height() / 4)); - set_default_cursor_shape(CURSOR_DRAG); - } else if ((hovering_v && !dragging_h) || dragging_v) { - draw_texture(v_grabber, Vector2((size.width - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2)); - set_default_cursor_shape(CURSOR_VSPLIT); - } else if (hovering_h || dragging_h) { - draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, mid_h + v_grabber->get_height() / 2 + (size_bottom - h_grabber->get_height()) / 2)); - set_default_cursor_shape(CURSOR_HSPLIT); - } + } break; + case VIEW_USE_3_VIEWPORTS: { + if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) { + draw_texture(hdiag_grabber, Vector2(mid_w - hdiag_grabber->get_width() / 2, mid_h - v_grabber->get_height() / 4)); + set_default_cursor_shape(CURSOR_DRAG); + } else if ((hovering_v && !dragging_h) || dragging_v) { + draw_texture(v_grabber, Vector2((size.width - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2)); + set_default_cursor_shape(CURSOR_VSPLIT); + } else if (hovering_h || dragging_h) { + draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, mid_h + v_grabber->get_height() / 2 + (size_bottom - h_grabber->get_height()) / 2)); + set_default_cursor_shape(CURSOR_HSPLIT); + } - } break; - case VIEW_USE_3_VIEWPORTS_ALT: { - if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) { - draw_texture(vdiag_grabber, Vector2(mid_w - vdiag_grabber->get_width() + v_grabber->get_height() / 4, mid_h - vdiag_grabber->get_height() / 2)); - set_default_cursor_shape(CURSOR_DRAG); - } else if ((hovering_v && !dragging_h) || dragging_v) { - draw_texture(v_grabber, Vector2((size_left - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2)); - set_default_cursor_shape(CURSOR_VSPLIT); - } else if (hovering_h || dragging_h) { - draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, (size.height - h_grabber->get_height()) / 2)); - set_default_cursor_shape(CURSOR_HSPLIT); - } + } break; + case VIEW_USE_3_VIEWPORTS_ALT: { + if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) { + draw_texture(vdiag_grabber, Vector2(mid_w - vdiag_grabber->get_width() + v_grabber->get_height() / 4, mid_h - vdiag_grabber->get_height() / 2)); + set_default_cursor_shape(CURSOR_DRAG); + } else if ((hovering_v && !dragging_h) || dragging_v) { + draw_texture(v_grabber, Vector2((size_left - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2)); + set_default_cursor_shape(CURSOR_VSPLIT); + } else if (hovering_h || dragging_h) { + draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, (size.height - h_grabber->get_height()) / 2)); + set_default_cursor_shape(CURSOR_HSPLIT); + } - } break; - case VIEW_USE_4_VIEWPORTS: { - Vector2 half(mid_w, mid_h); - if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) { - draw_texture(vh_grabber, half - vh_grabber->get_size() / 2.0); - set_default_cursor_shape(CURSOR_DRAG); - } else if ((hovering_v && !dragging_h) || dragging_v) { - draw_texture(v_grabber, half - v_grabber->get_size() / 2.0); - set_default_cursor_shape(CURSOR_VSPLIT); - } else if (hovering_h || dragging_h) { - draw_texture(h_grabber, half - h_grabber->get_size() / 2.0); - set_default_cursor_shape(CURSOR_HSPLIT); - } + } break; + case VIEW_USE_4_VIEWPORTS: { + Vector2 half(mid_w, mid_h); + if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) { + draw_texture(vh_grabber, half - vh_grabber->get_size() / 2.0); + set_default_cursor_shape(CURSOR_DRAG); + } else if ((hovering_v && !dragging_h) || dragging_v) { + draw_texture(v_grabber, half - v_grabber->get_size() / 2.0); + set_default_cursor_shape(CURSOR_VSPLIT); + } else if (hovering_h || dragging_h) { + draw_texture(h_grabber, half - h_grabber->get_size() / 2.0); + set_default_cursor_shape(CURSOR_HSPLIT); + } - } break; - } - } + } break; + } + } + } break; - if (p_what == NOTIFICATION_SORT_CHILDREN) { - Node3DEditorViewport *viewports[4]; - int vc = 0; - for (int i = 0; i < get_child_count(); i++) { - viewports[vc] = Object::cast_to<Node3DEditorViewport>(get_child(i)); - if (viewports[vc]) { - vc++; + case NOTIFICATION_SORT_CHILDREN: { + Node3DEditorViewport *viewports[4]; + int vc = 0; + for (int i = 0; i < get_child_count(); i++) { + viewports[vc] = Object::cast_to<Node3DEditorViewport>(get_child(i)); + if (viewports[vc]) { + vc++; + } } - } - ERR_FAIL_COND(vc != 4); + ERR_FAIL_COND(vc != 4); - Size2 size = get_size(); + Size2 size = get_size(); - if (size.x < 10 || size.y < 10) { - for (int i = 0; i < 4; i++) { - viewports[i]->hide(); + if (size.x < 10 || size.y < 10) { + for (int i = 0; i < 4; i++) { + viewports[i]->hide(); + } + return; } - return; - } - int h_sep = get_theme_constant(SNAME("separation"), SNAME("HSplitContainer")); + int h_sep = get_theme_constant(SNAME("separation"), SNAME("HSplitContainer")); - int v_sep = get_theme_constant(SNAME("separation"), SNAME("VSplitContainer")); + int v_sep = get_theme_constant(SNAME("separation"), SNAME("VSplitContainer")); - int mid_w = size.width * ratio_h; - int mid_h = size.height * ratio_v; + int mid_w = size.width * ratio_h; + int mid_h = size.height * ratio_v; - int size_left = mid_w - h_sep / 2; - int size_right = size.width - mid_w - h_sep / 2; + int size_left = mid_w - h_sep / 2; + int size_right = size.width - mid_w - h_sep / 2; - int size_top = mid_h - v_sep / 2; - int size_bottom = size.height - mid_h - v_sep / 2; + int size_top = mid_h - v_sep / 2; + int size_bottom = size.height - mid_h - v_sep / 2; - switch (view) { - case VIEW_USE_1_VIEWPORT: { - viewports[0]->show(); - for (int i = 1; i < 4; i++) { - viewports[i]->hide(); - } + switch (view) { + case VIEW_USE_1_VIEWPORT: { + viewports[0]->show(); + for (int i = 1; i < 4; i++) { + viewports[i]->hide(); + } - fit_child_in_rect(viewports[0], Rect2(Vector2(), size)); + fit_child_in_rect(viewports[0], Rect2(Vector2(), size)); - } break; - case VIEW_USE_2_VIEWPORTS: { - for (int i = 0; i < 4; i++) { - if (i == 1 || i == 3) { - viewports[i]->hide(); - } else { - viewports[i]->show(); + } break; + case VIEW_USE_2_VIEWPORTS: { + for (int i = 0; i < 4; i++) { + if (i == 1 || i == 3) { + viewports[i]->hide(); + } else { + viewports[i]->show(); + } } - } - fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size.width, size_top))); - fit_child_in_rect(viewports[2], Rect2(Vector2(0, mid_h + v_sep / 2), Vector2(size.width, size_bottom))); + fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size.width, size_top))); + fit_child_in_rect(viewports[2], Rect2(Vector2(0, mid_h + v_sep / 2), Vector2(size.width, size_bottom))); - } break; - case VIEW_USE_2_VIEWPORTS_ALT: { - for (int i = 0; i < 4; i++) { - if (i == 1 || i == 3) { - viewports[i]->hide(); - } else { - viewports[i]->show(); + } break; + case VIEW_USE_2_VIEWPORTS_ALT: { + for (int i = 0; i < 4; i++) { + if (i == 1 || i == 3) { + viewports[i]->hide(); + } else { + viewports[i]->show(); + } } - } - fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size_left, size.height))); - fit_child_in_rect(viewports[2], Rect2(Vector2(mid_w + h_sep / 2, 0), Vector2(size_right, size.height))); + fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size_left, size.height))); + fit_child_in_rect(viewports[2], Rect2(Vector2(mid_w + h_sep / 2, 0), Vector2(size_right, size.height))); - } break; - case VIEW_USE_3_VIEWPORTS: { - for (int i = 0; i < 4; i++) { - if (i == 1) { - viewports[i]->hide(); - } else { - viewports[i]->show(); + } break; + case VIEW_USE_3_VIEWPORTS: { + for (int i = 0; i < 4; i++) { + if (i == 1) { + viewports[i]->hide(); + } else { + viewports[i]->show(); + } } - } - fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size.width, size_top))); - fit_child_in_rect(viewports[2], Rect2(Vector2(0, mid_h + v_sep / 2), Vector2(size_left, size_bottom))); - fit_child_in_rect(viewports[3], Rect2(Vector2(mid_w + h_sep / 2, mid_h + v_sep / 2), Vector2(size_right, size_bottom))); + fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size.width, size_top))); + fit_child_in_rect(viewports[2], Rect2(Vector2(0, mid_h + v_sep / 2), Vector2(size_left, size_bottom))); + fit_child_in_rect(viewports[3], Rect2(Vector2(mid_w + h_sep / 2, mid_h + v_sep / 2), Vector2(size_right, size_bottom))); - } break; - case VIEW_USE_3_VIEWPORTS_ALT: { - for (int i = 0; i < 4; i++) { - if (i == 1) { - viewports[i]->hide(); - } else { - viewports[i]->show(); + } break; + case VIEW_USE_3_VIEWPORTS_ALT: { + for (int i = 0; i < 4; i++) { + if (i == 1) { + viewports[i]->hide(); + } else { + viewports[i]->show(); + } } - } - fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size_left, size_top))); - fit_child_in_rect(viewports[2], Rect2(Vector2(0, mid_h + v_sep / 2), Vector2(size_left, size_bottom))); - fit_child_in_rect(viewports[3], Rect2(Vector2(mid_w + h_sep / 2, 0), Vector2(size_right, size.height))); + fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size_left, size_top))); + fit_child_in_rect(viewports[2], Rect2(Vector2(0, mid_h + v_sep / 2), Vector2(size_left, size_bottom))); + fit_child_in_rect(viewports[3], Rect2(Vector2(mid_w + h_sep / 2, 0), Vector2(size_right, size.height))); - } break; - case VIEW_USE_4_VIEWPORTS: { - for (int i = 0; i < 4; i++) { - viewports[i]->show(); - } + } break; + case VIEW_USE_4_VIEWPORTS: { + for (int i = 0; i < 4; i++) { + viewports[i]->show(); + } - fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size_left, size_top))); - fit_child_in_rect(viewports[1], Rect2(Vector2(mid_w + h_sep / 2, 0), Vector2(size_right, size_top))); - fit_child_in_rect(viewports[2], Rect2(Vector2(0, mid_h + v_sep / 2), Vector2(size_left, size_bottom))); - fit_child_in_rect(viewports[3], Rect2(Vector2(mid_w + h_sep / 2, mid_h + v_sep / 2), Vector2(size_right, size_bottom))); + fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size_left, size_top))); + fit_child_in_rect(viewports[1], Rect2(Vector2(mid_w + h_sep / 2, 0), Vector2(size_right, size_top))); + fit_child_in_rect(viewports[2], Rect2(Vector2(0, mid_h + v_sep / 2), Vector2(size_left, size_bottom))); + fit_child_in_rect(viewports[3], Rect2(Vector2(mid_w + h_sep / 2, mid_h + v_sep / 2), Vector2(size_right, size_bottom))); - } break; - } + } break; + } + } break; } } @@ -6951,6 +6962,7 @@ void Node3DEditor::_notification(int p_what) { sun_state->set_custom_minimum_size(sun_vb->get_combined_minimum_size()); environ_state->set_custom_minimum_size(environ_vb->get_combined_minimum_size()); } break; + case NOTIFICATION_ENTER_TREE: { _update_theme(); _register_all_gizmos(); @@ -6958,9 +6970,11 @@ void Node3DEditor::_notification(int p_what) { _init_indicators(); update_all_gizmos(); } break; + case NOTIFICATION_EXIT_TREE: { _finish_indicators(); } break; + case NOTIFICATION_THEME_CHANGED: { _update_theme(); _update_gizmos_menu_theme(); @@ -6968,11 +6982,13 @@ void Node3DEditor::_notification(int p_what) { sun_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); environ_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); } break; + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { // Update grid color by rebuilding grid. _finish_grid(); _init_grid(); } break; + case NOTIFICATION_VISIBILITY_CHANGED: { if (!is_visible() && tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->is_pressed()) { EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton(); diff --git a/editor/plugins/ot_features_plugin.cpp b/editor/plugins/ot_features_plugin.cpp index 719b9ecc7c..f8e6054848 100644 --- a/editor/plugins/ot_features_plugin.cpp +++ b/editor/plugins/ot_features_plugin.cpp @@ -46,12 +46,15 @@ void OpenTypeFeaturesEditor::update_property() { } void OpenTypeFeaturesEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); - - button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); - button->set_size(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))->get_size()); - spin->set_custom_label_color(true, base); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + + button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + button->set_size(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))->get_size()); + spin->set_custom_label_color(true, base); + } break; } } @@ -139,10 +142,13 @@ void OpenTypeFeaturesAdd::_features_menu() { } void OpenTypeFeaturesAdd::_notification(int p_what) { - if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { - set_label(""); - button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - button->set_size(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))->get_size()); + switch (p_what) { + case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_ENTER_TREE: { + set_label(""); + button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button->set_size(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))->get_size()); + } break; } } diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 22b79921bb..f096b2abb1 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -69,6 +69,7 @@ void Polygon2DEditor::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { uv_panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning"))); } break; + case NOTIFICATION_READY: { button_uv->set_icon(get_theme_icon(SNAME("Uv"), SNAME("EditorIcons"))); @@ -96,6 +97,7 @@ void Polygon2DEditor::_notification(int p_what) { uv_edit_draw->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); bone_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } break; + case NOTIFICATION_VISIBILITY_CHANGED: { if (!is_visible()) { uv_edit->hide(); @@ -1068,7 +1070,7 @@ void Polygon2DEditor::_uv_draw() { if (uv_create && i == uvs.size() - 1) { next_point = uv_create_to; } - if (i < uv_draw_max /*&& polygons.size() == 0 && polygon_create.size() == 0*/) { //if using or creating polygons, do not show outline (will show polygons instead) + if (i < uv_draw_max) { // If using or creating polygons, do not show outline (will show polygons instead). uv_edit_draw->draw_line(mtx.xform(uvs[i]), mtx.xform(next_point), poly_line_color, Math::round(EDSCALE)); } } diff --git a/editor/plugins/polygon_3d_editor_plugin.cpp b/editor/plugins/polygon_3d_editor_plugin.cpp index 6cba3e2861..2d4812c55b 100644 --- a/editor/plugins/polygon_3d_editor_plugin.cpp +++ b/editor/plugins/polygon_3d_editor_plugin.cpp @@ -50,6 +50,7 @@ void Polygon3DEditor::_notification(int p_what) { get_tree()->connect("node_removed", callable_mp(this, &Polygon3DEditor::_node_removed)); } break; + case NOTIFICATION_PROCESS: { if (!node) { return; diff --git a/editor/plugins/replication_editor_plugin.cpp b/editor/plugins/replication_editor_plugin.cpp index 604cbcd103..e4c1c69804 100644 --- a/editor/plugins/replication_editor_plugin.cpp +++ b/editor/plugins/replication_editor_plugin.cpp @@ -94,10 +94,15 @@ void ReplicationEditor::_bind_methods() { } void ReplicationEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel"))); - } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - update_keying(); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { + add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel"))); + } break; + + case NOTIFICATION_VISIBILITY_CHANGED: { + update_keying(); + } break; } } @@ -355,13 +360,15 @@ void ReplicationEditorPlugin::_property_keyed(const String &p_keyed, const Varia } void ReplicationEditorPlugin::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - //Node3DEditor::get_singleton()->connect("transform_key_request", callable_mp(this, &AnimationPlayerEditorPlugin::_transform_key_request)); - InspectorDock::get_inspector_singleton()->connect("property_keyed", callable_mp(this, &ReplicationEditorPlugin::_property_keyed)); - repl_editor->connect("keying_changed", callable_mp(this, &ReplicationEditorPlugin::_keying_changed)); - // TODO make lock usable. - //InspectorDock::get_inspector_singleton()->connect("object_inspected", callable_mp(repl_editor, &ReplicationEditor::update_keying)); - get_tree()->connect("node_removed", callable_mp(this, &ReplicationEditorPlugin::_node_removed)); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + //Node3DEditor::get_singleton()->connect("transform_key_request", callable_mp(this, &AnimationPlayerEditorPlugin::_transform_key_request)); + InspectorDock::get_inspector_singleton()->connect("property_keyed", callable_mp(this, &ReplicationEditorPlugin::_property_keyed)); + repl_editor->connect("keying_changed", callable_mp(this, &ReplicationEditorPlugin::_keying_changed)); + // TODO make lock usable. + //InspectorDock::get_inspector_singleton()->connect("object_inspected", callable_mp(repl_editor, &ReplicationEditor::update_keying)); + get_tree()->connect("node_removed", callable_mp(this, &ReplicationEditorPlugin::_node_removed)); + } break; } } diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index e04e3c146f..b7aef7f1bb 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -38,15 +38,10 @@ #include "editor/editor_settings.h" void ResourcePreloaderEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - load->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); - } - - if (p_what == NOTIFICATION_READY) { - //NodePath("/root")->connect("node_removed", this,"_node_removed",Vector<Variant>(),true); - } - - if (p_what == NOTIFICATION_DRAW) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + load->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + } break; } } diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index 34b39d2a17..bfb672d694 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -233,9 +233,12 @@ void EditorPropertyRootMotion::setup(const NodePath &p_base_hint) { } void EditorPropertyRootMotion::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Ref<Texture2D> t = get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")); - clear->set_icon(t); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + Ref<Texture2D> t = get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")); + clear->set_icon(t); + } break; } } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 315879d4ac..205464daee 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -356,6 +356,7 @@ void ScriptEditorQuickOpen::_notification(int p_what) { case NOTIFICATION_VISIBILITY_CHANGED: { search_box->set_right_icon(search_options->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); } break; + case NOTIFICATION_EXIT_TREE: { disconnect("confirmed", callable_mp(this, &ScriptEditorQuickOpen::_confirmed)); } break; @@ -1667,9 +1668,6 @@ void ScriptEditor::_notification(int p_what) { } } break; - - default: - break; } } diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 4a47766fc0..b87f2995ed 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1343,8 +1343,6 @@ void ScriptTextEditor::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { code_editor->get_text_editor()->set_gutter_width(connection_gutter, code_editor->get_text_editor()->get_line_height()); } break; - default: - break; } } diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 25906f33de..cea1a0e808 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -464,14 +464,6 @@ void ShaderEditor::_bind_methods() { } void ShaderEditor::ensure_select_current() { - /* - if (tab_container->get_child_count() && tab_container->get_current_tab()>=0) { - ShaderTextEditor *ste = Object::cast_to<ShaderTextEditor>(tab_container->get_child(tab_container->get_current_tab())); - if (!ste) - return; - Ref<Shader> shader = ste->get_edited_shader(); - get_scene()->get_root_node()->call("_resource_selected",shader); - }*/ } void ShaderEditor::goto_line_selection(int p_line, int p_begin, int p_end) { diff --git a/editor/plugins/shader_file_editor_plugin.cpp b/editor/plugins/shader_file_editor_plugin.cpp index 6d761729b0..4458555de2 100644 --- a/editor/plugins/shader_file_editor_plugin.cpp +++ b/editor/plugins/shader_file_editor_plugin.cpp @@ -200,10 +200,12 @@ void ShaderFileEditor::_update_options() { } void ShaderFileEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_WM_WINDOW_FOCUS_IN) { - if (is_visible_in_tree() && shader_file.is_valid()) { - _update_options(); - } + switch (p_what) { + case NOTIFICATION_WM_WINDOW_FOCUS_IN: { + if (is_visible_in_tree() && shader_file.is_valid()) { + _update_options(); + } + } break; } } diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index 761a0cdfbd..282ee9a5b7 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -103,8 +103,7 @@ void BoneTransformEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { create_editors(); - break; - } + } break; } } diff --git a/editor/plugins/text_control_editor_plugin.cpp b/editor/plugins/text_control_editor_plugin.cpp index ab3d6dcca9..4290888e94 100644 --- a/editor/plugins/text_control_editor_plugin.cpp +++ b/editor/plugins/text_control_editor_plugin.cpp @@ -34,8 +34,8 @@ #include "editor/editor_scale.h" #include "editor/multi_node_edit.h" -void TextControlEditor::_notification(int p_notification) { - switch (p_notification) { +void TextControlEditor::_notification(int p_what) { + switch (p_what) { case NOTIFICATION_ENTER_TREE: { if (!EditorFileSystem::get_singleton()->is_connected("filesystem_changed", callable_mp(this, &TextControlEditor::_reload_fonts))) { EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &TextControlEditor::_reload_fonts), make_binds("")); @@ -45,13 +45,12 @@ void TextControlEditor::_notification(int p_notification) { case NOTIFICATION_THEME_CHANGED: { clear_formatting->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); } break; + case NOTIFICATION_EXIT_TREE: { if (EditorFileSystem::get_singleton()->is_connected("filesystem_changed", callable_mp(this, &TextControlEditor::_reload_fonts))) { EditorFileSystem::get_singleton()->disconnect("filesystem_changed", callable_mp(this, &TextControlEditor::_reload_fonts)); } } break; - default: - break; } } diff --git a/editor/plugins/text_control_editor_plugin.h b/editor/plugins/text_control_editor_plugin.h index 1d65073c98..1349003a9c 100644 --- a/editor/plugins/text_control_editor_plugin.h +++ b/editor/plugins/text_control_editor_plugin.h @@ -66,7 +66,7 @@ class TextControlEditor : public HBoxContainer { Ref<Font> custom_font; protected: - void _notification(int p_notification); + void _notification(int p_what); static void _bind_methods(); void _find_resources(EditorFileSystemDirectory *p_dir); diff --git a/editor/plugins/texture_3d_editor_plugin.cpp b/editor/plugins/texture_3d_editor_plugin.cpp index 880cbeffba..0fc7079a24 100644 --- a/editor/plugins/texture_3d_editor_plugin.cpp +++ b/editor/plugins/texture_3d_editor_plugin.cpp @@ -35,18 +35,17 @@ void Texture3DEditor::_texture_rect_draw() { } void Texture3DEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - //get_scene()->connect("node_removed",this,"_node_removed"); - } - if (p_what == NOTIFICATION_RESIZED) { - _texture_rect_update_area(); - } + switch (p_what) { + case NOTIFICATION_RESIZED: { + _texture_rect_update_area(); + } break; - if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); - Size2 size = get_size(); + case NOTIFICATION_DRAW: { + Ref<Texture2D> checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); + Size2 size = get_size(); - draw_texture_rect(checkerboard, Rect2(Point2(), size), true); + draw_texture_rect(checkerboard, Rect2(Point2(), size), true); + } break; } } diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp index 22f4cebf2e..cb146fd342 100644 --- a/editor/plugins/texture_layered_editor_plugin.cpp +++ b/editor/plugins/texture_layered_editor_plugin.cpp @@ -46,18 +46,17 @@ void TextureLayeredEditor::_texture_rect_draw() { } void TextureLayeredEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - //get_scene()->connect("node_removed",this,"_node_removed"); - } - if (p_what == NOTIFICATION_RESIZED) { - _texture_rect_update_area(); - } + switch (p_what) { + case NOTIFICATION_RESIZED: { + _texture_rect_update_area(); + } break; - if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); - Size2 size = get_size(); + case NOTIFICATION_DRAW: { + Ref<Texture2D> checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); + Size2 size = get_size(); - draw_texture_rect(checkerboard, Rect2(Point2(), size), true); + draw_texture_rect(checkerboard, Rect2(Point2(), size), true); + } break; } } diff --git a/editor/plugins/theme_editor_preview.cpp b/editor/plugins/theme_editor_preview.cpp index c3e4e66fd4..252a19a7db 100644 --- a/editor/plugins/theme_editor_preview.cpp +++ b/editor/plugins/theme_editor_preview.cpp @@ -203,6 +203,7 @@ void ThemeEditorPreview::_notification(int p_what) { theme_cache.preview_picker_font = get_theme_font(SNAME("status_source"), SNAME("EditorFonts")); theme_cache.font_size = get_theme_font_size(SNAME("font_size"), SNAME("EditorFonts")); } break; + case NOTIFICATION_PROCESS: { time_left -= get_process_delta_time(); if (time_left < 0) { diff --git a/editor/plugins/tiles/tile_atlas_view.cpp b/editor/plugins/tiles/tile_atlas_view.cpp index d685c634bd..71947ae185 100644 --- a/editor/plugins/tiles/tile_atlas_view.cpp +++ b/editor/plugins/tiles/tile_atlas_view.cpp @@ -524,13 +524,13 @@ void TileAtlasView::update() { void TileAtlasView::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: - case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning"))); - break; + } break; - case NOTIFICATION_READY: + case NOTIFICATION_READY: { button_center_view->set_icon(get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons"))); - break; + } break; } } diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index a4d2dfc9d9..6c12573cc4 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -1160,13 +1160,11 @@ void TileDataDefaultEditor::setup_property_editor(Variant::Type p_type, String p void TileDataDefaultEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: - case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_THEME_CHANGED: { picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); tile_bool_checked = get_theme_icon(SNAME("TileChecked"), SNAME("EditorIcons")); tile_bool_unchecked = get_theme_icon(SNAME("TileUnchecked"), SNAME("EditorIcons")); - break; - default: - break; + } break; } } @@ -1315,11 +1313,9 @@ void TileDataOcclusionShapeEditor::_tile_set_changed() { void TileDataOcclusionShapeEditor::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_ENTER_TREE: { polygon_editor->set_polygons_color(get_tree()->get_debug_collisions_color()); - break; - default: - break; + } break; } } @@ -1514,11 +1510,9 @@ void TileDataCollisionEditor::_tile_set_changed() { void TileDataCollisionEditor::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_ENTER_TREE: { polygon_editor->set_polygons_color(get_tree()->get_debug_collisions_color()); - break; - default: - break; + } break; } } @@ -2487,11 +2481,9 @@ void TileDataTerrainsEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform void TileDataTerrainsEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: - case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_THEME_CHANGED: { picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); - break; - default: - break; + } break; } } @@ -2593,11 +2585,9 @@ void TileDataNavigationEditor::_tile_set_changed() { void TileDataNavigationEditor::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_ENTER_TREE: { polygon_editor->set_polygons_color(get_tree()->get_debug_navigation_color()); - break; - default: - break; + } break; } } diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index 1cd9a17cd1..95cd5683a6 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -3374,15 +3374,16 @@ TileMapEditorTerrainsPlugin::~TileMapEditorTerrainsPlugin() { void TileMapEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: - case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_THEME_CHANGED: { missing_tile_texture = get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")); warning_pattern_texture = get_theme_icon(SNAME("WarningPattern"), SNAME("EditorIcons")); advanced_menu_button->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); toggle_grid_button->set_icon(get_theme_icon(SNAME("Grid"), SNAME("EditorIcons"))); toggle_grid_button->set_pressed(EditorSettings::get_singleton()->get("editors/tiles_editor/display_grid")); toogle_highlight_selected_layer_button->set_icon(get_theme_icon(SNAME("TileMapHighlightSelected"), SNAME("EditorIcons"))); - break; - case NOTIFICATION_INTERNAL_PROCESS: + } break; + + case NOTIFICATION_INTERNAL_PROCESS: { if (is_visible_in_tree() && tileset_changed_needs_update) { _update_bottom_panel(); _update_layers_selection(); @@ -3390,11 +3391,13 @@ void TileMapEditor::_notification(int p_what) { CanvasItemEditor::get_singleton()->update_viewport(); tileset_changed_needs_update = false; } - break; - case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: + } break; + + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { toggle_grid_button->set_pressed(EditorSettings::get_singleton()->get("editors/tiles_editor/display_grid")); - break; - case NOTIFICATION_VISIBILITY_CHANGED: + } break; + + case NOTIFICATION_VISIBILITY_CHANGED: { TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); if (tile_map) { if (is_visible_in_tree()) { @@ -3403,7 +3406,7 @@ void TileMapEditor::_notification(int p_what) { tile_map->set_selected_layer(-1); } } - break; + } break; } } diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 9a16e3d682..ade591cde6 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -2270,7 +2270,7 @@ void TileSetAtlasSourceEditor::_auto_remove_tiles() { void TileSetAtlasSourceEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: - case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_THEME_CHANGED: { tool_setup_atlas_source_button->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); tool_select_button->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); tool_paint_button->set_icon(get_theme_icon(SNAME("CanvasItem"), SNAME("EditorIcons"))); @@ -2281,8 +2281,9 @@ void TileSetAtlasSourceEditor::_notification(int p_what) { resize_handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); resize_handle_disabled = get_theme_icon(SNAME("EditorHandleDisabled"), SNAME("EditorIcons")); - break; - case NOTIFICATION_INTERNAL_PROCESS: + } break; + + case NOTIFICATION_INTERNAL_PROCESS: { if (tile_set_changed_needs_update) { // Update everything. _update_source_inspector(); @@ -2298,9 +2299,7 @@ void TileSetAtlasSourceEditor::_notification(int p_what) { tile_set_changed_needs_update = false; } - break; - default: - break; + } break; } } diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index 97b342c6a7..49e589c9ef 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -333,14 +333,15 @@ void TileSetEditor::_set_source_sort(int p_sort) { void TileSetEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: - case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_THEME_CHANGED: { sources_delete_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); sources_add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); source_sort_button->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons"))); sources_advanced_menu_button->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); missing_texture_texture = get_theme_icon(SNAME("TileSet"), SNAME("EditorIcons")); - break; - case NOTIFICATION_INTERNAL_PROCESS: + } break; + + case NOTIFICATION_INTERNAL_PROCESS: { if (tile_set_changed_needs_update) { if (tile_set.is_valid()) { tile_set->set_edited(true); @@ -349,9 +350,7 @@ void TileSetEditor::_notification(int p_what) { _update_patterns_list(); tile_set_changed_needs_update = false; } - break; - default: - break; + } break; } } diff --git a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp index acb6ffc77b..21ebcbd655 100644 --- a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp @@ -330,12 +330,13 @@ void TileSetScenesCollectionSourceEditor::_update_scenes_list() { void TileSetScenesCollectionSourceEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: - case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_THEME_CHANGED: { scene_tile_add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); scene_tile_delete_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); _update_scenes_list(); - break; - case NOTIFICATION_INTERNAL_PROCESS: + } break; + + case NOTIFICATION_INTERNAL_PROCESS: { if (tile_set_scenes_collection_source_changed_needs_update) { // Update everything. _update_source_inspector(); @@ -344,14 +345,13 @@ void TileSetScenesCollectionSourceEditor::_notification(int p_what) { _update_tile_inspector(); tile_set_scenes_collection_source_changed_needs_update = false; } - break; - case NOTIFICATION_VISIBILITY_CHANGED: + } break; + + case NOTIFICATION_VISIBILITY_CHANGED: { // Update things just in case. _update_scenes_list(); _update_action_buttons(); - break; - default: - break; + } break; } } diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 5d43813572..446ad12104 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -3373,91 +3373,98 @@ void VisualShaderEditor::_sbox_input(const Ref<InputEvent> &p_ie) { } void VisualShaderEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - node_filter->set_clear_button_enabled(true); - - // collapse tree by default - - TreeItem *category = members->get_root()->get_first_child(); - while (category) { - category->set_collapsed(true); - TreeItem *sub_category = category->get_first_child(); - while (sub_category) { - sub_category->set_collapsed(true); - sub_category = sub_category->get_next(); - } - category = category->get_next(); - } - } + switch (p_what) { + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { + graph->get_panner()->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning"))); + graph->set_warped_panning(bool(EditorSettings::get_singleton()->get("editors/panning/warped_mouse_panning"))); + } break; - if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - graph->get_panner()->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning"))); - graph->set_warped_panning(bool(EditorSettings::get_singleton()->get("editors/panning/warped_mouse_panning"))); - } + case NOTIFICATION_ENTER_TREE: { + node_filter->set_clear_button_enabled(true); - if (p_what == NOTIFICATION_DRAG_BEGIN) { - Dictionary dd = get_viewport()->gui_get_drag_data(); - if (members->is_visible_in_tree() && dd.has("id")) { - members->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM); - } - } else if (p_what == NOTIFICATION_DRAG_END) { - members->set_drop_mode_flags(0); - } + // collapse tree by default + + TreeItem *category = members->get_root()->get_first_child(); + while (category) { + category->set_collapsed(true); + TreeItem *sub_category = category->get_first_child(); + while (sub_category) { + sub_category->set_collapsed(true); + sub_category = sub_category->get_next(); + } + category = category->get_next(); + } - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - highend_label->set_modulate(get_theme_color(SNAME("vulkan_color"), SNAME("Editor"))); + graph->get_panner()->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning"))); + graph->set_warped_panning(bool(EditorSettings::get_singleton()->get("editors/panning/warped_mouse_panning"))); + [[fallthrough]]; + } + case NOTIFICATION_THEME_CHANGED: { + highend_label->set_modulate(get_theme_color(SNAME("vulkan_color"), SNAME("Editor"))); - node_filter->set_right_icon(Control::get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + node_filter->set_right_icon(Control::get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - preview_shader->set_icon(Control::get_theme_icon(SNAME("Shader"), SNAME("EditorIcons"))); + preview_shader->set_icon(Control::get_theme_icon(SNAME("Shader"), SNAME("EditorIcons"))); - { - Color background_color = EDITOR_GET("text_editor/theme/highlighting/background_color"); - Color text_color = EDITOR_GET("text_editor/theme/highlighting/text_color"); - Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color"); - Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color"); - Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color"); - Color symbol_color = EDITOR_GET("text_editor/theme/highlighting/symbol_color"); - Color function_color = EDITOR_GET("text_editor/theme/highlighting/function_color"); - Color number_color = EDITOR_GET("text_editor/theme/highlighting/number_color"); - Color members_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color"); + { + Color background_color = EDITOR_GET("text_editor/theme/highlighting/background_color"); + Color text_color = EDITOR_GET("text_editor/theme/highlighting/text_color"); + Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color"); + Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color"); + Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color"); + Color symbol_color = EDITOR_GET("text_editor/theme/highlighting/symbol_color"); + Color function_color = EDITOR_GET("text_editor/theme/highlighting/function_color"); + Color number_color = EDITOR_GET("text_editor/theme/highlighting/number_color"); + Color members_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color"); - preview_text->add_theme_color_override("background_color", background_color); + preview_text->add_theme_color_override("background_color", background_color); - for (const String &E : keyword_list) { - if (ShaderLanguage::is_control_flow_keyword(E)) { - syntax_highlighter->add_keyword_color(E, control_flow_keyword_color); - } else { - syntax_highlighter->add_keyword_color(E, keyword_color); + for (const String &E : keyword_list) { + if (ShaderLanguage::is_control_flow_keyword(E)) { + syntax_highlighter->add_keyword_color(E, control_flow_keyword_color); + } else { + syntax_highlighter->add_keyword_color(E, keyword_color); + } } - } - preview_text->add_theme_font_override("font", get_theme_font(SNAME("expression"), SNAME("EditorFonts"))); - preview_text->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("expression_size"), SNAME("EditorFonts"))); - preview_text->add_theme_color_override("font_color", text_color); - syntax_highlighter->set_number_color(number_color); - syntax_highlighter->set_symbol_color(symbol_color); - syntax_highlighter->set_function_color(function_color); - syntax_highlighter->set_member_variable_color(members_color); - syntax_highlighter->clear_color_regions(); - syntax_highlighter->add_color_region("/*", "*/", comment_color, false); - syntax_highlighter->add_color_region("//", "", comment_color, true); + preview_text->add_theme_font_override("font", get_theme_font(SNAME("expression"), SNAME("EditorFonts"))); + preview_text->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("expression_size"), SNAME("EditorFonts"))); + preview_text->add_theme_color_override("font_color", text_color); + syntax_highlighter->set_number_color(number_color); + syntax_highlighter->set_symbol_color(symbol_color); + syntax_highlighter->set_function_color(function_color); + syntax_highlighter->set_member_variable_color(members_color); + syntax_highlighter->clear_color_regions(); + syntax_highlighter->add_color_region("/*", "*/", comment_color, false); + syntax_highlighter->add_color_region("//", "", comment_color, true); + + preview_text->clear_comment_delimiters(); + preview_text->add_comment_delimiter("/*", "*/", false); + preview_text->add_comment_delimiter("//", "", true); + + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Panel"))); + error_label->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); + error_label->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + } - preview_text->clear_comment_delimiters(); - preview_text->add_comment_delimiter("/*", "*/", false); - preview_text->add_comment_delimiter("//", "", true); + tools->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); - error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Panel"))); - error_label->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); - error_label->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); - error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); - } + if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree()) { + _update_graph(); + } + } break; - tools->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); + case NOTIFICATION_DRAG_BEGIN: { + Dictionary dd = get_viewport()->gui_get_drag_data(); + if (members->is_visible_in_tree() && dd.has("id")) { + members->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM); + } + } break; - if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree()) { - _update_graph(); - } + case NOTIFICATION_DRAG_END: { + members->set_drop_mode_flags(0); + } break; } } @@ -5052,8 +5059,10 @@ class VisualShaderNodePluginInputEditor : public OptionButton { public: void _notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - connect("item_selected", callable_mp(this, &VisualShaderNodePluginInputEditor::_item_selected)); + switch (p_what) { + case NOTIFICATION_READY: { + connect("item_selected", callable_mp(this, &VisualShaderNodePluginInputEditor::_item_selected)); + } break; } } @@ -5100,8 +5109,10 @@ class VisualShaderNodePluginUniformRefEditor : public OptionButton { public: void _notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - connect("item_selected", callable_mp(this, &VisualShaderNodePluginUniformRefEditor::_item_selected)); + switch (p_what) { + case NOTIFICATION_READY: { + connect("item_selected", callable_mp(this, &VisualShaderNodePluginUniformRefEditor::_item_selected)); + } break; } } @@ -5514,29 +5525,31 @@ Size2 VisualShaderNodePortPreview::get_minimum_size() const { } void VisualShaderNodePortPreview::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAW) { - Vector<Vector2> points = { - Vector2(), - Vector2(get_size().width, 0), - get_size(), - Vector2(0, get_size().height) - }; - - Vector<Vector2> uvs = { - Vector2(0, 0), - Vector2(1, 0), - Vector2(1, 1), - Vector2(0, 1) - }; - - Vector<Color> colors = { - Color(1, 1, 1, 1), - Color(1, 1, 1, 1), - Color(1, 1, 1, 1), - Color(1, 1, 1, 1) - }; - - draw_primitive(points, colors, uvs); + switch (p_what) { + case NOTIFICATION_DRAW: { + Vector<Vector2> points = { + Vector2(), + Vector2(get_size().width, 0), + get_size(), + Vector2(0, get_size().height) + }; + + Vector<Vector2> uvs = { + Vector2(0, 0), + Vector2(1, 0), + Vector2(1, 1), + Vector2(0, 1) + }; + + Vector<Color> colors = { + Color(1, 1, 1, 1), + Color(1, 1, 1, 1), + Color(1, 1, 1, 1), + Color(1, 1, 1, 1) + }; + + draw_primitive(points, colors, uvs); + } break; } } diff --git a/editor/plugins/voxel_gi_editor_plugin.cpp b/editor/plugins/voxel_gi_editor_plugin.cpp index 9ecdb56e50..6fc6c1ad39 100644 --- a/editor/plugins/voxel_gi_editor_plugin.cpp +++ b/editor/plugins/voxel_gi_editor_plugin.cpp @@ -65,41 +65,43 @@ bool VoxelGIEditorPlugin::handles(Object *p_object) const { } void VoxelGIEditorPlugin::_notification(int p_what) { - if (p_what == NOTIFICATION_PROCESS) { - if (!voxel_gi) { - return; - } + switch (p_what) { + case NOTIFICATION_PROCESS: { + if (!voxel_gi) { + return; + } - // Set information tooltip on the Bake button. This information is useful - // to optimize performance (video RAM size) and reduce light leaking (individual cell size). + // Set information tooltip on the Bake button. This information is useful + // to optimize performance (video RAM size) and reduce light leaking (individual cell size). - const Vector3i size = voxel_gi->get_estimated_cell_size(); + const Vector3i size = voxel_gi->get_estimated_cell_size(); - const Vector3 extents = voxel_gi->get_extents(); + const Vector3 extents = voxel_gi->get_extents(); - const int data_size = 4; - const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0); - // Add a qualitative measurement to help the user assess whether a VoxelGI node is using a lot of VRAM. - String size_quality; - if (size_mb < 16.0) { - size_quality = TTR("Low"); - } else if (size_mb < 64.0) { - size_quality = TTR("Moderate"); - } else { - size_quality = TTR("High"); - } + const int data_size = 4; + const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0); + // Add a qualitative measurement to help the user assess whether a VoxelGI node is using a lot of VRAM. + String size_quality; + if (size_mb < 16.0) { + size_quality = TTR("Low"); + } else if (size_mb < 64.0) { + size_quality = TTR("Moderate"); + } else { + size_quality = TTR("High"); + } - String text; - text += vformat(TTR("Subdivisions: %s"), vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z)) + "\n"; - text += vformat(TTR("Cell size: %s"), vformat(String::utf8("%.3f × %.3f × %.3f"), extents.x / size.x, extents.y / size.y, extents.z / size.z)) + "\n"; - text += vformat(TTR("Video RAM size: %s MB (%s)"), String::num(size_mb, 2), size_quality); + String text; + text += vformat(TTR("Subdivisions: %s"), vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z)) + "\n"; + text += vformat(TTR("Cell size: %s"), vformat(String::utf8("%.3f × %.3f × %.3f"), extents.x / size.x, extents.y / size.y, extents.z / size.z)) + "\n"; + text += vformat(TTR("Video RAM size: %s MB (%s)"), String::num(size_mb, 2), size_quality); - // Only update the tooltip when needed to avoid constant redrawing. - if (bake->get_tooltip(Point2()) == text) { - return; - } + // Only update the tooltip when needed to avoid constant redrawing. + if (bake->get_tooltip(Point2()) == text) { + return; + } - bake->set_tooltip(text); + bake->set_tooltip(text); + } break; } } diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 21163531d8..55a4dc2c67 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -61,6 +61,7 @@ void ProjectExportDialog::_notification(int p_what) { EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "export", Rect2(get_position(), get_size())); } } break; + case NOTIFICATION_READY: { duplicate_preset->set_icon(presets->get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons"))); delete_preset->set_icon(presets->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 2a9f699ee6..87d008d144 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -647,8 +647,10 @@ private: } void _notification(int p_what) { - if (p_what == NOTIFICATION_WM_CLOSE_REQUEST) { - _remove_created_folder(); + switch (p_what) { + case NOTIFICATION_WM_CLOSE_REQUEST: { + _remove_created_folder(); + } break; } } @@ -978,10 +980,12 @@ public: hover = true; update(); } break; + case NOTIFICATION_MOUSE_EXIT: { hover = false; update(); } break; + case NOTIFICATION_DRAW: { if (hover) { draw_style_box(get_theme_stylebox(SNAME("hover"), SNAME("Tree")), Rect2(Point2(), get_size())); @@ -1143,18 +1147,20 @@ void ProjectList::update_icons_async() { } void ProjectList::_notification(int p_what) { - if (p_what == NOTIFICATION_PROCESS) { - // Load icons as a coroutine to speed up launch when you have hundreds of projects - if (_icon_load_index < _projects.size()) { - Item &item = _projects.write[_icon_load_index]; - if (item.control->icon_needs_reload) { - load_project_icon(_icon_load_index); - } - _icon_load_index++; + switch (p_what) { + case NOTIFICATION_PROCESS: { + // Load icons as a coroutine to speed up launch when you have hundreds of projects + if (_icon_load_index < _projects.size()) { + Item &item = _projects.write[_icon_load_index]; + if (item.control->icon_needs_reload) { + load_project_icon(_icon_load_index); + } + _icon_load_index++; - } else { - set_process(false); - } + } else { + set_process(false); + } + } break; } } @@ -1872,17 +1878,20 @@ void ProjectManager::_notification(int p_what) { settings_hb->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT); update(); } break; + case NOTIFICATION_ENTER_TREE: { search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); Engine::get_singleton()->set_editor_hint(false); } break; + case NOTIFICATION_RESIZED: { if (open_templates->is_visible()) { open_templates->popup_centered(); } } break; + case NOTIFICATION_READY: { int default_sorting = (int)EditorSettings::get_singleton()->get("project_manager/sorting_order"); filter_option->select(default_sorting); @@ -1898,12 +1907,15 @@ void ProjectManager::_notification(int p_what) { search_box->grab_focus(); } } break; + case NOTIFICATION_VISIBILITY_CHANGED: { set_process_unhandled_key_input(is_visible_in_tree()); } break; + case NOTIFICATION_WM_CLOSE_REQUEST: { _dim_window(); } break; + case NOTIFICATION_WM_ABOUT: { _show_about(); } break; diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index c0ff1d72ee..03179733d5 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -531,11 +531,13 @@ void ProjectSettingsEditor::_notification(int p_what) { EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "project_settings", Rect2(get_position(), get_size())); } } break; + case NOTIFICATION_ENTER_TREE: { general_settings_inspector->edit(ps); _update_action_map_editor(); _update_theme(); } break; + case NOTIFICATION_THEME_CHANGED: { _update_theme(); } break; diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 40f7b86ffc..cd65ee7ae6 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -94,8 +94,10 @@ Ref<Resource> EditorResourceConversionPlugin::convert(const Ref<Resource> &p_res } void CustomPropertyEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_WM_CLOSE_REQUEST) { - hide(); + switch (p_what) { + case NOTIFICATION_WM_CLOSE_REQUEST: { + hide(); + } break; } } diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 825802d852..453ecb6b24 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -421,10 +421,14 @@ void PropertySelector::_hide_requested() { } void PropertySelector::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - connect("confirmed", callable_mp(this, &PropertySelector::_confirmed)); - } else if (p_what == NOTIFICATION_EXIT_TREE) { - disconnect("confirmed", callable_mp(this, &PropertySelector::_confirmed)); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + connect("confirmed", callable_mp(this, &PropertySelector::_confirmed)); + } break; + + case NOTIFICATION_EXIT_TREE: { + disconnect("confirmed", callable_mp(this, &PropertySelector::_confirmed)); + } break; } } diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index 2a8ca67fe6..4e64aba1db 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -229,6 +229,7 @@ void EditorQuickOpen::_notification(int p_what) { search_box->set_clear_button_enabled(true); } break; + case NOTIFICATION_EXIT_TREE: { disconnect("confirmed", callable_mp(this, &EditorQuickOpen::_confirmed)); } break; diff --git a/editor/reparent_dialog.cpp b/editor/reparent_dialog.cpp index 1a83a61534..8879085d86 100644 --- a/editor/reparent_dialog.cpp +++ b/editor/reparent_dialog.cpp @@ -35,12 +35,14 @@ #include "scene/gui/label.h" void ReparentDialog::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - connect("confirmed", callable_mp(this, &ReparentDialog::_reparent)); - } - - if (p_what == NOTIFICATION_EXIT_TREE) { - disconnect("confirmed", callable_mp(this, &ReparentDialog::_reparent)); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + connect("confirmed", callable_mp(this, &ReparentDialog::_reparent)); + } break; + + case NOTIFICATION_EXIT_TREE: { + disconnect("confirmed", callable_mp(this, &ReparentDialog::_reparent)); + } break; } } diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index db78546fd3..628e7880a1 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1270,6 +1270,7 @@ void SceneTreeDock::_notification(int p_what) { case NOTIFICATION_EXIT_TREE: { clear_inherit_confirm->disconnect("confirmed", callable_mp(this, &SceneTreeDock::_tool_selected)); } break; + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { scene_tree->set_auto_expand_selected(EditorSettings::get_singleton()->get("docks/scene_tree/auto_expand_to_selected"), false); button_add->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); @@ -1286,6 +1287,7 @@ void SceneTreeDock::_notification(int p_what) { filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); filter->set_clear_button_enabled(true); } break; + case NOTIFICATION_PROCESS: { bool show_create_root = bool(EDITOR_GET("interface/editors/show_scene_tree_root_selection")) && get_tree()->get_edited_scene_root() == nullptr; @@ -1298,7 +1300,6 @@ void SceneTreeDock::_notification(int p_what) { scene_tree->show(); } } - } break; } } diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index c10dd2e2de..ba65828ac1 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -700,6 +700,7 @@ void SceneTreeEditor::_notification(int p_what) { _update_tree(); } break; + case NOTIFICATION_EXIT_TREE: { get_tree()->disconnect("tree_changed", callable_mp(this, &SceneTreeEditor::_tree_changed)); get_tree()->disconnect("tree_process_mode_changed", callable_mp(this, &SceneTreeEditor::_tree_process_mode_changed)); @@ -708,6 +709,7 @@ void SceneTreeEditor::_notification(int p_what) { tree->disconnect("item_collapsed", callable_mp(this, &SceneTreeEditor::_cell_collapsed)); get_tree()->disconnect("node_configuration_warning_changed", callable_mp(this, &SceneTreeEditor::_warning_changed)); } break; + case NOTIFICATION_THEME_CHANGED: { _update_tree(); } break; @@ -1283,13 +1285,16 @@ void SceneTreeDialog::_notification(int p_what) { tree->update_tree(); } } break; + case NOTIFICATION_ENTER_TREE: { connect("confirmed", callable_mp(this, &SceneTreeDialog::_select)); _update_theme(); } break; + case NOTIFICATION_THEME_CHANGED: { _update_theme(); } break; + case NOTIFICATION_EXIT_TREE: { disconnect("confirmed", callable_mp(this, &SceneTreeDialog::_select)); } break; diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp index 3c807548ab..dbc78e846c 100644 --- a/editor/shader_create_dialog.cpp +++ b/editor/shader_create_dialog.cpp @@ -57,6 +57,7 @@ void ShaderCreateDialog::_notification(int p_what) { current_mode = EditorSettings::get_singleton()->get_project_metadata("shader_setup", "last_selected_mode", 0); mode_menu->select(current_mode); } break; + case NOTIFICATION_THEME_CHANGED: { _update_theme(); } break; diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp index 034f6d4857..70a43d24ba 100644 --- a/editor/shader_globals_editor.cpp +++ b/editor/shader_globals_editor.cpp @@ -438,13 +438,16 @@ void ShaderGlobalsEditor::_bind_methods() { } void ShaderGlobalsEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - if (is_visible_in_tree()) { - inspector->edit(interface); - } - } - if (p_what == NOTIFICATION_PREDELETE) { - inspector->edit(nullptr); + switch (p_what) { + case NOTIFICATION_VISIBILITY_CHANGED: { + if (is_visible_in_tree()) { + inspector->edit(interface); + } + } break; + + case NOTIFICATION_PREDELETE: { + inspector->edit(nullptr); + } break; } } diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp index 12f9c6fc00..a3c662ba08 100644 --- a/modules/basis_universal/register_types.cpp +++ b/modules/basis_universal/register_types.cpp @@ -32,7 +32,6 @@ #include "core/os/os.h" #include "servers/rendering_server.h" -#include "texture_basisu.h" #ifdef TOOLS_ENABLED #include <encoder/basisu_comp.h> @@ -272,7 +271,6 @@ void register_basis_universal_types() { Image::basis_universal_packer = basis_universal_packer; #endif Image::basis_universal_unpacker = basis_universal_unpacker; - //GDREGISTER_CLASS(TextureBasisU); } void unregister_basis_universal_types() { diff --git a/modules/basis_universal/texture_basisu.cpp b/modules/basis_universal/texture_basisu.cpp deleted file mode 100644 index 1ac4df8d19..0000000000 --- a/modules/basis_universal/texture_basisu.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/*************************************************************************/ -/* texture_basisu.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "texture_basisu.h" -#if 0 -#include "core/os/os.h" - -#ifdef TOOLS_ENABLED -#include <encoder/basisu_comp.h> -#endif - -#include <transcoder/basisu_transcoder.h> - -void TextureBasisU::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_basisu_data", "data"), &TextureBasisU::set_basisu_data); - ClassDB::bind_method(D_METHOD("get_basisu_data"), &TextureBasisU::get_data); - ClassDB::bind_method(D_METHOD("import"), &TextureBasisU::import); - - ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "basisu_data"), "set_basisu_data", "get_basisu_data"); -}; - -int TextureBasisU::get_width() const { - return tex_size.x; -}; - -int TextureBasisU::get_height() const { - return tex_size.y; -}; - -RID TextureBasisU::get_rid() const { - return texture; -}; - - -bool TextureBasisU::has_alpha() const { - return false; -}; - -void TextureBasisU::set_flags(uint32_t p_flags) { - flags = p_flags; - RenderingServer::get_singleton()->texture_set_flags(texture, p_flags); -}; - -uint32_t TextureBasisU::get_flags() const { - return flags; -}; - - -void TextureBasisU::set_basisu_data(const Vector<uint8_t>& p_data) { - -#ifdef TOOLS_ENABLED - data = p_data; -#endif - - const uint8_t* r = p_data.ptr(); - const void* ptr = r.ptr(); - int size = p_data.size(); - - basist::transcoder_texture_format format; - Image::Format imgfmt; - - if (OS::get_singleton()->has_feature("s3tc")) { - format = basist::cTFBC3; // get this from renderer - imgfmt = Image::FORMAT_DXT5; - - } else if (OS::get_singleton()->has_feature("etc2")) { - format = basist::cTFETC2; - imgfmt = Image::FORMAT_ETC2_RGBA8; - }; - - basist::basisu_transcoder tr(nullptr); - - ERR_FAIL_COND(!tr.validate_header(ptr, size)); - - basist::basisu_image_info info; - tr.get_image_info(ptr, size, info, 0); - tex_size = Size2(info.m_width, info.m_height); - - int block_size = basist::basis_get_bytes_per_block(format); - Vector<uint8_t> gpudata; - gpudata.resize(info.m_total_blocks * block_size); - - { - uint8_t* w = gpudata.ptrw(); - uint8_t* dst = w.ptr(); - for (int i=0; i<gpudata.size(); i++) - dst[i] = 0x00; - - int ofs = 0; - tr.start_transcoding(ptr, size); - for (int i=0; i<info.m_total_levels; i++) { - basist::basisu_image_level_info level; - tr.get_image_level_info(ptr, size, level, 0, i); - - bool ret = tr.transcode_image_level(ptr, size, 0, i, dst + ofs, level.m_total_blocks - i, format); - if (!ret) { - printf("failed! on level %i\n", i); - break; - }; - - ofs += level.m_total_blocks * block_size; - }; - }; - - Ref<Image> img; - img.instantiate(); - img->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata); - - RenderingServer::get_singleton()->texture_allocate(texture, tex_size.x, tex_size.y, 0, img->get_format(), RS::TEXTURE_TYPE_2D, flags); - RenderingServer::get_singleton()->texture_set_data(texture, img); -}; - -Error TextureBasisU::import(const Ref<Image>& p_img) { - -#ifdef TOOLS_ENABLED - - Vector<uint8_t> budata; - - { - Image::Format format = p_img->get_format(); - if (format != Image::FORMAT_RGB8 && format != Image::FORMAT_RGBA8) { - ERR_FAIL_V(ERR_INVALID_PARAMETER); - return ERR_INVALID_PARAMETER; - }; - - Ref<Image> copy = p_img->duplicate(); - if (format == Image::FORMAT_RGB8) - copy->convert(Image::FORMAT_RGBA8); - - basisu::image buimg(p_img->get_width(), p_img->get_height()); - int size = p_img->get_width() * p_img->get_height() * 4; - - Vector<uint8_t> vec = copy->get_data(); - { - const uint8_t* r = vec.ptr(); - memcpy(buimg.get_ptr(), r.ptr(), size); - }; - - basisu::basis_compressor_params params; - params.m_max_endpoint_clusters = 512; - params.m_max_selector_clusters = 512; - params.m_multithreading = true; - - basisu::job_pool jpool(1); - params.m_pJob_pool = &jpool; - - params.m_mip_gen = p_img->get_mipmap_count() > 0; - params.m_source_images.push_back(buimg); - - basisu::basis_compressor c; - c.init(params); - - int buerr = c.process(); - if (buerr != basisu::basis_compressor::cECSuccess) { - ERR_FAIL_V(ERR_INVALID_PARAMETER); - return ERR_INVALID_PARAMETER; - }; - - const basisu::uint8_vec& buvec = c.get_output_basis_file(); - budata.resize(buvec.size()); - - { - uint8_t* w = budata.ptrw(); - memcpy(w.ptr(), &buvec[0], budata.size()); - }; - }; - - set_basisu_data(budata); - - return OK; -#else - - return ERR_UNAVAILABLE; -#endif -}; - - -Vector<uint8_t> TextureBasisU::get_basisu_data() const { - return data; -}; - -TextureBasisU::TextureBasisU() { - texture = RenderingServer::get_singleton()->texture_create(); -}; - - -TextureBasisU::~TextureBasisU() { - RenderingServer::get_singleton()->free(texture); -}; - -#endif diff --git a/modules/basis_universal/texture_basisu.h b/modules/basis_universal/texture_basisu.h deleted file mode 100644 index 8c8be68254..0000000000 --- a/modules/basis_universal/texture_basisu.h +++ /dev/null @@ -1,80 +0,0 @@ -/*************************************************************************/ -/* texture_basisu.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef BASIS_UNIVERSAL_TEXTURE_BASISU_H -#define BASIS_UNIVERSAL_TEXTURE_BASISU_H - -#include "scene/resources/texture.h" - -#ifdef TOOLS_ENABLED -#include <encoder/basisu_comp.h> -#endif - -#include <transcoder/basisu_transcoder.h> - -#if 0 -class TextureBasisU : public Texture { - GDCLASS(TextureBasisU, Texture); - RES_BASE_EXTENSION("butex"); - - RID texture; - Size2 tex_size; - - uint32_t flags = FLAGS_DEFAULT; - - Vector<uint8_t> data; - - static void _bind_methods(); - -public: - - virtual int get_width() const; - virtual int get_height() const; - virtual RID get_rid() const; - virtual bool has_alpha() const; - - virtual void set_flags(uint32_t p_flags); - virtual uint32_t get_flags() const; - - - Error import(const Ref<Image> &p_img); - - void set_basisu_data(const Vector<uint8_t>& p_data); - - Vector<uint8_t> get_basisu_data() const; - String get_img_path() const; - - TextureBasisU(); - ~TextureBasisU(); -}; - -#endif - -#endif // BASIS_UNIVERSAL_TEXTURE_BASISU_H diff --git a/modules/bullet/slider_joint_bullet.cpp b/modules/bullet/slider_joint_bullet.cpp index 61c3b3b0a3..b06cdeaa6a 100644 --- a/modules/bullet/slider_joint_bullet.cpp +++ b/modules/bullet/slider_joint_bullet.cpp @@ -334,7 +334,6 @@ real_t SliderJointBullet::getMaxAngMotorForce() { real_t SliderJointBullet::getLinearPos() { return sliderConstraint->getLinearPos(); - ; } void SliderJointBullet::set_param(PhysicsServer3D::SliderJointParam p_param, real_t p_value) { diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index fbddedbe55..39e4751be3 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -491,61 +491,63 @@ Vector<Face3> CSGShape3D::get_faces(uint32_t p_usage_flags) const { } void CSGShape3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - Node *parentn = get_parent(); - if (parentn) { - parent = Object::cast_to<CSGShape3D>(parentn); - if (parent) { - set_base(RID()); - root_mesh.unref(); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + Node *parentn = get_parent(); + if (parentn) { + parent = Object::cast_to<CSGShape3D>(parentn); + if (parent) { + set_base(RID()); + root_mesh.unref(); + } } - } - if (use_collision && is_root_shape()) { - root_collision_shape.instantiate(); - root_collision_instance = PhysicsServer3D::get_singleton()->body_create(); - PhysicsServer3D::get_singleton()->body_set_mode(root_collision_instance, PhysicsServer3D::BODY_MODE_STATIC); - PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); - PhysicsServer3D::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid()); - PhysicsServer3D::get_singleton()->body_set_space(root_collision_instance, get_world_3d()->get_space()); - PhysicsServer3D::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id()); - set_collision_layer(collision_layer); - set_collision_mask(collision_mask); - } + if (use_collision && is_root_shape()) { + root_collision_shape.instantiate(); + root_collision_instance = PhysicsServer3D::get_singleton()->body_create(); + PhysicsServer3D::get_singleton()->body_set_mode(root_collision_instance, PhysicsServer3D::BODY_MODE_STATIC); + PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); + PhysicsServer3D::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid()); + PhysicsServer3D::get_singleton()->body_set_space(root_collision_instance, get_world_3d()->get_space()); + PhysicsServer3D::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id()); + set_collision_layer(collision_layer); + set_collision_mask(collision_mask); + } - _make_dirty(); - } + _make_dirty(); + } break; - if (p_what == NOTIFICATION_TRANSFORM_CHANGED) { - if (use_collision && is_root_shape() && root_collision_instance.is_valid()) { - PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); - } - } + case NOTIFICATION_TRANSFORM_CHANGED: { + if (use_collision && is_root_shape() && root_collision_instance.is_valid()) { + PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); + } + } break; - if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) { - if (parent) { - parent->_make_dirty(); - } - } + case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { + if (parent) { + parent->_make_dirty(); + } + } break; - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - if (parent) { - parent->_make_dirty(); - } - } + case NOTIFICATION_VISIBILITY_CHANGED: { + if (parent) { + parent->_make_dirty(); + } + } break; - if (p_what == NOTIFICATION_EXIT_TREE) { - if (parent) { - parent->_make_dirty(); - } - parent = nullptr; + case NOTIFICATION_EXIT_TREE: { + if (parent) { + parent->_make_dirty(); + } + parent = nullptr; - if (use_collision && is_root_shape() && root_collision_instance.is_valid()) { - PhysicsServer3D::get_singleton()->free(root_collision_instance); - root_collision_instance = RID(); - root_collision_shape.unref(); - } - _make_dirty(); + if (use_collision && is_root_shape() && root_collision_instance.is_valid()) { + PhysicsServer3D::get_singleton()->free(root_collision_instance); + root_collision_instance = RID(); + root_collision_shape.unref(); + } + _make_dirty(); + } break; } } diff --git a/modules/fbx/fbx_parser/FBXMeshGeometry.cpp b/modules/fbx/fbx_parser/FBXMeshGeometry.cpp index b3956af762..591f2e5503 100644 --- a/modules/fbx/fbx_parser/FBXMeshGeometry.cpp +++ b/modules/fbx/fbx_parser/FBXMeshGeometry.cpp @@ -212,32 +212,6 @@ MeshGeometry::MeshGeometry(uint64_t id, const ElementPtr element, const std::str m_normals = resolve_vertex_data_array<Vector3>(layer_scope, MappingInformationType, ReferenceInformationType, "Normals"); } else if (layer_type_name == "LayerElementColor") { m_colors = resolve_vertex_data_array<Color>(layer_scope, MappingInformationType, ReferenceInformationType, "Colors", "ColorIndex"); - // NOTE: this is a useful sanity check to ensure you're getting any color data which is not default. - // const Color first_color_check = m_colors.data[0]; - // bool colors_are_all_the_same = true; - // size_t i = 1; - // for(i = 1; i < m_colors.data.size(); i++) - // { - // const Color current_color = m_colors.data[i]; - // if(current_color.is_equal_approx(first_color_check)) - // { - // continue; - // } - // else - // { - // colors_are_all_the_same = false; - // break; - // } - // } - // - // if(colors_are_all_the_same) - // { - // print_error("Color serialisation is not working for vertex colors some should be different in the test asset."); - // } - // else - // { - // print_verbose("Color array has unique colors at index: " + itos(i)); - // } } } } diff --git a/modules/gdnative/gdnative_library_singleton_editor.cpp b/modules/gdnative/gdnative_library_singleton_editor.cpp index e0079f93ee..ce1f41bdf1 100644 --- a/modules/gdnative/gdnative_library_singleton_editor.cpp +++ b/modules/gdnative/gdnative_library_singleton_editor.cpp @@ -183,10 +183,12 @@ void GDNativeLibrarySingletonEditor::_item_edited() { } void GDNativeLibrarySingletonEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - if (is_visible_in_tree()) { - _update_libraries(); - } + switch (p_what) { + case NOTIFICATION_VISIBILITY_CHANGED: { + if (is_visible_in_tree()) { + _update_libraries(); + } + } break; } } diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 5d5414c694..95976a8827 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -763,17 +763,19 @@ Variant NativeScriptInstance::call(const StringName &p_method, const Variant **p return Variant(); } -void NativeScriptInstance::notification(int p_notification) { +void NativeScriptInstance::notification(int p_what) { #ifdef DEBUG_ENABLED - if (p_notification == MainLoop::NOTIFICATION_CRASH) { - if (current_method_call != StringName()) { - ERR_PRINT("NativeScriptInstance detected crash on method: " + current_method_call); - current_method_call = ""; - } + switch (p_what) { + case MainLoop::NOTIFICATION_CRASH: { + if (current_method_call != StringName()) { + ERR_PRINT("NativeScriptInstance detected crash on method: " + current_method_call); + current_method_call = ""; + } + } break; } #endif - Variant value = p_notification; + Variant value = p_what; const Variant *args[1] = { &value }; Callable::CallError error; call("_notification", args, 1, error); @@ -1639,7 +1641,6 @@ void NativeReloadNode::_bind_methods() { void NativeReloadNode::_notification(int p_what) { #ifdef TOOLS_ENABLED - switch (p_what) { case NOTIFICATION_APPLICATION_FOCUS_OUT: { if (unloaded) { @@ -1672,7 +1673,6 @@ void NativeReloadNode::_notification(int p_what) { } unloaded = true; - } break; case NOTIFICATION_APPLICATION_FOCUS_IN: { @@ -1736,10 +1736,7 @@ void NativeReloadNode::_notification(int p_what) { for (Set<StringName>::Element *R = libs_to_remove.front(); R; R = R->next()) { NSL->library_gdnatives.erase(R->get()); } - } break; - default: { - }; } #endif } diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h index 6c47d35abc..2d01de5832 100644 --- a/modules/gdnative/nativescript/nativescript.h +++ b/modules/gdnative/nativescript/nativescript.h @@ -209,7 +209,7 @@ public: virtual void get_method_list(List<MethodInfo> *p_list) const; virtual bool has_method(const StringName &p_method) const; virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error); - virtual void notification(int p_notification); + virtual void notification(int p_what); String to_string(bool *r_valid); virtual Ref<Script> get_script() const; diff --git a/modules/gdscript/language_server/gdscript_language_server.cpp b/modules/gdscript/language_server/gdscript_language_server.cpp index 33c1c834f1..14337e87da 100644 --- a/modules/gdscript/language_server/gdscript_language_server.cpp +++ b/modules/gdscript/language_server/gdscript_language_server.cpp @@ -45,17 +45,20 @@ GDScriptLanguageServer::GDScriptLanguageServer() { void GDScriptLanguageServer::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_ENTER_TREE: { start(); - break; - case NOTIFICATION_EXIT_TREE: + } break; + + case NOTIFICATION_EXIT_TREE: { stop(); - break; + } break; + case NOTIFICATION_INTERNAL_PROCESS: { if (started && !use_thread) { protocol.poll(); } } break; + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { String host = String(_EDITOR_GET("network/language_server/remote_host")); int port = (int)_EDITOR_GET("network/language_server/remote_port"); diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 4b72c71a5a..7c4d33ff17 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -703,8 +703,8 @@ void GridMap::_notification(int p_what) { RS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, get_world_3d()->get_scenario()); RS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform()); } - } break; + case NOTIFICATION_TRANSFORM_CHANGED: { Transform3D new_xform = get_global_transform(); if (new_xform == last_transform) { @@ -721,6 +721,7 @@ void GridMap::_notification(int p_what) { RS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform()); } } break; + case NOTIFICATION_EXIT_WORLD: { for (const KeyValue<OctantKey, Octant *> &E : octant_map) { _octant_exit_world(E.key); @@ -732,8 +733,8 @@ void GridMap::_notification(int p_what) { for (int i = 0; i < baked_meshes.size(); i++) { RS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, RID()); } - } break; + case NOTIFICATION_VISIBILITY_CHANGED: { _update_visibility(); } break; diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index a7f93a6ce9..80856d37c2 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -1456,15 +1456,17 @@ GridMapEditor::~GridMapEditor() { } void GridMapEditorPlugin::_notification(int p_what) { - if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - switch ((int)EditorSettings::get_singleton()->get("editors/grid_map/editor_side")) { - case 0: { // Left. - Node3DEditor::get_singleton()->move_control_to_left_panel(grid_map_editor); - } break; - case 1: { // Right. - Node3DEditor::get_singleton()->move_control_to_right_panel(grid_map_editor); - } break; - } + switch (p_what) { + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { + switch ((int)EditorSettings::get_singleton()->get("editors/grid_map/editor_side")) { + case 0: { // Left. + Node3DEditor::get_singleton()->move_control_to_left_panel(grid_map_editor); + } break; + case 1: { // Right. + Node3DEditor::get_singleton()->move_control_to_right_panel(grid_map_editor); + } break; + } + } break; } } diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index 2de923c125..d6cd9e6e57 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -53,8 +53,9 @@ class CSharpLanguage; #ifdef NO_SAFE_CAST template <typename TScriptInstance, typename TScriptLanguage> TScriptInstance *cast_script_instance(ScriptInstance *p_inst) { - if (!p_inst) + if (!p_inst) { return nullptr; + } return p_inst->get_language() == TScriptLanguage::get_singleton() ? static_cast<TScriptInstance *>(p_inst) : nullptr; } #else diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index f345dff333..07128770b7 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -2149,8 +2149,9 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { } output.append("#ifdef TOOLS_ENABLED\n"); - for (const InternalCall &internal_call : editor_custom_icalls) + for (const InternalCall &internal_call : editor_custom_icalls) { ADD_INTERNAL_CALL_REGISTRATION(internal_call); + } output.append("#endif // TOOLS_ENABLED\n"); for (const InternalCall &internal_call : method_icalls) { diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index a7269d7f87..4cd4772d2c 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -151,8 +151,9 @@ void gd_mono_debug_init() { .utf8(); } #else - if (da_args.length() == 0) + if (da_args.length() == 0) { return; // Exported games don't use the project settings to setup the debugger agent + } #endif // Debugging enabled @@ -226,8 +227,9 @@ void GDMono::add_mono_shared_libs_dir_to_path() { path_value += mono_reg_info.bin_dir; } #else - if (DirAccess::exists(bundled_bin_dir)) + if (DirAccess::exists(bundled_bin_dir)) { path_value += bundled_bin_dir; + } #endif // TOOLS_ENABLED #else @@ -1269,8 +1271,9 @@ GDMono::~GDMono() { print_verbose("Mono: Finalizing scripts domain..."); - if (mono_domain_get() != root_domain) + if (mono_domain_get() != root_domain) { mono_domain_set(root_domain, true); + } finalizing_scripts_domain = true; diff --git a/modules/mono/mono_gd/support/android_support.cpp b/modules/mono/mono_gd/support/android_support.cpp index eb8bbab948..4797d5dae1 100644 --- a/modules/mono/mono_gd/support/android_support.cpp +++ b/modules/mono/mono_gd/support/android_support.cpp @@ -134,8 +134,9 @@ String determine_app_native_lib_dir() { } String get_app_native_lib_dir() { - if (app_native_lib_dir_cache.is_empty()) + if (app_native_lib_dir_cache.is_empty()) { app_native_lib_dir_cache = determine_app_native_lib_dir(); + } return app_native_lib_dir_cache; } @@ -144,10 +145,11 @@ int gd_mono_convert_dl_flags(int flags) { int lflags = flags & MONO_DL_LOCAL ? 0 : RTLD_GLOBAL; - if (flags & MONO_DL_LAZY) + if (flags & MONO_DL_LAZY) { lflags |= RTLD_LAZY; - else + } else { lflags |= RTLD_NOW; + } return lflags; } @@ -164,8 +166,9 @@ void *godot_dl_handle = nullptr; void *try_dlopen(const String &p_so_path, int p_flags) { if (!FileAccess::exists(p_so_path)) { - if (OS::get_singleton()->is_stdout_verbose()) + if (OS::get_singleton()->is_stdout_verbose()) { OS::get_singleton()->print("Cannot find shared library: '%s'\n", p_so_path.utf8().get_data()); + } return nullptr; } @@ -174,13 +177,15 @@ void *try_dlopen(const String &p_so_path, int p_flags) { void *handle = dlopen(p_so_path.utf8().get_data(), lflags); if (!handle) { - if (OS::get_singleton()->is_stdout_verbose()) + if (OS::get_singleton()->is_stdout_verbose()) { OS::get_singleton()->print("Failed to open shared library: '%s'. Error: '%s'\n", p_so_path.utf8().get_data(), dlerror()); + } return nullptr; } - if (OS::get_singleton()->is_stdout_verbose()) + if (OS::get_singleton()->is_stdout_verbose()) { OS::get_singleton()->print("Successfully loaded shared library: '%s'\n", p_so_path.utf8().get_data()); + } return handle; } @@ -217,20 +222,23 @@ void *gd_mono_android_dlopen(const char *p_name, int p_flags, char **r_err, void void *gd_mono_android_dlsym(void *p_handle, const char *p_name, char **r_err, void *p_user_data) { void *sym_addr = dlsym(p_handle, p_name); - if (sym_addr) + if (sym_addr) { return sym_addr; + } if (p_handle == mono_dl_handle && godot_dl_handle) { // Looking up for '__Internal' P/Invoke. We want to search in both the Mono and Godot shared libraries. // This is needed to resolve the monodroid P/Invoke functions that are defined at the bottom of the file. sym_addr = dlsym(godot_dl_handle, p_name); - if (sym_addr) + if (sym_addr) { return sym_addr; + } } - if (r_err) + if (r_err) { *r_err = str_format_new("%s\n", dlerror()); + } return nullptr; } @@ -239,8 +247,9 @@ void *gd_mono_android_dlclose(void *p_handle, void *p_user_data) { dlclose(p_handle); // Not sure if this ever happens. Does Mono close the handle for the main module? - if (p_handle == mono_dl_handle) + if (p_handle == mono_dl_handle) { mono_dl_handle = nullptr; + } return nullptr; } @@ -292,13 +301,15 @@ MonoBoolean _gd_mono_init_cert_store() { ScopedLocalRef<jobject> certStoreLocal(env, env->CallStaticObjectMethod(keyStoreClass, getInstance, androidCAStoreString.get())); - if (jni_exception_check(env)) + if (jni_exception_check(env)) { return 0; + } env->CallVoidMethod(certStoreLocal, load, nullptr); - if (jni_exception_check(env)) + if (jni_exception_check(env)) { return 0; + } certStore = env->NewGlobalRef(certStoreLocal); @@ -309,8 +320,9 @@ MonoArray *_gd_mono_android_cert_store_lookup(MonoString *p_alias) { // The JNI code is the equivalent of: // // Certificate certificate = certStore.getCertificate(alias); - // if (certificate == null) + // if (certificate == null) { // return null; + // } // return certificate.getEncoded(); MonoError mono_error; @@ -340,8 +352,9 @@ MonoArray *_gd_mono_android_cert_store_lookup(MonoString *p_alias) { ScopedLocalRef<jobject> certificate(env, env->CallObjectMethod(certStore, getCertificate, js_alias.get())); - if (!certificate) + if (!certificate) { return nullptr; + } ScopedLocalRef<jbyteArray> encoded(env, (jbyteArray)env->CallObjectMethod(certificate, getEncoded)); jsize encodedLength = env->GetArrayLength(encoded); @@ -374,11 +387,13 @@ void initialize() { void cleanup() { // This is called after shutting down the Mono runtime - if (mono_dl_handle) + if (mono_dl_handle) { gd_mono_android_dlclose(mono_dl_handle, nullptr); + } - if (godot_dl_handle) + if (godot_dl_handle) { gd_mono_android_dlclose(godot_dl_handle, nullptr); + } JNIEnv *env = get_jni_env(); @@ -431,8 +446,9 @@ GD_PINVOKE_EXPORT mono_bool _monodroid_get_network_interface_up_state(const char // // NetworkInterface.getByName(p_ifname).isUp() - if (!r_is_up || !p_ifname || strlen(p_ifname) == 0) + if (!r_is_up || !p_ifname || strlen(p_ifname) == 0) { return 0; + } *r_is_up = 0; @@ -450,8 +466,9 @@ GD_PINVOKE_EXPORT mono_bool _monodroid_get_network_interface_up_state(const char ScopedLocalRef<jstring> js_ifname(env, env->NewStringUTF(p_ifname)); ScopedLocalRef<jobject> networkInterface(env, env->CallStaticObjectMethod(networkInterfaceClass, getByName, js_ifname.get())); - if (!networkInterface) + if (!networkInterface) { return 0; + } *r_is_up = (mono_bool)env->CallBooleanMethod(networkInterface, isUp); @@ -463,8 +480,9 @@ GD_PINVOKE_EXPORT mono_bool _monodroid_get_network_interface_supports_multicast( // // NetworkInterface.getByName(p_ifname).supportsMulticast() - if (!r_supports_multicast || !p_ifname || strlen(p_ifname) == 0) + if (!r_supports_multicast || !p_ifname || strlen(p_ifname) == 0) { return 0; + } *r_supports_multicast = 0; @@ -482,8 +500,9 @@ GD_PINVOKE_EXPORT mono_bool _monodroid_get_network_interface_supports_multicast( ScopedLocalRef<jstring> js_ifname(env, env->NewStringUTF(p_ifname)); ScopedLocalRef<jobject> networkInterface(env, env->CallStaticObjectMethod(networkInterfaceClass, getByName, js_ifname.get())); - if (!networkInterface) + if (!networkInterface) { return 0; + } *r_supports_multicast = (mono_bool)env->CallBooleanMethod(networkInterface, supportsMulticast); @@ -528,8 +547,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn ScopedLocalRef<jobject> connectivityManager(env, env->CallObjectMethod(applicationContext, getSystemService, connectivityServiceString.get())); - if (!connectivityManager) + if (!connectivityManager) { return; + } ScopedLocalRef<jclass> connectivityManagerClass(env, env->FindClass("android/net/ConnectivityManager")); ERR_FAIL_NULL(connectivityManagerClass); @@ -539,8 +559,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn ScopedLocalRef<jobject> activeNetwork(env, env->CallObjectMethod(connectivityManager, getActiveNetwork)); - if (!activeNetwork) + if (!activeNetwork) { return; + } jmethodID getLinkProperties = env->GetMethodID(connectivityManagerClass, "getLinkProperties", "(Landroid/net/Network;)Landroid/net/LinkProperties;"); @@ -548,8 +569,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn ScopedLocalRef<jobject> linkProperties(env, env->CallObjectMethod(connectivityManager, getLinkProperties, activeNetwork.get())); - if (!linkProperties) + if (!linkProperties) { return; + } ScopedLocalRef<jclass> linkPropertiesClass(env, env->FindClass("android/net/LinkProperties")); ERR_FAIL_NULL(linkPropertiesClass); @@ -559,8 +581,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn ScopedLocalRef<jobject> dnsServers(env, env->CallObjectMethod(linkProperties, getDnsServers)); - if (!dnsServers) + if (!dnsServers) { return; + } ScopedLocalRef<jclass> listClass(env, env->FindClass("java/util/List")); ERR_FAIL_NULL(listClass); @@ -570,11 +593,13 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn int dnsServersCount = env->CallIntMethod(dnsServers, listSize); - if (dnsServersCount > dns_servers_len) + if (dnsServersCount > dns_servers_len) { dnsServersCount = dns_servers_len; + } - if (dnsServersCount <= 0) + if (dnsServersCount <= 0) { return; + } jmethodID listGet = env->GetMethodID(listClass, "get", "(I)Ljava/lang/Object;"); ERR_FAIL_NULL(listGet); @@ -587,8 +612,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn for (int i = 0; i < dnsServersCount; i++) { ScopedLocalRef<jobject> dnsServer(env, env->CallObjectMethod(dnsServers, listGet, (jint)i)); - if (!dnsServer) + if (!dnsServer) { continue; + } ScopedLocalRef<jstring> hostAddress(env, (jstring)env->CallObjectMethod(dnsServer, getHostAddress)); const char *host_address = env->GetStringUTFChars(hostAddress, 0); @@ -603,8 +629,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn } GD_PINVOKE_EXPORT int32_t _monodroid_get_dns_servers(void **r_dns_servers_array) { - if (!r_dns_servers_array) + if (!r_dns_servers_array) { return -1; + } *r_dns_servers_array = nullptr; @@ -661,13 +688,15 @@ GD_PINVOKE_EXPORT const char *_monodroid_timezone_get_default_id() { ScopedLocalRef<jobject> defaultTimeZone(env, env->CallStaticObjectMethod(timeZoneClass, getDefault)); - if (!defaultTimeZone) + if (!defaultTimeZone) { return nullptr; + } ScopedLocalRef<jstring> defaultTimeZoneID(env, (jstring)env->CallObjectMethod(defaultTimeZone, getID)); - if (!defaultTimeZoneID) + if (!defaultTimeZoneID) { return nullptr; + } const char *default_time_zone_id = env->GetStringUTFChars(defaultTimeZoneID, 0); diff --git a/modules/mono/mono_gd/support/ios_support.mm b/modules/mono/mono_gd/support/ios_support.mm index e66b88db32..df97dfba49 100644 --- a/modules/mono/mono_gd/support/ios_support.mm +++ b/modules/mono/mono_gd/support/ios_support.mm @@ -94,8 +94,9 @@ GD_PINVOKE_EXPORT const char *xamarin_get_locale_country_code() { GD_PINVOKE_EXPORT void xamarin_log(const uint16_t *p_unicode_message) { int length = 0; const uint16_t *ptr = p_unicode_message; - while (*ptr++) + while (*ptr++) { length += sizeof(uint16_t); + } NSString *msg = [[NSString alloc] initWithBytes:p_unicode_message length:length encoding:NSUTF16LittleEndianStringEncoding]; os_log_info(OS_LOG_DEFAULT, "%{public}@", msg); diff --git a/modules/mono/utils/mono_reg_utils.cpp b/modules/mono/utils/mono_reg_utils.cpp index f388661207..8e37e6943c 100644 --- a/modules/mono/utils/mono_reg_utils.cpp +++ b/modules/mono/utils/mono_reg_utils.cpp @@ -60,8 +60,9 @@ REGSAM _get_bitness_sam() { LONG _RegOpenKey(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult) { LONG res = RegOpenKeyExW(hKey, lpSubKey, 0, KEY_READ, phkResult); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { res = RegOpenKeyExW(hKey, lpSubKey, 0, KEY_READ | _get_bitness_sam(), phkResult); + } return res; } @@ -92,31 +93,37 @@ LONG _find_mono_in_reg(const String &p_subkey, MonoRegInfo &r_info, bool p_old_r HKEY hKey; LONG res = _RegOpenKey(HKEY_LOCAL_MACHINE, (LPCWSTR)(p_subkey.utf16().get_data()), &hKey); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { goto cleanup; + } if (!p_old_reg) { res = _RegKeyQueryString(hKey, "Version", r_info.version); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { goto cleanup; + } } res = _RegKeyQueryString(hKey, "SdkInstallRoot", r_info.install_root_dir); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { goto cleanup; + } res = _RegKeyQueryString(hKey, "FrameworkAssemblyDirectory", r_info.assembly_dir); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { goto cleanup; + } res = _RegKeyQueryString(hKey, "MonoConfigDir", r_info.config_dir); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { goto cleanup; + } - if (r_info.install_root_dir.ends_with("\\")) + if (r_info.install_root_dir.ends_with("\\")) { r_info.bin_dir = r_info.install_root_dir + "bin"; - else + } else { r_info.bin_dir = r_info.install_root_dir + "\\bin"; + } cleanup: RegCloseKey(hKey); @@ -129,8 +136,9 @@ LONG _find_mono_in_reg_old(const String &p_subkey, MonoRegInfo &r_info) { HKEY hKey; LONG res = _RegOpenKey(HKEY_LOCAL_MACHINE, (LPCWSTR)(p_subkey.utf16().get_data()), &hKey); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { goto cleanup; + } res = _RegKeyQueryString(hKey, "DefaultCLR", default_clr); @@ -147,11 +155,13 @@ cleanup: MonoRegInfo find_mono() { MonoRegInfo info; - if (_find_mono_in_reg("Software\\Mono", info) == ERROR_SUCCESS) + if (_find_mono_in_reg("Software\\Mono", info) == ERROR_SUCCESS) { return info; + } - if (_find_mono_in_reg_old("Software\\Novell\\Mono", info) == ERROR_SUCCESS) + if (_find_mono_in_reg_old("Software\\Novell\\Mono", info) == ERROR_SUCCESS) { return info; + } return MonoRegInfo(); } @@ -212,13 +222,15 @@ String find_msbuild_tools_path() { HKEY hKey; LONG res = _RegOpenKey(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\14.0", &hKey); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { goto cleanup; + } res = _RegKeyQueryString(hKey, "MSBuildToolsPath", msbuild_tools_path); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { goto cleanup; + } cleanup: RegCloseKey(hKey); diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp index 89851fc4d3..15a0b28181 100644 --- a/modules/mono/utils/path_utils.cpp +++ b/modules/mono/utils/path_utils.cpp @@ -57,8 +57,9 @@ String cwd() { Char16String buffer; buffer.resize((int)expected_size); - if (::GetCurrentDirectoryW(expected_size, (wchar_t *)buffer.ptrw()) == 0) + if (::GetCurrentDirectoryW(expected_size, (wchar_t *)buffer.ptrw()) == 0) { return "."; + } String result; if (result.parse_utf16(buffer.ptr())) { @@ -95,8 +96,9 @@ String realpath(const String &p_path) { FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); - if (hFile == INVALID_HANDLE_VALUE) + if (hFile == INVALID_HANDLE_VALUE) { return p_path; + } const DWORD expected_size = ::GetFinalPathNameByHandleW(hFile, nullptr, 0, FILE_NAME_NORMALIZED); @@ -177,8 +179,9 @@ String relative_to_impl(const String &p_path, const String &p_relative_to) { #ifdef WINDOWS_ENABLED String get_drive_letter(const String &p_norm_path) { int idx = p_norm_path.find(":/"); - if (idx != -1 && idx < p_norm_path.find("/")) + if (idx != -1 && idx < p_norm_path.find("/")) { return p_norm_path.substr(0, idx + 1); + } return String(); } #endif diff --git a/modules/navigation/navigation_mesh_editor_plugin.cpp b/modules/navigation/navigation_mesh_editor_plugin.cpp index 04eca5fb0b..511490ba07 100644 --- a/modules/navigation/navigation_mesh_editor_plugin.cpp +++ b/modules/navigation/navigation_mesh_editor_plugin.cpp @@ -46,10 +46,12 @@ void NavigationMeshEditor::_node_removed(Node *p_node) { } } -void NavigationMeshEditor::_notification(int p_option) { - if (p_option == NOTIFICATION_ENTER_TREE) { - button_bake->set_icon(get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); - button_reset->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); +void NavigationMeshEditor::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + button_bake->set_icon(get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); + button_reset->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); + } break; } } diff --git a/modules/navigation/navigation_mesh_editor_plugin.h b/modules/navigation/navigation_mesh_editor_plugin.h index 0e4175eca0..d581b453b3 100644 --- a/modules/navigation/navigation_mesh_editor_plugin.h +++ b/modules/navigation/navigation_mesh_editor_plugin.h @@ -57,7 +57,7 @@ class NavigationMeshEditor : public Control { protected: void _node_removed(Node *p_node); static void _bind_methods(); - void _notification(int p_option); + void _notification(int p_what); public: void edit(NavigationRegion3D *p_nav_region); diff --git a/modules/ogg/ogg_packet_sequence.cpp b/modules/ogg/ogg_packet_sequence.cpp index 65058f088e..da52ecfdd5 100644 --- a/modules/ogg/ogg_packet_sequence.cpp +++ b/modules/ogg/ogg_packet_sequence.cpp @@ -162,6 +162,7 @@ bool OGGPacketSequencePlayback::next_ogg_packet(ogg_packet **p_packet) const { } uint32_t OGGPacketSequencePlayback::seek_page_internal(int64_t granule, uint32_t after_page_inclusive, uint32_t before_page_inclusive) { + // FIXME: This function needs better corner case handling. if (before_page_inclusive == after_page_inclusive) { return before_page_inclusive; } @@ -169,7 +170,8 @@ uint32_t OGGPacketSequencePlayback::seek_page_internal(int64_t granule, uint32_t // Complicating the bisection search algorithm, the middle page might not have a packet that ends on it, // which means it might not have a correct granule position. Find a nearby page that does have a packet ending on it. uint32_t bisection_page = -1; - for (uint32_t test_page = actual_middle_page; test_page <= before_page_inclusive; test_page++) { + // Don't include before_page_inclusive because that always succeeds and will cause infinite recursion later. + for (uint32_t test_page = actual_middle_page; test_page < before_page_inclusive; test_page++) { if (ogg_packet_sequence->page_data[test_page].size() > 0) { bisection_page = test_page; break; diff --git a/modules/visual_script/editor/visual_script_editor.cpp b/modules/visual_script/editor/visual_script_editor.cpp index 9433f3dba2..e2432a1282 100644 --- a/modules/visual_script/editor/visual_script_editor.cpp +++ b/modules/visual_script/editor/visual_script_editor.cpp @@ -1081,6 +1081,7 @@ void VisualScriptEditor::_update_members() { Control::get_theme_icon(SNAME("Basis"), SNAME("EditorIcons")), Control::get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), Control::get_theme_icon(SNAME("Color"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("StringName"), SNAME("EditorIcons")), Control::get_theme_icon(SNAME("NodePath"), SNAME("EditorIcons")), Control::get_theme_icon(SNAME("RID"), SNAME("EditorIcons")), Control::get_theme_icon(SNAME("MiniObject"), SNAME("EditorIcons")), @@ -1090,7 +1091,9 @@ void VisualScriptEditor::_update_members() { Control::get_theme_icon(SNAME("Array"), SNAME("EditorIcons")), Control::get_theme_icon(SNAME("PackedByteArray"), SNAME("EditorIcons")), Control::get_theme_icon(SNAME("PackedInt32Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedInt64Array"), SNAME("EditorIcons")), Control::get_theme_icon(SNAME("PackedFloat32Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedFloat64Array"), SNAME("EditorIcons")), Control::get_theme_icon(SNAME("PackedStringArray"), SNAME("EditorIcons")), Control::get_theme_icon(SNAME("PackedVector2Array"), SNAME("EditorIcons")), Control::get_theme_icon(SNAME("PackedVector3Array"), SNAME("EditorIcons")), @@ -3978,6 +3981,7 @@ void VisualScriptEditor::_notification(int p_what) { _update_graph(); } } break; + case NOTIFICATION_VISIBILITY_CHANGED: { update_toggle_scripts_button(); members_section->set_visible(is_visible_in_tree()); diff --git a/modules/visual_script/editor/visual_script_property_selector.cpp b/modules/visual_script/editor/visual_script_property_selector.cpp index 563c12eec4..31406a2a6f 100644 --- a/modules/visual_script/editor/visual_script_property_selector.cpp +++ b/modules/visual_script/editor/visual_script_property_selector.cpp @@ -118,9 +118,11 @@ void VisualScriptPropertySelector::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { _update_icons(); } break; + case NOTIFICATION_ENTER_TREE: { connect("confirmed", callable_mp(this, &VisualScriptPropertySelector::_confirmed)); } break; + case NOTIFICATION_PROCESS: { // Update background search. if (search_runner.is_valid()) { diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 88445f2f98..9549137aef 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -930,8 +930,6 @@ void VisualScript::get_script_property_list(List<PropertyInfo> *p_list) const { get_variable_list(&vars); for (const StringName &E : vars) { - //if (!variables[E]._export) - // continue; PropertyInfo pi = variables[E].info; pi.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE; p_list->push_back(pi); diff --git a/modules/webrtc/webrtc_data_channel_js.cpp b/modules/webrtc/webrtc_data_channel_js.cpp index 4c41a4c7ee..0fb074b0c2 100644 --- a/modules/webrtc/webrtc_data_channel_js.cpp +++ b/modules/webrtc/webrtc_data_channel_js.cpp @@ -31,6 +31,7 @@ #ifdef JAVASCRIPT_ENABLED #include "webrtc_data_channel_js.h" + #include "emscripten.h" extern "C" { @@ -104,8 +105,9 @@ int WebRTCDataChannelJS::get_available_packet_count() const { Error WebRTCDataChannelJS::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { ERR_FAIL_COND_V(get_ready_state() != STATE_OPEN, ERR_UNCONFIGURED); - if (queue_count == 0) + if (queue_count == 0) { return ERR_UNAVAILABLE; + } uint32_t to_read = 0; uint32_t left = 0; diff --git a/modules/websocket/emws_client.cpp b/modules/websocket/emws_client.cpp index 2d029dfbbc..e051a3b564 100644 --- a/modules/websocket/emws_client.cpp +++ b/modules/websocket/emws_client.cpp @@ -31,6 +31,7 @@ #ifdef JAVASCRIPT_ENABLED #include "emws_client.h" + #include "core/config/project_settings.h" #include "core/io/ip.h" #include "emscripten.h" @@ -45,8 +46,9 @@ void EMWSClient::_esws_on_message(void *obj, const uint8_t *p_data, int p_data_s EMWSClient *client = static_cast<EMWSClient *>(obj); Error err = static_cast<EMWSPeer *>(*client->get_peer(1))->read_msg(p_data, p_data_size, p_is_string == 1); - if (err == OK) + if (err == OK) { client->_on_peer_packet(); + } } void EMWSClient::_esws_on_error(void *obj) { @@ -71,8 +73,9 @@ Error EMWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port, String proto_string; for (int i = 0; i < p_protocols.size(); i++) { - if (i != 0) + if (i != 0) { proto_string += ","; + } proto_string += p_protocols[i]; } @@ -109,8 +112,9 @@ Ref<WebSocketPeer> EMWSClient::get_peer(int p_peer_id) const { MultiplayerPeer::ConnectionStatus EMWSClient::get_connection_status() const { if (_peer->is_connected_to_host()) { - if (_is_connecting) + if (_is_connecting) { return CONNECTION_CONNECTING; + } return CONNECTION_CONNECTED; } diff --git a/modules/websocket/emws_peer.cpp b/modules/websocket/emws_peer.cpp index 77a96c8e4f..86169f88e9 100644 --- a/modules/websocket/emws_peer.cpp +++ b/modules/websocket/emws_peer.cpp @@ -31,6 +31,7 @@ #ifdef JAVASCRIPT_ENABLED #include "emws_peer.h" + #include "core/io/ip.h" void EMWSPeer::set_sock(int p_sock, unsigned int p_in_buf_size, unsigned int p_in_pkt_size, unsigned int p_out_buf_size) { @@ -66,8 +67,9 @@ Error EMWSPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) { } Error EMWSPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { - if (_in_buffer.packets_left() == 0) + if (_in_buffer.packets_left() == 0) { return ERR_UNAVAILABLE; + } int read = 0; Error err = _in_buffer.read_packet(_packet_buffer.ptrw(), _packet_buffer.size(), &_is_string, read); @@ -109,7 +111,7 @@ void EMWSPeer::close(int p_code, String p_reason) { IPAddress EMWSPeer::get_connected_host() const { ERR_FAIL_V_MSG(IPAddress(), "Not supported in HTML5 export."); -}; +} uint16_t EMWSPeer::get_connected_port() const { ERR_FAIL_V_MSG(0, "Not supported in HTML5 export."); diff --git a/modules/webxr/webxr_interface_js.cpp b/modules/webxr/webxr_interface_js.cpp index 86b857f72c..06b0e31801 100644 --- a/modules/webxr/webxr_interface_js.cpp +++ b/modules/webxr/webxr_interface_js.cpp @@ -31,11 +31,13 @@ #ifdef JAVASCRIPT_ENABLED #include "webxr_interface_js.h" + #include "core/input/input.h" #include "core/os/os.h" #include "emscripten.h" #include "godot_webxr.h" #include "servers/rendering/renderer_compositor.h" + #include <stdlib.h> void _emwebxr_on_session_supported(char *p_session_mode, int p_supported) { @@ -481,7 +483,6 @@ void WebXRInterfaceJS::_update_tracker(int p_controller_id) { sprintf(name, "axis_%i", i); float value = *((float *)axes + (i + 1)); - ; tracker->set_input(name, value); } free(axes); diff --git a/platform/android/android_input_handler.cpp b/platform/android/android_input_handler.cpp index 246ec6b198..10f23b320b 100644 --- a/platform/android/android_input_handler.cpp +++ b/platform/android/android_input_handler.cpp @@ -165,8 +165,9 @@ void AndroidInputHandler::process_touch(int p_event, int p_pointer, const Vector ERR_CONTINUE(idx == -1); - if (touch[i].pos == p_points[idx].pos) - continue; //no move unncesearily + if (touch[i].pos == p_points[idx].pos) { + continue; // Don't move unnecessarily. + } Ref<InputEventScreenDrag> ev; ev.instantiate(); diff --git a/platform/android/api/jni_singleton.h b/platform/android/api/jni_singleton.h index d8503b6caf..57d08ac83e 100644 --- a/platform/android/api/jni_singleton.h +++ b/platform/android/api/jni_singleton.h @@ -31,10 +31,10 @@ #ifndef JNI_SINGLETON_H #define JNI_SINGLETON_H -#include <core/config/engine.h> -#include <core/variant/variant.h> +#include "core/config/engine.h" +#include "core/variant/variant.h" #ifdef ANDROID_ENABLED -#include <platform/android/jni_utils.h> +#include "platform/android/jni_utils.h" #endif class JNISingleton : public Object { @@ -93,8 +93,9 @@ public: for (int i = 0; i < p_argcount; i++) { jvalret vr = _variant_to_jvalue(env, E->get().argtypes[i], p_args[i]); v[i] = vr.val; - if (vr.obj) + if (vr.obj) { to_erase.push_back(vr.obj); + } } Variant ret; @@ -197,18 +198,19 @@ public: } void add_signal(const StringName &p_name, const Vector<Variant::Type> &p_args) { - if (p_args.size() == 0) + if (p_args.size() == 0) { ADD_SIGNAL(MethodInfo(p_name)); - else if (p_args.size() == 1) + } else if (p_args.size() == 1) { ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"))); - else if (p_args.size() == 2) + } else if (p_args.size() == 2) { ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"), PropertyInfo(p_args[1], "arg2"))); - else if (p_args.size() == 3) + } else if (p_args.size() == 3) { ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"), PropertyInfo(p_args[1], "arg2"), PropertyInfo(p_args[2], "arg3"))); - else if (p_args.size() == 4) + } else if (p_args.size() == 4) { ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"), PropertyInfo(p_args[1], "arg2"), PropertyInfo(p_args[2], "arg3"), PropertyInfo(p_args[3], "arg4"))); - else if (p_args.size() == 5) + } else if (p_args.size() == 5) { ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"), PropertyInfo(p_args[1], "arg2"), PropertyInfo(p_args[2], "arg3"), PropertyInfo(p_args[3], "arg4"), PropertyInfo(p_args[4], "arg5"))); + } } #endif diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp index cd478bb90f..8495d2cc18 100644 --- a/platform/android/audio_driver_opensl.cpp +++ b/platform/android/audio_driver_opensl.cpp @@ -56,8 +56,9 @@ void AudioDriverOpenSL::_buffer_callback( } } - if (mix) + if (mix) { mutex.unlock(); + } const int32_t *src_buff = mixdown_buffer; @@ -312,13 +313,15 @@ AudioDriver::SpeakerMode AudioDriverOpenSL::get_speaker_mode() const { } void AudioDriverOpenSL::lock() { - if (active) + if (active) { mutex.lock(); + } } void AudioDriverOpenSL::unlock() { - if (active) + if (active) { mutex.unlock(); + } } void AudioDriverOpenSL::finish() { diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index 5461a3aefa..7fb4f54fca 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "dir_access_jandroid.h" + #include "core/string/print_string.h" #include "file_access_android.h" #include "string_android.h" @@ -51,8 +52,9 @@ Error DirAccessJAndroid::list_dir_begin() { jstring js = env->NewStringUTF(current_dir.utf8().get_data()); int res = env->CallIntMethod(io, _dir_open, js); - if (res <= 0) + if (res <= 0) { return ERR_CANT_OPEN; + } id = res; @@ -64,8 +66,9 @@ String DirAccessJAndroid::get_next() { JNIEnv *env = get_jni_env(); jstring str = (jstring)env->CallObjectMethod(io, _dir_next, id); - if (!str) + if (!str) { return ""; + } String ret = jstring_to_string((jstring)str, env); env->DeleteLocalRef((jobject)str); @@ -83,8 +86,9 @@ bool DirAccessJAndroid::current_is_hidden() const { } void DirAccessJAndroid::list_dir_end() { - if (id == 0) + if (id == 0) { return; + } JNIEnv *env = get_jni_env(); env->CallVoidMethod(io, _dir_close, id); @@ -102,22 +106,25 @@ String DirAccessJAndroid::get_drive(int p_drive) { Error DirAccessJAndroid::change_dir(String p_dir) { JNIEnv *env = get_jni_env(); - if (p_dir.is_empty() || p_dir == "." || (p_dir == ".." && current_dir.is_empty())) + if (p_dir.is_empty() || p_dir == "." || (p_dir == ".." && current_dir.is_empty())) { return OK; + } String new_dir; - if (p_dir != "res://" && p_dir.length() > 1 && p_dir.ends_with("/")) + if (p_dir != "res://" && p_dir.length() > 1 && p_dir.ends_with("/")) { p_dir = p_dir.substr(0, p_dir.length() - 1); + } - if (p_dir.begins_with("/")) + if (p_dir.begins_with("/")) { new_dir = p_dir.substr(1, p_dir.length()); - else if (p_dir.begins_with("res://")) + } else if (p_dir.begins_with("res://")) { new_dir = p_dir.substr(6, p_dir.length()); - else if (current_dir.is_empty()) + } else if (current_dir.is_empty()) { new_dir = p_dir; - else + } else { new_dir = current_dir.plus_file(p_dir); + } //test if newdir exists new_dir = new_dir.simplify_path(); @@ -125,8 +132,9 @@ Error DirAccessJAndroid::change_dir(String p_dir) { jstring js = env->NewStringUTF(new_dir.utf8().get_data()); int res = env->CallIntMethod(io, _dir_open, js); env->DeleteLocalRef(js); - if (res <= 0) + if (res <= 0) { return ERR_INVALID_PARAMETER; + } env->CallVoidMethod(io, _dir_close, res); @@ -141,10 +149,11 @@ String DirAccessJAndroid::get_current_dir(bool p_include_drive) { bool DirAccessJAndroid::file_exists(String p_file) { String sd; - if (current_dir.is_empty()) + if (current_dir.is_empty()) { sd = p_file; - else + } else { sd = current_dir.plus_file(p_file); + } FileAccessAndroid *f = memnew(FileAccessAndroid); bool exists = f->file_exists(sd); @@ -158,27 +167,30 @@ bool DirAccessJAndroid::dir_exists(String p_dir) { String sd; - if (current_dir.is_empty()) + if (current_dir.is_empty()) { sd = p_dir; - else { - if (p_dir.is_relative_path()) + } else { + if (p_dir.is_relative_path()) { sd = current_dir.plus_file(p_dir); - else + } else { sd = fix_path(p_dir); + } } String path = sd.simplify_path(); - if (path.begins_with("/")) + if (path.begins_with("/")) { path = path.substr(1, path.length()); - else if (path.begins_with("res://")) + } else if (path.begins_with("res://")) { path = path.substr(6, path.length()); + } jstring js = env->NewStringUTF(path.utf8().get_data()); int res = env->CallIntMethod(io, _dir_open, js); env->DeleteLocalRef(js); - if (res <= 0) + if (res <= 0) { return false; + } env->CallVoidMethod(io, _dir_close, res); diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp index 26bdcb9520..c84a919b6b 100644 --- a/platform/android/file_access_android.cpp +++ b/platform/android/file_access_android.cpp @@ -29,30 +29,28 @@ /*************************************************************************/ #include "file_access_android.h" + #include "core/string/print_string.h" AAssetManager *FileAccessAndroid::asset_manager = nullptr; -/*void FileAccessAndroid::make_default() { - create_func=create_android; -}*/ - FileAccess *FileAccessAndroid::create_android() { return memnew(FileAccessAndroid); } Error FileAccessAndroid::_open(const String &p_path, int p_mode_flags) { String path = fix_path(p_path).simplify_path(); - if (path.begins_with("/")) + if (path.begins_with("/")) { path = path.substr(1, path.length()); - else if (path.begins_with("res://")) + } else if (path.begins_with("res://")) { path = path.substr(6, path.length()); + } ERR_FAIL_COND_V(p_mode_flags & FileAccess::WRITE, ERR_UNAVAILABLE); //can't write on android.. a = AAssetManager_open(asset_manager, path.utf8().get_data(), AASSET_MODE_STREAMING); - if (!a) + if (!a) { return ERR_CANT_OPEN; - //ERR_FAIL_COND_V(!a,ERR_FILE_NOT_FOUND); + } len = AAsset_getLength(a); pos = 0; eof = false; @@ -61,8 +59,9 @@ Error FileAccessAndroid::_open(const String &p_path, int p_mode_flags) { } void FileAccessAndroid::close() { - if (!a) + if (!a) { return; + } AAsset_close(a); a = nullptr; } @@ -146,15 +145,17 @@ void FileAccessAndroid::store_8(uint8_t p_dest) { bool FileAccessAndroid::file_exists(const String &p_path) { String path = fix_path(p_path).simplify_path(); - if (path.begins_with("/")) + if (path.begins_with("/")) { path = path.substr(1, path.length()); - else if (path.begins_with("res://")) + } else if (path.begins_with("res://")) { path = path.substr(6, path.length()); + } AAsset *at = AAssetManager_open(asset_manager, path.utf8().get_data(), AASSET_MODE_STREAMING); - if (!at) + if (!at) { return false; + } AAsset_close(at); return true; diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java b/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java index 8fc16ab7ba..4525c5c212 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java +++ b/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java @@ -147,8 +147,9 @@ public class GLUtils { Log.i(TAG, String.format(" %s: %d\n", name, value[0])); } else { // Log.w(TAG, String.format(" %s: failed\n", name)); - while (egl.eglGetError() != EGL10.EGL_SUCCESS) - ; + while (egl.eglGetError() != EGL10.EGL_SUCCESS) { + // Continue. + } } } } diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp index f823e2c27f..7c788b4dc4 100644 --- a/platform/android/java_class_wrapper.cpp +++ b/platform/android/java_class_wrapper.cpp @@ -29,13 +29,15 @@ /*************************************************************************/ #include "api/java_class_wrapper.h" + #include "string_android.h" #include "thread_jandroid.h" bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error, Variant &ret) { Map<StringName, List<MethodInfo>>::Element *M = methods.find(p_method); - if (!M) + if (!M) { return false; + } JNIEnv *env = get_jni_env(); ERR_FAIL_COND_V(env == nullptr, false); @@ -68,8 +70,9 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, //bug? } break; case ARG_TYPE_BOOLEAN: { - if (p_args[i]->get_type() != Variant::BOOL) + if (p_args[i]->get_type() != Variant::BOOL) { arg_expected = Variant::BOOL; + } } break; case ARG_NUMBER_CLASS_BIT | ARG_TYPE_BYTE: case ARG_NUMBER_CLASS_BIT | ARG_TYPE_CHAR: @@ -81,27 +84,27 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, case ARG_TYPE_SHORT: case ARG_TYPE_INT: case ARG_TYPE_LONG: { - if (!p_args[i]->is_num()) + if (!p_args[i]->is_num()) { arg_expected = Variant::INT; - + } } break; case ARG_NUMBER_CLASS_BIT | ARG_TYPE_FLOAT: case ARG_NUMBER_CLASS_BIT | ARG_TYPE_DOUBLE: case ARG_TYPE_FLOAT: case ARG_TYPE_DOUBLE: { - if (!p_args[i]->is_num()) + if (!p_args[i]->is_num()) { arg_expected = Variant::FLOAT; - + } } break; case ARG_TYPE_STRING: { - if (p_args[i]->get_type() != Variant::STRING) + if (p_args[i]->get_type() != Variant::STRING) { arg_expected = Variant::STRING; - + } } break; case ARG_TYPE_CLASS: { - if (p_args[i]->get_type() != Variant::OBJECT) + if (p_args[i]->get_type() != Variant::OBJECT) { arg_expected = Variant::OBJECT; - else { + } else { Ref<RefCounted> ref = *p_args[i]; if (!ref.is_null()) { if (Object::cast_to<JavaObject>(ref.ptr())) { @@ -118,12 +121,11 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, } } } - } break; default: { - if (p_args[i]->get_type() != Variant::ARRAY) + if (p_args[i]->get_type() != Variant::ARRAY) { arg_expected = Variant::ARRAY; - + } } break; } @@ -135,15 +137,17 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, break; } } - if (!valid) + if (!valid) { continue; + } method = &E; break; } - if (!method) + if (!method) { return true; //no version convinces + } r_error.error = Callable::CallError::CALL_OK; @@ -780,9 +784,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { bool val = env->CallBooleanMethod(o, JavaClassWrapper::singleton->Boolean_booleanValue); ret.push_back(val); } @@ -801,9 +805,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { int val = env->CallByteMethod(o, JavaClassWrapper::singleton->Byte_byteValue); ret.push_back(val); } @@ -821,9 +825,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { int val = env->CallCharMethod(o, JavaClassWrapper::singleton->Character_characterValue); ret.push_back(val); } @@ -841,9 +845,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { int val = env->CallShortMethod(o, JavaClassWrapper::singleton->Short_shortValue); ret.push_back(val); } @@ -861,9 +865,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { int val = env->CallIntMethod(o, JavaClassWrapper::singleton->Integer_integerValue); ret.push_back(val); } @@ -881,9 +885,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { int64_t val = env->CallLongMethod(o, JavaClassWrapper::singleton->Long_longValue); ret.push_back(val); } @@ -901,9 +905,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { float val = env->CallFloatMethod(o, JavaClassWrapper::singleton->Float_floatValue); ret.push_back(val); } @@ -921,9 +925,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { double val = env->CallDoubleMethod(o, JavaClassWrapper::singleton->Double_doubleValue); ret.push_back(val); } @@ -942,9 +946,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { String val = jstring_to_string((jstring)o, env); ret.push_back(val); } @@ -962,8 +966,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va } Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { - if (class_cache.has(p_class)) + if (class_cache.has(p_class)) { return class_cache[p_class]; + } JNIEnv *env = get_jni_env(); ERR_FAIL_COND_V(env == nullptr, Ref<JavaClass>()); @@ -971,10 +976,6 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { jclass bclass = env->FindClass(p_class.utf8().get_data()); ERR_FAIL_COND_V(!bclass, Ref<JavaClass>()); - //jmethodID getDeclaredMethods = env->GetMethodID(bclass,"getDeclaredMethods", "()[Ljava/lang/reflect/Method;"); - - //ERR_FAIL_COND_V(!getDeclaredMethods,Ref<JavaClass>()); - jobjectArray methods = (jobjectArray)env->CallObjectMethod(bclass, getDeclaredMethods); ERR_FAIL_COND_V(!methods, Ref<JavaClass>()); @@ -1057,8 +1058,9 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { float new_likeliness = 0; float existing_likeliness = 0; - if (E->get().param_types.size() != mi.param_types.size()) + if (E->get().param_types.size() != mi.param_types.size()) { continue; + } bool valid = true; for (int j = 0; j < E->get().param_types.size(); j++) { Variant::Type _new; @@ -1075,8 +1077,9 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { existing_likeliness = existing_l; } - if (!valid) + if (!valid) { continue; + } if (new_likeliness > existing_likeliness) { java_class->methods[str_method].erase(E); @@ -1087,10 +1090,11 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { } if (!discard) { - if (mi._static) + if (mi._static) { mi.method = env->GetStaticMethodID(bclass, str_method.utf8().get_data(), signature.utf8().get_data()); - else + } else { mi.method = env->GetMethodID(bclass, str_method.utf8().get_data(), signature.utf8().get_data()); + } ERR_CONTINUE(!mi.method); @@ -1100,7 +1104,7 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { env->DeleteLocalRef(obj); env->DeleteLocalRef(param_types); env->DeleteLocalRef(return_type); - }; + } env->DeleteLocalRef(methods); diff --git a/platform/android/java_godot_io_wrapper.cpp b/platform/android/java_godot_io_wrapper.cpp index ff0bcf0716..d6e3ad90b1 100644 --- a/platform/android/java_godot_io_wrapper.cpp +++ b/platform/android/java_godot_io_wrapper.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "java_godot_io_wrapper.h" + #include "core/error/error_list.h" // JNIEnv is only valid within the thread it belongs to, in a multi threading environment diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index e7ab0ef7ed..dd4fa9de7b 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -200,8 +200,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *en } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jclass clazz) { - if (step.get() == 0) + if (step.get() == 0) { return; + } if (DisplayServerAndroid *dsa = Object::cast_to<DisplayServerAndroid>(DisplayServer::get_singleton())) { dsa->send_window_event(DisplayServer::WINDOW_EVENT_GO_BACK_REQUEST); @@ -209,8 +210,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jcl } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jclass clazz) { - if (step.get() == -1) + if (step.get() == -1) { return; + } if (step.get() == 0) { // Since Godot is initialized on the UI thread, main_thread_id was set to that thread's id, @@ -243,8 +245,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jcl } void touch_preprocessing(JNIEnv *env, jclass clazz, jint input_device, jint ev, jint pointer, jint pointer_count, jfloatArray positions, jint buttons_mask, jfloat vertical_factor, jfloat horizontal_factor) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } Vector<AndroidInputHandler::TouchPos> points; for (int i = 0; i < pointer_count; i++) { @@ -279,32 +282,36 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_touch__IIII_3FIFF(JNI // Called on the UI thread JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_hover(JNIEnv *env, jclass clazz, jint p_type, jfloat p_x, jfloat p_y) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } input_handler->process_hover(p_type, Point2(p_x, p_y)); } // Called on the UI thread JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_doubleTap(JNIEnv *env, jclass clazz, jint p_button_mask, jint p_x, jint p_y) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } input_handler->process_double_tap(p_button_mask, Point2(p_x, p_y)); } // Called on the UI thread JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_scroll(JNIEnv *env, jclass clazz, jint p_x, jint p_y) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } input_handler->process_scroll(Point2(p_x, p_y)); } // Called on the UI thread JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv *env, jclass clazz, jint p_device, jint p_button, jboolean p_pressed) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } AndroidInputHandler::JoypadEvent jevent; jevent.device = p_device; @@ -369,8 +376,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyconnectionchanged( // Called on the UI thread JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jclass clazz, jint p_keycode, jint p_scancode, jint p_unicode_char, jboolean p_pressed) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } input_handler->process_key_event(p_keycode, p_scancode, p_unicode_char, p_pressed); } @@ -392,15 +400,17 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gyroscope(JNIEnv *env } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv *env, jclass clazz) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } os_android->main_loop_focusin(); } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv *env, jclass clazz) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } os_android->main_loop_focusout(); } @@ -426,13 +436,14 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *en for (int i = 0; i < count; i++) { jobject obj = env->GetObjectArrayElement(params, i); Variant v; - if (obj) + if (obj) { v = _jobject_to_variant(env, obj); + } memnew_placement(&vlist[i], Variant); vlist[i] = v; vptr[i] = &vlist[i]; env->DeleteLocalRef(obj); - }; + } Callable::CallError err; obj->call(str_method, (const Variant **)vptr, count, err); @@ -455,10 +466,11 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * for (int i = 0; i < MIN(count, VARIANT_ARG_MAX); i++) { jobject obj = env->GetObjectArrayElement(params, i); - if (obj) + if (obj) { args[i] = _jobject_to_variant(env, obj); + } env->DeleteLocalRef(obj); - }; + } static_assert(VARIANT_ARG_MAX == 8, "This code needs to be updated if VARIANT_ARG_MAX != 8"); obj->call_deferred(str_method, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); @@ -478,8 +490,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_requestPermissionResu } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererResumed(JNIEnv *env, jclass clazz) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } if (os_android->get_main_loop()) { os_android->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_RESUMED); @@ -487,8 +500,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererResumed(JNI } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererPaused(JNIEnv *env, jclass clazz) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } if (os_android->get_main_loop()) { os_android->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_PAUSED); diff --git a/platform/android/java_godot_wrapper.cpp b/platform/android/java_godot_wrapper.cpp index 5beec6b611..754267c834 100644 --- a/platform/android/java_godot_wrapper.cpp +++ b/platform/android/java_godot_wrapper.cpp @@ -92,8 +92,9 @@ jobject GodotJavaWrapper::get_activity() { jobject GodotJavaWrapper::get_member_object(const char *p_name, const char *p_class, JNIEnv *p_env) { if (godot_class) { - if (p_env == nullptr) + if (p_env == nullptr) { p_env = get_jni_env(); + } ERR_FAIL_COND_V(p_env == nullptr, nullptr); @@ -129,8 +130,9 @@ GodotJavaViewWrapper *GodotJavaWrapper::get_godot_view() { void GodotJavaWrapper::on_video_init(JNIEnv *p_env) { if (_on_video_init) { - if (p_env == nullptr) + if (p_env == nullptr) { p_env = get_jni_env(); + } ERR_FAIL_COND(p_env == nullptr); p_env->CallVoidMethod(godot_instance, _on_video_init); @@ -158,8 +160,9 @@ void GodotJavaWrapper::on_godot_main_loop_started(JNIEnv *p_env) { void GodotJavaWrapper::restart(JNIEnv *p_env) { if (_restart) { - if (p_env == nullptr) + if (p_env == nullptr) { p_env = get_jni_env(); + } ERR_FAIL_COND(p_env == nullptr); p_env->CallVoidMethod(godot_instance, _restart); @@ -168,8 +171,9 @@ void GodotJavaWrapper::restart(JNIEnv *p_env) { void GodotJavaWrapper::force_quit(JNIEnv *p_env) { if (_finish) { - if (p_env == nullptr) + if (p_env == nullptr) { p_env = get_jni_env(); + } ERR_FAIL_COND(p_env == nullptr); p_env->CallVoidMethod(godot_instance, _finish); diff --git a/platform/android/jni_utils.cpp b/platform/android/jni_utils.cpp index 7e81565d9d..e2573d10f8 100644 --- a/platform/android/jni_utils.cpp +++ b/platform/android/jni_utils.cpp @@ -46,7 +46,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a env->DeleteLocalRef(bclass); } else { v.val.z = *p_arg; - }; + } } break; case Variant::INT: { if (force_jobject) { @@ -61,7 +61,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a } else { v.val.i = *p_arg; - }; + } } break; case Variant::FLOAT: { if (force_jobject) { @@ -76,7 +76,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a } else { v.val.f = *p_arg; - }; + } } break; case Variant::STRING: { String s = *p_arg; @@ -111,7 +111,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a jstring str = env->NewStringUTF(String(keys[j]).utf8().get_data()); env->SetObjectArrayElement(jkeys, j, str); env->DeleteLocalRef(str); - }; + } jmethodID set_keys = env->GetMethodID(dclass, "set_keys", "([Ljava/lang/String;)V"); jvalue val; @@ -128,7 +128,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a if (v.obj) { env->DeleteLocalRef(v.obj); } - }; + } jmethodID set_values = env->GetMethodID(dclass, "set_values", "([Ljava/lang/Object;)V"); val.l = jvalues; @@ -205,7 +205,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { if (name == "java.lang.String") { return jstring_to_string((jstring)obj, env); - }; + } if (name == "[Ljava.lang.String;") { jobjectArray arr = (jobjectArray)obj; @@ -219,20 +219,20 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { } return sarr; - }; + } if (name == "java.lang.Boolean") { jmethodID boolValue = env->GetMethodID(c, "booleanValue", "()Z"); bool ret = env->CallBooleanMethod(obj, boolValue); return ret; - }; + } if (name == "java.lang.Integer" || name == "java.lang.Long") { jclass nclass = env->FindClass("java/lang/Number"); jmethodID longValue = env->GetMethodID(nclass, "longValue", "()J"); jlong ret = env->CallLongMethod(obj, longValue); return ret; - }; + } if (name == "[I") { jintArray arr = (jintArray)obj; @@ -243,7 +243,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { int *w = sarr.ptrw(); env->GetIntArrayRegion(arr, 0, fCount, w); return sarr; - }; + } if (name == "[B") { jbyteArray arr = (jbyteArray)obj; @@ -254,14 +254,14 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { uint8_t *w = sarr.ptrw(); env->GetByteArrayRegion(arr, 0, fCount, reinterpret_cast<signed char *>(w)); return sarr; - }; + } if (name == "java.lang.Float" || name == "java.lang.Double") { jclass nclass = env->FindClass("java/lang/Number"); jmethodID doubleValue = env->GetMethodID(nclass, "doubleValue", "()D"); double ret = env->CallDoubleMethod(obj, doubleValue); return ret; - }; + } if (name == "[D") { jdoubleArray arr = (jdoubleArray)obj; @@ -275,9 +275,9 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { double n; env->GetDoubleArrayRegion(arr, i, 1, &n); w[i] = n; - }; + } return sarr; - }; + } if (name == "[F") { jfloatArray arr = (jfloatArray)obj; @@ -291,9 +291,9 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { float n; env->GetFloatArrayRegion(arr, i, 1, &n); w[i] = n; - }; + } return sarr; - }; + } if (name == "[Ljava.lang.Object;") { jobjectArray arr = (jobjectArray)obj; @@ -308,7 +308,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { } return varr; - }; + } if (name == "java.util.HashMap" || name == "org.godotengine.godot.Dictionary") { Dictionary ret; @@ -327,10 +327,10 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { for (int i = 0; i < keys.size(); i++) { ret[keys[i]] = vals[i]; - }; + } return ret; - }; + } env->DeleteLocalRef(c); @@ -359,8 +359,9 @@ Variant::Type get_jni_type(const String &p_type) { int idx = 0; while (_type_to_vtype[idx].name) { - if (p_type == _type_to_vtype[idx].name) + if (p_type == _type_to_vtype[idx].name) { return _type_to_vtype[idx].type; + } idx++; } @@ -390,8 +391,9 @@ const char *get_jni_sig(const String &p_type) { int idx = 0; while (_type_to_vtype[idx].name) { - if (p_type == _type_to_vtype[idx].name) + if (p_type == _type_to_vtype[idx].name) { return _type_to_vtype[idx].sig; + } idx++; } diff --git a/platform/android/net_socket_android.cpp b/platform/android/net_socket_android.cpp index 620df539e4..a65e7c6724 100644 --- a/platform/android/net_socket_android.cpp +++ b/platform/android/net_socket_android.cpp @@ -77,18 +77,21 @@ NetSocketAndroid::~NetSocketAndroid() { void NetSocketAndroid::close() { NetSocketPosix::close(); - if (wants_broadcast) + if (wants_broadcast) { multicast_lock_release(); - if (multicast_groups) + } + if (multicast_groups) { multicast_lock_release(); + } wants_broadcast = false; multicast_groups = 0; } Error NetSocketAndroid::set_broadcasting_enabled(bool p_enabled) { Error err = NetSocketPosix::set_broadcasting_enabled(p_enabled); - if (err != OK) + if (err != OK) { return err; + } if (p_enabled != wants_broadcast) { if (p_enabled) { @@ -105,11 +108,13 @@ Error NetSocketAndroid::set_broadcasting_enabled(bool p_enabled) { Error NetSocketAndroid::join_multicast_group(const IPAddress &p_multi_address, String p_if_name) { Error err = NetSocketPosix::join_multicast_group(p_multi_address, p_if_name); - if (err != OK) + if (err != OK) { return err; + } - if (!multicast_groups) + if (!multicast_groups) { multicast_lock_acquire(); + } multicast_groups++; return OK; @@ -117,14 +122,16 @@ Error NetSocketAndroid::join_multicast_group(const IPAddress &p_multi_address, S Error NetSocketAndroid::leave_multicast_group(const IPAddress &p_multi_address, String p_if_name) { Error err = NetSocketPosix::leave_multicast_group(p_multi_address, p_if_name); - if (err != OK) + if (err != OK) { return err; + } ERR_FAIL_COND_V(multicast_groups == 0, ERR_BUG); multicast_groups--; - if (!multicast_groups) + if (!multicast_groups) { multicast_lock_release(); + } return OK; } diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index d1672d6ea3..b17b0f3139 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -81,17 +81,18 @@ void OS_Android::alert(const String &p_alert, const String &p_title) { void OS_Android::initialize_core() { OS_Unix::initialize_core(); - if (use_apk_expansion) + if (use_apk_expansion) { FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_RESOURCES); - else { + } else { FileAccess::make_default<FileAccessAndroid>(FileAccess::ACCESS_RESOURCES); } FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA); FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_FILESYSTEM); - if (use_apk_expansion) + if (use_apk_expansion) { DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_RESOURCES); - else + } else { DirAccess::make_default<DirAccessJAndroid>(DirAccess::ACCESS_RESOURCES); + } DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_USERDATA); DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_FILESYSTEM); @@ -162,20 +163,23 @@ MainLoop *OS_Android::get_main_loop() const { } void OS_Android::main_loop_begin() { - if (main_loop) + if (main_loop) { main_loop->initialize(); + } } bool OS_Android::main_loop_iterate() { - if (!main_loop) + if (!main_loop) { return false; + } DisplayServerAndroid::get_singleton()->process_events(); return Main::iteration(); } void OS_Android::main_loop_end() { - if (main_loop) + if (main_loop) { main_loop->finalize(); + } } void OS_Android::main_loop_focusout() { @@ -207,8 +211,9 @@ String OS_Android::get_locale() const { String OS_Android::get_model_name() const { String model = godot_io_java->get_model(); - if (!model.is_empty()) + if (!model.is_empty()) { return model; + } return OS_Unix::get_model_name(); } @@ -218,8 +223,9 @@ String OS_Android::get_data_path() const { } String OS_Android::get_user_data_dir() const { - if (!data_dir_cache.is_empty()) + if (!data_dir_cache.is_empty()) { return data_dir_cache; + } String data_dir = godot_io_java->get_user_data_dir(); if (!data_dir.is_empty()) { @@ -230,8 +236,9 @@ String OS_Android::get_user_data_dir() const { } String OS_Android::get_cache_path() const { - if (!cache_dir_cache.is_empty()) + if (!cache_dir_cache.is_empty()) { return cache_dir_cache; + } String cache_dir = godot_io_java->get_cache_dir(); if (!cache_dir.is_empty()) { @@ -243,8 +250,9 @@ String OS_Android::get_cache_path() const { String OS_Android::get_unique_id() const { String unique_id = godot_io_java->get_unique_id(); - if (!unique_id.is_empty()) + if (!unique_id.is_empty()) { return unique_id; + } return OS::get_unique_id(); } diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index 5130a26f15..c5c9b5a5f9 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -29,6 +29,7 @@ /*************************************************************************/ #import "app_delegate.h" + #include "core/config/project_settings.h" #include "drivers/coreaudio/audio_driver_coreaudio.h" #import "godot_view.h" @@ -76,7 +77,7 @@ static ViewController *mainViewController = nil; // bail, things did not go very well for us, should probably output a message on screen with our error code... exit(0); return NO; - }; + } ViewController *viewController = [[ViewController alloc] init]; viewController.godotView.useCADisplayLink = bool(GLOBAL_DEF("display.iOS/use_cadisplaylink", true)) ? YES : NO; @@ -99,7 +100,7 @@ static ViewController *mainViewController = nil; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil]; return YES; -}; +} - (void)onAudioInterruption:(NSNotification *)notification { if ([notification.name isEqualToString:AVAudioSessionInterruptionNotification]) { @@ -111,17 +112,17 @@ static ViewController *mainViewController = nil; OSIPhone::get_singleton()->on_focus_in(); } } -}; +} - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { if (OS::get_singleton()->get_main_loop()) { OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_OS_MEMORY_WARNING); } -}; +} - (void)applicationWillTerminate:(UIApplication *)application { iphone_finish(); -}; +} // When application goes to background (e.g. user switches to another app or presses Home), // then applicationWillResignActive -> applicationDidEnterBackground are called. diff --git a/platform/iphone/display_layer.mm b/platform/iphone/display_layer.mm index 7448dfed4a..92e81448ac 100644 --- a/platform/iphone/display_layer.mm +++ b/platform/iphone/display_layer.mm @@ -29,6 +29,7 @@ /*************************************************************************/ #import "display_layer.h" + #include "core/config/project_settings.h" #include "core/os/keyboard.h" #include "display_server_iphone.h" @@ -153,17 +154,6 @@ return NO; } - // if (OS::get_singleton()) { - // OS::VideoMode vm; - // vm.fullscreen = true; - // vm.width = backingWidth; - // vm.height = backingHeight; - // vm.resizable = false; - // OS::get_singleton()->set_video_mode(vm); - // OSIPhone::get_singleton()->set_base_framebuffer(viewFramebuffer); - // }; - // gl_view_base_fb = viewFramebuffer; - return YES; } diff --git a/platform/iphone/display_server_iphone.mm b/platform/iphone/display_server_iphone.mm index 9491c9cf90..a0f8daf5a0 100644 --- a/platform/iphone/display_server_iphone.mm +++ b/platform/iphone/display_server_iphone.mm @@ -29,6 +29,7 @@ /*************************************************************************/ #include "display_server_iphone.h" + #import "app_delegate.h" #include "core/config/project_settings.h" #include "core/io/file_access_pack.h" @@ -231,7 +232,7 @@ void DisplayServerIPhone::touch_press(int p_idx, int p_x, int p_y, bool p_presse ev->set_position(Vector2(p_x, p_y)); perform_event(ev); } -}; +} void DisplayServerIPhone::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y) { if (!GLOBAL_DEF("debug/disable_touch", false)) { @@ -241,16 +242,16 @@ void DisplayServerIPhone::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int ev->set_position(Vector2(p_x, p_y)); ev->set_relative(Vector2(p_x - p_prev_x, p_y - p_prev_y)); perform_event(ev); - }; -}; + } +} void DisplayServerIPhone::perform_event(const Ref<InputEvent> &p_event) { Input::get_singleton()->parse_input_event(p_event); -}; +} void DisplayServerIPhone::touches_cancelled(int p_idx) { touch_press(p_idx, -1, -1, false, false); -}; +} // MARK: Keyboard @@ -263,13 +264,13 @@ void DisplayServerIPhone::key(Key p_key, bool p_pressed) { ev->set_physical_keycode(p_key); ev->set_unicode((char32_t)p_key); perform_event(ev); -}; +} // MARK: Motion void DisplayServerIPhone::update_gravity(float p_x, float p_y, float p_z) { Input::get_singleton()->set_gravity(Vector3(p_x, p_y, p_z)); -}; +} void DisplayServerIPhone::update_accelerometer(float p_x, float p_y, float p_z) { // Found out the Z should not be negated! Pass as is! @@ -279,15 +280,15 @@ void DisplayServerIPhone::update_accelerometer(float p_x, float p_y, float p_z) p_z / kDisplayServerIPhoneAcceleration); Input::get_singleton()->set_accelerometer(v_accelerometer); -}; +} void DisplayServerIPhone::update_magnetometer(float p_x, float p_y, float p_z) { Input::get_singleton()->set_magnetometer(Vector3(p_x, p_y, p_z)); -}; +} void DisplayServerIPhone::update_gyroscope(float p_x, float p_y, float p_z) { Input::get_singleton()->set_gyroscope(Vector3(p_x, p_y, p_z)); -}; +} // MARK: - @@ -520,7 +521,7 @@ void DisplayServerIPhone::window_move_to_foreground(WindowID p_window) { float DisplayServerIPhone::screen_get_max_scale() const { return screen_get_scale(SCREEN_OF_MAIN_WINDOW); -}; +} void DisplayServerIPhone::screen_set_orientation(DisplayServer::ScreenOrientation p_orientation, int p_screen) { screen_orientation = p_orientation; diff --git a/platform/iphone/godot_iphone.mm b/platform/iphone/godot_iphone.mm index a76276e815..49474ef554 100644 --- a/platform/iphone/godot_iphone.mm +++ b/platform/iphone/godot_iphone.mm @@ -53,7 +53,7 @@ int add_path(int p_argc, char **p_args) { p_args[p_argc] = nullptr; return p_argc; -}; +} int add_cmdline(int p_argc, char **p_args) { NSArray *arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_cmdline"]; @@ -67,12 +67,12 @@ int add_cmdline(int p_argc, char **p_args) { continue; } p_args[p_argc++] = (char *)[str cStringUsingEncoding:NSUTF8StringEncoding]; - }; + } p_args[p_argc] = nullptr; return p_argc; -}; +} int iphone_main(int argc, char **argv, String data_dir, String cache_dir) { size_t len = strlen(argv[0]); @@ -103,7 +103,7 @@ int iphone_main(int argc, char **argv, String data_dir, String cache_dir) { char *fargv[64]; for (int i = 0; i < argc; i++) { fargv[i] = argv[i]; - }; + } fargv[argc] = nullptr; argc = add_path(argc, fargv); argc = add_cmdline(argc, fargv); @@ -119,10 +119,10 @@ int iphone_main(int argc, char **argv, String data_dir, String cache_dir) { os->initialize_modules(); return 0; -}; +} void iphone_finish() { printf("iphone_finish\n"); Main::cleanup(); delete os; -}; +} diff --git a/platform/iphone/godot_view.mm b/platform/iphone/godot_view.mm index ae92f32851..da71312fc4 100644 --- a/platform/iphone/godot_view.mm +++ b/platform/iphone/godot_view.mm @@ -29,6 +29,7 @@ /*************************************************************************/ #import "godot_view.h" + #include "core/os/keyboard.h" #include "core/string/ustring.h" #import "display_layer.h" @@ -226,8 +227,9 @@ static const float earth_gravity = 9.80665; [self.displayLink setPaused:YES]; // Process all input events - while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, TRUE) == kCFRunLoopRunHandledSource) - ; + while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, TRUE) == kCFRunLoopRunHandledSource) { + // Continue. + } // We are good to go, resume the CADisplayLink [self.displayLink setPaused:NO]; diff --git a/platform/iphone/godot_view_gesture_recognizer.mm b/platform/iphone/godot_view_gesture_recognizer.mm index a46c42765a..18939f7108 100644 --- a/platform/iphone/godot_view_gesture_recognizer.mm +++ b/platform/iphone/godot_view_gesture_recognizer.mm @@ -29,6 +29,7 @@ /*************************************************************************/ #import "godot_view_gesture_recognizer.h" + #import "godot_view.h" #include "core/config/project_settings.h" diff --git a/platform/iphone/godot_view_renderer.mm b/platform/iphone/godot_view_renderer.mm index e49edf5b74..32477ae41c 100644 --- a/platform/iphone/godot_view_renderer.mm +++ b/platform/iphone/godot_view_renderer.mm @@ -29,6 +29,7 @@ /*************************************************************************/ #import "godot_view_renderer.h" + #include "core/config/project_settings.h" #include "core/os/keyboard.h" #import "display_server_iphone.h" @@ -101,7 +102,7 @@ double dval = [n doubleValue]; ProjectSettings::get_singleton()->set("Info.plist/" + ukey, dval); - }; + } // do stuff } } diff --git a/platform/iphone/ios.mm b/platform/iphone/ios.mm index da21ad0ace..ad1ea70c10 100644 --- a/platform/iphone/ios.mm +++ b/platform/iphone/ios.mm @@ -29,6 +29,7 @@ /*************************************************************************/ #include "ios.h" + #import "app_delegate.h" #import "view_controller.h" #import <UIKit/UIKit.h> @@ -36,7 +37,7 @@ void iOS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_rate_url", "app_id"), &iOS::get_rate_url); -}; +} void iOS::alert(const char *p_alert, const char *p_title) { NSString *title = [NSString stringWithUTF8String:p_title]; @@ -75,6 +76,6 @@ String iOS::get_rate_url(int p_app_id) const { printf("returning rate url %s\n", ret.utf8().get_data()); return ret; -}; +} iOS::iOS() {} diff --git a/platform/iphone/joypad_iphone.mm b/platform/iphone/joypad_iphone.mm index f45f4da5a8..9c2feeaaca 100644 --- a/platform/iphone/joypad_iphone.mm +++ b/platform/iphone/joypad_iphone.mm @@ -29,6 +29,7 @@ /*************************************************************************/ #import "joypad_iphone.h" + #include "core/config/project_settings.h" #include "drivers/coreaudio/audio_driver_coreaudio.h" #include "main/main.h" @@ -139,10 +140,10 @@ void JoypadIPhone::start_processing() { for (NSNumber *key in keys) { int joy_id = [key intValue]; return joy_id; - }; + } return -1; -}; +} - (void)addiOSJoypad:(GCController *)controller { // get a new id for our controller @@ -156,7 +157,7 @@ void JoypadIPhone::start_processing() { // assign our player index if (controller.playerIndex == GCControllerPlayerIndexUnset) { controller.playerIndex = [self getFreePlayerIndex]; - }; + } // tell Godot about our new controller Input::get_singleton()->joy_connection_changed(joy_id, true, String::utf8([controller.vendorName UTF8String])); @@ -202,8 +203,8 @@ void JoypadIPhone::start_processing() { // and remove it from our dictionary [self.connectedJoypads removeObjectForKey:key]; - }; -}; + } +} - (GCControllerPlayerIndex)getFreePlayerIndex { bool have_player_1 = false; @@ -223,9 +224,9 @@ void JoypadIPhone::start_processing() { have_player_3 = true; } else if (controller.playerIndex == GCControllerPlayerIndex4) { have_player_4 = true; - }; - }; - }; + } + } + } if (!have_player_1) { return GCControllerPlayerIndex1; @@ -237,7 +238,7 @@ void JoypadIPhone::start_processing() { return GCControllerPlayerIndex4; } else { return GCControllerPlayerIndexUnset; - }; + } } - (void)setControllerInputHandler:(GCController *)controller { @@ -285,7 +286,7 @@ void JoypadIPhone::start_processing() { gamepad.dpad.left.isPressed); Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_RIGHT, gamepad.dpad.right.isPressed); - }; + } if (element == gamepad.leftThumbstick) { float value = gamepad.leftThumbstick.xAxis.value; @@ -303,7 +304,7 @@ void JoypadIPhone::start_processing() { } else if (element == gamepad.rightTrigger) { float value = gamepad.rightTrigger.value; Input::get_singleton()->joy_axis(joy_id, JoyAxis::TRIGGER_RIGHT, value); - }; + } }; } else if (controller.microGamepad != nil) { // micro gamepads were added in OS 9 and feature just 2 buttons and a d-pad @@ -329,7 +330,7 @@ void JoypadIPhone::start_processing() { gamepad.dpad.down.isPressed); Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_LEFT, gamepad.dpad.left.isPressed); Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_RIGHT, gamepad.dpad.right.isPressed); - }; + } }; } @@ -338,6 +339,6 @@ void JoypadIPhone::start_processing() { ///@TODO need to add support for controllerPausedHandler which should be a /// toggle -}; +} @end diff --git a/platform/iphone/os_iphone.mm b/platform/iphone/os_iphone.mm index 9fb6426b21..56cb49318c 100644 --- a/platform/iphone/os_iphone.mm +++ b/platform/iphone/os_iphone.mm @@ -31,6 +31,7 @@ #ifdef IPHONE_ENABLED #include "os_iphone.h" + #import "app_delegate.h" #include "core/config/project_settings.h" #include "core/io/dir_access.h" @@ -169,7 +170,7 @@ void OSIPhone::delete_main_loop() { if (main_loop) { main_loop->finalize(); memdelete(main_loop); - }; + } main_loop = nullptr; } @@ -198,7 +199,7 @@ void OSIPhone::finalize() { deinitialize_modules(); // Already gets called - // delete_main_loop(); + //delete_main_loop(); } // MARK: Dynamic Libraries @@ -231,12 +232,13 @@ Error OSIPhone::get_dynamic_library_symbol_handle(void *p_library_handle, const String OSIPhone::get_name() const { return "iOS"; -}; +} String OSIPhone::get_model_name() const { String model = ios->get_model(); - if (model != "") + if (model != "") { return model; + } return OS_Unix::get_model_name(); } @@ -254,7 +256,7 @@ Error OSIPhone::shell_open(String p_uri) { [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; return OK; -}; +} void OSIPhone::set_user_data_dir(String p_dir) { DirAccess *da = DirAccess::open(p_dir); diff --git a/platform/iphone/view_controller.mm b/platform/iphone/view_controller.mm index e1fc645c13..4f4ef4f046 100644 --- a/platform/iphone/view_controller.mm +++ b/platform/iphone/view_controller.mm @@ -203,7 +203,7 @@ case DisplayServer::SCREEN_LANDSCAPE: return UIInterfaceOrientationMaskLandscapeLeft; } -}; +} - (BOOL)prefersStatusBarHidden { return YES; diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp index a0e1246c55..2caf369354 100644 --- a/platform/javascript/display_server_javascript.cpp +++ b/platform/javascript/display_server_javascript.cpp @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "platform/javascript/display_server_javascript.h" +#include "display_server_javascript.h" #ifdef GLES3_ENABLED #include "drivers/gles3/rasterizer_gles3.h" @@ -325,12 +325,13 @@ void DisplayServerJavaScript::cursor_set_custom_image(const RES &p_cursor, Curso image = image->duplicate(); - if (atlas_texture.is_valid()) + if (atlas_texture.is_valid()) { image->crop_from_point( atlas_rect.position.x, atlas_rect.position.y, texture_size.width, texture_size.height); + } if (image->get_format() != Image::FORMAT_RGBA8) { image->convert(Image::FORMAT_RGBA8); @@ -618,8 +619,9 @@ void DisplayServerJavaScript::set_icon(const Ref<Image> &p_icon) { ERR_FAIL_COND(icon->decompress() != OK); } if (icon->get_format() != Image::FORMAT_RGBA8) { - if (icon == p_icon) + if (icon == p_icon) { icon = icon->duplicate(); + } icon->convert(Image::FORMAT_RGBA8); } @@ -891,8 +893,9 @@ Size2i DisplayServerJavaScript::window_get_real_size(WindowID p_window) const { } void DisplayServerJavaScript::window_set_mode(WindowMode p_mode, WindowID p_window) { - if (window_mode == p_mode) + if (window_mode == p_mode) { return; + } switch (p_mode) { case WINDOW_MODE_WINDOWED: { diff --git a/platform/javascript/javascript_singleton.cpp b/platform/javascript/javascript_singleton.cpp index 77858bff01..eb5c02822f 100644 --- a/platform/javascript/javascript_singleton.cpp +++ b/platform/javascript/javascript_singleton.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "api/javascript_singleton.h" + #include "emscripten.h" #include "os_javascript.h" diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index de5ca44f9d..da88ea18b0 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -175,7 +175,7 @@ String OS_JavaScript::get_name() const { String OS_JavaScript::get_user_data_dir() const { return "/userfs"; -}; +} String OS_JavaScript::get_cache_path() const { return "/home/web_user/.cache"; diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 86c3534fc9..bca38d9f20 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -4794,7 +4794,7 @@ DisplayServerX11::~DisplayServerX11() { if (img[i] != nullptr) { XcursorImageDestroy(img[i]); } - }; + } if (xim) { XCloseIM(xim); diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp index 8e963238e3..65d53b266f 100644 --- a/platform/linuxbsd/joypad_linux.cpp +++ b/platform/linuxbsd/joypad_linux.cpp @@ -238,7 +238,7 @@ void JoypadLinux::close_joypad(int p_id) { if (p_id == -1) { for (int i = 0; i < JOYPADS_MAX; i++) { close_joypad(i); - }; + } return; } else if (p_id < 0) { return; @@ -251,7 +251,7 @@ void JoypadLinux::close_joypad(int p_id) { joy.fd = -1; attached_devices.remove_at(attached_devices.find(joy.devpath)); input->joy_connection_changed(p_id, false, ""); - }; + } } static String _hex_str(uint8_t p_byte) { @@ -516,7 +516,7 @@ void JoypadLinux::process_joypads() { } if (len == 0 || (len < 0 && errno != EAGAIN)) { close_joypad(i); - }; + } if (joy->force_feedback) { uint64_t timestamp = input->get_joy_vibration_timestamp(i); diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index 5e8656c79f..d876932a83 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -356,7 +356,7 @@ void OS_LinuxBSD::run() { if (Main::iteration()) { break; } - }; + } main_loop->finalize(); } diff --git a/platform/linuxbsd/vulkan_context_x11.cpp b/platform/linuxbsd/vulkan_context_x11.cpp index e2fd8c76d2..b4f585726f 100644 --- a/platform/linuxbsd/vulkan_context_x11.cpp +++ b/platform/linuxbsd/vulkan_context_x11.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "vulkan_context_x11.h" + #ifdef USE_VOLK #include <volk.h> #else diff --git a/platform/osx/crash_handler_osx.mm b/platform/osx/crash_handler_osx.mm index 3e640b3bf3..06ed91907c 100644 --- a/platform/osx/crash_handler_osx.mm +++ b/platform/osx/crash_handler_osx.mm @@ -89,8 +89,9 @@ static void handle_crash(int sig) { fprintf(stderr, "\n================================================================\n"); fprintf(stderr, "%s: Program crashed with signal %d\n", __FUNCTION__, sig); - if (OS::get_singleton()->get_main_loop()) + if (OS::get_singleton()->get_main_loop()) { OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_CRASH); + } // Print the engine version just before, so that people are reminded to include the version in backtrace reports. if (String(VERSION_HASH).is_empty()) { @@ -119,8 +120,9 @@ static void handle_crash(int sig) { snprintf(fname, 1024, "%s", demangled); } - if (demangled) + if (demangled) { free(demangled); + } } } @@ -177,8 +179,9 @@ CrashHandler::~CrashHandler() { } void CrashHandler::disable() { - if (disabled) + if (disabled) { return; + } #ifdef CRASH_HANDLER_ENABLED signal(SIGSEGV, nullptr); diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index b7258e6cf4..b2201eabbc 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -790,8 +790,9 @@ String DisplayServerOSX::global_menu_get_item_submenu(const String &p_menu_root, const NSMenu *sub_menu = [menu_item submenu]; if (sub_menu) { for (Map<String, NSMenu *>::Element *E = submenu.front(); E; E = E->next()) { - if (E->get() == sub_menu) + if (E->get() == sub_menu) { return E->key(); + } } } } diff --git a/platform/osx/godot_main_osx.mm b/platform/osx/godot_main_osx.mm index 7fabfaa1b7..f3db363151 100644 --- a/platform/osx/godot_main_osx.mm +++ b/platform/osx/godot_main_osx.mm @@ -49,7 +49,7 @@ int main(int argc, char **argv) { first_arg = i + 2; } printf("%i: %s\n", i, argv[i]); - }; + } #ifdef DEBUG_ENABLED // Lets report the path we made current after all that. @@ -84,4 +84,4 @@ int main(int argc, char **argv) { Main::cleanup(); return os.get_exit_code(); -}; +} diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp index d518206f04..7d31ede61d 100644 --- a/platform/osx/joypad_osx.cpp +++ b/platform/osx/joypad_osx.cpp @@ -322,10 +322,11 @@ bool JoypadOSX::configure_joypad(IOHIDDeviceRef p_device_ref, joypad *p_joy) { // Bluetooth device. String guid = "05000000"; for (int i = 0; i < 12; i++) { - if (i < name.size()) + if (i < name.size()) { guid += _hex_str(name[i]); - else + } else { guid += "00"; + } } input->joy_connection_changed(id, true, name, guid); } @@ -381,8 +382,9 @@ bool joypad::check_ff_features() { if (ret == FF_OK && (features.supportedEffects & FFCAP_ET_CONSTANTFORCE)) { uint32_t val; ret = FFDeviceGetForceFeedbackProperty(ff_device, FFPROP_FFGAIN, &val, sizeof(val)); - if (ret != FF_OK) + if (ret != FF_OK) { return false; + } int num_axes = features.numFfAxes; ff_axes = (DWORD *)memalloc(sizeof(DWORD) * num_axes); ff_directions = (LONG *)memalloc(sizeof(LONG) * num_axes); @@ -509,16 +511,18 @@ void JoypadOSX::joypad_vibration_stop(int p_id, uint64_t p_timestamp) { int JoypadOSX::get_joy_index(int p_id) const { for (int i = 0; i < device_list.size(); i++) { - if (device_list[i].id == p_id) + if (device_list[i].id == p_id) { return i; + } } return -1; } int JoypadOSX::get_joy_ref(IOHIDDeviceRef p_device) const { for (int i = 0; i < device_list.size(); i++) { - if (device_list[i].device_ref == p_device) + if (device_list[i].device_ref == p_device) { return i; + } } return -1; } diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 868721e875..6700f8fe82 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -441,7 +441,7 @@ void OS_OSX::run() { } @catch (NSException *exception) { ERR_PRINT("NSException: " + String::utf8([exception reason].UTF8String)); } - }; + } main_loop->finalize(); } diff --git a/platform/osx/osx_terminal_logger.mm b/platform/osx/osx_terminal_logger.mm index c1dca111a7..48e26f42bf 100644 --- a/platform/osx/osx_terminal_logger.mm +++ b/platform/osx/osx_terminal_logger.mm @@ -40,10 +40,11 @@ void OSXTerminalLogger::log_error(const char *p_function, const char *p_file, in } const char *err_details; - if (p_rationale && p_rationale[0]) + if (p_rationale && p_rationale[0]) { err_details = p_rationale; - else + } else { err_details = p_code; + } switch (p_type) { case ERR_WARNING: diff --git a/platform/uwp/app_uwp.cpp b/platform/uwp/app_uwp.cpp index 6832d71a6f..6460c43447 100644 --- a/platform/uwp/app_uwp.cpp +++ b/platform/uwp/app_uwp.cpp @@ -177,7 +177,7 @@ static MouseButton _get_button(Windows::UI::Input::PointerPoint ^ pt) { #endif return MOUSE_BUTTON_NONE; -}; +} static bool _is_touch(Windows::UI::Input::PointerPoint ^ pointerPoint) { #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP @@ -231,11 +231,11 @@ static Windows::Foundation::Point _get_pixel_position(CoreWindow ^ window, Windo outputPosition.Y *= vm.height; return outputPosition; -}; +} static int _get_finger(uint32_t p_touch_id) { return p_touch_id % 31; // for now -}; +} void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args, bool p_pressed, bool p_is_wheel) { Windows::UI::Input::PointerPoint ^ point = args->CurrentPoint; @@ -281,15 +281,15 @@ void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Cor os->input_event(mouse_button); } } -}; +} void App::OnPointerPressed(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) { pointer_event(sender, args, true); -}; +} void App::OnPointerReleased(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) { pointer_event(sender, args, false); -}; +} void App::OnPointerWheelChanged(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) { pointer_event(sender, args, true, true); @@ -416,8 +416,9 @@ void App::Load(Platform::String ^ entryPoint) { // This method is called after the window becomes active. void App::Run() { - if (Main::start()) + if (Main::start()) { os->run(); + } } // Terminate events do not cause Uninitialize to be called. It will be called if your IFrameworkView diff --git a/platform/uwp/context_egl_uwp.cpp b/platform/uwp/context_egl_uwp.cpp index a08693c72f..8ec7bdfcee 100644 --- a/platform/uwp/context_egl_uwp.cpp +++ b/platform/uwp/context_egl_uwp.cpp @@ -36,26 +36,26 @@ using Platform::Exception; void ContextEGL_UWP::release_current() { eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, mEglContext); -}; +} void ContextEGL_UWP::make_current() { eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext); -}; +} int ContextEGL_UWP::get_window_width() { return width; -}; +} int ContextEGL_UWP::get_window_height() { return height; -}; +} void ContextEGL_UWP::reset() { cleanup(); window = CoreWindow::GetForCurrentThread(); initialize(); -}; +} void ContextEGL_UWP::swap_buffers() { if (eglSwapBuffers(mEglDisplay, mEglSurface) != EGL_TRUE) { @@ -66,7 +66,7 @@ void ContextEGL_UWP::swap_buffers() { // tell rasterizer to reload textures and stuff? } -}; +} Error ContextEGL_UWP::initialize() { EGLint configAttribList[] = { @@ -170,7 +170,7 @@ Error ContextEGL_UWP::initialize() { } } catch (...) { return FAILED; - }; + } mEglDisplay = display; mEglSurface = surface; @@ -180,7 +180,7 @@ Error ContextEGL_UWP::initialize() { eglQuerySurface(display, surface, EGL_HEIGHT, &height); return OK; -}; +} void ContextEGL_UWP::cleanup() { if (mEglDisplay != EGL_NO_DISPLAY && mEglSurface != EGL_NO_SURFACE) { @@ -197,7 +197,7 @@ void ContextEGL_UWP::cleanup() { eglTerminate(mEglDisplay); mEglDisplay = EGL_NO_DISPLAY; } -}; +} ContextEGL_UWP::ContextEGL_UWP(CoreWindow ^ p_window, Driver p_driver) : mEglDisplay(EGL_NO_DISPLAY), @@ -209,4 +209,4 @@ ContextEGL_UWP::ContextEGL_UWP(CoreWindow ^ p_window, Driver p_driver) : ContextEGL_UWP::~ContextEGL_UWP() { cleanup(); -}; +} diff --git a/platform/uwp/joypad_uwp.cpp b/platform/uwp/joypad_uwp.cpp index e48016919b..85c8959cf1 100644 --- a/platform/uwp/joypad_uwp.cpp +++ b/platform/uwp/joypad_uwp.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "joypad_uwp.h" + #include "core/os/os.h" using namespace Windows::Gaming::Input; @@ -45,8 +46,9 @@ void JoypadUWP::process_controllers() { for (int i = 0; i < MAX_CONTROLLERS; i++) { ControllerDevice &joy = controllers[i]; - if (!joy.connected) + if (!joy.connected) { break; + } switch (joy.type) { case ControllerType::GAMEPAD_CONTROLLER: { @@ -76,8 +78,9 @@ void JoypadUWP::process_controllers() { } } else if (joy.vibrating && joy.ff_end_timestamp != 0) { uint64_t current_time = OS::get_singleton()->get_ticks_usec(); - if (current_time >= joy.ff_end_timestamp) + if (current_time >= joy.ff_end_timestamp) { joypad_vibration_stop(i, current_time); + } } break; @@ -87,8 +90,9 @@ void JoypadUWP::process_controllers() { } JoypadUWP::JoypadUWP() { - for (int i = 0; i < MAX_CONTROLLERS; i++) + for (int i = 0; i < MAX_CONTROLLERS; i++) { controllers[i].id = i; + } } JoypadUWP::JoypadUWP(InputDefault *p_input) { diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index b6dde9c63f..22a54911f9 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -95,12 +95,12 @@ void OS_UWP::set_window_fullscreen(bool p_enabled) { video_mode.fullscreen = view->IsFullScreenMode; - if (video_mode.fullscreen == p_enabled) + if (video_mode.fullscreen == p_enabled) { return; + } if (p_enabled) { video_mode.fullscreen = view->TryEnterFullScreenMode(); - } else { view->ExitFullScreenMode(); video_mode.fullscreen = false; @@ -112,13 +112,15 @@ bool OS_UWP::is_window_fullscreen() const { } void OS_UWP::set_keep_screen_on(bool p_enabled) { - if (is_keep_screen_on() == p_enabled) + if (is_keep_screen_on() == p_enabled) { return; + } - if (p_enabled) + if (p_enabled) { display_request->RequestActive(); - else + } else { display_request->RequestRelease(); + } OS::set_keep_screen_on(p_enabled); } @@ -150,7 +152,7 @@ void OS_UWP::set_window(Windows::UI::Core::CoreWindow ^ p_window) { void OS_UWP::screen_size_changed() { gl_context->reset(); -}; +} Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { main_loop = nullptr; @@ -269,8 +271,9 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a _ensure_user_data_dir(); - if (is_keep_screen_on()) + if (is_keep_screen_on()) { display_request->RequestActive(); + } set_keep_screen_on(GLOBAL_DEF("display/window/energy_saving/keep_screen_on", true)); @@ -283,22 +286,24 @@ void OS_UWP::set_clipboard(const String &p_text) { clip->SetText(ref new Platform::String((LPCWSTR)(p_text.utf16().get_data()))); Clipboard::SetContent(clip); -}; +} String OS_UWP::get_clipboard() const { - if (managed_object->clipboard != nullptr) + if (managed_object->clipboard != nullptr) { return managed_object->clipboard->Data(); - else + } else { return ""; -}; + } +} void OS_UWP::input_event(const Ref<InputEvent> &p_event) { input->parse_input_event(p_event); -}; +} void OS_UWP::delete_main_loop() { - if (main_loop) + if (main_loop) { memdelete(main_loop); + } main_loop = nullptr; } @@ -308,16 +313,18 @@ void OS_UWP::set_main_loop(MainLoop *p_main_loop) { } void OS_UWP::finalize() { - if (main_loop) + if (main_loop) { memdelete(main_loop); + } main_loop = nullptr; rendering_server->finish(); memdelete(rendering_server); #ifdef GLES3_ENABLED - if (gl_context) + if (gl_context) { memdelete(gl_context); + } #endif memdelete(input); @@ -472,8 +479,9 @@ OS::Time OS_UWP::get_time(bool p_utc) const { OS::TimeZoneInfo OS_UWP::get_time_zone_info() const { TIME_ZONE_INFORMATION info; bool daylight = false; - if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) + if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) { daylight = true; + } TimeZoneInfo ret; if (daylight) { @@ -507,7 +515,7 @@ uint64_t OS_UWP::get_unix_time() const { SystemTimeToFileTime(&ep, &fep); return (*(uint64_t *)&ft - *(uint64_t *)&fep) / 10000000; -}; +} void OS_UWP::delay_usec(uint32_t p_usec) const { int msec = p_usec < 1000 ? 1 : p_usec / 1000; @@ -590,8 +598,9 @@ void OS_UWP::queue_key_event(KeyEvent &p_event) { void OS_UWP::set_cursor_shape(CursorShape p_shape) { ERR_FAIL_INDEX(p_shape, CURSOR_MAX); - if (cursor_shape == p_shape) + if (cursor_shape == p_shape) { return; + } static const CoreCursorType uwp_cursors[CURSOR_MAX] = { CoreCursorType::Arrow, @@ -628,15 +637,15 @@ void OS_UWP::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c Error OS_UWP::execute(const String &p_path, const List<String> &p_arguments, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex, bool p_open_console) { return FAILED; -}; +} Error OS_UWP::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id, bool p_open_console) { return FAILED; -}; +} Error OS_UWP::kill(const ProcessID &p_pid) { return FAILED; -}; +} Error OS_UWP::set_cwd(const String &p_cwd) { return FAILED; @@ -651,11 +660,11 @@ void OS_UWP::set_icon(const Ref<Image> &p_icon) { bool OS_UWP::has_environment(const String &p_var) const { return false; -}; +} String OS_UWP::get_environment(const String &p_var) const { return ""; -}; +} bool OS_UWP::set_environment(const String &p_var, const String &p_value) const { return false; @@ -751,8 +760,9 @@ Error OS_UWP::get_dynamic_library_symbol_handle(void *p_library_handle, const St } void OS_UWP::run() { - if (!main_loop) + if (!main_loop) { return; + } main_loop->init(); @@ -763,12 +773,14 @@ void OS_UWP::run() { while (!force_quit) { CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); - if (managed_object->alert_close_handle) + if (managed_object->alert_close_handle) { continue; + } process_events(); // get rid of pending events - if (Main::iteration()) + if (Main::iteration()) { break; - }; + } + } main_loop->finish(); } diff --git a/platform/windows/crash_handler_windows.cpp b/platform/windows/crash_handler_windows.cpp index 5064f6b97f..3b2c6fe9f6 100644 --- a/platform/windows/crash_handler_windows.cpp +++ b/platform/windows/crash_handler_windows.cpp @@ -80,8 +80,9 @@ public: std::string name() { return std::string(sym->Name); } std::string undecorated_name() { - if (*sym->Name == '\0') + if (*sym->Name == '\0') { return "<couldn't map PC to fn name>"; + } std::vector<char> und_name(max_name_len); UnDecorateSymbolName(sym->Name, &und_name[0], max_name_len, UNDNAME_COMPLETE); return std::string(&und_name[0], strlen(&und_name[0])); @@ -131,12 +132,14 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) { fprintf(stderr, "\n================================================================\n"); fprintf(stderr, "%s: Program crashed\n", __FUNCTION__); - if (OS::get_singleton()->get_main_loop()) + if (OS::get_singleton()->get_main_loop()) { OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_CRASH); + } // Load the symbols: - if (!SymInitialize(process, nullptr, false)) + if (!SymInitialize(process, nullptr, false)) { return EXCEPTION_CONTINUE_SEARCH; + } SymSetOptions(SymGetOptions() | SYMOPT_LOAD_LINES | SYMOPT_UNDNAME); EnumProcessModules(process, &module_handles[0], module_handles.size() * sizeof(HMODULE), &cbNeeded); @@ -193,18 +196,21 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) { if (frame.AddrPC.Offset != 0) { std::string fnName = symbol(process, frame.AddrPC.Offset).undecorated_name(); - if (SymGetLineFromAddr64(process, frame.AddrPC.Offset, &offset_from_symbol, &line)) + if (SymGetLineFromAddr64(process, frame.AddrPC.Offset, &offset_from_symbol, &line)) { fprintf(stderr, "[%d] %s (%s:%d)\n", n, fnName.c_str(), line.FileName, line.LineNumber); - else + } else { fprintf(stderr, "[%d] %s\n", n, fnName.c_str()); - } else + } + } else { fprintf(stderr, "[%d] ???\n", n); + } n++; } - if (!StackWalk64(image_type, process, hThread, &frame, context, nullptr, SymFunctionTableAccess64, SymGetModuleBase64, nullptr)) + if (!StackWalk64(image_type, process, hThread, &frame, context, nullptr, SymFunctionTableAccess64, SymGetModuleBase64, nullptr)) { break; + } } while (frame.AddrReturn.Offset != 0 && n < 256); fprintf(stderr, "-- END OF BACKTRACE --\n"); @@ -225,8 +231,9 @@ CrashHandler::~CrashHandler() { } void CrashHandler::disable() { - if (disabled) + if (disabled) { return; + } disabled = true; } diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index c7955ebf31..2f0b3b4490 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -231,7 +231,7 @@ String DisplayServerWindows::clipboard_get() const { String ret; if (!OpenClipboard(windows[last_focused_window].hWnd)) { ERR_FAIL_V_MSG("", "Unable to open clipboard."); - }; + } if (IsClipboardFormatAvailable(CF_UNICODETEXT)) { HGLOBAL mem = GetClipboardData(CF_UNICODETEXT); @@ -240,8 +240,8 @@ String DisplayServerWindows::clipboard_get() const { if (ptr != nullptr) { ret = String::utf16((const char16_t *)ptr); GlobalUnlock(mem); - }; - }; + } + } } else if (IsClipboardFormatAvailable(CF_TEXT)) { HGLOBAL mem = GetClipboardData(CF_UNICODETEXT); @@ -250,9 +250,9 @@ String DisplayServerWindows::clipboard_get() const { if (ptr != nullptr) { ret.parse_utf8((const char *)ptr); GlobalUnlock(mem); - }; - }; - }; + } + } + } CloseClipboard(); @@ -422,8 +422,9 @@ static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType = MDT_Defau getDPIForMonitor = Shcore ? (GetDPIForMonitor_t)GetProcAddress(Shcore, "GetDpiForMonitor") : nullptr; if ((Shcore == nullptr) || (getDPIForMonitor == nullptr)) { - if (Shcore) + if (Shcore) { FreeLibrary(Shcore); + } Shcore = (HMODULE)INVALID_HANDLE_VALUE; } } @@ -1326,8 +1327,9 @@ void DisplayServerWindows::window_set_ime_position(const Point2i &p_pos, WindowI wd.im_position = p_pos; HIMC himc = ImmGetContext(wd.hWnd); - if (himc == (HIMC)0) + if (himc == (HIMC)0) { return; + } COMPOSITIONFORM cps; cps.dwStyle = CFS_FORCE_POSITION; @@ -2026,7 +2028,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA } else { return DefWindowProcW(hWnd, uMsg, wParam, lParam); } - }; + } WindowID window_id = INVALID_WINDOW_ID; bool window_created = false; @@ -2131,8 +2133,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA case SC_MONITORPOWER: // Monitor trying to enter powersave? return 0; // Prevent from happening. case SC_KEYMENU: - if ((lParam >> 16) <= 0) + if ((lParam >> 16) <= 0) { return 0; + } } } break; case WM_CLOSE: // Did we receive a close message? @@ -2164,8 +2167,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA return 0; } - if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize) + if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize) { OutputDebugString(TEXT("GetRawInputData does not return correct size !\n")); + } RAWINPUT *raw = (RAWINPUT *)lpb; @@ -2260,8 +2264,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA ScreenToClient(windows[window_id].hWnd, &coords); // Don't calculate relative mouse movement if we don't have focus in CAPTURED mode. - if (!windows[window_id].window_has_focus && mouse_mode == MOUSE_MODE_CAPTURED) + if (!windows[window_id].window_has_focus && mouse_mode == MOUSE_MODE_CAPTURED) { break; + } Ref<InputEventMouseMotion> mm; mm.instantiate(); @@ -2306,8 +2311,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA mm->set_relative(Vector2(mm->get_position() - Vector2(old_x, old_y))); old_x = mm->get_position().x; old_y = mm->get_position().y; - if (windows[window_id].window_has_focus) + if (windows[window_id].window_has_focus) { Input::get_singleton()->parse_input_event(mm); + } } return 0; } @@ -2547,8 +2553,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA mm->set_relative(Vector2(mm->get_position() - Vector2(old_x, old_y))); old_x = mm->get_position().x; old_y = mm->get_position().y; - if (windows[window_id].window_has_focus) + if (windows[window_id].window_has_focus) { Input::get_singleton()->parse_input_event(mm); + } } break; case WM_LBUTTONDOWN: @@ -2694,8 +2701,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA if (uMsg != WM_MOUSEWHEEL && uMsg != WM_MOUSEHWHEEL) { if (mb->is_pressed()) { - if (++pressrc > 0 && mouse_mode != MOUSE_MODE_CAPTURED) + if (++pressrc > 0 && mouse_mode != MOUSE_MODE_CAPTURED) { SetCapture(hWnd); + } } else { if (--pressrc <= 0) { if (mouse_mode != MOUSE_MODE_CAPTURED) { @@ -2823,14 +2831,17 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA case WM_SYSKEYUP: case WM_KEYUP: case WM_KEYDOWN: { - if (wParam == VK_SHIFT) + if (wParam == VK_SHIFT) { shift_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN); - if (wParam == VK_CONTROL) + } + if (wParam == VK_CONTROL) { control_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN); + } if (wParam == VK_MENU) { alt_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN); - if (lParam & (1 << 24)) + if (lParam & (1 << 24)) { gr_mem = alt_mem; + } } if (mouse_mode == MOUSE_MODE_CAPTURED) { @@ -2839,10 +2850,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA _send_window_event(windows[window_id], WINDOW_EVENT_CLOSE_REQUEST); } } - /* - if (wParam==VK_WIN) TODO wtf is this? - meta_mem=uMsg==WM_KEYDOWN; - */ [[fallthrough]]; } case WM_CHAR: { @@ -2857,10 +2864,12 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA ke.uMsg = uMsg; ke.window_id = window_id; - if (ke.uMsg == WM_SYSKEYDOWN) + if (ke.uMsg == WM_SYSKEYDOWN) { ke.uMsg = WM_KEYDOWN; - if (ke.uMsg == WM_SYSKEYUP) + } + if (ke.uMsg == WM_SYSKEYUP) { ke.uMsg = WM_KEYUP; + } ke.wParam = wParam; ke.lParam = lParam; @@ -2888,7 +2897,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA _drag_event(window_id, touch_pos.x, touch_pos.y, ti.dwID); } else if (ti.dwFlags & (TOUCHEVENTF_UP | TOUCHEVENTF_DOWN)) { _touch_event(window_id, ti.dwFlags & TOUCHEVENTF_DOWN, touch_pos.x, touch_pos.y, ti.dwID); - }; + } } bHandled = TRUE; } else { @@ -2901,7 +2910,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA if (bHandled) { CloseTouchInputHandle((HTOUCHINPUT)lParam); return 0; - }; + } } break; case WM_DEVICECHANGE: { @@ -2955,8 +2964,8 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA default: { if (user_proc) { return CallWindowProcW(user_proc, hWnd, uMsg, wParam, lParam); - }; - }; + } + } } return DefWindowProcW(hWnd, uMsg, wParam, lParam); @@ -2964,10 +2973,11 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { DisplayServerWindows *ds_win = static_cast<DisplayServerWindows *>(DisplayServer::get_singleton()); - if (ds_win) + if (ds_win) { return ds_win->WndProc(hWnd, uMsg, wParam, lParam); - else + } else { return DefWindowProcW(hWnd, uMsg, wParam, lParam); + } } void DisplayServerWindows::_process_activate_event(WindowID p_window_id, WPARAM wParam, LPARAM lParam) { @@ -3034,8 +3044,9 @@ void DisplayServerWindows::_process_key_events() { k->set_ctrl_pressed(false); } - if (k->get_unicode() < 32) + if (k->get_unicode() < 32) { k->set_unicode(0); + } Input::get_singleton()->parse_input_event(k); } else { @@ -3090,8 +3101,9 @@ void DisplayServerWindows::_process_key_events() { k->set_ctrl_pressed(false); } - if (k->get_unicode() < 32) + if (k->get_unicode() < 32) { k->set_unicode(0); + } k->set_echo((ke.uMsg == WM_KEYDOWN && (ke.lParam & (1 << 30)))); @@ -3395,7 +3407,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win wc.cbWndExtra = 0; wc.hInstance = hInstance ? hInstance : GetModuleHandle(nullptr); wc.hIcon = LoadIcon(nullptr, IDI_WINLOGO); - wc.hCursor = nullptr; //LoadCursor(nullptr, IDC_ARROW); + wc.hCursor = nullptr; wc.hbrBackground = nullptr; wc.lpszMenuName = nullptr; wc.lpszClassName = L"Engine"; @@ -3446,7 +3458,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win return; } - // gl_manager->set_use_vsync(current_videomode.use_vsync); + //gl_manager->set_use_vsync(current_videomode.use_vsync); RasterizerGLES3::make_current(); } #endif @@ -3476,14 +3488,13 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win } #endif - //set_ime_active(false); - if (!OS::get_singleton()->is_in_low_processor_usage_mode()) { SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS); DWORD index = 0; HANDLE handle = AvSetMmThreadCharacteristics("Games", &index); - if (handle) + if (handle) { AvSetMmThreadPriority(handle, AVRT_PRIORITY_CRITICAL); + } // This is needed to make sure that background work does not starve the main thread. // This is only setting the priority of this thread, not the whole process. @@ -3537,10 +3548,10 @@ DisplayServerWindows::~DisplayServerWindows() { if (user_proc) { SetWindowLongPtr(windows[MAIN_WINDOW_ID].hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc); - }; + } #ifdef GLES3_ENABLED - // destroy windows .. NYI? + // destroy windows .. NYI? #endif if (windows.has(MAIN_WINDOW_ID)) { diff --git a/platform/windows/gl_manager_windows.cpp b/platform/windows/gl_manager_windows.cpp index 74b5f48502..a97fa99d7f 100644 --- a/platform/windows/gl_manager_windows.cpp +++ b/platform/windows/gl_manager_windows.cpp @@ -56,14 +56,9 @@ typedef HGLRC(APIENTRY *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int int GLManager_Windows::_find_or_create_display(GLWindow &win) { // find display NYI, only 1 supported so far - if (_displays.size()) + if (_displays.size()) { return 0; - - // for (unsigned int n = 0; n < _displays.size(); n++) { - // const GLDisplay &d = _displays[n]; - // if (d.x11_display == p_x11_display) - // return n; - // } + } // create GLDisplay d_temp = {}; @@ -230,23 +225,27 @@ void GLManager_Windows::window_destroy(DisplayServer::WindowID p_window_id) { } void GLManager_Windows::release_current() { - if (!_current_window) + if (!_current_window) { return; + } wglMakeCurrent(_current_window->hDC, nullptr); } void GLManager_Windows::window_make_current(DisplayServer::WindowID p_window_id) { - if (p_window_id == -1) + if (p_window_id == -1) { return; + } GLWindow &win = _windows[p_window_id]; - if (!win.in_use) + if (!win.in_use) { return; + } // noop - if (&win == _current_window) + if (&win == _current_window) { return; + } const GLDisplay &disp = get_display(win.gldisplay_id); wglMakeCurrent(win.hDC, disp.hRC); @@ -255,8 +254,9 @@ void GLManager_Windows::window_make_current(DisplayServer::WindowID p_window_id) } void GLManager_Windows::make_current() { - if (!_current_window) + if (!_current_window) { return; + } if (!_current_window->in_use) { WARN_PRINT("current window not in use!"); return; @@ -269,8 +269,9 @@ void GLManager_Windows::swap_buffers() { // NO NEED TO CALL SWAP BUFFERS for each window... // see https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glXSwapBuffers.xml - if (!_current_window) + if (!_current_window) { return; + } if (!_current_window->in_use) { WARN_PRINT("current window not in use!"); return; @@ -304,12 +305,15 @@ void GLManager_Windows::set_use_vsync(bool p_use) { if (!setup) { setup = true; String extensions = glXQueryExtensionsString(x11_display, DefaultScreen(x11_display)); - if (extensions.find("GLX_EXT_swap_control") != -1) + if (extensions.find("GLX_EXT_swap_control") != -1) { glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalEXT"); - if (extensions.find("GLX_MESA_swap_control") != -1) + } + if (extensions.find("GLX_MESA_swap_control") != -1) { glXSwapIntervalMESA = (PFNGLXSWAPINTERVALSGIPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalMESA"); - if (extensions.find("GLX_SGI_swap_control") != -1) + } + if (extensions.find("GLX_SGI_swap_control") != -1) { glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalSGI"); + } } int val = p_use ? 1 : 0; if (glXSwapIntervalMESA) { @@ -319,8 +323,9 @@ void GLManager_Windows::set_use_vsync(bool p_use) { } else if (glXSwapIntervalEXT) { GLXDrawable drawable = glXGetCurrentDrawable(); glXSwapIntervalEXT(x11_display, drawable, val); - } else + } else { return; + } use_vsync = p_use; */ } diff --git a/platform/windows/godot_windows.cpp b/platform/windows/godot_windows.cpp index 618d5670d2..ad4e3ae77c 100644 --- a/platform/windows/godot_windows.cpp +++ b/platform/windows/godot_windows.cpp @@ -163,8 +163,9 @@ int widechar_main(int argc, wchar_t **argv) { return 255; } - if (Main::start()) + if (Main::start()) { os.run(); + } Main::cleanup(); for (int i = 0; i < argc; ++i) { @@ -173,7 +174,7 @@ int widechar_main(int argc, wchar_t **argv) { delete[] argv_utf8; return os.get_exit_code(); -}; +} int _main() { LPWSTR *wc_argv; diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp index b0dd86a4b7..494e0b9105 100644 --- a/platform/windows/joypad_windows.cpp +++ b/platform/windows/joypad_windows.cpp @@ -60,8 +60,9 @@ JoypadWindows::JoypadWindows(HWND *hwnd) { load_xinput(); - for (int i = 0; i < JOYPADS_MAX; i++) + for (int i = 0; i < JOYPADS_MAX; i++) { attached_joypads[i] = false; + } HRESULT result = DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&dinput, nullptr); if (result == DI_OK) { @@ -144,8 +145,9 @@ bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE *instance) { HRESULT hr; int num = input->get_unused_joy_id(); - if (have_device(instance->guidInstance) || num == -1) + if (have_device(instance->guidInstance) || num == -1) { return false; + } d_joypads[num] = dinput_gamepad(); dinput_gamepad *joy = &d_joypads[num]; @@ -196,27 +198,28 @@ void JoypadWindows::setup_joypad_object(const DIDEVICEOBJECTINSTANCE *ob, int p_ DIPROPRANGE prop_range; DIPROPDWORD dilong; LONG ofs; - if (ob->guidType == GUID_XAxis) + if (ob->guidType == GUID_XAxis) { ofs = DIJOFS_X; - else if (ob->guidType == GUID_YAxis) + } else if (ob->guidType == GUID_YAxis) { ofs = DIJOFS_Y; - else if (ob->guidType == GUID_ZAxis) + } else if (ob->guidType == GUID_ZAxis) { ofs = DIJOFS_Z; - else if (ob->guidType == GUID_RxAxis) + } else if (ob->guidType == GUID_RxAxis) { ofs = DIJOFS_RX; - else if (ob->guidType == GUID_RyAxis) + } else if (ob->guidType == GUID_RyAxis) { ofs = DIJOFS_RY; - else if (ob->guidType == GUID_RzAxis) + } else if (ob->guidType == GUID_RzAxis) { ofs = DIJOFS_RZ; - else if (ob->guidType == GUID_Slider) { + } else if (ob->guidType == GUID_Slider) { if (slider_count < 2) { ofs = DIJOFS_SLIDER(slider_count); slider_count++; } else { return; } - } else + } else { return; + } prop_range.diph.dwSize = sizeof(DIPROPRANGE); prop_range.diph.dwHeaderSize = sizeof(DIPROPHEADER); prop_range.diph.dwObj = ob->dwType; @@ -227,8 +230,9 @@ void JoypadWindows::setup_joypad_object(const DIDEVICEOBJECTINSTANCE *ob, int p_ dinput_gamepad &joy = d_joypads[p_joy_id]; res = IDirectInputDevice8_SetProperty(joy.di_joy, DIPROP_RANGE, &prop_range.diph); - if (FAILED(res)) + if (FAILED(res)) { return; + } dilong.diph.dwSize = sizeof(dilong); dilong.diph.dwHeaderSize = sizeof(dilong.diph); @@ -237,8 +241,9 @@ void JoypadWindows::setup_joypad_object(const DIDEVICEOBJECTINSTANCE *ob, int p_ dilong.dwData = 0; res = IDirectInputDevice8_SetProperty(joy.di_joy, DIPROP_DEADZONE, &dilong.diph); - if (FAILED(res)) + if (FAILED(res)) { return; + } joy.joy_axis.push_back(ofs); } @@ -268,8 +273,9 @@ void JoypadWindows::close_joypad(int id) { return; } - if (!d_joypads[id].attached) + if (!d_joypads[id].attached) { return; + } d_joypads[id].di_joy->Unacquire(); d_joypads[id].di_joy->Release(); @@ -355,16 +361,18 @@ void JoypadWindows::process_joypads() { } } else if (joy.vibrating && joy.ff_end_timestamp != 0) { uint64_t current_time = OS::get_singleton()->get_ticks_usec(); - if (current_time >= joy.ff_end_timestamp) + if (current_time >= joy.ff_end_timestamp) { joypad_vibration_stop_xinput(i, current_time); + } } } for (int i = 0; i < JOYPADS_MAX; i++) { dinput_gamepad *joy = &d_joypads[i]; - if (!joy->attached) + if (!joy->attached) { continue; + } DIJOYSTATE2 js; hr = joy->di_joy->Poll(); @@ -404,9 +412,9 @@ void JoypadWindows::process_joypads() { if (joy->joy_axis[j] == axes[k]) { input->joy_axis(joy->id, (JoyAxis)j, axis_correct(values[k])); break; - }; - }; - }; + } + } + } } return; } @@ -446,7 +454,7 @@ void JoypadWindows::post_hat(int p_device, DWORD p_dpad) { dpad_val = (HatMask)(HatMask::LEFT | HatMask::UP); } input->joy_hat(p_device, dpad_val); -}; +} float JoypadWindows::axis_correct(int p_val, bool p_xinput, bool p_trigger, bool p_negate) const { if (Math::abs(p_val) < MIN_JOY_AXIS) { diff --git a/platform/windows/joypad_windows.h b/platform/windows/joypad_windows.h index 0e3d03fa52..4f15bcf080 100644 --- a/platform/windows/joypad_windows.h +++ b/platform/windows/joypad_windows.h @@ -86,8 +86,9 @@ private: attached = false; confirmed = false; - for (int i = 0; i < MAX_JOY_BUTTONS; i++) + for (int i = 0; i < MAX_JOY_BUTTONS; i++) { last_buttons[i] = false; + } } }; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 99c9712834..13e3aa7883 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -107,8 +107,9 @@ void RedirectIOToConsole() { } BOOL WINAPI HandlerRoutine(_In_ DWORD dwCtrlType) { - if (!EngineDebugger::is_active()) + if (!EngineDebugger::is_active()) { return FALSE; + } switch (dwCtrlType) { case CTRL_C_EVENT: @@ -166,8 +167,9 @@ void OS_Windows::initialize() { } void OS_Windows::delete_main_loop() { - if (main_loop) + if (main_loop) { memdelete(main_loop); + } main_loop = nullptr; } @@ -180,8 +182,9 @@ void OS_Windows::finalize() { driver_midi.close(); #endif - if (main_loop) + if (main_loop) { memdelete(main_loop); + } main_loop = nullptr; } @@ -288,8 +291,9 @@ OS::Time OS_Windows::get_time(bool p_utc) const { OS::TimeZoneInfo OS_Windows::get_time_zone_info() const { TIME_ZONE_INFORMATION info; bool daylight = false; - if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) + if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) { daylight = true; + } TimeZoneInfo ret; if (daylight) { @@ -322,10 +326,11 @@ double OS_Windows::get_unix_time() const { } void OS_Windows::delay_usec(uint32_t p_usec) const { - if (p_usec < 1000) + if (p_usec < 1000) { Sleep(1); - else + } else { Sleep(p_usec / 1000); + } } uint64_t OS_Windows::get_ticks_usec() const { @@ -430,7 +435,7 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, if (p_pipe_mutex) { p_pipe_mutex->unlock(); } - }; + } CloseHandle(pipe[0]); // Close pipe read handle. } else { WaitForSingleObject(pi.pi.hProcess, INFINITE); @@ -446,7 +451,7 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, CloseHandle(pi.pi.hThread); return OK; -}; +} Error OS_Windows::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id, bool p_open_console) { String path = p_path.replace("/", "\\"); @@ -478,7 +483,7 @@ Error OS_Windows::create_process(const String &p_path, const List<String> &p_arg process_map->insert(pid, pi); return OK; -}; +} Error OS_Windows::kill(const ProcessID &p_pid) { ERR_FAIL_COND_V(!process_map->has(p_pid), FAILED); @@ -492,15 +497,16 @@ Error OS_Windows::kill(const ProcessID &p_pid) { CloseHandle(pi.hThread); return ret != 0 ? OK : FAILED; -}; +} int OS_Windows::get_process_id() const { return _getpid(); } Error OS_Windows::set_cwd(const String &p_cwd) { - if (_wchdir((LPCWSTR)(p_cwd.utf16().get_data())) != 0) + if (_wchdir((LPCWSTR)(p_cwd.utf16().get_data())) != 0) { return ERR_CANT_OPEN; + } return OK; } @@ -523,7 +529,7 @@ bool OS_Windows::has_environment(const String &p_var) const { free(env); return has_env; #endif -}; +} String OS_Windows::get_environment(const String &p_var) const { WCHAR wval[0x7fff]; // MSDN says 32767 char is the maximum @@ -542,7 +548,7 @@ String OS_Windows::get_stdin_string(bool p_block) { if (p_block) { char buff[1024]; return fgets(buff, 1024, stdin); - }; + } return String(); } @@ -580,17 +586,20 @@ String OS_Windows::get_locale() const { int sublang = SUBLANGID(langid); while (wl->locale) { - if (wl->main_lang == lang && wl->sublang == SUBLANG_NEUTRAL) + if (wl->main_lang == lang && wl->sublang == SUBLANG_NEUTRAL) { neutral = wl->locale; + } - if (lang == wl->main_lang && sublang == wl->sublang) + if (lang == wl->main_lang && sublang == wl->sublang) { return String(wl->locale).replace("-", "_"); + } wl++; } - if (!neutral.is_empty()) + if (!neutral.is_empty()) { return String(neutral).replace("-", "_"); + } return "en"; } @@ -617,10 +626,11 @@ BOOL is_wow64() { int OS_Windows::get_processor_count() const { SYSTEM_INFO sysinfo; - if (is_wow64()) + if (is_wow64()) { GetNativeSystemInfo(&sysinfo); - else + } else { GetSystemInfo(&sysinfo); + } return sysinfo.dwNumberOfProcessors; } @@ -646,16 +656,18 @@ String OS_Windows::get_processor_name() const { } void OS_Windows::run() { - if (!main_loop) + if (!main_loop) { return; + } main_loop->initialize(); while (!force_quit) { DisplayServer::get_singleton()->process_events(); // get rid of pending events - if (Main::iteration()) + if (Main::iteration()) { break; - }; + } + } main_loop->finalize(); } diff --git a/platform/windows/windows_terminal_logger.cpp b/platform/windows/windows_terminal_logger.cpp index 0d5f0e617c..df21977698 100644 --- a/platform/windows/windows_terminal_logger.cpp +++ b/platform/windows/windows_terminal_logger.cpp @@ -44,25 +44,29 @@ void WindowsTerminalLogger::logv(const char *p_format, va_list p_list, bool p_er const unsigned int BUFFER_SIZE = 16384; char buf[BUFFER_SIZE + 1]; // +1 for the terminating character int len = vsnprintf(buf, BUFFER_SIZE, p_format, p_list); - if (len <= 0) + if (len <= 0) { return; - if ((unsigned int)len >= BUFFER_SIZE) + } + if ((unsigned int)len >= BUFFER_SIZE) { len = BUFFER_SIZE; // Output is too big, will be truncated + } buf[len] = 0; int wlen = MultiByteToWideChar(CP_UTF8, 0, buf, len, nullptr, 0); - if (wlen < 0) + if (wlen < 0) { return; + } wchar_t *wbuf = (wchar_t *)memalloc((len + 1) * sizeof(wchar_t)); ERR_FAIL_NULL_MSG(wbuf, "Out of memory."); MultiByteToWideChar(CP_UTF8, 0, buf, len, wbuf, wlen); wbuf[wlen] = 0; - if (p_err) + if (p_err) { fwprintf(stderr, L"%ls", wbuf); - else + } else { wprintf(L"%ls", wbuf); + } memfree(wbuf); diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp index 312ba0272e..2716bb2e25 100644 --- a/scene/2d/line_2d.cpp +++ b/scene/2d/line_2d.cpp @@ -247,10 +247,7 @@ float Line2D::get_sharp_limit() const { } void Line2D::set_round_precision(int p_precision) { - if (p_precision < 1) { - p_precision = 1; - } - _round_precision = p_precision; + _round_precision = MAX(1, p_precision); update(); } @@ -409,7 +406,7 @@ void Line2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "end_cap_mode", PROPERTY_HINT_ENUM, "None,Box,Round"), "set_end_cap_mode", "get_end_cap_mode"); ADD_GROUP("Border", ""); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sharp_limit"), "set_sharp_limit", "get_sharp_limit"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "round_precision"), "set_round_precision", "get_round_precision"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "round_precision", PROPERTY_HINT_RANGE, "1,32,1"), "set_round_precision", "get_round_precision"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "antialiased"), "set_antialiased", "get_antialiased"); BIND_ENUM_CONSTANT(LINE_JOINT_SHARP); diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 1f4dec6864..1fe4adb4db 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -428,15 +428,6 @@ Vector<Color> Polygon2D::get_vertex_colors() const { void Polygon2D::set_texture(const Ref<Texture2D> &p_texture) { texture = p_texture; - - /*if (texture.is_valid()) { - uint32_t flags=texture->get_flags(); - flags&=~Texture::FLAG_REPEAT; - if (tex_tile) - flags|=Texture::FLAG_REPEAT; - - texture->set_flags(flags); - }*/ update(); } diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp index 375692d049..4eace17cc0 100644 --- a/scene/3d/camera_3d.cpp +++ b/scene/3d/camera_3d.cpp @@ -82,12 +82,6 @@ void Camera3D::_update_camera() { RenderingServer::get_singleton()->camera_set_transform(camera, get_camera_transform()); - // here goes listener stuff - /* - if (viewport_ptr && is_inside_scene() && is_current()) - get_viewport()->_camera_3d_transform_changed_notify(); - */ - if (get_tree()->is_node_being_edited(this) || !is_current()) { return; } diff --git a/scene/3d/occluder_instance_3d.cpp b/scene/3d/occluder_instance_3d.cpp index 2488bfb8ba..855922c341 100644 --- a/scene/3d/occluder_instance_3d.cpp +++ b/scene/3d/occluder_instance_3d.cpp @@ -192,7 +192,6 @@ void QuadOccluder3D::set_size(const Vector2 &p_size) { } size = p_size.max(Vector2()); - ; _update(); } @@ -237,7 +236,6 @@ void BoxOccluder3D::set_size(const Vector3 &p_size) { } size = Vector3(MAX(p_size.x, 0.0f), MAX(p_size.y, 0.0f), MAX(p_size.z, 0.0f)); - ; _update(); } diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 68c9ff8ece..b9fb3e9287 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -696,10 +696,6 @@ Rect2 Sprite3D::get_item_rect() const { if (texture.is_null()) { return Rect2(0, 0, 1, 1); } - /* - if (texture.is_null()) - return CanvasItem::get_item_rect(); - */ Size2 s; diff --git a/scene/3d/vehicle_body_3d.cpp b/scene/3d/vehicle_body_3d.cpp index a5fd3a7dd0..8d02d26fc4 100644 --- a/scene/3d/vehicle_body_3d.cpp +++ b/scene/3d/vehicle_body_3d.cpp @@ -116,9 +116,7 @@ TypedArray<String> VehicleWheel3D::get_configuration_warnings() const { } void VehicleWheel3D::_update(PhysicsDirectBodyState3D *s) { - if (m_raycastInfo.m_isInContact) - - { + if (m_raycastInfo.m_isInContact) { real_t project = m_raycastInfo.m_contactNormalWS.dot(m_raycastInfo.m_wheelDirectionWS); Vector3 chassis_velocity_at_contactPoint; Vector3 relpos = m_raycastInfo.m_contactPointWS - s->get_transform().origin; @@ -135,11 +133,7 @@ void VehicleWheel3D::_update(PhysicsDirectBodyState3D *s) { m_suspensionRelativeVelocity = projVel * inv; m_clippedInvContactDotSuspension = inv; } - - } - - else // Not in contact : position wheel in a nice (rest length) position - { + } else { // Not in contact : position wheel in a nice (rest length) position m_raycastInfo.m_suspensionLength = m_suspensionRestLength; m_suspensionRelativeVelocity = real_t(0.0); m_raycastInfo.m_contactNormalWS = -m_raycastInfo.m_wheelDirectionWS; diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 7ad76e43a2..e243915c13 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -595,18 +595,12 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double } if (update_mode == Animation::UPDATE_CONTINUOUS || update_mode == Animation::UPDATE_CAPTURE || (p_delta == 0 && update_mode == Animation::UPDATE_DISCRETE)) { //delta == 0 means seek - Variant value = a->value_track_interpolate(i, p_time); if (value == Variant()) { continue; } - //thanks to trigger mode, this should be solved now.. - /* - if (p_delta==0 && value.get_type()==Variant::STRING) - continue; // doing this with strings is messy, should find another way - */ if (pa->accum_pass != accum_pass) { ERR_CONTINUE(cache_update_prop_size >= NODE_CACHE_UPDATE_MAX); cache_update_prop[cache_update_prop_size++] = pa; diff --git a/scene/gui/nine_patch_rect.cpp b/scene/gui/nine_patch_rect.cpp index 7940056e2f..4f34ece86f 100644 --- a/scene/gui/nine_patch_rect.cpp +++ b/scene/gui/nine_patch_rect.cpp @@ -95,10 +95,6 @@ void NinePatchRect::set_texture(const Ref<Texture2D> &p_tex) { } texture = p_tex; update(); - /* - if (texture.is_valid()) - texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites - */ update_minimum_size(); emit_signal(SceneStringNames::get_singleton()->texture_changed); } diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index b04cb39920..e1b0e8cca8 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -426,11 +426,6 @@ double ScrollBar::get_grabber_size() const { } float page = (get_page() > 0) ? get_page() : 0; - /* - if (grabber_range < get_step()) - grabber_range=get_step(); - */ - double area_size = get_area_size(); double grabber_size = page / range * area_size; return grabber_size + get_grabber_min_size(); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index fc0258a760..73cf2b9c6e 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1701,8 +1701,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 bool skip = (p_item == root && hide_root); if (!skip && (p_pos.y + label_h - cache.offset.y) > 0) { - //draw separation. - //if (p_item->get_parent()!=root || !hide_root) + // Draw separation. ERR_FAIL_COND_V(cache.font.is_null(), -1); @@ -2259,11 +2258,6 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c emit_signal(SNAME("item_selected")); emitted_row = true; } - /* - if (p_col==i) - p_current->selected_signal.call(p_col); - */ - } else if (c.selected) { if (p_selected != p_current) { // Deselect other rows. @@ -4065,10 +4059,6 @@ int Tree::get_edited_column() const { } TreeItem *Tree::get_next_selected(TreeItem *p_item) { - /* - if (!p_item) - return nullptr; - */ if (!root) { return nullptr; } diff --git a/scene/gui/video_stream_player.cpp b/scene/gui/video_stream_player.cpp index 17dd3123f5..d7c76aa070 100644 --- a/scene/gui/video_stream_player.cpp +++ b/scene/gui/video_stream_player.cpp @@ -240,11 +240,11 @@ void VideoStreamPlayer::set_stream(const Ref<VideoStream> &p_stream) { if (!expand) { update_minimum_size(); } -}; +} Ref<VideoStream> VideoStreamPlayer::get_stream() const { return stream; -}; +} void VideoStreamPlayer::play() { ERR_FAIL_COND(!is_inside_tree()); @@ -254,10 +254,8 @@ void VideoStreamPlayer::play() { playback->stop(); playback->play(); set_process_internal(true); - // AudioServer::get_singleton()->stream_set_active(stream_rid,true); - // AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume); last_audio_time = 0; -}; +} void VideoStreamPlayer::stop() { if (!is_inside_tree()) { @@ -268,11 +266,10 @@ void VideoStreamPlayer::stop() { } playback->stop(); - // AudioServer::get_singleton()->stream_set_active(stream_rid,false); resampler.flush(); set_process_internal(false); last_audio_time = 0; -}; +} bool VideoStreamPlayer::is_playing() const { if (playback.is_null()) { @@ -280,16 +277,16 @@ bool VideoStreamPlayer::is_playing() const { } return playback->is_playing(); -}; +} void VideoStreamPlayer::set_paused(bool p_paused) { paused = p_paused; if (playback.is_valid()) { playback->set_paused(p_paused); set_process_internal(!p_paused); - }; + } last_audio_time = 0; -}; +} bool VideoStreamPlayer::is_paused() const { return paused; @@ -313,11 +310,11 @@ int VideoStreamPlayer::get_audio_track() const { void VideoStreamPlayer::set_volume(float p_vol) { volume = p_vol; -}; +} float VideoStreamPlayer::get_volume() const { return volume; -}; +} void VideoStreamPlayer::set_volume_db(float p_db) { if (p_db < -79) { @@ -325,7 +322,7 @@ void VideoStreamPlayer::set_volume_db(float p_db) { } else { set_volume(Math::db2linear(p_db)); } -}; +} float VideoStreamPlayer::get_volume_db() const { if (volume == 0) { @@ -333,21 +330,21 @@ float VideoStreamPlayer::get_volume_db() const { } else { return Math::linear2db(volume); } -}; +} String VideoStreamPlayer::get_stream_name() const { if (stream.is_null()) { return "<No Stream>"; } return stream->get_name(); -}; +} float VideoStreamPlayer::get_stream_position() const { if (playback.is_null()) { return 0; } return playback->get_playback_position(); -}; +} void VideoStreamPlayer::set_stream_position(float p_position) { if (playback.is_valid()) { @@ -365,14 +362,14 @@ Ref<Texture2D> VideoStreamPlayer::get_video_texture() const { void VideoStreamPlayer::set_autoplay(bool p_enable) { autoplay = p_enable; -}; +} bool VideoStreamPlayer::has_autoplay() const { return autoplay; -}; +} void VideoStreamPlayer::set_bus(const StringName &p_bus) { - //if audio is active, must lock this + // If audio is active, must lock this. AudioServer::get_singleton()->lock(); bus = p_bus; AudioServer::get_singleton()->unlock(); @@ -446,7 +443,6 @@ void VideoStreamPlayer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "audio_track", PROPERTY_HINT_RANGE, "0,128,1"), "set_audio_track", "get_audio_track"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "VideoStream"), "set_stream", "get_stream"); - //ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), "set_loop", "has_loop") ; ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01"), "set_volume_db", "get_volume_db"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volume", PROPERTY_HINT_RANGE, "0,15,0.01,exp", PROPERTY_USAGE_NONE), "set_volume", "get_volume"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "has_autoplay"); @@ -461,7 +457,5 @@ void VideoStreamPlayer::_bind_methods() { VideoStreamPlayer::VideoStreamPlayer() {} VideoStreamPlayer::~VideoStreamPlayer() { - // if (stream_rid.is_valid()) - // AudioServer::get_singleton()->free(stream_rid); - resampler.clear(); //Not necessary here, but make in consistent with other "stream_player" classes -}; + resampler.clear(); // Not necessary here, but make in consistent with other "stream_player" classes. +} diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index f9a4eba978..9d388d465d 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -529,10 +529,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map if (!gi.persistent) { continue; } - /* - if (instance_state_node>=0 && instance_state->is_node_in_group(instance_state_node,gi.name)) - continue; //group was instantiated, don't add here - */ bool skip = false; for (const SceneState::PackState &ia : states_stack) { diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index 52151ae846..8ff1fde2cf 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -150,12 +150,15 @@ uint32_t SurfaceTool::TriangleHasher::hash(const int *p_triangle) { int t1 = p_triangle[1]; int t2 = p_triangle[2]; - if (t0 > t1) + if (t0 > t1) { SWAP(t0, t1); - if (t1 > t2) + } + if (t1 > t2) { SWAP(t1, t2); - if (t0 > t1) + } + if (t0 > t1) { SWAP(t0, t1); + } return (t0 * 73856093) ^ (t1 * 19349663) ^ (t2 * 83492791); } @@ -165,23 +168,29 @@ bool SurfaceTool::TriangleHasher::compare(const int *p_lhs, const int *p_rhs) { int r1 = p_rhs[1]; int r2 = p_rhs[2]; - if (r0 > r1) + if (r0 > r1) { SWAP(r0, r1); - if (r1 > r2) + } + if (r1 > r2) { SWAP(r1, r2); - if (r0 > r1) + } + if (r0 > r1) { SWAP(r0, r1); + } int l0 = p_lhs[0]; int l1 = p_lhs[1]; int l2 = p_lhs[2]; - if (l0 > l1) + if (l0 > l1) { SWAP(l0, l1); - if (l1 > l2) + } + if (l1 > l2) { SWAP(l1, l2); - if (l0 > l1) + } + if (l0 > l1) { SWAP(l0, l1); + } return l0 == r0 && l1 == r1 && l2 == r2; } diff --git a/scene/resources/visual_shader_particle_nodes.cpp b/scene/resources/visual_shader_particle_nodes.cpp index 1885211d57..398c33c452 100644 --- a/scene/resources/visual_shader_particle_nodes.cpp +++ b/scene/resources/visual_shader_particle_nodes.cpp @@ -1318,7 +1318,7 @@ String VisualShaderNodeParticleOutput::generate_code(Shader::Mode p_mode, Visual code += tab + "TRANSFORM = " + p_input_vars[5] + ";\n"; } } else { - if (!p_input_vars[0].is_empty()) { // active (begin) + if (!p_input_vars[0].is_empty()) { // Active (begin). code += tab + "ACTIVE = " + p_input_vars[0] + ";\n"; code += tab + "if(ACTIVE) {\n"; tab += " "; @@ -1381,7 +1381,7 @@ String VisualShaderNodeParticleOutput::generate_code(Shader::Mode p_mode, Visual code += tab + "TRANSFORM " + op + " mat4(vec4(" + p_input_vars[scale] + ", 0, 0, 0), vec4(0, " + p_input_vars[scale] + ", 0, 0), vec4(0, 0, " + p_input_vars[scale] + ", 0), vec4(0, 0, 0, 1));\n"; } } - if (!p_input_vars[0].is_empty()) { // active (end) + if (!p_input_vars[0].is_empty()) { // Active (end). code += " }\n"; } } diff --git a/servers/audio/effects/audio_effect_delay.cpp b/servers/audio/effects/audio_effect_delay.cpp index bddd235204..1909ab6eae 100644 --- a/servers/audio/effects/audio_effect_delay.cpp +++ b/servers/audio/effects/audio_effect_delay.cpp @@ -54,15 +54,12 @@ void AudioEffectDelayInstance::_process_chunk(const AudioFrame *p_src_frames, Au float tap_1_level_f = base->tap_1_active ? Math::db2linear(base->tap_1_level) : 0.0; int tap_1_delay_frames = int((base->tap_1_delay_ms / 1000.0) * mix_rate); - ; float tap_2_level_f = base->tap_2_active ? Math::db2linear(base->tap_2_level) : 0.0; int tap_2_delay_frames = int((base->tap_2_delay_ms / 1000.0) * mix_rate); - ; float feedback_level_f = base->feedback_active ? Math::db2linear(base->feedback_level) : 0.0; unsigned int feedback_delay_frames = int((base->feedback_delay_ms / 1000.0) * mix_rate); - ; AudioFrame tap1_vol = AudioFrame(tap_1_level_f, tap_1_level_f); diff --git a/servers/audio/effects/audio_effect_stereo_enhance.cpp b/servers/audio/effects/audio_effect_stereo_enhance.cpp index 757edd6d43..c81efc55e2 100644 --- a/servers/audio/effects/audio_effect_stereo_enhance.cpp +++ b/servers/audio/effects/audio_effect_stereo_enhance.cpp @@ -61,7 +61,6 @@ void AudioEffectStereoEnhanceInstance::process(const AudioFrame *p_src_frames, A //r is delayed r = delay_ringbuff[(ringbuff_pos - delay_frames) & ringbuff_mask]; - ; } p_dst_frames[i].l = l; diff --git a/servers/physics_2d/godot_body_pair_2d.cpp b/servers/physics_2d/godot_body_pair_2d.cpp index 1986191cc3..2bf1e5a1d4 100644 --- a/servers/physics_2d/godot_body_pair_2d.cpp +++ b/servers/physics_2d/godot_body_pair_2d.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "godot_body_pair_2d.h" + #include "godot_collision_solver_2d.h" #include "godot_space_2d.h" @@ -303,7 +304,7 @@ bool GodotBodyPair2D::setup(real_t p_step) { bool valid = false; for (int i = 0; i < contact_count; i++) { Contact &c = contacts[i]; - if (c.normal.dot(direction) > -CMP_EPSILON) { //greater (normal inverted) + if (c.normal.dot(direction) > -CMP_EPSILON) { // Greater (normal inverted). continue; } valid = true; @@ -321,7 +322,7 @@ bool GodotBodyPair2D::setup(real_t p_step) { bool valid = false; for (int i = 0; i < contact_count; i++) { Contact &c = contacts[i]; - if (c.normal.dot(direction) < CMP_EPSILON) { //less (normal ok) + if (c.normal.dot(direction) < CMP_EPSILON) { // Less (normal ok). continue; } valid = true; diff --git a/servers/physics_2d/godot_collision_solver_2d_sat.cpp b/servers/physics_2d/godot_collision_solver_2d_sat.cpp index a965795bee..ded3ff356b 100644 --- a/servers/physics_2d/godot_collision_solver_2d_sat.cpp +++ b/servers/physics_2d/godot_collision_solver_2d_sat.cpp @@ -41,10 +41,6 @@ struct _CollectorCallback2D { Vector2 *sep_axis = nullptr; _FORCE_INLINE_ void call(const Vector2 &p_point_A, const Vector2 &p_point_B) { - /* - if (normal.dot(p_point_A) >= normal.dot(p_point_B)) - return; - */ if (swap) { callback(p_point_B, p_point_A, userdata); } else { diff --git a/servers/physics_2d/godot_physics_server_2d.cpp b/servers/physics_2d/godot_physics_server_2d.cpp index 5e099e27ec..a9b499c6b5 100644 --- a/servers/physics_2d/godot_physics_server_2d.cpp +++ b/servers/physics_2d/godot_physics_server_2d.cpp @@ -1188,14 +1188,6 @@ void GodotPhysicsServer2D::free(RID p_rid) { } else if (body_owner.owns(p_rid)) { GodotBody2D *body = body_owner.get_or_null(p_rid); - /* - if (body->get_state_query()) - _clear_query(body->get_state_query()); - - if (body->get_direct_state_query()) - _clear_query(body->get_direct_state_query()); - */ - body_set_space(p_rid, RID()); while (body->get_shape_count()) { @@ -1208,11 +1200,6 @@ void GodotPhysicsServer2D::free(RID p_rid) { } else if (area_owner.owns(p_rid)) { GodotArea2D *area = area_owner.get_or_null(p_rid); - /* - if (area->get_monitor_query()) - _clear_query(area->get_monitor_query()); - */ - area->set_space(nullptr); while (area->get_shape_count()) { diff --git a/servers/physics_2d/godot_shape_2d.cpp b/servers/physics_2d/godot_shape_2d.cpp index 1e8799a727..b5dbb8a2dd 100644 --- a/servers/physics_2d/godot_shape_2d.cpp +++ b/servers/physics_2d/godot_shape_2d.cpp @@ -544,12 +544,6 @@ bool GodotConvexPolygonShape2D::intersect_segment(const Vector2 &p_begin, const bool inters = false; for (int i = 0; i < point_count; i++) { - //hmm.. no can do.. - /* - if (d.dot(points[i].normal)>=0) - continue; - */ - Vector2 res; if (!Geometry2D::segment_intersects_segment(p_begin, p_end, points[i].pos, points[(i + 1) % point_count].pos, &res)) { diff --git a/servers/physics_3d/gjk_epa.cpp b/servers/physics_3d/gjk_epa.cpp index 928ffe0980..23c8079538 100644 --- a/servers/physics_3d/gjk_epa.cpp +++ b/servers/physics_3d/gjk_epa.cpp @@ -918,7 +918,7 @@ bool Distance( const GodotShape3D* shape0, { results.status = gjk_status==GJK::eStatus::Inside? sResults::Penetrating : - sResults::GJK_Failed ; + sResults::GJK_Failed; return(false); } } diff --git a/servers/physics_3d/godot_collision_solver_3d_sat.cpp b/servers/physics_3d/godot_collision_solver_3d_sat.cpp index 82e04a7e31..ca429040f5 100644 --- a/servers/physics_3d/godot_collision_solver_3d_sat.cpp +++ b/servers/physics_3d/godot_collision_solver_3d_sat.cpp @@ -345,10 +345,6 @@ static void _generate_contacts_face_face(const Vector3 *p_points_A, int p_point_ for (int i = 0; i < clipbuf_len; i++) { real_t d = plane_B.distance_to(clipbuf_src[i]); - /* - if (d>CMP_EPSILON) - continue; - */ Vector3 closest_B = clipbuf_src[i] - plane_B.normal * d; diff --git a/servers/physics_3d/godot_physics_server_3d.cpp b/servers/physics_3d/godot_physics_server_3d.cpp index 4e1680e6ac..a1912dc660 100644 --- a/servers/physics_3d/godot_physics_server_3d.cpp +++ b/servers/physics_3d/godot_physics_server_3d.cpp @@ -1540,14 +1540,6 @@ void GodotPhysicsServer3D::free(RID p_rid) { } else if (body_owner.owns(p_rid)) { GodotBody3D *body = body_owner.get_or_null(p_rid); - /* - if (body->get_state_query()) - _clear_query(body->get_state_query()); - - if (body->get_direct_state_query()) - _clear_query(body->get_direct_state_query()); - */ - body->set_space(nullptr); while (body->get_shape_count()) { @@ -1566,11 +1558,6 @@ void GodotPhysicsServer3D::free(RID p_rid) { } else if (area_owner.owns(p_rid)) { GodotArea3D *area = area_owner.get_or_null(p_rid); - /* - if (area->get_monitor_query()) - _clear_query(area->get_monitor_query()); - */ - area->set_space(nullptr); while (area->get_shape_count()) { diff --git a/servers/physics_3d/godot_shape_3d.cpp b/servers/physics_3d/godot_shape_3d.cpp index 666e773c1c..7762c4829e 100644 --- a/servers/physics_3d/godot_shape_3d.cpp +++ b/servers/physics_3d/godot_shape_3d.cpp @@ -1284,12 +1284,6 @@ Vector3 GodotConcavePolygonShape3D::get_support(const Vector3 &p_normal) const { void GodotConcavePolygonShape3D::_cull_segment(int p_idx, _SegmentCullParams *p_params) const { const BVH *bvh = &p_params->bvh[p_idx]; - /* - if (p_params->dir.dot(bvh->aabb.get_support(-p_params->dir))>p_params->min_d) - return; //test against whole AABB, which isn't very costly - */ - - //printf("addr: %p\n",bvh); if (!bvh->aabb.intersects_segment(p_params->from, p_params->to)) { return; } diff --git a/servers/physics_3d/joints/godot_hinge_joint_3d.cpp b/servers/physics_3d/joints/godot_hinge_joint_3d.cpp index a7a7843499..1c4d5dec23 100644 --- a/servers/physics_3d/joints/godot_hinge_joint_3d.cpp +++ b/servers/physics_3d/joints/godot_hinge_joint_3d.cpp @@ -213,16 +213,12 @@ bool GodotHingeJoint3D::setup(real_t p_step) { m_solveLimit = false; m_accLimitImpulse = real_t(0.); - //if (m_lowerLimit < m_upperLimit) if (m_useLimit && m_lowerLimit <= m_upperLimit) { - //if (hingeAngle <= m_lowerLimit*m_limitSoftness) if (hingeAngle <= m_lowerLimit) { m_correction = (m_lowerLimit - hingeAngle); m_limitSign = 1.0f; m_solveLimit = true; - } - //else if (hingeAngle >= m_upperLimit*m_limitSoftness) - else if (hingeAngle >= m_upperLimit) { + } else if (hingeAngle >= m_upperLimit) { m_correction = m_upperLimit - hingeAngle; m_limitSign = -1.0f; m_solveLimit = true; diff --git a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp index cb07c75db4..1a84bafbd0 100644 --- a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp @@ -1894,7 +1894,6 @@ void RendererSceneGIRD::SDFGI::render_static_lights(RID p_render_buffers, uint32 RD::get_singleton()->draw_command_begin_label("SDFGI Render Static Lighs"); update_cascades(); - ; //need cascades updated for this SDFGIShader::Light lights[SDFGI::MAX_STATIC_LIGHTS]; uint32_t light_count[SDFGI::MAX_STATIC_LIGHTS]; diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl index 97f7e0a6e6..5d65b00bee 100644 --- a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl +++ b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl @@ -552,7 +552,6 @@ void cluster_get_item_range(uint p_offset, out uint item_min, out uint item_max, uint item_min_max = cluster_buffer.data[p_offset]; item_min = item_min_max & 0xFFFF; item_max = item_min_max >> 16; - ; item_from = item_min >> 5; item_to = (item_max == 0) ? 0 : ((item_max - 1) >> 5) + 1; //side effect of how it is stored, as item_max 0 means no elements diff --git a/servers/rendering/renderer_rd/shaders/volumetric_fog_process.glsl b/servers/rendering/renderer_rd/shaders/volumetric_fog_process.glsl index 7c8d4f7f99..7a0cea421e 100644 --- a/servers/rendering/renderer_rd/shaders/volumetric_fog_process.glsl +++ b/servers/rendering/renderer_rd/shaders/volumetric_fog_process.glsl @@ -235,7 +235,6 @@ void cluster_get_item_range(uint p_offset, out uint item_min, out uint item_max, uint item_min_max = cluster_buffer.data[p_offset]; item_min = item_min_max & 0xFFFF; item_max = item_min_max >> 16; - ; item_from = item_min >> 5; item_to = (item_max == 0) ? 0 : ((item_max - 1) >> 5) + 1; //side effect of how it is stored, as item_max 0 means no elements diff --git a/servers/rendering/shader_compiler.cpp b/servers/rendering/shader_compiler.cpp index 5b43ca4bcd..a0b0b31a7b 100644 --- a/servers/rendering/shader_compiler.cpp +++ b/servers/rendering/shader_compiler.cpp @@ -609,7 +609,6 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene r_gen_code.uniforms += uniform_defines[i]; } -#if 1 // add up int offset = 0; for (int i = 0; i < uniform_sizes.size(); i++) { @@ -629,41 +628,6 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene if (r_gen_code.uniform_total_size % 16 != 0) { //UBO sizes must be multiples of 16 r_gen_code.uniform_total_size += 16 - (r_gen_code.uniform_total_size % 16); } -#else - // add up - for (int i = 0; i < uniform_sizes.size(); i++) { - if (i > 0) { - int align = uniform_sizes[i - 1] % uniform_alignments[i]; - if (align != 0) { - uniform_sizes[i - 1] += uniform_alignments[i] - align; - } - - uniform_sizes[i] = uniform_sizes[i] + uniform_sizes[i - 1]; - } - } - //offset - r_gen_code.uniform_offsets.resize(uniform_sizes.size()); - for (int i = 0; i < uniform_sizes.size(); i++) { - if (i > 0) - r_gen_code.uniform_offsets[i] = uniform_sizes[i - 1]; - else - r_gen_code.uniform_offsets[i] = 0; - } - /* - for(Map<StringName,SL::ShaderNode::Uniform>::Element *E=pnode->uniforms.front();E;E=E->next()) { - if (SL::is_sampler_type(E->get().type)) { - continue; - } - - } - -*/ - if (uniform_sizes.size()) { - r_gen_code.uniform_total_size = uniform_sizes[uniform_sizes.size() - 1]; - } else { - r_gen_code.uniform_total_size = 0; - } -#endif uint32_t index = p_default_actions.base_varying_index; diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 91201b2028..7683cf20b3 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "shader_language.h" + #include "core/os/os.h" #include "core/string/print_string.h" #include "servers/rendering_server.h" @@ -632,7 +633,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() { char32_t last_char = str[str.length() - 1]; - if (hexa_found) { // Integer(hex) + if (hexa_found) { // Integer (hex). if (str.size() > 11 || !str.is_valid_hex_number(true)) { // > 0xFFFFFFFF return _make_token(TK_ERROR, "Invalid (hexadecimal) numeric constant"); } diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 2037268134..a7fcbcce42 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -429,7 +429,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], &value, 4); } - } else { // if (type == Variant::PACKED_FLOAT64_ARRAY) + } else { // PACKED_FLOAT64_ARRAY Vector<double> array = p_arrays[ai]; ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER); const double *src = array.ptr(); @@ -573,7 +573,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint memcpy(&sw[p_offsets[ai] + i * p_skin_stride], data, 2 * bone_count); } } - } else { // if (type == Variant::PACKED_FLOAT64_ARRAY) + } else { // PACKED_FLOAT64_ARRAY Vector<double> array = p_arrays[ai]; ERR_FAIL_COND_V(array.size() != (int32_t)(p_vertex_array_len * bone_count), ERR_INVALID_PARAMETER); const double *src = array.ptr(); diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h index bf78298450..87016dddf6 100644 --- a/tests/core/string/test_string.h +++ b/tests/core/string/test_string.h @@ -39,7 +39,7 @@ namespace TestString { int u32scmp(const char32_t *l, const char32_t *r) { for (; *l == *r && *l && *r; l++, r++) { - ; + // Continue. } return *l - *r; } diff --git a/tests/servers/test_physics_2d.cpp b/tests/servers/test_physics_2d.cpp index 8b77458a33..138412ec09 100644 --- a/tests/servers/test_physics_2d.cpp +++ b/tests/servers/test_physics_2d.cpp @@ -84,6 +84,7 @@ class TestPhysics2DMainLoop : public MainLoop { body_shape_data[PhysicsServer2D::SHAPE_SEGMENT].shape = segment_shape; } + // CIRCLE { @@ -182,10 +183,7 @@ class TestPhysics2DMainLoop : public MainLoop { } void _do_ray_query() { - /* - PhysicsServer2D *ps = PhysicsServer2D::get_singleton(); - ps->query_intersection_segment(ray_query,ray_from,ray_to); - */ + // FIXME: Do something? } protected: @@ -231,11 +229,10 @@ protected: ps->body_set_continuous_collision_detection_mode(body, PhysicsServer2D::CCD_MODE_CAST_SHAPE); ps->body_set_state(body, PhysicsServer2D::BODY_STATE_TRANSFORM, p_xform); - //print_line("add body with xform: "+p_xform); RID sprite = vs->canvas_item_create(); vs->canvas_item_set_parent(sprite, canvas); vs->canvas_item_set_transform(sprite, p_xform); - Size2 imgsize(5, 5); //vs->texture_get_width(body_shape_data[p_shape].image), vs->texture_get_height(body_shape_data[p_shape].image)); + Size2 imgsize(5, 5); vs->canvas_item_add_texture_rect(sprite, Rect2(-imgsize / 2.0, imgsize), body_shape_data[p_shape].image); ps->body_set_force_integration_callback(body, callable_mp(this, &TestPhysics2DMainLoop::_body_moved), sprite); @@ -326,21 +323,11 @@ public: vs->viewport_set_size(vp, screen_size.x, screen_size.y); vs->viewport_attach_to_screen(vp, Rect2(Vector2(), screen_size)); vs->viewport_set_active(vp, true); - - Transform2D smaller; - //smaller.scale(Vector2(0.6,0.6)); - //smaller.elements[2]=Vector2(100,0); - - //view_xform = smaller; vs->viewport_set_canvas_transform(vp, canvas, view_xform); } ray = vs->canvas_item_create(); vs->canvas_item_set_parent(ray, canvas); - //ray_query = ps->query_create(this,"_ray_query_callback",Variant()); - //ps->query_intersection(ray_query,space); - - _create_body_shape_data(); for (int i = 0; i < 32; i++) { PhysicsServer2D::ShapeType types[4] = { @@ -352,17 +339,9 @@ public: }; PhysicsServer2D::ShapeType type = types[i % 4]; - //type=PhysicsServer2D::SHAPE_SEGMENT; _add_body(type, Transform2D(i * 0.8, Point2(152 + i * 40, 100 - 40 * i))); - /* - if (i==0) - ps->body_set_mode(b,PhysicsServer2D::BODY_MODE_STATIC); - */ } - //RID b= _add_body(PhysicsServer2D::SHAPE_CIRCLE,Transform2D(0,Point2(101,140))); - //ps->body_set_mode(b,PhysicsServer2D::BODY_MODE_STATIC); - Point2 prev; Vector<Point2> parr; @@ -376,9 +355,6 @@ public: } _add_concave(parr); - //_add_world_boundary(Vector2(0.0,-1).normalized(),-300); - //_add_world_boundary(Vector2(1,0).normalized(),50); - //_add_world_boundary(Vector2(-1,0).normalized(),-600); } virtual bool process(double p_time) override { |