From 710b34b70227becdc652b4ae027fe0ac47409642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 13:20:05 +0200 Subject: Style: Fix missing/invalid copyright headers --- modules/denoise/denoise_wrapper.cpp | 30 ++++++++++++++++++++++ modules/denoise/denoise_wrapper.h | 30 ++++++++++++++++++++++ modules/lightmapper_rd/lightmapper_rd.cpp | 30 ++++++++++++++++++++++ modules/lightmapper_rd/lightmapper_rd.h | 30 ++++++++++++++++++++++ .../websocket/editor_debugger_server_websocket.cpp | 6 ++--- .../websocket/editor_debugger_server_websocket.h | 6 ++--- .../websocket/remote_debugger_peer_websocket.cpp | 6 ++--- modules/websocket/remote_debugger_peer_websocket.h | 6 ++--- 8 files changed, 132 insertions(+), 12 deletions(-) (limited to 'modules') diff --git a/modules/denoise/denoise_wrapper.cpp b/modules/denoise/denoise_wrapper.cpp index feeeaef507..c12c6d9c31 100644 --- a/modules/denoise/denoise_wrapper.cpp +++ b/modules/denoise/denoise_wrapper.cpp @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* denoise_wrapper.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 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 "denoise_wrapper.h" #include "thirdparty/oidn/include/OpenImageDenoise/oidn.h" #include diff --git a/modules/denoise/denoise_wrapper.h b/modules/denoise/denoise_wrapper.h index 3aef326e22..2107df09c1 100644 --- a/modules/denoise/denoise_wrapper.h +++ b/modules/denoise/denoise_wrapper.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* denoise_wrapper.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 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 DENOISE_WRAPPER_H #define DENOISE_WRAPPER_H diff --git a/modules/lightmapper_rd/lightmapper_rd.cpp b/modules/lightmapper_rd/lightmapper_rd.cpp index 6983c222c0..10f8512237 100644 --- a/modules/lightmapper_rd/lightmapper_rd.cpp +++ b/modules/lightmapper_rd/lightmapper_rd.cpp @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* lightmapper_rd.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 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 "lightmapper_rd.h" #include "core/math/geometry.h" #include "core/project_settings.h" diff --git a/modules/lightmapper_rd/lightmapper_rd.h b/modules/lightmapper_rd/lightmapper_rd.h index cb98efbeaa..c6f1b0e710 100644 --- a/modules/lightmapper_rd/lightmapper_rd.h +++ b/modules/lightmapper_rd/lightmapper_rd.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* lightmapper_rd.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 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 LIGHTMAPPER_RD_H #define LIGHTMAPPER_RD_H diff --git a/modules/websocket/editor_debugger_server_websocket.cpp b/modules/websocket/editor_debugger_server_websocket.cpp index 0cf78eaa9e..66f3dac907 100644 --- a/modules/websocket/editor_debugger_server_websocket.cpp +++ b/modules/websocket/editor_debugger_server_websocket.cpp @@ -1,12 +1,12 @@ /*************************************************************************/ -/* script_editor_debugger_websocket.cpp */ +/* editor_debugger_server_websocket.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 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 */ diff --git a/modules/websocket/editor_debugger_server_websocket.h b/modules/websocket/editor_debugger_server_websocket.h index 81a31d8364..cd2c1e45cd 100644 --- a/modules/websocket/editor_debugger_server_websocket.h +++ b/modules/websocket/editor_debugger_server_websocket.h @@ -1,12 +1,12 @@ /*************************************************************************/ -/* script_editor_debugger_websocket.h */ +/* editor_debugger_server_websocket.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 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 */ diff --git a/modules/websocket/remote_debugger_peer_websocket.cpp b/modules/websocket/remote_debugger_peer_websocket.cpp index d156a39f53..6ff03651d1 100644 --- a/modules/websocket/remote_debugger_peer_websocket.cpp +++ b/modules/websocket/remote_debugger_peer_websocket.cpp @@ -1,12 +1,12 @@ /*************************************************************************/ -/* script_debugger_websocket.cpp */ +/* remote_debugger_peer_websocket.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 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 */ diff --git a/modules/websocket/remote_debugger_peer_websocket.h b/modules/websocket/remote_debugger_peer_websocket.h index fe46533bed..33e4edaa21 100644 --- a/modules/websocket/remote_debugger_peer_websocket.h +++ b/modules/websocket/remote_debugger_peer_websocket.h @@ -1,12 +1,12 @@ /*************************************************************************/ -/* script_debugger_websocket.h */ +/* remote_debugger_peer_websocket.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 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 */ -- cgit v1.2.3 From 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 13:23:58 +0200 Subject: Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027. --- modules/assimp/editor_scene_importer_assimp.cpp | 25 -- modules/assimp/import_state.h | 1 - modules/assimp/import_utils.h | 2 - modules/assimp/register_types.cpp | 1 - modules/basis_universal/register_types.cpp | 5 - modules/bmp/image_loader_bmp.cpp | 4 - modules/bullet/area_bullet.cpp | 2 - modules/bullet/btRayShape.cpp | 3 - modules/bullet/btRayShape.h | 1 - modules/bullet/bullet_physics_server.cpp | 21 - modules/bullet/collision_object_bullet.cpp | 2 - modules/bullet/cone_twist_joint_bullet.cpp | 2 - modules/bullet/constraint_bullet.h | 1 - modules/bullet/generic_6dof_joint_bullet.cpp | 1 - modules/bullet/godot_collision_configuration.cpp | 22 -- modules/bullet/godot_motion_state.h | 1 - modules/bullet/godot_ray_world_algorithm.cpp | 4 - modules/bullet/godot_ray_world_algorithm.h | 3 - modules/bullet/godot_result_callbacks.cpp | 5 - modules/bullet/hinge_joint_bullet.cpp | 5 - modules/bullet/joint_bullet.h | 1 - modules/bullet/pin_joint_bullet.cpp | 1 - modules/bullet/rigid_body_bullet.cpp | 19 - modules/bullet/rigid_body_bullet.h | 2 - modules/bullet/shape_bullet.cpp | 5 - modules/bullet/shape_bullet.h | 9 - modules/bullet/slider_joint_bullet.cpp | 2 - modules/bullet/soft_body_bullet.cpp | 6 - modules/bullet/soft_body_bullet.h | 1 - modules/bullet/space_bullet.cpp | 38 -- modules/bullet/space_bullet.h | 1 - modules/csg/csg.cpp | 69 ---- modules/csg/csg.h | 4 - modules/csg/csg_gizmos.cpp | 18 - modules/csg/csg_gizmos.h | 1 - modules/csg/csg_shape.cpp | 84 ---- modules/csg/csg_shape.h | 5 - modules/csg/register_types.cpp | 1 - modules/cvtt/image_compress_cvtt.cpp | 4 - modules/cvtt/register_types.cpp | 1 - modules/dds/register_types.cpp | 2 - modules/dds/texture_loader_dds.cpp | 43 --- modules/denoise/lightmap_denoiser.cpp | 1 - modules/denoise/lightmap_denoiser.h | 1 - modules/denoise/register_types.cpp | 1 - modules/enet/networked_multiplayer_enet.cpp | 60 --- modules/enet/networked_multiplayer_enet.h | 2 - modules/enet/register_types.cpp | 2 - modules/etc/image_etc.cpp | 1 - modules/etc/register_types.cpp | 2 - modules/etc/texture_loader_pkm.cpp | 4 - modules/gdnative/gdnative.cpp | 8 - modules/gdnative/gdnative/color.cpp | 2 - modules/gdnative/gdnative/gdnative.cpp | 2 - modules/gdnative/gdnative/plane.cpp | 1 - modules/gdnative/gdnative/quat.cpp | 1 - modules/gdnative/gdnative/rect2.cpp | 1 - modules/gdnative/gdnative/vector2.cpp | 1 - modules/gdnative/gdnative/vector3.cpp | 1 - .../gdnative/gdnative_library_editor_plugin.cpp | 22 -- modules/gdnative/gdnative_library_editor_plugin.h | 2 - .../gdnative/gdnative_library_singleton_editor.cpp | 6 - modules/gdnative/include/net/godot_net.h | 1 - modules/gdnative/nativescript/api_generator.cpp | 7 - .../gdnative/nativescript/godot_nativescript.cpp | 6 - modules/gdnative/nativescript/nativescript.cpp | 49 --- modules/gdnative/nativescript/nativescript.h | 3 - modules/gdnative/nativescript/register_types.cpp | 1 - modules/gdnative/net/multiplayer_peer_gdnative.cpp | 1 - modules/gdnative/net/packet_peer_gdnative.cpp | 1 - modules/gdnative/net/stream_peer_gdnative.h | 1 - .../gdnative/pluginscript/pluginscript_loader.cpp | 2 - .../gdnative/pluginscript/pluginscript_loader.h | 2 - .../gdnative/pluginscript/pluginscript_script.cpp | 5 - .../gdnative/pluginscript/pluginscript_script.h | 1 - modules/gdnative/register_types.cpp | 7 - modules/gdnative/videodecoder/register_types.cpp | 2 - .../videodecoder/video_stream_gdnative.cpp | 8 - .../gdnative/videodecoder/video_stream_gdnative.h | 2 - modules/gdnative/xr/xr_interface_gdnative.cpp | 8 - modules/gdnavigation/gd_navigation_server.cpp | 1 - modules/gdnavigation/nav_map.cpp | 23 -- modules/gdnavigation/nav_map.h | 1 - modules/gdnavigation/nav_region.cpp | 2 - modules/gdnavigation/nav_utils.h | 3 - .../gdnavigation/navigation_mesh_editor_plugin.cpp | 11 - .../gdnavigation/navigation_mesh_editor_plugin.h | 1 - modules/gdnavigation/navigation_mesh_generator.cpp | 8 - modules/gdscript/editor/gdscript_highlighter.cpp | 6 - modules/gdscript/gdscript.cpp | 146 ------- modules/gdscript/gdscript.h | 8 - modules/gdscript/gdscript_compiler.cpp | 108 ------ modules/gdscript/gdscript_compiler.h | 4 - modules/gdscript/gdscript_editor.cpp | 65 ---- modules/gdscript/gdscript_function.cpp | 106 ------ modules/gdscript/gdscript_function.h | 3 - modules/gdscript/gdscript_functions.cpp | 114 ------ modules/gdscript/gdscript_parser.cpp | 285 -------------- modules/gdscript/gdscript_parser.h | 6 - modules/gdscript/gdscript_tokenizer.cpp | 73 ---- modules/gdscript/gdscript_tokenizer.h | 2 - .../language_server/gdscript_extend_parser.cpp | 21 - .../language_server/gdscript_extend_parser.h | 1 - .../language_server/gdscript_language_protocol.cpp | 5 - .../language_server/gdscript_language_server.cpp | 1 - .../language_server/gdscript_text_document.cpp | 17 - .../language_server/gdscript_workspace.cpp | 21 - modules/gdscript/language_server/lsp.hpp | 11 - modules/gdscript/register_types.cpp | 8 - modules/glslang/register_types.cpp | 3 - modules/gridmap/grid_map.cpp | 73 ---- modules/gridmap/grid_map.h | 9 - modules/gridmap/grid_map_editor_plugin.cpp | 104 ----- modules/gridmap/grid_map_editor_plugin.h | 5 - modules/gridmap/register_types.cpp | 1 - modules/hdr/image_loader_hdr.cpp | 4 - modules/hdr/image_loader_hdr.h | 1 - modules/hdr/register_types.cpp | 2 - modules/jpg/image_loader_jpegd.cpp | 5 - modules/jpg/image_loader_jpegd.h | 1 - modules/jpg/register_types.cpp | 2 - modules/jsonrpc/jsonrpc.cpp | 1 - modules/lightmapper_rd/lightmapper_rd.cpp | 39 -- modules/lightmapper_rd/lightmapper_rd.h | 1 - modules/lightmapper_rd/lm_blendseams.glsl | 2 - modules/lightmapper_rd/lm_compute.glsl | 7 - modules/lightmapper_rd/lm_raster.glsl | 2 - modules/lightmapper_rd/register_types.cpp | 1 - modules/mbedtls/crypto_mbedtls.cpp | 1 - modules/mbedtls/crypto_mbedtls.h | 3 - modules/mbedtls/dtls_server_mbedtls.cpp | 2 - modules/mbedtls/dtls_server_mbedtls.h | 1 - modules/mbedtls/packet_peer_mbed_dtls.cpp | 15 - modules/mbedtls/register_types.cpp | 2 - modules/mbedtls/ssl_context_mbedtls.cpp | 1 - modules/mbedtls/ssl_context_mbedtls.h | 2 - modules/mbedtls/stream_peer_mbedtls.cpp | 18 - modules/mono/class_db_api_json.cpp | 6 - modules/mono/csharp_script.cpp | 128 ------- modules/mono/csharp_script.h | 4 - modules/mono/editor/bindings_generator.cpp | 32 -- modules/mono/editor/bindings_generator.h | 1 - modules/mono/editor/csharp_project.cpp | 1 - modules/mono/editor/editor_internal_calls.cpp | 1 - modules/mono/editor/script_class_parser.cpp | 9 - modules/mono/editor/script_class_parser.h | 1 - modules/mono/glue/arguments_vector.h | 1 - modules/mono/glue/gd_glue.cpp | 1 - modules/mono/godotsharp_dirs.cpp | 1 - modules/mono/mono_gc_handle.cpp | 2 - modules/mono/mono_gc_handle.h | 1 - modules/mono/mono_gd/gd_mono.cpp | 44 --- modules/mono/mono_gd/gd_mono.h | 2 - modules/mono/mono_gd/gd_mono_assembly.cpp | 14 - modules/mono/mono_gd/gd_mono_assembly.h | 1 - modules/mono/mono_gd/gd_mono_cache.cpp | 4 - modules/mono/mono_gd/gd_mono_cache.h | 1 - modules/mono/mono_gd/gd_mono_class.cpp | 23 -- modules/mono/mono_gd/gd_mono_field.h | 1 - modules/mono/mono_gd/gd_mono_internals.cpp | 1 - modules/mono/mono_gd/gd_mono_log.cpp | 9 - modules/mono/mono_gd/gd_mono_log.h | 1 - modules/mono/mono_gd/gd_mono_marshal.cpp | 1 - modules/mono/mono_gd/gd_mono_method.cpp | 1 - modules/mono/mono_gd/gd_mono_method.h | 1 - modules/mono/mono_gd/gd_mono_method_thunk.h | 4 - modules/mono/mono_gd/gd_mono_property.h | 1 - modules/mono/mono_gd/gd_mono_utils.cpp | 1 - modules/mono/signal_awaiter_utils.cpp | 1 - modules/mono/utils/mono_reg_utils.cpp | 6 - modules/mono/utils/mono_reg_utils.h | 1 - modules/mono/utils/osx_utils.cpp | 1 - modules/mono/utils/string_utils.cpp | 1 - modules/opensimplex/noise_texture.cpp | 11 - modules/opensimplex/open_simplex_noise.cpp | 11 - modules/opensimplex/register_types.cpp | 1 - modules/pvr/register_types.cpp | 2 - modules/pvr/texture_loader_pvr.cpp | 20 - modules/regex/regex.cpp | 48 --- modules/regex/regex.h | 2 - modules/regex/register_types.cpp | 1 - modules/squish/image_compress_squish.cpp | 9 - modules/squish/register_types.cpp | 1 - modules/stb_vorbis/audio_stream_ogg_vorbis.cpp | 20 - modules/stb_vorbis/audio_stream_ogg_vorbis.h | 2 - modules/stb_vorbis/register_types.cpp | 1 - .../stb_vorbis/resource_importer_ogg_vorbis.cpp | 8 - modules/svg/image_loader_svg.cpp | 7 - modules/svg/image_loader_svg.h | 1 - modules/svg/register_types.cpp | 2 - modules/tga/image_loader_tga.cpp | 4 - modules/tga/register_types.cpp | 2 - modules/theora/register_types.cpp | 2 - modules/theora/video_stream_theora.cpp | 39 -- modules/theora/video_stream_theora.h | 2 - modules/tinyexr/image_loader_tinyexr.cpp | 7 - modules/tinyexr/image_loader_tinyexr.h | 1 - modules/tinyexr/image_saver_tinyexr.cpp | 5 - modules/tinyexr/register_types.cpp | 2 - modules/upnp/register_types.cpp | 1 - modules/upnp/upnp.h | 1 - modules/upnp/upnp_device.h | 1 - modules/vhacd/register_types.cpp | 1 - modules/visual_script/register_types.cpp | 2 - modules/visual_script/visual_script.cpp | 205 ---------- modules/visual_script/visual_script.h | 17 - .../visual_script/visual_script_builtin_funcs.cpp | 119 ------ .../visual_script/visual_script_builtin_funcs.h | 1 - modules/visual_script/visual_script_editor.cpp | 200 ---------- modules/visual_script/visual_script_editor.h | 1 - modules/visual_script/visual_script_expression.cpp | 93 ----- modules/visual_script/visual_script_expression.h | 9 - .../visual_script/visual_script_flow_control.cpp | 98 ----- modules/visual_script/visual_script_flow_control.h | 7 - modules/visual_script/visual_script_func_nodes.cpp | 215 ----------- modules/visual_script/visual_script_func_nodes.h | 4 - modules/visual_script/visual_script_nodes.cpp | 422 --------------------- modules/visual_script/visual_script_nodes.h | 28 -- .../visual_script_property_selector.cpp | 17 - .../visual_script/visual_script_yield_nodes.cpp | 53 --- modules/visual_script/visual_script_yield_nodes.h | 2 - modules/webm/register_types.cpp | 2 - modules/webm/video_stream_webm.cpp | 56 --- modules/webm/video_stream_webm.h | 2 - modules/webp/image_loader_webp.cpp | 7 - modules/webp/image_loader_webp.h | 1 - modules/webp/register_types.cpp | 2 - modules/webrtc/webrtc_data_channel_js.cpp | 1 - modules/webrtc/webrtc_multiplayer.cpp | 2 - modules/webrtc/webrtc_multiplayer.h | 2 - modules/webrtc/webrtc_peer_connection.cpp | 2 - modules/webrtc/webrtc_peer_connection_gdnative.cpp | 1 - modules/webrtc/webrtc_peer_connection_js.h | 1 - .../websocket/editor_debugger_server_websocket.h | 1 - modules/websocket/emws_client.cpp | 7 - modules/websocket/emws_client.h | 1 - modules/websocket/emws_peer.cpp | 12 - modules/websocket/emws_peer.h | 1 - modules/websocket/emws_server.cpp | 3 - modules/websocket/emws_server.h | 1 - modules/websocket/packet_buffer.h | 1 - .../websocket/remote_debugger_peer_websocket.cpp | 2 - modules/websocket/remote_debugger_peer_websocket.h | 1 - modules/websocket/websocket_client.cpp | 11 - modules/websocket/websocket_client.h | 1 - modules/websocket/websocket_multiplayer_peer.cpp | 28 -- modules/websocket/websocket_multiplayer_peer.h | 1 - modules/websocket/websocket_peer.h | 1 - modules/websocket/websocket_server.cpp | 6 - modules/websocket/websocket_server.h | 1 - modules/websocket/wsl_client.cpp | 7 - modules/websocket/wsl_client.h | 1 - modules/websocket/wsl_peer.cpp | 9 - modules/websocket/wsl_peer.h | 1 - modules/websocket/wsl_server.cpp | 1 - modules/websocket/wsl_server.h | 2 - modules/xatlas_unwrap/register_types.cpp | 2 - 257 files changed, 4223 deletions(-) mode change 100755 => 100644 modules/mbedtls/register_types.cpp (limited to 'modules') diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp index cc74674eff..a861b39537 100644 --- a/modules/assimp/editor_scene_importer_assimp.cpp +++ b/modules/assimp/editor_scene_importer_assimp.cpp @@ -53,7 +53,6 @@ aiBone *get_bone_by_name(const aiScene *scene, aiString bone_name) { // iterate over all the bones on the mesh for this node only! for (unsigned int boneIndex = 0; boneIndex < mesh->mNumBones; boneIndex++) { - aiBone *bone = mesh->mBones[boneIndex]; if (bone->mName == bone_name) { printf("matched bone by name: %s\n", bone->mName.C_Str()); @@ -66,7 +65,6 @@ aiBone *get_bone_by_name(const aiScene *scene, aiString bone_name) { } void EditorSceneImporterAssimp::get_extensions(List *r_extensions) const { - const String import_setting_string = "filesystem/import/open_asset_import/"; Map import_format; @@ -156,14 +154,11 @@ Node *EditorSceneImporterAssimp::import_scene(const String &p_path, uint32_t p_f template struct EditorSceneImporterAssetImportInterpolate { - T lerp(const T &a, const T &b, float c) const { - return a + (b - a) * c; } T catmull_rom(const T &p0, const T &p1, const T &p2, const T &p3, float t) { - float t2 = t * t; float t3 = t2 * t; @@ -185,7 +180,6 @@ struct EditorSceneImporterAssetImportInterpolate { //thank you for existing, partial specialization template <> struct EditorSceneImporterAssetImportInterpolate { - Quat lerp(const Quat &a, const Quat &b, float c) const { ERR_FAIL_COND_V_MSG(!a.is_normalized(), Quat(), "The quaternion \"a\" must be normalized."); ERR_FAIL_COND_V_MSG(!b.is_normalized(), Quat(), "The quaternion \"b\" must be normalized."); @@ -223,7 +217,6 @@ T EditorSceneImporterAssimp::_interpolate_track(const Vector &p_times, co switch (p_interp) { case AssetImportAnimation::INTERP_LINEAR: { - if (idx == -1) { return p_values[0]; } else if (idx >= p_times.size() - 1) { @@ -236,7 +229,6 @@ T EditorSceneImporterAssimp::_interpolate_track(const Vector &p_times, co } break; case AssetImportAnimation::INTERP_STEP: { - if (idx == -1) { return p_values[0]; } else if (idx >= p_times.size() - 1) { @@ -247,7 +239,6 @@ T EditorSceneImporterAssimp::_interpolate_track(const Vector &p_times, co } break; case AssetImportAnimation::INTERP_CATMULLROMSPLINE: { - if (idx == -1) { return p_values[1]; } else if (idx >= p_times.size() - 1) { @@ -260,7 +251,6 @@ T EditorSceneImporterAssimp::_interpolate_track(const Vector &p_times, co } break; case AssetImportAnimation::INTERP_CUBIC_SPLINE: { - if (idx == -1) { return p_values[1]; } else if (idx >= p_times.size() - 1) { @@ -310,7 +300,6 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene, // populate light map for (unsigned int l = 0; l < scene->mNumLights; l++) { - aiLight *ai_light = scene->mLights[l]; ERR_CONTINUE(ai_light == nullptr); state.light_cache[AssimpUtils::get_assimp_string(ai_light->mName)] = l; @@ -490,7 +479,6 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene, if (assimp_node->mNumMeshes > 0) { MeshInstance3D *mesh = create_mesh(state, assimp_node, node_name, parent_node, node_transform); if (mesh) { - parent_node->remove_child(mesh_template); // re-parent children @@ -530,7 +518,6 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene, } if (p_flags & IMPORT_ANIMATION && scene->mNumAnimations) { - state.animation_player = memnew(AnimationPlayer); state.root->add_child(state.animation_player); state.animation_player->set_owner(state.root); @@ -621,7 +608,6 @@ void EditorSceneImporterAssimp::_insert_animation_track(ImportState &scene, cons int skeleton_bone = skeleton->find_bone(node_name); if (skeleton_bone >= 0 && track_bone) { - Transform xform; xform.basis.set_quat_scale(rot, scale); xform.origin = pos; @@ -666,7 +652,6 @@ Node *EditorSceneImporterAssimp::get_node_by_name(ImportState &state, String nam /* Bone stack is a fifo handler for multiple armatures since armatures aren't a thing in assimp (yet) */ void EditorSceneImporterAssimp::RegenerateBoneStack(ImportState &state) { - state.bone_stack.clear(); // build bone stack list for (unsigned int mesh_id = 0; mesh_id < state.assimp_scene->mNumMeshes; ++mesh_id) { @@ -700,7 +685,6 @@ void EditorSceneImporterAssimp::RegenerateBoneStack(ImportState &state, aiMesh * // animation tracks are per bone void EditorSceneImporterAssimp::_import_animation(ImportState &state, int p_animation_index, int p_bake_fps) { - ERR_FAIL_INDEX(p_animation_index, (int)state.assimp_scene->mNumAnimations); const aiAnimation *anim = state.assimp_scene->mAnimations[p_animation_index]; @@ -795,7 +779,6 @@ void EditorSceneImporterAssimp::_import_animation(ImportState &state, int p_anim //blend shape tracks for (size_t i = 0; i < anim->mNumMorphMeshChannels; i++) { - const aiMeshMorphAnim *anim_mesh = anim->mMorphMeshChannels[i]; const String prop_name = AssimpUtils::get_assimp_string(anim_mesh->mName); @@ -816,14 +799,12 @@ void EditorSceneImporterAssimp::_import_animation(ImportState &state, int p_anim //add the tracks for this mesh int base_track = animation->get_track_count(); for (int j = 0; j < mesh->get_blend_shape_count(); j++) { - animation->add_track(Animation::TYPE_VALUE); animation->track_set_path(base_track + j, base_path + ":blend_shapes/" + mesh->get_blend_shape_name(j)); } for (size_t k = 0; k < anim_mesh->mNumKeys; k++) { for (size_t j = 0; j < anim_mesh->mKeys[k].mNumValuesAndWeights; j++) { - float t = anim_mesh->mKeys[k].mTime / ticks_per_second; float w = anim_mesh->mKeys[k].mWeights[j]; @@ -843,7 +824,6 @@ Ref EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &state, const Vector &p_surface_indices, const aiNode *assimp_node, Ref &skin, Skeleton3D *&skeleton_assigned) { - Ref mesh; mesh.instance(); bool has_uvs = false; @@ -894,7 +874,6 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat int bone_index = skeleton_assigned->find_bone(bone_name); ERR_CONTINUE(bone_index == -1); for (size_t w = 0; w < bone->mNumWeights; w++) { - aiVertexWeight ai_weights = bone->mWeights[w]; BoneInfo bi; @@ -920,7 +899,6 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat st->begin(Mesh::PRIMITIVE_TRIANGLES); for (size_t j = 0; j < ai_mesh->mNumVertices; j++) { - // Get the texture coordinates if they exist if (ai_mesh->HasTextureCoords(0)) { has_uvs = true; @@ -956,7 +934,6 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // We have vertex weights right? if (vertex_weights.has(j)) { - Vector bone_info = vertex_weights[j]; Vector bones; bones.resize(bone_info.size()); @@ -1200,7 +1177,6 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat Mesh::PrimitiveType primitive = Mesh::PRIMITIVE_TRIANGLES; for (size_t j = 0; j < ai_mesh->mNumAnimMeshes; j++) { - String ai_anim_mesh_name = AssimpUtils::get_assimp_string(ai_mesh->mAnimMeshes[j]->mName); if (ai_anim_mesh_name.empty()) { @@ -1482,7 +1458,6 @@ Node3D *EditorSceneImporterAssimp::create_camera( void EditorSceneImporterAssimp::_generate_node( ImportState &state, const aiNode *assimp_node) { - ERR_FAIL_COND(assimp_node == nullptr); state.nodes.push_back(assimp_node); String parent_name = AssimpUtils::get_assimp_string(assimp_node->mParent->mName); diff --git a/modules/assimp/import_state.h b/modules/assimp/import_state.h index cda1a854f0..4a3bd17acb 100644 --- a/modules/assimp/import_state.h +++ b/modules/assimp/import_state.h @@ -55,7 +55,6 @@ namespace AssimpImporter { * This makes the code simpler and contains useful lookups. */ struct ImportState { - String path; Node3D *root; const aiScene *assimp_scene; diff --git a/modules/assimp/import_utils.h b/modules/assimp/import_utils.h index e3510c2cb3..dc85d06fed 100644 --- a/modules/assimp/import_utils.h +++ b/modules/assimp/import_utils.h @@ -162,7 +162,6 @@ public: } static String get_anim_string_from_assimp(const aiString &p_string) { - String name; name.parse_utf8(p_string.C_Str() /*,p_string.length*/); if (name.find(":") != -1) { @@ -354,7 +353,6 @@ public: * Load or load from cache image :) */ static Ref load_image(ImportState &state, const aiScene *p_scene, String p_path) { - Map>::Element *match = state.path_to_image_cache.find(p_path); // if our cache contains this image then don't bother diff --git a/modules/assimp/register_types.cpp b/modules/assimp/register_types.cpp index 3af8827bf9..6cb0fc982f 100644 --- a/modules/assimp/register_types.cpp +++ b/modules/assimp/register_types.cpp @@ -42,7 +42,6 @@ static void _editor_init() { #endif void register_assimp_types() { - #ifdef TOOLS_ENABLED ClassDB::APIType prev_api = ClassDB::get_current_api(); ClassDB::set_current_api(ClassDB::API_EDITOR); diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp index f31c889a6d..d3cfcc0092 100644 --- a/modules/basis_universal/register_types.cpp +++ b/modules/basis_universal/register_types.cpp @@ -54,7 +54,6 @@ basist::etc1_global_selector_codebook *sel_codebook = nullptr; #ifdef TOOLS_ENABLED static Vector basis_universal_packer(const Ref &p_image, Image::UsedChannels p_channels) { - Vector budata; { @@ -163,7 +162,6 @@ static Ref basis_universal_unpacker(const Vector &p_buffer) { switch (*(uint32_t *)(ptr)) { case BASIS_DECOMPRESS_RG: { - if (RS::get_singleton()->has_os_feature("rgtc")) { format = basist::transcoder_texture_format::cTFBC5; // get this from renderer imgfmt = Image::FORMAT_RGTC_RG; @@ -186,7 +184,6 @@ static Ref basis_universal_unpacker(const Vector &p_buffer) { format = basist::transcoder_texture_format::cTFBC1; // get this from renderer imgfmt = Image::FORMAT_DXT1; } else if (RS::get_singleton()->has_os_feature("etc")) { - format = basist::transcoder_texture_format::cTFETC1; // get this from renderer imgfmt = Image::FORMAT_ETC; } else { @@ -249,7 +246,6 @@ static Ref basis_universal_unpacker(const Vector &p_buffer) { int ofs = 0; tr.start_transcoding(ptr, size); for (uint32_t i = 0; i < info.m_total_levels; i++) { - basist::basisu_image_level_info level; tr.get_image_level_info(ptr, size, level, 0, i); @@ -279,7 +275,6 @@ void register_basis_universal_types() { } void unregister_basis_universal_types() { - #ifdef TOOLS_ENABLED delete sel_codebook; Image::basis_universal_packer = nullptr; diff --git a/modules/bmp/image_loader_bmp.cpp b/modules/bmp/image_loader_bmp.cpp index f69f3a43a4..89947d1ef9 100644 --- a/modules/bmp/image_loader_bmp.cpp +++ b/modules/bmp/image_loader_bmp.cpp @@ -35,7 +35,6 @@ Error ImageLoaderBMP::convert_to_image(Ref p_image, const uint8_t *p_color_buffer, const uint32_t color_table_size, const bmp_header_s &p_header) { - Error err = OK; if (p_buffer == nullptr) @@ -60,7 +59,6 @@ Error ImageLoaderBMP::convert_to_image(Ref p_image, ERR_FAIL_COND_V(height % 2 != 0, ERR_UNAVAILABLE); } else if (bits_per_pixel == 16) { - ERR_FAIL_V(ERR_UNAVAILABLE); } @@ -201,7 +199,6 @@ Error ImageLoaderBMP::convert_to_image(Ref p_image, Error ImageLoaderBMP::load_image(Ref p_image, FileAccess *f, bool p_force_linear, float p_scale) { - bmp_header_s bmp_header; Error err = ERR_INVALID_DATA; @@ -290,7 +287,6 @@ Error ImageLoaderBMP::load_image(Ref p_image, FileAccess *f, void ImageLoaderBMP::get_recognized_extensions( List *p_extensions) const { - p_extensions->push_back("bmp"); } diff --git a/modules/bullet/area_bullet.cpp b/modules/bullet/area_bullet.cpp index a4a86ab751..d5b03015a9 100644 --- a/modules/bullet/area_bullet.cpp +++ b/modules/bullet/area_bullet.cpp @@ -45,7 +45,6 @@ AreaBullet::AreaBullet() : RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_AREA) { - btGhost = bulletnew(btGhostObject); reload_shapes(); setupBulletCollisionObject(btGhost); @@ -91,7 +90,6 @@ void AreaBullet::dispatch_callbacks() { } void AreaBullet::call_event(CollisionObjectBullet *p_otherObject, PhysicsServer3D::AreaBodyStatus p_status) { - InOutEventCallback &event = eventsCallbacks[static_cast(p_otherObject->getType())]; Object *areaGodoObject = ObjectDB::get_instance(event.event_callback_id); diff --git a/modules/bullet/btRayShape.cpp b/modules/bullet/btRayShape.cpp index 0f54f848dc..ee84354315 100644 --- a/modules/bullet/btRayShape.cpp +++ b/modules/bullet/btRayShape.cpp @@ -50,7 +50,6 @@ btRayShape::~btRayShape() { } void btRayShape::setLength(btScalar p_length) { - m_length = p_length; reload_cache(); } @@ -61,7 +60,6 @@ void btRayShape::setMargin(btScalar margin) { } void btRayShape::setSlipsOnSlope(bool p_slipsOnSlope) { - slipsOnSlope = p_slipsOnSlope; } @@ -101,7 +99,6 @@ void btRayShape::getPreferredPenetrationDirection(int index, btVector3 &penetrat } void btRayShape::reload_cache() { - m_cacheScaledLength = m_length * m_localScaling[2]; m_cacheSupportPoint.setIdentity(); diff --git a/modules/bullet/btRayShape.h b/modules/bullet/btRayShape.h index df6dd93d57..d9ecde81e6 100644 --- a/modules/bullet/btRayShape.h +++ b/modules/bullet/btRayShape.h @@ -42,7 +42,6 @@ /// Ray shape around z axis ATTRIBUTE_ALIGNED16(class) btRayShape : public btConvexInternalShape { - btScalar m_length; bool slipsOnSlope; /// The default axis is the z diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp index 09a5f6f983..c20fade011 100644 --- a/modules/bullet/bullet_physics_server.cpp +++ b/modules/bullet/bullet_physics_server.cpp @@ -88,35 +88,27 @@ RID BulletPhysicsServer3D::shape_create(ShapeType p_shape) { switch (p_shape) { case SHAPE_PLANE: { - shape = bulletnew(PlaneShapeBullet); } break; case SHAPE_SPHERE: { - shape = bulletnew(SphereShapeBullet); } break; case SHAPE_BOX: { - shape = bulletnew(BoxShapeBullet); } break; case SHAPE_CAPSULE: { - shape = bulletnew(CapsuleShapeBullet); } break; case SHAPE_CYLINDER: { - shape = bulletnew(CylinderShapeBullet); } break; case SHAPE_CONVEX_POLYGON: { - shape = bulletnew(ConvexPolygonShapeBullet); } break; case SHAPE_CONCAVE_POLYGON: { - shape = bulletnew(ConcavePolygonShapeBullet); } break; case SHAPE_HEIGHTMAP: { - shape = bulletnew(HeightMapShapeBullet); } break; case SHAPE_RAY: { @@ -176,7 +168,6 @@ RID BulletPhysicsServer3D::space_create() { } void BulletPhysicsServer3D::space_set_active(RID p_space, bool p_active) { - SpaceBullet *space = space_owner.getornull(p_space); ERR_FAIL_COND(!space); @@ -371,7 +362,6 @@ void BulletPhysicsServer3D::area_set_param(RID p_area, AreaParameter p_param, co space->set_param(p_param, p_value); } } else { - AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); @@ -497,7 +487,6 @@ PhysicsServer3D::BodyMode BulletPhysicsServer3D::body_get_mode(RID p_body) const } void BulletPhysicsServer3D::body_add_shape(RID p_body, RID p_shape, const Transform &p_transform, bool p_disabled) { - RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -651,7 +640,6 @@ void BulletPhysicsServer3D::body_set_kinematic_safe_margin(RID p_body, real_t p_ ERR_FAIL_COND(!body); if (body->get_kinematic_utilities()) { - body->get_kinematic_utilities()->setSafeMargin(p_margin); } } @@ -661,7 +649,6 @@ real_t BulletPhysicsServer3D::body_get_kinematic_safe_margin(RID p_body) const { ERR_FAIL_COND_V(!body, 0); if (body->get_kinematic_utilities()) { - return body->get_kinematic_utilities()->safe_margin; } @@ -1487,7 +1474,6 @@ int BulletPhysicsServer3D::generic_6dof_joint_get_precision(RID p_joint) { void BulletPhysicsServer3D::free(RID p_rid) { if (shape_owner.owns(p_rid)) { - ShapeBullet *shape = shape_owner.getornull(p_rid); // Notify the shape is configured @@ -1498,7 +1484,6 @@ void BulletPhysicsServer3D::free(RID p_rid) { shape_owner.free(p_rid); bulletdelete(shape); } else if (rigid_body_owner.owns(p_rid)) { - RigidBodyBullet *body = rigid_body_owner.getornull(p_rid); body->set_space(nullptr); @@ -1509,7 +1494,6 @@ void BulletPhysicsServer3D::free(RID p_rid) { bulletdelete(body); } else if (soft_body_owner.owns(p_rid)) { - SoftBodyBullet *body = soft_body_owner.getornull(p_rid); body->set_space(nullptr); @@ -1518,7 +1502,6 @@ void BulletPhysicsServer3D::free(RID p_rid) { bulletdelete(body); } else if (area_owner.owns(p_rid)) { - AreaBullet *area = area_owner.getornull(p_rid); area->set_space(nullptr); @@ -1529,14 +1512,12 @@ void BulletPhysicsServer3D::free(RID p_rid) { bulletdelete(area); } else if (joint_owner.owns(p_rid)) { - JointBullet *joint = joint_owner.getornull(p_rid); joint->destroy_internal_constraint(); joint_owner.free(p_rid); bulletdelete(joint); } else if (space_owner.owns(p_rid)) { - SpaceBullet *space = space_owner.getornull(p_rid); space->remove_all_collision_objects(); @@ -1545,7 +1526,6 @@ void BulletPhysicsServer3D::free(RID p_rid) { space_owner.free(p_rid); bulletdelete(space); } else { - ERR_FAIL_MSG("Invalid ID."); } } @@ -1561,7 +1541,6 @@ void BulletPhysicsServer3D::step(float p_deltaTime) { BulletPhysicsDirectBodyState3D::singleton_setDeltaTime(p_deltaTime); for (int i = 0; i < active_spaces_count; ++i) { - active_spaces[i]->step(p_deltaTime); } } diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp index 9ad74ad262..0d456a155a 100644 --- a/modules/bullet/collision_object_bullet.cpp +++ b/modules/bullet/collision_object_bullet.cpp @@ -184,7 +184,6 @@ int CollisionObjectBullet::get_godot_object_flags() const { } void CollisionObjectBullet::set_transform(const Transform &p_global_transform) { - set_body_scale(p_global_transform.basis.get_scale_abs()); btTransform bt_transform; @@ -323,7 +322,6 @@ void RigidCollisionObjectBullet::shape_changed(int p_shape_index) { } void RigidCollisionObjectBullet::reload_shapes() { - if (mainShape && mainShape->isCompound()) { // Destroy compound bulletdelete(mainShape); diff --git a/modules/bullet/cone_twist_joint_bullet.cpp b/modules/bullet/cone_twist_joint_bullet.cpp index aac51034b8..b4735fa9e9 100644 --- a/modules/bullet/cone_twist_joint_bullet.cpp +++ b/modules/bullet/cone_twist_joint_bullet.cpp @@ -42,7 +42,6 @@ ConeTwistJointBullet::ConeTwistJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &rbAFrame, const Transform &rbBFrame) : JointBullet() { - Transform scaled_AFrame(rbAFrame.scaled(rbA->get_body_scale())); scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis); @@ -50,7 +49,6 @@ ConeTwistJointBullet::ConeTwistJointBullet(RigidBodyBullet *rbA, RigidBodyBullet G_TO_B(scaled_AFrame, btFrameA); if (rbB) { - Transform scaled_BFrame(rbBFrame.scaled(rbB->get_body_scale())); scaled_BFrame.basis.rotref_posscale_decomposition(scaled_BFrame.basis); diff --git a/modules/bullet/constraint_bullet.h b/modules/bullet/constraint_bullet.h index 125940439f..538808be51 100644 --- a/modules/bullet/constraint_bullet.h +++ b/modules/bullet/constraint_bullet.h @@ -45,7 +45,6 @@ class SpaceBullet; class btTypedConstraint; class ConstraintBullet : public RIDBullet { - protected: SpaceBullet *space = nullptr; btTypedConstraint *constraint = nullptr; diff --git a/modules/bullet/generic_6dof_joint_bullet.cpp b/modules/bullet/generic_6dof_joint_bullet.cpp index 638944df76..56a66dba45 100644 --- a/modules/bullet/generic_6dof_joint_bullet.cpp +++ b/modules/bullet/generic_6dof_joint_bullet.cpp @@ -42,7 +42,6 @@ Generic6DOFJointBullet::Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB) : JointBullet() { - for (int i = 0; i < 3; i++) { for (int j = 0; j < PhysicsServer3D::G6DOF_JOINT_FLAG_MAX; j++) { flags[i][j] = false; diff --git a/modules/bullet/godot_collision_configuration.cpp b/modules/bullet/godot_collision_configuration.cpp index 8e29845a36..ec7a1dbd9a 100644 --- a/modules/bullet/godot_collision_configuration.cpp +++ b/modules/bullet/godot_collision_configuration.cpp @@ -41,7 +41,6 @@ GodotCollisionConfiguration::GodotCollisionConfiguration(const btDiscreteDynamicsWorld *world, const btDefaultCollisionConstructionInfo &constructionInfo) : btDefaultCollisionConfiguration(constructionInfo) { - void *mem = nullptr; mem = btAlignedAlloc(sizeof(GodotRayWorldAlgorithm::CreateFunc), 16); @@ -60,44 +59,33 @@ GodotCollisionConfiguration::~GodotCollisionConfiguration() { } btCollisionAlgorithmCreateFunc *GodotCollisionConfiguration::getCollisionAlgorithmCreateFunc(int proxyType0, int proxyType1) { - if (CUSTOM_CONVEX_SHAPE_TYPE == proxyType0 && CUSTOM_CONVEX_SHAPE_TYPE == proxyType1) { - // This collision is not supported return m_emptyCreateFunc; } else if (CUSTOM_CONVEX_SHAPE_TYPE == proxyType0) { - return m_rayWorldCF; } else if (CUSTOM_CONVEX_SHAPE_TYPE == proxyType1) { - return m_swappedRayWorldCF; } else { - return btDefaultCollisionConfiguration::getCollisionAlgorithmCreateFunc(proxyType0, proxyType1); } } btCollisionAlgorithmCreateFunc *GodotCollisionConfiguration::getClosestPointsAlgorithmCreateFunc(int proxyType0, int proxyType1) { - if (CUSTOM_CONVEX_SHAPE_TYPE == proxyType0 && CUSTOM_CONVEX_SHAPE_TYPE == proxyType1) { - // This collision is not supported return m_emptyCreateFunc; } else if (CUSTOM_CONVEX_SHAPE_TYPE == proxyType0) { - return m_rayWorldCF; } else if (CUSTOM_CONVEX_SHAPE_TYPE == proxyType1) { - return m_swappedRayWorldCF; } else { - return btDefaultCollisionConfiguration::getClosestPointsAlgorithmCreateFunc(proxyType0, proxyType1); } } GodotSoftCollisionConfiguration::GodotSoftCollisionConfiguration(const btDiscreteDynamicsWorld *world, const btDefaultCollisionConstructionInfo &constructionInfo) : btSoftBodyRigidBodyCollisionConfiguration(constructionInfo) { - void *mem = nullptr; mem = btAlignedAlloc(sizeof(GodotRayWorldAlgorithm::CreateFunc), 16); @@ -116,37 +104,27 @@ GodotSoftCollisionConfiguration::~GodotSoftCollisionConfiguration() { } btCollisionAlgorithmCreateFunc *GodotSoftCollisionConfiguration::getCollisionAlgorithmCreateFunc(int proxyType0, int proxyType1) { - if (CUSTOM_CONVEX_SHAPE_TYPE == proxyType0 && CUSTOM_CONVEX_SHAPE_TYPE == proxyType1) { - // This collision is not supported return m_emptyCreateFunc; } else if (CUSTOM_CONVEX_SHAPE_TYPE == proxyType0) { - return m_rayWorldCF; } else if (CUSTOM_CONVEX_SHAPE_TYPE == proxyType1) { - return m_swappedRayWorldCF; } else { - return btSoftBodyRigidBodyCollisionConfiguration::getCollisionAlgorithmCreateFunc(proxyType0, proxyType1); } } btCollisionAlgorithmCreateFunc *GodotSoftCollisionConfiguration::getClosestPointsAlgorithmCreateFunc(int proxyType0, int proxyType1) { - if (CUSTOM_CONVEX_SHAPE_TYPE == proxyType0 && CUSTOM_CONVEX_SHAPE_TYPE == proxyType1) { - // This collision is not supported return m_emptyCreateFunc; } else if (CUSTOM_CONVEX_SHAPE_TYPE == proxyType0) { - return m_rayWorldCF; } else if (CUSTOM_CONVEX_SHAPE_TYPE == proxyType1) { - return m_swappedRayWorldCF; } else { - return btSoftBodyRigidBodyCollisionConfiguration::getClosestPointsAlgorithmCreateFunc(proxyType0, proxyType1); } } diff --git a/modules/bullet/godot_motion_state.h b/modules/bullet/godot_motion_state.h index e2c1b10e94..90d1614a77 100644 --- a/modules/bullet/godot_motion_state.h +++ b/modules/bullet/godot_motion_state.h @@ -46,7 +46,6 @@ class RigidBodyBullet; /// DOC: /// http://www.bulletphysics.org/mediawiki-1.5.8/index.php/MotionStates#What.27s_a_MotionState.3F class GodotMotionState : public btMotionState { - /// This data is used to store the new world position for kinematic body btTransform bodyKinematicWorldTransf; /// This data is used to store last world position diff --git a/modules/bullet/godot_ray_world_algorithm.cpp b/modules/bullet/godot_ray_world_algorithm.cpp index 2caa75c2a7..fbb336ca56 100644 --- a/modules/bullet/godot_ray_world_algorithm.cpp +++ b/modules/bullet/godot_ray_world_algorithm.cpp @@ -61,7 +61,6 @@ GodotRayWorldAlgorithm::~GodotRayWorldAlgorithm() { } void GodotRayWorldAlgorithm::processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut) { - if (!m_manifoldPtr) { if (m_isSwapped) { m_manifoldPtr = m_dispatcher->getNewManifold(body1Wrap->getCollisionObject(), body0Wrap->getCollisionObject()); @@ -79,13 +78,11 @@ void GodotRayWorldAlgorithm::processCollision(const btCollisionObjectWrapper *bo const btCollisionObjectWrapper *other_co_wrapper; if (m_isSwapped) { - ray_shape = static_cast(body1Wrap->getCollisionShape()); ray_transform = body1Wrap->getWorldTransform(); other_co_wrapper = body0Wrap; } else { - ray_shape = static_cast(body0Wrap->getCollisionShape()); ray_transform = body0Wrap->getWorldTransform(); @@ -99,7 +96,6 @@ void GodotRayWorldAlgorithm::processCollision(const btCollisionObjectWrapper *bo m_world->rayTestSingleInternal(ray_transform, to, other_co_wrapper, btResult); if (btResult.hasHit()) { - btScalar depth(ray_shape->getScaledLength() * (btResult.m_closestHitFraction - 1)); if (depth > -RAY_PENETRATION_DEPTH_EPSILON) diff --git a/modules/bullet/godot_ray_world_algorithm.h b/modules/bullet/godot_ray_world_algorithm.h index ec7f68dc51..45344186f5 100644 --- a/modules/bullet/godot_ray_world_algorithm.h +++ b/modules/bullet/godot_ray_world_algorithm.h @@ -42,7 +42,6 @@ class btDiscreteDynamicsWorld; class GodotRayWorldAlgorithm : public btActivatingCollisionAlgorithm { - const btDiscreteDynamicsWorld *m_world; btPersistentManifold *m_manifoldPtr; bool m_ownManifold = false; @@ -61,7 +60,6 @@ public: manifoldArray.push_back(m_manifoldPtr); } struct CreateFunc : public btCollisionAlgorithmCreateFunc { - const btDiscreteDynamicsWorld *m_world; CreateFunc(const btDiscreteDynamicsWorld *world); @@ -72,7 +70,6 @@ public: }; struct SwappedCreateFunc : public btCollisionAlgorithmCreateFunc { - const btDiscreteDynamicsWorld *m_world; SwappedCreateFunc(const btDiscreteDynamicsWorld *world); diff --git a/modules/bullet/godot_result_callbacks.cpp b/modules/bullet/godot_result_callbacks.cpp index ad20a7e451..b9c2a00b34 100644 --- a/modules/bullet/godot_result_callbacks.cpp +++ b/modules/bullet/godot_result_callbacks.cpp @@ -126,7 +126,6 @@ bool GodotKinClosestConvexResultCallback::needsCollision(btBroadphaseProxy *prox if (gObj == m_self_object) { return false; } else { - // A kinematic body can't be stopped by a rigid body since the mass of kinematic body is infinite if (m_infinite_inertia && !btObj->isStaticOrKinematicObject()) return false; @@ -201,12 +200,10 @@ bool GodotAllContactResultCallback::needsCollision(btBroadphaseProxy *proxy0) co } btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1) { - if (m_count >= m_resultMax) return cp.getDistance(); if (cp.getDistance() <= 0) { - PhysicsDirectSpaceState3D::ShapeResult &result = m_results[m_count]; // Penetrated @@ -295,7 +292,6 @@ bool GodotRestInfoContactResultCallback::needsCollision(btBroadphaseProxy *proxy } btScalar GodotRestInfoContactResultCallback::addSingleResult(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1) { - if (cp.getDistance() <= m_min_distance) { m_min_distance = cp.getDistance(); @@ -325,7 +321,6 @@ btScalar GodotRestInfoContactResultCallback::addSingleResult(btManifoldPoint &cp } void GodotDeepPenetrationContactResultCallback::addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorldOnB, btScalar depth) { - if (m_penetration_distance > depth) { // Has penetration? const bool isSwapped = m_manifoldPtr->getBody0() != m_body0Wrap->getCollisionObject(); diff --git a/modules/bullet/hinge_joint_bullet.cpp b/modules/bullet/hinge_joint_bullet.cpp index e7f3d75c10..2338277565 100644 --- a/modules/bullet/hinge_joint_bullet.cpp +++ b/modules/bullet/hinge_joint_bullet.cpp @@ -42,7 +42,6 @@ HingeJointBullet::HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameA, const Transform &frameB) : JointBullet() { - Transform scaled_AFrame(frameA.scaled(rbA->get_body_scale())); scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis); @@ -50,7 +49,6 @@ HingeJointBullet::HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, c G_TO_B(scaled_AFrame, btFrameA); if (rbB) { - Transform scaled_BFrame(frameB.scaled(rbB->get_body_scale())); scaled_BFrame.basis.rotref_posscale_decomposition(scaled_BFrame.basis); @@ -59,7 +57,6 @@ HingeJointBullet::HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, c hingeConstraint = bulletnew(btHingeConstraint(*rbA->get_bt_rigid_body(), *rbB->get_bt_rigid_body(), btFrameA, btFrameB)); } else { - hingeConstraint = bulletnew(btHingeConstraint(*rbA->get_bt_rigid_body(), btFrameA)); } @@ -68,7 +65,6 @@ HingeJointBullet::HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, c HingeJointBullet::HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB, const Vector3 &axisInA, const Vector3 &axisInB) : JointBullet() { - btVector3 btPivotA; btVector3 btAxisA; G_TO_B(pivotInA * rbA->get_body_scale(), btPivotA); @@ -82,7 +78,6 @@ HingeJointBullet::HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, c hingeConstraint = bulletnew(btHingeConstraint(*rbA->get_bt_rigid_body(), *rbB->get_bt_rigid_body(), btPivotA, btPivotB, btAxisA, btAxisB)); } else { - hingeConstraint = bulletnew(btHingeConstraint(*rbA->get_bt_rigid_body(), btPivotA, btAxisA)); } diff --git a/modules/bullet/joint_bullet.h b/modules/bullet/joint_bullet.h index 9cb8aab276..c70cea817e 100644 --- a/modules/bullet/joint_bullet.h +++ b/modules/bullet/joint_bullet.h @@ -42,7 +42,6 @@ class RigidBodyBullet; class btTypedConstraint; class JointBullet : public ConstraintBullet { - public: JointBullet(); virtual ~JointBullet(); diff --git a/modules/bullet/pin_joint_bullet.cpp b/modules/bullet/pin_joint_bullet.cpp index 68b40d7405..1cfbc65c78 100644 --- a/modules/bullet/pin_joint_bullet.cpp +++ b/modules/bullet/pin_joint_bullet.cpp @@ -42,7 +42,6 @@ PinJointBullet::PinJointBullet(RigidBodyBullet *p_body_a, const Vector3 &p_pos_a, RigidBodyBullet *p_body_b, const Vector3 &p_pos_b) : JointBullet() { if (p_body_b) { - btVector3 btPivotA; btVector3 btPivotB; G_TO_B(p_pos_a * p_body_a->get_body_scale(), btPivotA); diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index 7a244b8c32..69a81f6f15 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -257,7 +257,6 @@ void RigidBodyBullet::KinematicUtilities::just_delete_shapes(int new_size) { RigidBodyBullet::RigidBodyBullet() : RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_RIGID_BODY) { - godotMotionState = bulletnew(GodotMotionState(this)); // Initial properties @@ -337,7 +336,6 @@ void RigidBodyBullet::set_space(SpaceBullet *p_space) { void RigidBodyBullet::dispatch_callbacks() { /// The check isFirstTransformChanged is necessary in order to call integrated forces only when the first transform is sent if ((btBody->isKinematicObject() || btBody->isActive() || previousActiveState != btBody->isActive()) && force_integration_callback && can_integrate_forces) { - if (omit_forces_integration) btBody->clearForces(); @@ -371,7 +369,6 @@ void RigidBodyBullet::dispatch_callbacks() { } void RigidBodyBullet::set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata) { - if (force_integration_callback) { memdelete(force_integration_callback); force_integration_callback = nullptr; @@ -398,7 +395,6 @@ void RigidBodyBullet::on_collision_filters_change() { } void RigidBodyBullet::on_collision_checker_start() { - prev_collision_count = collisionsCount; collisionsCount = 0; @@ -414,7 +410,6 @@ void RigidBodyBullet::on_collision_checker_end() { } bool RigidBodyBullet::add_collision_object(RigidBodyBullet *p_otherObject, const Vector3 &p_hitWorldLocation, const Vector3 &p_hitLocalLocation, const Vector3 &p_hitNormal, const float &p_appliedImpulse, int p_other_shape_index, int p_local_shape_index) { - if (collisionsCount >= maxCollisionsDetection) { return false; } @@ -565,7 +560,6 @@ PhysicsServer3D::BodyMode RigidBodyBullet::get_mode() const { } void RigidBodyBullet::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant) { - switch (p_state) { case PhysicsServer3D::BODY_STATE_TRANSFORM: set_transform(p_variant); @@ -714,7 +708,6 @@ bool RigidBodyBullet::is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const { } void RigidBodyBullet::reload_axis_lock() { - btBody->setLinearFactor(btVector3(float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_X)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Y)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Z)))); if (PhysicsServer3D::BODY_MODE_CHARACTER == mode) { /// When character angular is always locked @@ -793,10 +786,8 @@ void RigidBodyBullet::set_transform__bullet(const btTransform &p_global_transfor const btTransform &RigidBodyBullet::get_transform__bullet() const { if (is_static()) { - return RigidCollisionObjectBullet::get_transform__bullet(); } else { - return godotMotionState->getCurrentWorldTransform(); } } @@ -831,7 +822,6 @@ void RigidBodyBullet::on_enter_area(AreaBullet *p_area) { return; } for (int i = 0; i < areaWhereIamCount; ++i) { - if (nullptr == areasWhereIam[i]) { // This area has the highest priority areasWhereIam.write[i] = p_area; @@ -901,7 +891,6 @@ void RigidBodyBullet::reload_space_override_modificator() { bool stopped = false; for (int i = areaWhereIamCount - 1; (0 <= i) && !stopped; --i) { - currentArea = areasWhereIam[i]; if (!currentArea || PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED == currentArea->get_spOv_mode()) { @@ -910,7 +899,6 @@ void RigidBodyBullet::reload_space_override_modificator() { /// Here is calculated the gravity if (currentArea->is_spOv_gravityPoint()) { - /// It calculates the direction of new gravity support_gravity = currentArea->get_transform().xform(currentArea->get_spOv_gravityVec()) - get_transform().get_origin(); real_t distanceMag = support_gravity.length(); @@ -1004,7 +992,6 @@ void RigidBodyBullet::notify_transform_changed() { } void RigidBodyBullet::_internal_set_mass(real_t p_mass) { - btVector3 localInertia(0, 0, 0); int clearedCurrentFlags = btBody->getCollisionFlags(); @@ -1013,7 +1000,6 @@ void RigidBodyBullet::_internal_set_mass(real_t p_mass) { // Rigidbody is dynamic if and only if mass is non Zero, otherwise static const bool isDynamic = p_mass != 0.f; if (isDynamic) { - if (PhysicsServer3D::BODY_MODE_RIGID != mode && PhysicsServer3D::BODY_MODE_CHARACTER != mode) return; @@ -1022,10 +1008,8 @@ void RigidBodyBullet::_internal_set_mass(real_t p_mass) { mainShape->calculateLocalInertia(p_mass, localInertia); if (PhysicsServer3D::BODY_MODE_RIGID == mode) { - btBody->setCollisionFlags(clearedCurrentFlags); // Just set the flags without Kin and Static } else { - btBody->setCollisionFlags(clearedCurrentFlags | btCollisionObject::CF_CHARACTER_OBJECT); } @@ -1035,16 +1019,13 @@ void RigidBodyBullet::_internal_set_mass(real_t p_mass) { btBody->forceActivationState(DISABLE_DEACTIVATION); // DISABLE_DEACTIVATION 4 } } else { - if (PhysicsServer3D::BODY_MODE_STATIC != mode && PhysicsServer3D::BODY_MODE_KINEMATIC != mode) return; m_isStatic = true; if (PhysicsServer3D::BODY_MODE_STATIC == mode) { - btBody->setCollisionFlags(clearedCurrentFlags | btCollisionObject::CF_STATIC_OBJECT); } else { - btBody->setCollisionFlags(clearedCurrentFlags | btCollisionObject::CF_KINEMATIC_OBJECT); set_transform__bullet(btBody->getWorldTransform()); // Set current Transform using kinematic method } diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h index f94dea8036..6d159504b8 100644 --- a/modules/bullet/rigid_body_bullet.h +++ b/modules/bullet/rigid_body_bullet.h @@ -142,7 +142,6 @@ public: }; class RigidBodyBullet : public RigidCollisionObjectBullet { - public: struct CollisionData { RigidBodyBullet *otherObject; @@ -249,7 +248,6 @@ public: virtual void on_collision_checker_end(); void set_max_collisions_detection(int p_maxCollisionsDetection) { - ERR_FAIL_COND(0 > p_maxCollisionsDetection); maxCollisionsDetection = p_maxCollisionsDetection; diff --git a/modules/bullet/shape_bullet.cpp b/modules/bullet/shape_bullet.cpp index e3b869ad8d..424daf7726 100644 --- a/modules/bullet/shape_bullet.cpp +++ b/modules/bullet/shape_bullet.cpp @@ -89,7 +89,6 @@ void ShapeBullet::remove_owner(ShapeOwnerBullet *p_owner, bool p_permanentlyFrom } bool ShapeBullet::is_owner(ShapeOwnerBullet *p_owner) const { - return owners.has(p_owner); } @@ -394,7 +393,6 @@ void ConcavePolygonShapeBullet::setup(Vector p_faces) { } int src_face_count = faces.size(); if (0 < src_face_count) { - // It counts the faces and assert the array contains the correct number of vertices. ERR_FAIL_COND(src_face_count % 3); @@ -513,7 +511,6 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) { // Compute min and max heights if not specified. if (!d.has("min_height") && !d.has("max_height")) { - const real_t *r = l_heights.ptr(); int heights_size = l_heights.size(); @@ -564,13 +561,11 @@ RayShapeBullet::RayShapeBullet() : ShapeBullet() {} void RayShapeBullet::set_data(const Variant &p_data) { - Dictionary d = p_data; setup(d["length"], d["slips_on_slope"]); } Variant RayShapeBullet::get_data() const { - Dictionary d; d["length"] = length; d["slips_on_slope"] = slips_on_slope; diff --git a/modules/bullet/shape_bullet.h b/modules/bullet/shape_bullet.h index 88b62b6dc9..b24ded574f 100644 --- a/modules/bullet/shape_bullet.h +++ b/modules/bullet/shape_bullet.h @@ -50,7 +50,6 @@ class ShapeOwnerBullet; class btBvhTriangleMeshShape; class ShapeBullet : public RIDBullet { - Map owners; real_t margin = 0.04; @@ -95,7 +94,6 @@ public: }; class PlaneShapeBullet : public ShapeBullet { - Plane plane; public: @@ -111,7 +109,6 @@ private: }; class SphereShapeBullet : public ShapeBullet { - real_t radius; public: @@ -128,7 +125,6 @@ private: }; class BoxShapeBullet : public ShapeBullet { - btVector3 half_extents; public: @@ -145,7 +141,6 @@ private: }; class CapsuleShapeBullet : public ShapeBullet { - real_t height; real_t radius; @@ -164,7 +159,6 @@ private: }; class CylinderShapeBullet : public ShapeBullet { - real_t height; real_t radius; @@ -183,7 +177,6 @@ private: }; class ConvexPolygonShapeBullet : public ShapeBullet { - public: btAlignedObjectArray vertices; @@ -218,7 +211,6 @@ private: }; class HeightMapShapeBullet : public ShapeBullet { - public: Vector heights; int width; @@ -238,7 +230,6 @@ private: }; class RayShapeBullet : public ShapeBullet { - public: real_t length = 1; bool slips_on_slope = false; diff --git a/modules/bullet/slider_joint_bullet.cpp b/modules/bullet/slider_joint_bullet.cpp index de47c91e5d..c248b78acf 100644 --- a/modules/bullet/slider_joint_bullet.cpp +++ b/modules/bullet/slider_joint_bullet.cpp @@ -42,7 +42,6 @@ SliderJointBullet::SliderJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB) : JointBullet() { - Transform scaled_AFrame(frameInA.scaled(rbA->get_body_scale())); scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis); @@ -50,7 +49,6 @@ SliderJointBullet::SliderJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, G_TO_B(scaled_AFrame, btFrameA); if (rbB) { - Transform scaled_BFrame(frameInB.scaled(rbB->get_body_scale())); scaled_BFrame.basis.rotref_posscale_decomposition(scaled_BFrame.basis); diff --git a/modules/bullet/soft_body_bullet.cpp b/modules/bullet/soft_body_bullet.cpp index bbaa23e064..3047a3eed1 100644 --- a/modules/bullet/soft_body_bullet.cpp +++ b/modules/bullet/soft_body_bullet.cpp @@ -105,14 +105,12 @@ void SoftBodyBullet::update_rendering_server(SoftBodyRenderingServerHandler *p_r } void SoftBodyBullet::set_soft_mesh(const Ref &p_mesh) { - if (p_mesh.is_null()) soft_mesh.unref(); else soft_mesh = p_mesh; if (soft_mesh.is_null()) { - destroy_soft_body(); return; } @@ -123,7 +121,6 @@ void SoftBodyBullet::set_soft_mesh(const Ref &p_mesh) { } void SoftBodyBullet::destroy_soft_body() { - if (!bt_soft_body) return; @@ -223,7 +220,6 @@ void SoftBodyBullet::reset_all_node_positions() { const Vector3 *vs_vertices_read = vs_vertices.ptr(); for (int vertex_index = bt_soft_body->m_nodes.size() - 1; 0 <= vertex_index; --vertex_index) { - G_TO_B(vs_vertices_read[indices_table[vertex_index][0]], bt_soft_body->m_nodes[vertex_index].m_x); bt_soft_body->m_nodes[vertex_index].m_q = bt_soft_body->m_nodes[vertex_index].m_x; @@ -331,7 +327,6 @@ void SoftBodyBullet::set_trimesh_body_shape(Vector p_indices, Vector::Element *e = unique_vertices.find(p_vertices_read[vs_vertex_index]); int vertex_id; if (e) { @@ -387,7 +382,6 @@ void SoftBodyBullet::set_trimesh_body_shape(Vector p_indices, Vector> indices_table; diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index aff203d7b4..433f1109c9 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -63,7 +63,6 @@ BulletPhysicsDirectSpaceState::BulletPhysicsDirectSpaceState(SpaceBullet *p_spac space(p_space) {} int BulletPhysicsDirectSpaceState::intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { - if (p_result_max <= 0) return 0; @@ -86,7 +85,6 @@ int BulletPhysicsDirectSpaceState::intersect_point(const Vector3 &p_point, Shape } bool BulletPhysicsDirectSpaceState::intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_ray) { - btVector3 btVec_from; btVector3 btVec_to; @@ -238,7 +236,6 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform & } bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform &p_shape_xform, float p_margin, ShapeRestInfo *r_info, const Set &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { - ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape); btCollisionShape *btShape = shape->create_bt_shape(p_shape_xform.basis.get_scale_abs(), p_margin); @@ -276,7 +273,6 @@ bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform &p_sh } Vector3 BulletPhysicsDirectSpaceState::get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const { - RigidCollisionObjectBullet *rigid_object = space->get_physics_server()->get_rigid_collisin_object(p_object); ERR_FAIL_COND_V(!rigid_object, Vector3()); @@ -320,12 +316,10 @@ Vector3 BulletPhysicsDirectSpaceState::get_closest_point_to_object_volume(RID p_ } if (shapes_found) { - Vector3 out; B_TO_G(out_closest_point, out); return out; } else { - // no shapes found, use distance to origin. return rigid_object->get_transform().get_origin(); } @@ -539,7 +533,6 @@ void onBulletPreTickCallback(btDynamicsWorld *p_dynamicsWorld, btScalar timeStep } void onBulletTickCallback(btDynamicsWorld *p_dynamicsWorld, btScalar timeStep) { - const btCollisionObjectArray &colObjArray = p_dynamicsWorld->getCollisionObjectArray(); // Notify all Collision objects the collision checker is started @@ -561,17 +554,14 @@ BulletPhysicsDirectSpaceState *SpaceBullet::get_direct_state() { } btScalar calculateGodotCombinedRestitution(const btCollisionObject *body0, const btCollisionObject *body1) { - return CLAMP(body0->getRestitution() + body1->getRestitution(), 0, 1); } btScalar calculateGodotCombinedFriction(const btCollisionObject *body0, const btCollisionObject *body1) { - return ABS(MIN(body0->getFriction(), body1->getFriction())); } void SpaceBullet::create_empty_world(bool p_create_soft_world) { - gjk_epa_pen_solver = bulletnew(btGjkEpaPenetrationDepthSolver); gjk_simplex_solver = bulletnew(btVoronoiSimplexSolver); @@ -624,7 +614,6 @@ void SpaceBullet::create_empty_world(bool p_create_soft_world) { } void SpaceBullet::destroy_world() { - /// The world elements (like: Collision Objects, Constraints, Shapes) are managed by godot dynamicsWorld->getBroadphase()->getOverlappingPairCache()->setInternalGhostPairCallback(nullptr); @@ -648,7 +637,6 @@ void SpaceBullet::destroy_world() { } void SpaceBullet::check_ghost_overlaps() { - /// Algorithm support variables btCollisionShape *other_body_shape; btConvexShape *area_shape; @@ -681,7 +669,6 @@ void SpaceBullet::check_ghost_overlaps() { // For each overlapping for (i = ghostOverlaps.size() - 1; 0 <= i; --i) { - bool hasOverlap = false; btCollisionObject *overlapped_bt_co = ghostOverlaps[i]; RigidCollisionObjectBullet *otherObject = static_cast(overlapped_bt_co->getUserPointer()); @@ -714,7 +701,6 @@ void SpaceBullet::check_ghost_overlaps() { // For each other object shape for (z = otherObject->get_shape_count() - 1; 0 <= z; --z) { - other_body_shape = static_cast(otherObject->get_bt_shape(z)); btTransform other_shape_transform(otherObject->get_bt_shape_transform(z)); @@ -725,7 +711,6 @@ void SpaceBullet::check_ghost_overlaps() { other_shape_transform; if (other_body_shape->isConvex()) { - btPointCollector result; btGjkPairDetector gjk_pair_detector( area_shape, @@ -740,7 +725,6 @@ void SpaceBullet::check_ghost_overlaps() { } } else { - btCollisionObjectWrapper obA(nullptr, area_shape, area->get_bt_ghost(), gjk_input.m_transformA, -1, y); btCollisionObjectWrapper obB(nullptr, other_body_shape, otherObject->get_bt_collision_object(), gjk_input.m_transformB, -1, z); @@ -823,7 +807,6 @@ void SpaceBullet::check_body_collision() { pt.getDistance() <= 0.0 || bodyA->was_colliding(bodyB) || bodyB->was_colliding(bodyA)) { - Vector3 collisionWorldPosition; Vector3 collisionLocalPosition; Vector3 normalOnB; @@ -883,7 +866,6 @@ static Ref blue_mat; #endif bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes) { - #if debug_test_motion /// Yes I know this is not good, but I've used it as fast debugging hack. /// I'm leaving it here just for speedup the other eventual debugs @@ -1000,7 +982,6 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f B_TO_G(motion + initial_recover_motion + __rec, r_result->motion); if (has_penetration) { - const btRigidBody *btRigid = static_cast(r_recover_result.other_collision_object); CollisionObjectBullet *collisionObject = static_cast(btRigid->getUserPointer()); @@ -1034,7 +1015,6 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f } int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, float p_margin) { - btTransform body_transform; G_TO_B(p_transform, body_transform); UNSCALE_BT_BASIS(body_transform); @@ -1099,14 +1079,12 @@ public: self_collision_object(p_self_collision_object), collision_layer(p_collision_layer), collision_mask(p_collision_mask) { - bounds = btDbvtVolume::FromMM(p_aabb_min, p_aabb_max); } virtual ~RecoverPenetrationBroadPhaseCallback() {} virtual bool process(const btBroadphaseProxy *proxy) { - btCollisionObject *co = static_cast(proxy->m_clientObject); if (co->getInternalType() <= btCollisionObject::CO_RIGID_BODY) { if (self_collision_object != proxy->m_clientObject && GodotFilterCallback::test_collision_filters(collision_layer, collision_mask, proxy->m_collisionFilterGroup, proxy->m_collisionFilterMask)) { @@ -1150,13 +1128,11 @@ public: }; bool SpaceBullet::recover_from_penetration(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result) { - // Calculate the cumulative AABB of all shapes of the kinematic body btVector3 aabb_min, aabb_max; bool shapes_found = false; for (int kinIndex = p_body->get_kinematic_utilities()->shapes.size() - 1; 0 <= kinIndex; --kinIndex) { - const RigidBodyBullet::KinematicShape &kin_shape(p_body->get_kinematic_utilities()->shapes[kinIndex]); if (!kin_shape.is_active()) { continue; @@ -1201,7 +1177,6 @@ bool SpaceBullet::recover_from_penetration(RigidBodyBullet *p_body, const btTran // Perform narrowphase per shape for (int kinIndex = p_body->get_kinematic_utilities()->shapes.size() - 1; 0 <= kinIndex; --kinIndex) { - const RigidBodyBullet::KinematicShape &kin_shape(p_body->get_kinematic_utilities()->shapes[kinIndex]); if (!kin_shape.is_active()) { continue; @@ -1230,23 +1205,19 @@ bool SpaceBullet::recover_from_penetration(RigidBodyBullet *p_body, const btTran if (cs->getChildShape(shape_idx)->isConvex()) { if (RFP_convex_convex_test(kin_shape.shape, static_cast(cs->getChildShape(shape_idx)), otherObject, kinIndex, shape_idx, shape_transform, otherObject->getWorldTransform() * cs->getChildTransform(shape_idx), p_recover_movement_scale, r_delta_recover_movement, r_recover_result)) { - penetration = true; } } else { if (RFP_convex_world_test(kin_shape.shape, cs->getChildShape(shape_idx), p_body->get_bt_collision_object(), otherObject, kinIndex, shape_idx, shape_transform, otherObject->getWorldTransform() * cs->getChildTransform(shape_idx), p_recover_movement_scale, r_delta_recover_movement, r_recover_result)) { - penetration = true; } } } else if (otherObject->getCollisionShape()->isConvex()) { /// Execute GJK test against object shape if (RFP_convex_convex_test(kin_shape.shape, static_cast(otherObject->getCollisionShape()), otherObject, kinIndex, 0, shape_transform, otherObject->getWorldTransform(), p_recover_movement_scale, r_delta_recover_movement, r_recover_result)) { - penetration = true; } } else { if (RFP_convex_world_test(kin_shape.shape, otherObject->getCollisionShape(), p_body->get_bt_collision_object(), otherObject, kinIndex, 0, shape_transform, otherObject->getWorldTransform(), p_recover_movement_scale, r_delta_recover_movement, r_recover_result)) { - penetration = true; } } @@ -1257,7 +1228,6 @@ bool SpaceBullet::recover_from_penetration(RigidBodyBullet *p_body, const btTran } bool SpaceBullet::RFP_convex_convex_test(const btConvexShape *p_shapeA, const btConvexShape *p_shapeB, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result) { - // Initialize GJK input btGjkPairDetector::ClosestPointInput gjk_input; gjk_input.m_transformA = p_transformA; @@ -1288,7 +1258,6 @@ bool SpaceBullet::RFP_convex_convex_test(const btConvexShape *p_shapeA, const bt } bool SpaceBullet::RFP_convex_world_test(const btConvexShape *p_shapeA, const btCollisionShape *p_shapeB, btCollisionObject *p_objectA, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result) { - /// Contact test btTransform tA(p_transformA); @@ -1325,7 +1294,6 @@ bool SpaceBullet::RFP_convex_world_test(const btConvexShape *p_shapeA, const btC } int SpaceBullet::add_separation_result(PhysicsServer3D::SeparationResult *r_result, const SpaceBullet::RecoverResult &p_recover_result, int p_shape_id, const btCollisionObject *p_other_object) const { - // optimize results (ignore non-colliding) if (p_recover_result.penetration_distance < 0.0) { const btRigidBody *btRigid = static_cast(p_other_object); @@ -1347,13 +1315,11 @@ int SpaceBullet::add_separation_result(PhysicsServer3D::SeparationResult *r_resu } int SpaceBullet::recover_from_penetration_ray(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, int p_result_max, btVector3 &r_delta_recover_movement, PhysicsServer3D::SeparationResult *r_results) { - // Calculate the cumulative AABB of all shapes of the kinematic body btVector3 aabb_min, aabb_max; bool shapes_found = false; for (int kinIndex = p_body->get_kinematic_utilities()->shapes.size() - 1; 0 <= kinIndex; --kinIndex) { - const RigidBodyBullet::KinematicShape &kin_shape(p_body->get_kinematic_utilities()->shapes[kinIndex]); if (!kin_shape.is_active()) { continue; @@ -1397,7 +1363,6 @@ int SpaceBullet::recover_from_penetration_ray(RigidBodyBullet *p_body, const btT // Perform narrowphase per shape for (int kinIndex = p_body->get_kinematic_utilities()->shapes.size() - 1; 0 <= kinIndex; --kinIndex) { - if (ray_count >= p_result_max) { break; } @@ -1429,14 +1394,11 @@ int SpaceBullet::recover_from_penetration_ray(RigidBodyBullet *p_body, const btT RecoverResult recover_result; if (RFP_convex_world_test(kin_shape.shape, cs->getChildShape(shape_idx), p_body->get_bt_collision_object(), otherObject, kinIndex, shape_idx, shape_transform, otherObject->getWorldTransform() * cs->getChildTransform(shape_idx), p_recover_movement_scale, r_delta_recover_movement, &recover_result)) { - ray_count = add_separation_result(&r_results[ray_count], recover_result, kinIndex, otherObject); } } else { - RecoverResult recover_result; if (RFP_convex_world_test(kin_shape.shape, otherObject->getCollisionShape(), p_body->get_bt_collision_object(), otherObject, kinIndex, 0, shape_transform, otherObject->getWorldTransform(), p_recover_movement_scale, r_delta_recover_movement, &recover_result)) { - ray_count = add_separation_result(&r_results[ray_count], recover_result, kinIndex, otherObject); } } diff --git a/modules/bullet/space_bullet.h b/modules/bullet/space_bullet.h index 6fe4571bba..2dad965de8 100644 --- a/modules/bullet/space_bullet.h +++ b/modules/bullet/space_bullet.h @@ -87,7 +87,6 @@ public: }; class SpaceBullet : public RIDBullet { - friend class AreaBullet; friend void onBulletTickCallback(btDynamicsWorld *world, btScalar timeStep); friend class BulletPhysicsDirectSpaceState; diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index a6951a9320..ccd1b89fb5 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -37,12 +37,10 @@ // Static helper functions. inline static bool is_snapable(const Vector3 &p_point1, const Vector3 &p_point2, real_t p_distance) { - return (p_point1 - p_point2).length_squared() < p_distance * p_distance; } inline static Vector2 interpolate_segment_uv(const Vector2 p_segement_points[2], const Vector2 p_uvs[2], const Vector2 &p_interpolation_point) { - float segment_length = (p_segement_points[1] - p_segement_points[0]).length(); if (segment_length < CMP_EPSILON) return p_uvs[0]; @@ -54,7 +52,6 @@ inline static Vector2 interpolate_segment_uv(const Vector2 p_segement_points[2], } inline static Vector2 interpolate_triangle_uv(const Vector2 p_vertices[3], const Vector2 p_uvs[3], const Vector2 &p_interpolation_point) { - if (p_interpolation_point.distance_squared_to(p_vertices[0]) < CMP_EPSILON2) return p_uvs[0]; if (p_interpolation_point.distance_squared_to(p_vertices[1]) < CMP_EPSILON2) @@ -83,7 +80,6 @@ inline static Vector2 interpolate_triangle_uv(const Vector2 p_vertices[3], const } static inline bool ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 p_vertices[3], float p_tolerance, Vector3 &r_intersection_point) { - Vector3 edge1 = p_vertices[1] - p_vertices[0]; Vector3 edge2 = p_vertices[2] - p_vertices[0]; Vector3 h = p_dir.cross(edge2); @@ -115,7 +111,6 @@ static inline bool ray_intersects_triangle(const Vector3 &p_from, const Vector3 } inline bool is_point_in_triangle(const Vector3 &p_point, const Vector3 p_vertices[3], int p_shifted = 0) { - real_t det = p_vertices[0].dot(p_vertices[1].cross(p_vertices[2])); // If determinant is, zero try shift the triangle and the point. @@ -149,7 +144,6 @@ inline bool is_point_in_triangle(const Vector3 &p_point, const Vector3 p_vertice } inline static bool are_segements_parallel(const Vector2 p_segment1_points[2], const Vector2 p_segment2_points[2], float p_vertex_snap2) { - Vector2 segment1 = p_segment1_points[1] - p_segment1_points[0]; Vector2 segment2 = p_segment2_points[1] - p_segment2_points[0]; real_t segment1_length2 = segment1.dot(segment1); @@ -172,7 +166,6 @@ inline static bool are_segements_parallel(const Vector2 p_segment1_points[2], co // CSGBrush void CSGBrush::_regen_face_aabbs() { - for (int i = 0; i < faces.size(); i++) { faces.write[i].aabb = AABB(); faces.write[i].aabb.position = faces[i].vertices[0]; @@ -182,7 +175,6 @@ void CSGBrush::_regen_face_aabbs() { } void CSGBrush::build_from_faces(const Vector &p_vertices, const Vector &p_uvs, const Vector &p_smooth, const Vector> &p_materials, const Vector &p_invert_faces) { - faces.clear(); int vc = p_vertices.size(); @@ -204,7 +196,6 @@ void CSGBrush::build_from_faces(const Vector &p_vertices, const Vector< faces.resize(p_vertices.size() / 3); for (int i = 0; i < faces.size(); i++) { - Face &f = faces.write[i]; f.vertices[0] = rv[i * 3 + 0]; f.vertices[1] = rv[i * 3 + 1]; @@ -227,10 +218,8 @@ void CSGBrush::build_from_faces(const Vector &p_vertices, const Vector< f.invert = false; if (mc == vc / 3) { - Ref mat = rm[i]; if (mat.is_valid()) { - const Map, int>::Element *E = material_map.find(mat); if (E) { @@ -255,7 +244,6 @@ void CSGBrush::build_from_faces(const Vector &p_vertices, const Vector< } void CSGBrush::copy_from(const CSGBrush &p_brush, const Transform &p_xform) { - faces = p_brush.faces; materials = p_brush.materials; @@ -271,7 +259,6 @@ void CSGBrush::copy_from(const CSGBrush &p_brush, const Transform &p_xform) { // CSGBrushOperation void CSGBrushOperation::merge_brushes(Operation p_operation, const CSGBrush &p_brush_a, const CSGBrush &p_brush_b, CSGBrush &r_merged_brush, float p_vertex_snap) { - // Check for face collisions and add necessary faces. Build2DFaceCollection build2DFaceCollection; for (int i = 0; i < p_brush_a.faces.size(); i++) { @@ -287,7 +274,6 @@ void CSGBrushOperation::merge_brushes(Operation p_operation, const CSGBrush &p_b mesh_merge.vertex_snap = p_vertex_snap; for (int i = 0; i < p_brush_a.faces.size(); i++) { - Ref material; if (p_brush_a.faces[i].material != -1) { material = p_brush_a.materials[p_brush_a.faces[i].material]; @@ -307,7 +293,6 @@ void CSGBrushOperation::merge_brushes(Operation p_operation, const CSGBrush &p_b } for (int i = 0; i < p_brush_b.faces.size(); i++) { - Ref material; if (p_brush_b.faces[i].material != -1) { material = p_brush_b.materials[p_brush_b.faces[i].material]; @@ -333,9 +318,7 @@ void CSGBrushOperation::merge_brushes(Operation p_operation, const CSGBrush &p_b r_merged_brush.faces.clear(); switch (p_operation) { - case OPERATION_UNION: { - int outside_count = 0; for (int i = 0; i < mesh_merge.faces.size(); i++) { @@ -349,7 +332,6 @@ void CSGBrushOperation::merge_brushes(Operation p_operation, const CSGBrush &p_b outside_count = 0; for (int i = 0; i < mesh_merge.faces.size(); i++) { - if (mesh_merge.faces[i].inside) continue; @@ -369,7 +351,6 @@ void CSGBrushOperation::merge_brushes(Operation p_operation, const CSGBrush &p_b } break; case OPERATION_INTERSECTION: { - int inside_count = 0; for (int i = 0; i < mesh_merge.faces.size(); i++) { @@ -383,7 +364,6 @@ void CSGBrushOperation::merge_brushes(Operation p_operation, const CSGBrush &p_b inside_count = 0; for (int i = 0; i < mesh_merge.faces.size(); i++) { - if (!mesh_merge.faces[i].inside) continue; @@ -403,7 +383,6 @@ void CSGBrushOperation::merge_brushes(Operation p_operation, const CSGBrush &p_b } break; case OPERATION_SUBSTRACTION: { - int face_count = 0; for (int i = 0; i < mesh_merge.faces.size(); i++) { @@ -419,7 +398,6 @@ void CSGBrushOperation::merge_brushes(Operation p_operation, const CSGBrush &p_b face_count = 0; for (int i = 0; i < mesh_merge.faces.size(); i++) { - if (mesh_merge.faces[i].from_b && !mesh_merge.faces[i].inside) continue; if (!mesh_merge.faces[i].from_b && mesh_merge.faces[i].inside) @@ -460,7 +438,6 @@ void CSGBrushOperation::merge_brushes(Operation p_operation, const CSGBrush &p_b #define BVH_LIMIT 8 int CSGBrushOperation::MeshMerge::_create_bvh(FaceBVH *facebvhptr, FaceBVH **facebvhptrptr, int p_from, int p_size, int p_depth, int &r_max_depth, int &r_max_alloc) { - if (p_depth > r_max_depth) { r_max_depth = p_depth; } @@ -485,7 +462,6 @@ int CSGBrushOperation::MeshMerge::_create_bvh(FaceBVH *facebvhptr, FaceBVH **fac int li = aabb.get_longest_axis_index(); switch (li) { - case Vector3::AXIS_X: { SortArray sort_x; sort_x.nth_element(0, p_size, p_size / 2, &facebvhptrptr[p_from]); @@ -521,7 +497,6 @@ int CSGBrushOperation::MeshMerge::_create_bvh(FaceBVH *facebvhptr, FaceBVH **fac } void CSGBrushOperation::MeshMerge::_add_distance(List &r_intersectionsA, List &r_intersectionsB, bool p_from_B, real_t p_distance) const { - List &intersections = p_from_B ? r_intersectionsB : r_intersectionsA; // Check if distance exists. @@ -533,7 +508,6 @@ void CSGBrushOperation::MeshMerge::_add_distance(List &r_intersectionsA, } bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_depth, int p_bvh_first, int p_face_idx) const { - Face face = faces[p_face_idx]; Vector3 face_points[3] = { points[face.points[0]], @@ -563,22 +537,16 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de stack[0] = pos; while (true) { - uint32_t node = stack[level] & NODE_IDX_MASK; const FaceBVH *current_facebvhptr = &(facebvhptr[node]); bool done = false; switch (stack[level] >> VISITED_BIT_SHIFT) { - case TEST_AABB_BIT: { - if (current_facebvhptr->face >= 0) { - while (current_facebvhptr) { - if (p_face_idx != current_facebvhptr->face && current_facebvhptr->aabb.intersects_ray(face_center, face_normal)) { - const Face ¤t_face = faces[current_facebvhptr->face]; Vector3 current_points[3] = { points[current_face.points[0]], @@ -610,7 +578,6 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node; } else { - bool valid = current_facebvhptr->aabb.intersects_ray(face_center, face_normal); if (!valid) { @@ -623,7 +590,6 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de } case VISIT_LEFT_BIT: { - stack[level] = (VISIT_RIGHT_BIT << VISITED_BIT_SHIFT) | node; stack[level + 1] = current_facebvhptr->left | TEST_AABB_BIT; level++; @@ -631,7 +597,6 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de } case VISIT_RIGHT_BIT: { - stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node; stack[level + 1] = current_facebvhptr->right | TEST_AABB_BIT; level++; @@ -639,7 +604,6 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de } case VISIT_DONE_BIT: { - if (level == 0) { done = true; break; @@ -658,7 +622,6 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de } void CSGBrushOperation::MeshMerge::mark_inside_faces() { - // Mark faces that are inside. This helps later do the boolean ops when merging. // This approach is very brute force with a bunch of optimizations, // such as BVH and pre AABB intersection test. @@ -719,7 +682,6 @@ void CSGBrushOperation::MeshMerge::mark_inside_faces() { _create_bvh(facebvh, bvhptr, 0, faces.size(), 1, max_depth, max_alloc); for (int i = 0; i < faces.size(); i++) { - // Check if face AABB intersects the intersection AABB. if (!intersection_aabb.intersects_inclusive(facebvh[i].aabb)) continue; @@ -730,10 +692,8 @@ void CSGBrushOperation::MeshMerge::mark_inside_faces() { } void CSGBrushOperation::MeshMerge::add_face(const Vector3 p_points[], const Vector2 p_uvs[], bool p_smooth, bool p_invert, const Ref &p_material, bool p_from_b) { - int indices[3]; for (int i = 0; i < 3; i++) { - VertexKey vk; vk.x = int((double(p_points[i].x) + double(vertex_snap) * 0.31234) / double(vertex_snap)); vk.y = int((double(p_points[i].y) + double(vertex_snap) * 0.31234) / double(vertex_snap)); @@ -781,7 +741,6 @@ void CSGBrushOperation::MeshMerge::add_face(const Vector3 p_points[], const Vect // CSGBrushOperation::Build2DFaces int CSGBrushOperation::Build2DFaces::_get_point_idx(const Vector2 &p_point) { - for (int vertex_idx = 0; vertex_idx < vertices.size(); ++vertex_idx) { if ((p_point - vertices[vertex_idx].point).length_squared() < vertex_snap2) return vertex_idx; @@ -790,7 +749,6 @@ int CSGBrushOperation::Build2DFaces::_get_point_idx(const Vector2 &p_point) { } int CSGBrushOperation::Build2DFaces::_add_vertex(const Vertex2D &p_vertex) { - // Check if vertex exists. int vertex_id = _get_point_idx(p_vertex.point); if (vertex_id != -1) @@ -801,7 +759,6 @@ int CSGBrushOperation::Build2DFaces::_add_vertex(const Vertex2D &p_vertex) { } void CSGBrushOperation::Build2DFaces::_add_vertex_idx_sorted(Vector &r_vertex_indices, int p_new_vertex_index) { - if (p_new_vertex_index >= 0 && r_vertex_indices.find(p_new_vertex_index) == -1) { ERR_FAIL_COND_MSG(p_new_vertex_index >= vertices.size(), "Invalid vertex index."); @@ -814,7 +771,6 @@ void CSGBrushOperation::Build2DFaces::_add_vertex_idx_sorted(Vector &r_vert // The second vertex. if (r_vertex_indices.size() == 1) { - Vector2 first_point = vertices[r_vertex_indices[0]].point; Vector2 new_point = vertices[p_new_vertex_index].point; @@ -857,14 +813,12 @@ void CSGBrushOperation::Build2DFaces::_add_vertex_idx_sorted(Vector &r_vert } void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector &p_segment_indices) { - int segments = p_segment_indices.size() - 1; if (segments < 2) return; // Faces around an inner vertex are merged by moving the inner vertex to the first vertex. for (int sorted_idx = 1; sorted_idx < segments; ++sorted_idx) { - int closest_idx = 0; int inner_idx = p_segment_indices[sorted_idx]; @@ -893,7 +847,6 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector &p_segment_ // Create the new faces. for (int merge_idx = 0; merge_idx < merge_faces.size(); ++merge_idx) { - int outer_edge_idx[2]; outer_edge_idx[0] = merge_faces[merge_idx].vertex_idx[(merge_faces_inner_vertex_idx[merge_idx] + 1) % 3]; outer_edge_idx[1] = merge_faces[merge_idx].vertex_idx[(merge_faces_inner_vertex_idx[merge_idx] + 2) % 3]; @@ -937,7 +890,6 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector &p_segment_ // Split faces using degenerate points. for (int face_idx = 0; face_idx < faces.size(); ++face_idx) { - Face2D face = faces[face_idx]; Vertex2D face_vertices[3] = { vertices[face.vertex_idx[0]], @@ -951,7 +903,6 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector &p_segment_ }; for (int point_idx = 0; point_idx < degenerate_points.size(); ++point_idx) { - int degenerate_idx = degenerate_points[point_idx]; Vector2 point_2D = vertices[degenerate_idx].point; @@ -968,7 +919,6 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector &p_segment_ // Check if point is on an each edge. for (int face_edge_idx = 0; face_edge_idx < 3; ++face_edge_idx) { - Vector2 edge_points[2] = { face_points[face_edge_idx], face_points[(face_edge_idx + 1) % 3] @@ -976,7 +926,6 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector &p_segment_ Vector2 closest_point = Geometry::get_closest_point_to_segment_2d(point_2D, edge_points); if ((closest_point - point_2D).length_squared() < vertex_snap2) { - int opposite_vertex_idx = face.vertex_idx[(face_edge_idx + 2) % 3]; // If new vertex snaps to degenerate vertex, just delete this face. @@ -1014,10 +963,8 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector &p_segment_ } void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_segment_points[2], Vector &r_segment_indices) { - // For each face. for (int face_idx = 0; face_idx < faces.size(); ++face_idx) { - Face2D face = faces[face_idx]; Vertex2D face_vertices[3] = { vertices[face.vertex_idx[0]], @@ -1027,7 +974,6 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s // Check each edge. for (int face_edge_idx = 0; face_edge_idx < 3; ++face_edge_idx) { - Vector2 edge_points[2] = { face_vertices[face_edge_idx].point, face_vertices[(face_edge_idx + 1) % 3].point @@ -1050,7 +996,6 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s // Else check if the segment intersects the edge. if (on_edge || Geometry::segment_intersects_segment_2d(p_segment_points[0], p_segment_points[1], edge_points[0], edge_points[1], &intersection_point)) { - // Check if intersection point is an edge point. if ((intersection_point - edge_points[0]).length_squared() < vertex_snap2 || (intersection_point - edge_points[1]).length_squared() < vertex_snap2) @@ -1113,11 +1058,9 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s } int CSGBrushOperation::Build2DFaces::_insert_point(const Vector2 &p_point) { - int new_vertex_idx = -1; for (int face_idx = 0; face_idx < faces.size(); ++face_idx) { - Face2D face = faces[face_idx]; Vertex2D face_vertices[3] = { vertices[face.vertex_idx[0]], @@ -1144,7 +1087,6 @@ int CSGBrushOperation::Build2DFaces::_insert_point(const Vector2 &p_point) { // Check if point is on an each edge. bool on_edge = false; for (int face_edge_idx = 0; face_edge_idx < 3; ++face_edge_idx) { - Vector2 edge_points[2] = { points[face_edge_idx], points[(face_edge_idx + 1) % 3] @@ -1206,7 +1148,6 @@ int CSGBrushOperation::Build2DFaces::_insert_point(const Vector2 &p_point) { // If not on an edge, check if the point is inside the face. if (!on_edge && Geometry::is_point_in_triangle(p_point, face_vertices[0].point, face_vertices[1].point, face_vertices[2].point)) { - // Add the point as a new vertex. Vertex2D new_vertex; new_vertex.point = p_point; @@ -1216,7 +1157,6 @@ int CSGBrushOperation::Build2DFaces::_insert_point(const Vector2 &p_point) { // Create three new faces around this point and remove this face. // The new vertex is the last vertex. for (int i = 0; i < 3; ++i) { - // Don't create degenerate triangles. Vector2 edge[2] = { points[i], points[(i + 1) % 3] }; Vector2 new_edge1[2] = { vertices[new_vertex_idx].point, points[i] }; @@ -1243,7 +1183,6 @@ int CSGBrushOperation::Build2DFaces::_insert_point(const Vector2 &p_point) { } void CSGBrushOperation::Build2DFaces::insert(const CSGBrush &p_brush, int p_face_idx) { - // Find edge points that cross the plane and face points that are in the plane. // Map those points to 2D. // Create new faces from those points. @@ -1252,7 +1191,6 @@ void CSGBrushOperation::Build2DFaces::insert(const CSGBrush &p_brush, int p_face int points_count = 0; for (int i = 0; i < 3; i++) { - Vector3 point_3D = p_brush.faces[p_face_idx].vertices[i]; if (plane.has_point(point_3D)) { @@ -1262,7 +1200,6 @@ void CSGBrushOperation::Build2DFaces::insert(const CSGBrush &p_brush, int p_face points_2D[points_count++] = Vector2(point_2D.x, point_2D.y); } else { - Vector3 next_point_3D = p_brush.faces[p_face_idx].vertices[(i + 1) % 3]; if (plane.has_point(next_point_3D)) @@ -1315,7 +1252,6 @@ void CSGBrushOperation::Build2DFaces::insert(const CSGBrush &p_brush, int p_face } void CSGBrushOperation::Build2DFaces::addFacesToMesh(MeshMerge &r_mesh_merge, bool p_smooth, bool p_invert, const Ref &p_material, bool p_from_b) { - for (int face_idx = 0; face_idx < faces.size(); ++face_idx) { Face2D face = faces[face_idx]; Vertex2D fv[3] = { @@ -1339,7 +1275,6 @@ void CSGBrushOperation::Build2DFaces::addFacesToMesh(MeshMerge &r_mesh_merge, bo CSGBrushOperation::Build2DFaces::Build2DFaces(const CSGBrush &p_brush, int p_face_idx, float p_vertex_snap2) : vertex_snap2(p_vertex_snap2 * p_vertex_snap2) { - // Convert 3D vertex points to 2D. Vector3 points_3D[3] = { p_brush.faces[p_face_idx].vertices[0], @@ -1368,7 +1303,6 @@ CSGBrushOperation::Build2DFaces::Build2DFaces(const CSGBrush &p_brush, int p_fac } void CSGBrushOperation::update_faces(const CSGBrush &p_brush_a, const int p_face_idx_a, const CSGBrush &p_brush_b, const int p_face_idx_b, Build2DFaceCollection &p_collection, float p_vertex_snap) { - Vector3 vertices_a[3] = { p_brush_a.faces[p_face_idx_a].vertices[0], p_brush_a.faces[p_face_idx_a].vertices[1], @@ -1437,14 +1371,11 @@ void CSGBrushOperation::update_faces(const CSGBrush &p_brush_a, const int p_face // Check for intersection using the SAT theorem. { - // Edge pair cross product combinations. for (int i = 0; i < 3; i++) { - Vector3 axis_a = (vertices_a[i] - vertices_a[(i + 1) % 3]).normalized(); for (int j = 0; j < 3; j++) { - Vector3 axis_b = (vertices_b[j] - vertices_b[(j + 1) % 3]).normalized(); Vector3 sep_axis = axis_a.cross(axis_b); diff --git a/modules/csg/csg.h b/modules/csg/csg.h index d389cbc283..34ee239c17 100644 --- a/modules/csg/csg.h +++ b/modules/csg/csg.h @@ -44,7 +44,6 @@ #include "scene/resources/material.h" struct CSGBrush { - struct Face { Vector3 vertices[3]; Vector2 uvs[3]; @@ -65,7 +64,6 @@ struct CSGBrush { }; struct CSGBrushOperation { - enum Operation { OPERATION_UNION, OPERATION_INTERSECTION, @@ -75,7 +73,6 @@ struct CSGBrushOperation { void merge_brushes(Operation p_operation, const CSGBrush &p_brush_a, const CSGBrush &p_brush_b, CSGBrush &r_merged_brush, float p_vertex_snap); struct MeshMerge { - struct Face { bool from_b; bool inside; @@ -156,7 +153,6 @@ struct CSGBrushOperation { }; struct Build2DFaces { - struct Vertex2D { Vector2 point; Vector2 uv; diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/csg_gizmos.cpp index a859ef80a6..ad04d9941b 100644 --- a/modules/csg/csg_gizmos.cpp +++ b/modules/csg/csg_gizmos.cpp @@ -33,7 +33,6 @@ /////////// CSGShape3DGizmoPlugin::CSGShape3DGizmoPlugin() { - Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/csg", Color(0.0, 0.4, 1, 0.15)); create_material("shape_union_material", gizmo_color); create_material("shape_union_solid_material", gizmo_color); @@ -50,44 +49,36 @@ CSGShape3DGizmoPlugin::CSGShape3DGizmoPlugin() { } String CSGShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - CSGShape3D *cs = Object::cast_to(p_gizmo->get_spatial_node()); if (Object::cast_to(cs)) { - return "Radius"; } if (Object::cast_to(cs)) { - static const char *hname[3] = { "Width", "Height", "Depth" }; return hname[p_idx]; } if (Object::cast_to(cs)) { - return p_idx == 0 ? "Radius" : "Height"; } if (Object::cast_to(cs)) { - return p_idx == 0 ? "InnerRadius" : "OuterRadius"; } return ""; } Variant CSGShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { - CSGShape3D *cs = Object::cast_to(p_gizmo->get_spatial_node()); if (Object::cast_to(cs)) { - CSGSphere3D *s = Object::cast_to(cs); return s->get_radius(); } if (Object::cast_to(cs)) { - CSGBox3D *s = Object::cast_to(cs); switch (p_idx) { case 0: @@ -100,13 +91,11 @@ Variant CSGShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int } if (Object::cast_to(cs)) { - CSGCylinder3D *s = Object::cast_to(cs); return p_idx == 0 ? s->get_radius() : s->get_height(); } if (Object::cast_to(cs)) { - CSGTorus3D *s = Object::cast_to(cs); return p_idx == 0 ? s->get_inner_radius() : s->get_outer_radius(); } @@ -114,7 +103,6 @@ Variant CSGShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int return Variant(); } void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - CSGShape3D *cs = Object::cast_to(p_gizmo->get_spatial_node()); Transform gt = cs->get_global_transform(); @@ -127,7 +115,6 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 16384) }; if (Object::cast_to(cs)) { - CSGSphere3D *s = Object::cast_to(cs); Vector3 ra, rb; @@ -144,7 +131,6 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca } if (Object::cast_to(cs)) { - CSGBox3D *s = Object::cast_to(cs); Vector3 axis; @@ -173,7 +159,6 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca } if (Object::cast_to(cs)) { - CSGCylinder3D *s = Object::cast_to(cs); Vector3 axis; @@ -195,7 +180,6 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca } if (Object::cast_to(cs)) { - CSGTorus3D *s = Object::cast_to(cs); Vector3 axis; @@ -217,7 +201,6 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca } } void CSGShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - CSGShape3D *cs = Object::cast_to(p_gizmo->get_spatial_node()); if (Object::cast_to(cs)) { @@ -337,7 +320,6 @@ bool CSGShape3DGizmoPlugin::is_selectable_when_hidden() const { } void CSGShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - CSGShape3D *cs = Object::cast_to(p_gizmo->get_spatial_node()); p_gizmo->clear(); diff --git a/modules/csg/csg_gizmos.h b/modules/csg/csg_gizmos.h index 7763989b2a..48a414d9c7 100644 --- a/modules/csg/csg_gizmos.h +++ b/modules/csg/csg_gizmos.h @@ -36,7 +36,6 @@ #include "editor/node_3d_editor_gizmos.h" class CSGShape3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(CSGShape3DGizmoPlugin, EditorNode3DGizmoPlugin); public: diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index a5b664eeab..8a0e1097c2 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -32,7 +32,6 @@ #include "scene/3d/path_3d.h" void CSGShape3D::set_use_collision(bool p_enable) { - if (use_collision == p_enable) return; @@ -71,12 +70,10 @@ void CSGShape3D::set_collision_layer(uint32_t p_layer) { } uint32_t CSGShape3D::get_collision_layer() const { - return collision_layer; } void CSGShape3D::set_collision_mask(uint32_t p_mask) { - collision_mask = p_mask; if (root_collision_instance.is_valid()) { PhysicsServer3D::get_singleton()->body_set_collision_mask(root_collision_instance, p_mask); @@ -84,12 +81,10 @@ void CSGShape3D::set_collision_mask(uint32_t p_mask) { } uint32_t CSGShape3D::get_collision_mask() const { - return collision_mask; } void CSGShape3D::set_collision_mask_bit(int p_bit, bool p_value) { - uint32_t mask = get_collision_mask(); if (p_value) mask |= 1 << p_bit; @@ -99,12 +94,10 @@ void CSGShape3D::set_collision_mask_bit(int p_bit, bool p_value) { } bool CSGShape3D::get_collision_mask_bit(int p_bit) const { - return get_collision_mask() & (1 << p_bit); } void CSGShape3D::set_collision_layer_bit(int p_bit, bool p_value) { - uint32_t mask = get_collision_layer(); if (p_value) mask |= 1 << p_bit; @@ -114,12 +107,10 @@ void CSGShape3D::set_collision_layer_bit(int p_bit, bool p_value) { } bool CSGShape3D::get_collision_layer_bit(int p_bit) const { - return get_collision_layer() & (1 << p_bit); } bool CSGShape3D::is_root_shape() const { - return !parent; } @@ -132,7 +123,6 @@ float CSGShape3D::get_snap() const { } void CSGShape3D::_make_dirty() { - if (!is_inside_tree()) return; @@ -151,7 +141,6 @@ void CSGShape3D::_make_dirty() { } CSGBrush *CSGShape3D::_get_brush() { - if (dirty) { if (brush) { memdelete(brush); @@ -161,7 +150,6 @@ CSGBrush *CSGShape3D::_get_brush() { CSGBrush *n = _build_brush(); for (int i = 0; i < get_child_count(); i++) { - CSGShape3D *child = Object::cast_to(get_child(i)); if (!child) continue; @@ -177,7 +165,6 @@ CSGBrush *CSGShape3D::_get_brush() { n->copy_from(*n2, child->get_transform()); } else { - CSGBrush *nn = memnew(CSGBrush); CSGBrush *nn2 = memnew(CSGBrush); nn2->copy_from(*n2, child->get_transform()); @@ -263,7 +250,6 @@ void CSGShape3D::mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvTe void CSGShape3D::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fvBiTangent[], const float fMagS, const float fMagT, const tbool bIsOrientationPreserving, const int iFace, const int iVert) { - ShapeUpdateSurface &surface = *((ShapeUpdateSurface *)pContext->m_pUserData); int i = iFace * 3 + iVert; @@ -280,7 +266,6 @@ void CSGShape3D::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const } void CSGShape3D::_update_shape() { - if (parent) return; @@ -325,7 +310,6 @@ void CSGShape3D::_update_shape() { //create arrays for (int i = 0; i < surfaces.size(); i++) { - surfaces.write[i].vertices.resize(face_count[i] * 3); surfaces.write[i].normals.resize(face_count[i] * 3); surfaces.write[i].uvs.resize(face_count[i] * 3); @@ -348,13 +332,11 @@ void CSGShape3D::_update_shape() { // Update collision faces. if (root_collision_shape.is_valid()) { - Vector physics_faces; physics_faces.resize(n->faces.size() * 3); Vector3 *physicsw = physics_faces.ptrw(); for (int i = 0; i < n->faces.size(); i++) { - int order[3] = { 0, 1, 2 }; if (n->faces[i].invert) { @@ -372,7 +354,6 @@ void CSGShape3D::_update_shape() { //fill arrays { for (int i = 0; i < n->faces.size(); i++) { - int order[3] = { 0, 1, 2 }; if (n->faces[i].invert) { @@ -388,7 +369,6 @@ void CSGShape3D::_update_shape() { Plane p(n->faces[i].vertices[0], n->faces[i].vertices[1], n->faces[i].vertices[2]); for (int j = 0; j < 3; j++) { - Vector3 v = n->faces[i].vertices[j]; Vector3 normal = p.normal; @@ -398,7 +378,6 @@ void CSGShape3D::_update_shape() { } if (n->faces[i].invert) { - normal = -normal; } @@ -491,14 +470,11 @@ Vector CSGShape3D::get_brush_faces() { } Vector CSGShape3D::get_faces(uint32_t p_usage_flags) const { - return Vector(); } void CSGShape3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - Node *parentn = get_parent(); if (parentn) { parent = Object::cast_to(parentn); @@ -523,21 +499,18 @@ void CSGShape3D::_notification(int p_what) { } if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) { - if (parent) { parent->_make_dirty(); } } if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - if (parent) { parent->_make_dirty(); } } if (p_what == NOTIFICATION_EXIT_TREE) { - if (parent) parent->_make_dirty(); parent = nullptr; @@ -552,7 +525,6 @@ void CSGShape3D::_notification(int p_what) { } void CSGShape3D::set_operation(Operation p_operation) { - operation = p_operation; _make_dirty(); update_gizmo(); @@ -582,7 +554,6 @@ void CSGShape3D::_validate_property(PropertyInfo &property) const { } Array CSGShape3D::get_meshes() const { - if (root_mesh.is_valid()) { Array arr; arr.resize(2); @@ -594,7 +565,6 @@ Array CSGShape3D::get_meshes() const { return Array(); } void CSGShape3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("_update_shape"), &CSGShape3D::_update_shape); ClassDB::bind_method(D_METHOD("is_root_shape"), &CSGShape3D::is_root_shape); @@ -660,7 +630,6 @@ CSGShape3D::~CSGShape3D() { ////////////////////////////////// CSGBrush *CSGCombiner3D::_build_brush() { - return nullptr; //does not build anything } @@ -670,7 +639,6 @@ CSGCombiner3D::CSGCombiner3D() { ///////////////////// CSGBrush *CSGPrimitive3D::_create_brush_from_arrays(const Vector &p_vertices, const Vector &p_uv, const Vector &p_smooth, const Vector> &p_materials) { - CSGBrush *brush = memnew(CSGBrush); Vector invert; @@ -688,7 +656,6 @@ CSGBrush *CSGPrimitive3D::_create_brush_from_arrays(const Vector &p_ver } void CSGPrimitive3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_invert_faces", "invert_faces"), &CSGPrimitive3D::set_invert_faces); ClassDB::bind_method(D_METHOD("is_inverting_faces"), &CSGPrimitive3D::is_inverting_faces); @@ -715,7 +682,6 @@ CSGPrimitive3D::CSGPrimitive3D() { ///////////////////// CSGBrush *CSGMesh3D::_build_brush() { - if (!mesh.is_valid()) return nullptr; @@ -726,7 +692,6 @@ CSGBrush *CSGMesh3D::_build_brush() { Ref material = get_material(); for (int i = 0; i < mesh->get_surface_count(); i++) { - if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) { continue; } @@ -781,7 +746,6 @@ CSGBrush *CSGMesh3D::_build_brush() { const int *ir = aindices.ptr(); for (int j = 0; j < is; j += 3) { - Vector3 vertex[3]; Vector3 normal[3]; Vector2 uv[3]; @@ -825,7 +789,6 @@ CSGBrush *CSGMesh3D::_build_brush() { Ref *mw = materials.ptrw(); for (int j = 0; j < is; j += 3) { - Vector3 vertex[3]; Vector3 normal[3]; Vector2 uv[3]; @@ -875,12 +838,10 @@ void CSGMesh3D::set_material(const Ref &p_material) { } Ref CSGMesh3D::get_material() const { - return material; } void CSGMesh3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &CSGMesh3D::set_mesh); ClassDB::bind_method(D_METHOD("get_mesh"), &CSGMesh3D::get_mesh); @@ -892,7 +853,6 @@ void CSGMesh3D::_bind_methods() { } void CSGMesh3D::set_mesh(const Ref &p_mesh) { - if (mesh == p_mesh) return; if (mesh.is_valid()) { @@ -914,7 +874,6 @@ Ref CSGMesh3D::get_mesh() { //////////////////////////////// CSGBrush *CSGSphere3D::_build_brush() { - // set our bounding box CSGBrush *brush = memnew(CSGBrush); @@ -938,7 +897,6 @@ CSGBrush *CSGSphere3D::_build_brush() { invert.resize(face_count); { - Vector3 *facesw = faces.ptrw(); Vector2 *uvsw = uvs.ptrw(); bool *smoothw = smooth.ptrw(); @@ -959,7 +917,6 @@ CSGBrush *CSGSphere3D::_build_brush() { double u1 = double(i) / rings; for (int j = radial_segments; j >= 1; j--) { - double lng0 = 2 * Math_PI * (double)(j - 1) / radial_segments; double x0 = Math::cos(lng0); double y0 = Math::sin(lng0); @@ -986,7 +943,6 @@ CSGBrush *CSGSphere3D::_build_brush() { }; if (i < rings) { - //face 1 facesw[face * 3 + 0] = v[0]; facesw[face * 3 + 1] = v[1]; @@ -1096,13 +1052,11 @@ bool CSGSphere3D::get_smooth_faces() const { } void CSGSphere3D::set_material(const Ref &p_material) { - material = p_material; _make_dirty(); } Ref CSGSphere3D::get_material() const { - return material; } @@ -1117,7 +1071,6 @@ CSGSphere3D::CSGSphere3D() { /////////////// CSGBrush *CSGBox3D::_build_brush() { - // set our bounding box CSGBrush *brush = memnew(CSGBrush); @@ -1141,7 +1094,6 @@ CSGBrush *CSGBox3D::_build_brush() { invert.resize(face_count); { - Vector3 *facesw = faces.ptrw(); Vector2 *uvsw = uvs.ptrw(); bool *smoothw = smooth.ptrw(); @@ -1153,21 +1105,17 @@ CSGBrush *CSGBox3D::_build_brush() { Vector3 vertex_mul(width * 0.5, height * 0.5, depth * 0.5); { - for (int i = 0; i < 6; i++) { - Vector3 face_points[4]; float uv_points[8] = { 0, 0, 0, 1, 1, 1, 1, 0 }; for (int j = 0; j < 4; j++) { - float v[3]; v[0] = 1.0; v[1] = 1 - 2 * ((j >> 1) & 1); v[2] = v[1] * (1 - 2 * (j & 1)); for (int k = 0; k < 3; k++) { - if (i < 3) face_points[j][(i + k) % 3] = v[k]; else @@ -1274,14 +1222,12 @@ float CSGBox3D::get_depth() const { } void CSGBox3D::set_material(const Ref &p_material) { - material = p_material; _make_dirty(); update_gizmo(); } Ref CSGBox3D::get_material() const { - return material; } @@ -1295,7 +1241,6 @@ CSGBox3D::CSGBox3D() { /////////////// CSGBrush *CSGCylinder3D::_build_brush() { - // set our bounding box CSGBrush *brush = memnew(CSGBrush); @@ -1319,7 +1264,6 @@ CSGBrush *CSGCylinder3D::_build_brush() { invert.resize(face_count); { - Vector3 *facesw = faces.ptrw(); Vector2 *uvsw = uvs.ptrw(); bool *smoothw = smooth.ptrw(); @@ -1331,9 +1275,7 @@ CSGBrush *CSGCylinder3D::_build_brush() { Vector3 vertex_mul(radius, height * 0.5, radius); { - for (int i = 0; i < sides; i++) { - float inc = float(i) / sides; float inc_n = float((i + 1)) / sides; @@ -1510,13 +1452,11 @@ bool CSGCylinder3D::get_smooth_faces() const { } void CSGCylinder3D::set_material(const Ref &p_material) { - material = p_material; _make_dirty(); } Ref CSGCylinder3D::get_material() const { - return material; } @@ -1532,7 +1472,6 @@ CSGCylinder3D::CSGCylinder3D() { /////////////// CSGBrush *CSGTorus3D::_build_brush() { - // set our bounding box float min_radius = inner_radius; @@ -1568,7 +1507,6 @@ CSGBrush *CSGTorus3D::_build_brush() { invert.resize(face_count); { - Vector3 *facesw = faces.ptrw(); Vector2 *uvsw = uvs.ptrw(); bool *smoothw = smooth.ptrw(); @@ -1578,9 +1516,7 @@ CSGBrush *CSGTorus3D::_build_brush() { int face = 0; { - for (int i = 0; i < sides; i++) { - float inci = float(i) / sides; float inci_n = float((i + 1)) / sides; @@ -1591,7 +1527,6 @@ CSGBrush *CSGTorus3D::_build_brush() { Vector3 normali_n = Vector3(Math::cos(angi_n), 0, Math::sin(angi_n)); for (int j = 0; j < ring_sides; j++) { - float incj = float(j) / ring_sides; float incj_n = float((j + 1)) / ring_sides; @@ -1738,13 +1673,11 @@ bool CSGTorus3D::get_smooth_faces() const { } void CSGTorus3D::set_material(const Ref &p_material) { - material = p_material; _make_dirty(); } Ref CSGTorus3D::get_material() const { - return material; } @@ -1760,7 +1693,6 @@ CSGTorus3D::CSGTorus3D() { /////////////// CSGBrush *CSGPolygon3D::_build_brush() { - // set our bounding box if (polygon.size() < 3) @@ -1871,7 +1803,6 @@ CSGBrush *CSGPolygon3D::_build_brush() { AABB aabb; //must be computed { - Vector3 *facesw = faces.ptrw(); Vector2 *uvsw = uvs.ptrw(); bool *smoothw = smooth.ptrw(); @@ -1882,10 +1813,8 @@ CSGBrush *CSGPolygon3D::_build_brush() { switch (mode) { case MODE_DEPTH: { - //add triangles, front and back for (int i = 0; i < 2; i++) { - for (int j = 0; j < triangles.size(); j += 3) { for (int k = 0; k < 3; k++) { int src[3] = { 0, i == 0 ? 1 : 2, i == 0 ? 2 : 1 }; @@ -1910,7 +1839,6 @@ CSGBrush *CSGPolygon3D::_build_brush() { //add triangles for depth for (int i = 0; i < final_polygon.size(); i++) { - int i_n = (i + 1) % final_polygon.size(); Vector3 v[4] = { @@ -1960,9 +1888,7 @@ CSGBrush *CSGPolygon3D::_build_brush() { } break; case MODE_SPIN: { - for (int i = 0; i < spin_sides; i++) { - float inci = float(i) / spin_sides; float inci_n = float((i + 1)) / spin_sides; @@ -1974,7 +1900,6 @@ CSGBrush *CSGPolygon3D::_build_brush() { //add triangles for depth for (int j = 0; j < final_polygon.size(); j++) { - int j_n = (j + 1) % final_polygon.size(); Vector3 v[4] = { @@ -2023,7 +1948,6 @@ CSGBrush *CSGPolygon3D::_build_brush() { } if (i == 0 && spin_degrees < 360) { - for (int j = 0; j < triangles.size(); j += 3) { for (int k = 0; k < 3; k++) { int src[3] = { 0, 2, 1 }; @@ -2041,7 +1965,6 @@ CSGBrush *CSGPolygon3D::_build_brush() { } if (i == spin_sides - 1 && spin_degrees < 360) { - for (int j = 0; j < triangles.size(); j += 3) { for (int k = 0; k < 3; k++) { int src[3] = { 0, 1, 2 }; @@ -2061,7 +1984,6 @@ CSGBrush *CSGPolygon3D::_build_brush() { } } break; case MODE_PATH: { - float bl = curve->get_baked_length(); int splits = MAX(2, Math::ceil(bl / path_interval)); float u1 = 0.0; @@ -2087,7 +2009,6 @@ CSGBrush *CSGPolygon3D::_build_brush() { } for (int i = 0; i <= splits; i++) { - float ofs = i * path_interval; if (ofs > bl) { ofs = bl; @@ -2127,7 +2048,6 @@ CSGBrush *CSGPolygon3D::_build_brush() { //put triangles where they belong //add triangles for depth for (int j = 0; j < final_polygon.size(); j++) { - int j_n = (j + 1) % final_polygon.size(); Vector3 v[4] = { @@ -2177,7 +2097,6 @@ CSGBrush *CSGPolygon3D::_build_brush() { } if (i == 0 && !path_joined) { - for (int j = 0; j < triangles.size(); j += 3) { for (int k = 0; k < 3; k++) { int src[3] = { 0, 1, 2 }; @@ -2195,7 +2114,6 @@ CSGBrush *CSGPolygon3D::_build_brush() { } if (i == splits && !path_joined) { - for (int j = 0; j < triangles.size(); j += 3) { for (int k = 0; k < 3; k++) { int src[3] = { 0, 2, 1 }; @@ -2461,13 +2379,11 @@ bool CSGPolygon3D::get_smooth_faces() const { } void CSGPolygon3D::set_material(const Ref &p_material) { - material = p_material; _make_dirty(); } Ref CSGPolygon3D::get_material() const { - return material; } diff --git a/modules/csg/csg_shape.h b/modules/csg/csg_shape.h index abab1ded20..7e95d685c5 100644 --- a/modules/csg/csg_shape.h +++ b/modules/csg/csg_shape.h @@ -204,7 +204,6 @@ public: }; class CSGSphere3D : public CSGPrimitive3D { - GDCLASS(CSGSphere3D, CSGPrimitive3D); virtual CSGBrush *_build_brush(); @@ -237,7 +236,6 @@ public: }; class CSGBox3D : public CSGPrimitive3D { - GDCLASS(CSGBox3D, CSGPrimitive3D); virtual CSGBrush *_build_brush(); @@ -266,7 +264,6 @@ public: }; class CSGCylinder3D : public CSGPrimitive3D { - GDCLASS(CSGCylinder3D, CSGPrimitive3D); virtual CSGBrush *_build_brush(); @@ -303,7 +300,6 @@ public: }; class CSGTorus3D : public CSGPrimitive3D { - GDCLASS(CSGTorus3D, CSGPrimitive3D); virtual CSGBrush *_build_brush(); @@ -340,7 +336,6 @@ public: }; class CSGPolygon3D : public CSGPrimitive3D { - GDCLASS(CSGPolygon3D, CSGPrimitive3D); public: diff --git a/modules/csg/register_types.cpp b/modules/csg/register_types.cpp index 40eef84b1b..a8bcc2fed1 100644 --- a/modules/csg/register_types.cpp +++ b/modules/csg/register_types.cpp @@ -34,7 +34,6 @@ #include "csg_shape.h" void register_csg_types() { - #ifndef _3D_DISABLED ClassDB::register_virtual_class(); diff --git a/modules/cvtt/image_compress_cvtt.cpp b/modules/cvtt/image_compress_cvtt.cpp index 9dbaa88202..40e0f1a08f 100644 --- a/modules/cvtt/image_compress_cvtt.cpp +++ b/modules/cvtt/image_compress_cvtt.cpp @@ -137,7 +137,6 @@ static void _digest_job_queue(void *p_job_queue) { } void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::UsedChannels p_channels) { - if (p_image->get_format() >= Image::FORMAT_BPTC_RGBA) return; //do not compress, already compressed @@ -222,7 +221,6 @@ void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::UsedChann Vector tasks; for (int i = 0; i <= mm_count; i++) { - int bw = w % 4 != 0 ? w + (4 - w % 4) : w; int bh = h % 4 != 0 ? h + (4 - h % 4) : h; @@ -280,7 +278,6 @@ void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::UsedChann } void image_decompress_cvtt(Image *p_image) { - Image::Format target_format; bool is_signed = false; bool is_hdr = false; @@ -318,7 +315,6 @@ void image_decompress_cvtt(Image *p_image) { int dst_ofs = 0; for (int i = 0; i <= mm_count; i++) { - int src_ofs = p_image->get_mipmap_offset(i); const uint8_t *in_bytes = &rb[src_ofs]; diff --git a/modules/cvtt/register_types.cpp b/modules/cvtt/register_types.cpp index 38542a33b9..e4a01cc787 100644 --- a/modules/cvtt/register_types.cpp +++ b/modules/cvtt/register_types.cpp @@ -35,7 +35,6 @@ #include "image_compress_cvtt.h" void register_cvtt_types() { - Image::set_compress_bptc_func(image_compress_cvtt); Image::_image_decompress_bptc = image_decompress_cvtt; } diff --git a/modules/dds/register_types.cpp b/modules/dds/register_types.cpp index c6281ff01b..3991964a28 100644 --- a/modules/dds/register_types.cpp +++ b/modules/dds/register_types.cpp @@ -35,13 +35,11 @@ static Ref resource_loader_dds; void register_dds_types() { - resource_loader_dds.instance(); ResourceLoader::add_resource_format_loader(resource_loader_dds); } void unregister_dds_types() { - ResourceLoader::remove_resource_format_loader(resource_loader_dds); resource_loader_dds.unref(); } diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp index 294d594135..052f2c5e01 100644 --- a/modules/dds/texture_loader_dds.cpp +++ b/modules/dds/texture_loader_dds.cpp @@ -95,7 +95,6 @@ static const DDSFormatInfo dds_format_info[DDS_MAX] = { }; RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { - if (r_error) *r_error = ERR_CANT_OPEN; @@ -126,7 +125,6 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, //validate if (magic != DDS_MAGIC || hsize != 124 || !(flags & DDSD_PIXELFORMAT) || !(flags & DDSD_CAPS)) { - ERR_FAIL_V_MSG(RES(), "Invalid or unsupported DDS texture file '" + p_path + "'."); } @@ -163,58 +161,41 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, DDSFormat dds_format; if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT1")) { - dds_format = DDS_DXT1; } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT3")) { - dds_format = DDS_DXT3; } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT5")) { - dds_format = DDS_DXT5; } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("ATI1")) { - dds_format = DDS_ATI1; } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("ATI2")) { - dds_format = DDS_ATI2; } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("A2XY")) { - dds_format = DDS_A2XY; } else if (format_flags & DDPF_RGB && format_flags & DDPF_ALPHAPIXELS && format_rgb_bits == 32 && format_red_mask == 0xff0000 && format_green_mask == 0xff00 && format_blue_mask == 0xff && format_alpha_mask == 0xff000000) { - dds_format = DDS_BGRA8; } else if (format_flags & DDPF_RGB && !(format_flags & DDPF_ALPHAPIXELS) && format_rgb_bits == 24 && format_red_mask == 0xff0000 && format_green_mask == 0xff00 && format_blue_mask == 0xff) { - dds_format = DDS_BGR8; } else if (format_flags & DDPF_RGB && format_flags & DDPF_ALPHAPIXELS && format_rgb_bits == 32 && format_red_mask == 0xff && format_green_mask == 0xff00 && format_blue_mask == 0xff0000 && format_alpha_mask == 0xff000000) { - dds_format = DDS_RGBA8; } else if (format_flags & DDPF_RGB && !(format_flags & DDPF_ALPHAPIXELS) && format_rgb_bits == 24 && format_red_mask == 0xff && format_green_mask == 0xff00 && format_blue_mask == 0xff0000) { - dds_format = DDS_RGB8; } else if (format_flags & DDPF_RGB && format_flags & DDPF_ALPHAPIXELS && format_rgb_bits == 16 && format_red_mask == 0x00007c00 && format_green_mask == 0x000003e0 && format_blue_mask == 0x0000001f && format_alpha_mask == 0x00008000) { - dds_format = DDS_BGR5A1; } else if (format_flags & DDPF_RGB && format_flags & DDPF_ALPHAPIXELS && format_rgb_bits == 32 && format_red_mask == 0x3ff00000 && format_green_mask == 0xffc00 && format_blue_mask == 0x3ff && format_alpha_mask == 0xc0000000) { - dds_format = DDS_BGR10A2; } else if (format_flags & DDPF_RGB && !(format_flags & DDPF_ALPHAPIXELS) && format_rgb_bits == 16 && format_red_mask == 0x0000f800 && format_green_mask == 0x000007e0 && format_blue_mask == 0x0000001f) { - dds_format = DDS_BGR565; } else if (!(format_flags & DDPF_ALPHAPIXELS) && format_rgb_bits == 8 && format_red_mask == 0xff && format_green_mask == 0xff && format_blue_mask == 0xff) { - dds_format = DDS_LUMINANCE; } else if ((format_flags & DDPF_ALPHAPIXELS) && format_rgb_bits == 16 && format_red_mask == 0xff && format_green_mask == 0xff && format_blue_mask == 0xff && format_alpha_mask == 0xff00) { - dds_format = DDS_LUMINANCE_ALPHA; } else if (format_flags & DDPF_INDEXED && format_rgb_bits == 8) { - dds_format = DDS_BGR565; } else { - printf("unrecognized fourcc %x format_flags: %x - rgbbits %i - red_mask %x green mask %x blue mask %x alpha mask %x\n", format_fourcc, format_flags, format_rgb_bits, format_red_mask, format_green_mask, format_blue_mask, format_alpha_mask); ERR_FAIL_V_MSG(RES(), "Unrecognized or unsupported color layout in DDS '" + p_path + "'."); } @@ -236,7 +217,6 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, ERR_FAIL_COND_V(!(flags & DDSD_LINEARSIZE), RES()); for (uint32_t i = 1; i < mipmaps; i++) { - w = MAX(1, w >> 1); h = MAX(1, h >> 1); uint32_t bsize = MAX(info.divisor, w) / info.divisor * MAX(info.divisor, h) / info.divisor * info.block_size; @@ -249,7 +229,6 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, f->get_buffer(wb, size); } else if (info.palette) { - //indexed ERR_FAIL_COND_V(!(flags & DDSD_PITCH), RES()); ERR_FAIL_COND_V(format_rgb_bits != 8, RES()); @@ -262,7 +241,6 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, int colsize = 3; for (int i = 0; i < 256; i++) { - if (palette[i * 4 + 3] < 255) colsize = 4; } @@ -271,7 +249,6 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, int h2 = height; for (uint32_t i = 1; i < mipmaps; i++) { - w2 = (w2 + 1) >> 1; h2 = (h2 + 1) >> 1; size += w2 * h2 * info.block_size; @@ -282,7 +259,6 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, f->get_buffer(wb, size); for (int i = 0; i < 256; i++) { - int dst_ofs = size + i * colsize; int src_ofs = i * 4; wb[dst_ofs + 0] = palette[src_ofs + 2]; @@ -297,7 +273,6 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, uint32_t size = width * height * info.block_size; for (uint32_t i = 1; i < mipmaps; i++) { - w = (w + 1) >> 1; h = (h + 1) >> 1; size += w * h * info.block_size; @@ -313,14 +288,11 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, f->get_buffer(wb, size); switch (dds_format) { - case DDS_BGR5A1: { - // TO RGBA int colcount = size / 4; for (int i = colcount - 1; i >= 0; i--) { - int src_ofs = i * 2; int dst_ofs = i * 4; @@ -335,11 +307,9 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, } } break; case DDS_BGR565: { - int colcount = size / 3; for (int i = colcount - 1; i >= 0; i--) { - int src_ofs = i * 2; int dst_ofs = i * 3; @@ -353,12 +323,10 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, } break; case DDS_BGR10A2: { - // TO RGBA int colcount = size / 4; for (int i = colcount - 1; i >= 0; i--) { - int ofs = i * 4; uint32_t w32 = uint32_t(wb[ofs + 0]) | (uint32_t(wb[ofs + 1]) << 8) | (uint32_t(wb[ofs + 2]) << 16) | (uint32_t(wb[ofs + 3]) << 24); @@ -375,26 +343,21 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, } } break; case DDS_BGRA8: { - int colcount = size / 4; for (int i = 0; i < colcount; i++) { - SWAP(wb[i * 4 + 0], wb[i * 4 + 2]); } } break; case DDS_BGR8: { - int colcount = size / 3; for (int i = 0; i < colcount; i++) { - SWAP(wb[i * 3 + 0], wb[i * 3 + 2]); } } break; case DDS_RGBA8: { - /* do nothing either int colcount = size/4; @@ -413,7 +376,6 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, */ } break; case DDS_RGB8: { - // do nothing /* int colcount = size/3; @@ -424,12 +386,10 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, }*/ } break; case DDS_LUMINANCE: { - // do nothing i guess? } break; case DDS_LUMINANCE_ALPHA: { - // do nothing i guess? } break; @@ -451,17 +411,14 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, } void ResourceFormatDDS::get_recognized_extensions(List *p_extensions) const { - p_extensions->push_back("dds"); } bool ResourceFormatDDS::handles_type(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Texture2D"); } String ResourceFormatDDS::get_resource_type(const String &p_path) const { - if (p_path.get_extension().to_lower() == "dds") return "ImageTexture"; return ""; diff --git a/modules/denoise/lightmap_denoiser.cpp b/modules/denoise/lightmap_denoiser.cpp index c821b22d85..29d02e8ee2 100644 --- a/modules/denoise/lightmap_denoiser.cpp +++ b/modules/denoise/lightmap_denoiser.cpp @@ -40,7 +40,6 @@ void LightmapDenoiserOIDN::make_default_denoiser() { } Ref LightmapDenoiserOIDN::denoise_image(const Ref &p_image) { - Ref img = p_image->duplicate(); img->convert(Image::FORMAT_RGBF); diff --git a/modules/denoise/lightmap_denoiser.h b/modules/denoise/lightmap_denoiser.h index ac0cc8b9db..5b6e257df8 100644 --- a/modules/denoise/lightmap_denoiser.h +++ b/modules/denoise/lightmap_denoiser.h @@ -37,7 +37,6 @@ struct OIDNDeviceImpl; class LightmapDenoiserOIDN : public LightmapDenoiser { - GDCLASS(LightmapDenoiserOIDN, LightmapDenoiser); protected: diff --git a/modules/denoise/register_types.cpp b/modules/denoise/register_types.cpp index b6b92701c8..b78734a531 100644 --- a/modules/denoise/register_types.cpp +++ b/modules/denoise/register_types.cpp @@ -33,7 +33,6 @@ #include "lightmap_denoiser.h" void register_denoise_types() { - LightmapDenoiserOIDN::make_default_denoiser(); } diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index 444ffae713..0ff747c6d8 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -34,21 +34,17 @@ #include "core/os/os.h" void NetworkedMultiplayerENet::set_transfer_mode(TransferMode p_mode) { - transfer_mode = p_mode; } NetworkedMultiplayerPeer::TransferMode NetworkedMultiplayerENet::get_transfer_mode() const { - return transfer_mode; } void NetworkedMultiplayerENet::set_target_peer(int p_peer) { - target_peer = p_peer; } int NetworkedMultiplayerENet::get_packet_peer() const { - ERR_FAIL_COND_V_MSG(!active, 1, "The multiplayer instance isn't currently active."); ERR_FAIL_COND_V(incoming_packets.size() == 0, 1); @@ -56,7 +52,6 @@ int NetworkedMultiplayerENet::get_packet_peer() const { } int NetworkedMultiplayerENet::get_packet_channel() const { - ERR_FAIL_COND_V_MSG(!active, -1, "The multiplayer instance isn't currently active."); ERR_FAIL_COND_V(incoming_packets.size() == 0, -1); @@ -64,7 +59,6 @@ int NetworkedMultiplayerENet::get_packet_channel() const { } int NetworkedMultiplayerENet::get_last_packet_channel() const { - ERR_FAIL_COND_V_MSG(!active, -1, "The multiplayer instance isn't currently active."); ERR_FAIL_COND_V(!current_packet.packet, -1); @@ -72,7 +66,6 @@ int NetworkedMultiplayerENet::get_last_packet_channel() const { } Error NetworkedMultiplayerENet::create_server(int p_port, int p_max_clients, int p_in_bandwidth, int p_out_bandwidth) { - ERR_FAIL_COND_V_MSG(active, ERR_ALREADY_IN_USE, "The multiplayer instance is already active."); ERR_FAIL_COND_V_MSG(p_port < 0 || p_port > 65535, ERR_INVALID_PARAMETER, "The port number must be set between 0 and 65535 (inclusive)."); ERR_FAIL_COND_V_MSG(p_max_clients < 1 || p_max_clients > 4095, ERR_INVALID_PARAMETER, "The number of clients must be set between 1 and 4095 (inclusive)."); @@ -121,7 +114,6 @@ Error NetworkedMultiplayerENet::create_server(int p_port, int p_max_clients, int return OK; } Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_port, int p_in_bandwidth, int p_out_bandwidth, int p_client_port) { - ERR_FAIL_COND_V_MSG(active, ERR_ALREADY_IN_USE, "The multiplayer instance is already active."); ERR_FAIL_COND_V_MSG(p_port < 0 || p_port > 65535, ERR_INVALID_PARAMETER, "The server port number must be set between 0 and 65535 (inclusive)."); ERR_FAIL_COND_V_MSG(p_client_port < 0 || p_client_port > 65535, ERR_INVALID_PARAMETER, "The client port number must be set between 0 and 65535 (inclusive)."); @@ -213,7 +205,6 @@ Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_por } void NetworkedMultiplayerENet::poll() { - ERR_FAIL_COND_MSG(!active, "The multiplayer instance isn't currently active."); _pop_current_packet(); @@ -221,7 +212,6 @@ void NetworkedMultiplayerENet::poll() { ENetEvent event; /* Keep servicing until there are no available events left in queue. */ while (true) { - if (!host || !active) // Might have been disconnected while emitting a notification return; @@ -272,7 +262,6 @@ void NetworkedMultiplayerENet::poll() { // Someone connected, notify all the peers available for (Map::Element *E = peer_map.front(); E; E = E->next()) { - if (E->key() == *new_id) continue; // Send existing peers to new peer @@ -287,13 +276,11 @@ void NetworkedMultiplayerENet::poll() { enet_peer_send(E->get(), SYSCH_CONFIG, packet); } } else { - emit_signal("connection_succeeded"); } } break; case ENET_EVENT_TYPE_DISCONNECT: { - // Reset the peer's client information. int *id = (int *)event.peer->data; @@ -307,16 +294,13 @@ void NetworkedMultiplayerENet::poll() { } if (!server) { - // Client just disconnected from server. emit_signal("server_disconnected"); close_connection(); return; } else if (server_relay) { - // Server just received a client disconnect and is in relay mode, notify everyone else. for (Map::Element *E = peer_map.front(); E; E = E->next()) { - if (E->key() == *id) continue; @@ -332,7 +316,6 @@ void NetworkedMultiplayerENet::poll() { memdelete(id); } break; case ENET_EVENT_TYPE_RECEIVE: { - if (event.channelID == SYSCH_CONFIG) { // Some config message ERR_CONTINUE(event.packet->dataLength < 8); @@ -345,13 +328,11 @@ void NetworkedMultiplayerENet::poll() { switch (msg) { case SYSMSG_ADD_PEER: { - peer_map[id] = nullptr; emit_signal("peer_connected", id); } break; case SYSMSG_REMOVE_PEER: { - peer_map.erase(id); emit_signal("peer_disconnected", id); } break; @@ -359,7 +340,6 @@ void NetworkedMultiplayerENet::poll() { enet_packet_destroy(event.packet); } else if (event.channelID < channel_count) { - Packet packet; packet.packet = event.packet; @@ -391,7 +371,6 @@ void NetworkedMultiplayerENet::poll() { incoming_packets.push_back(packet); // And make copies for sending for (Map::Element *E = peer_map.front(); E; E = E->next()) { - if (uint32_t(E->key()) == source) // Do not resend to self continue; @@ -405,7 +384,6 @@ void NetworkedMultiplayerENet::poll() { // And make copies for sending for (Map::Element *E = peer_map.front(); E; E = E->next()) { - if (uint32_t(E->key()) == source || E->key() == -target) // Do not resend to self, also do not send to excluded continue; @@ -428,7 +406,6 @@ void NetworkedMultiplayerENet::poll() { enet_peer_send(peer_map[target], event.channelID, packet.packet); } } else { - incoming_packets.push_back(packet); } @@ -452,7 +429,6 @@ bool NetworkedMultiplayerENet::is_server() const { } void NetworkedMultiplayerENet::close_connection(uint32_t wait_usec) { - ERR_FAIL_COND_MSG(!active, "The multiplayer instance isn't currently active."); _pop_current_packet(); @@ -484,7 +460,6 @@ void NetworkedMultiplayerENet::close_connection(uint32_t wait_usec) { } void NetworkedMultiplayerENet::disconnect_peer(int p_peer, bool now) { - ERR_FAIL_COND_MSG(!active, "The multiplayer instance isn't currently active."); ERR_FAIL_COND_MSG(!is_server(), "Can't disconnect a peer when not acting as a server."); ERR_FAIL_COND_MSG(!peer_map.has(p_peer), vformat("Peer ID %d not found in the list of peers.", p_peer)); @@ -497,7 +472,6 @@ void NetworkedMultiplayerENet::disconnect_peer(int p_peer, bool now) { // notify everyone else, send disconnect signal & remove from peer_map like in poll() if (server_relay) { for (Map::Element *E = peer_map.front(); E; E = E->next()) { - if (E->key() == p_peer) { continue; } @@ -520,12 +494,10 @@ void NetworkedMultiplayerENet::disconnect_peer(int p_peer, bool now) { } int NetworkedMultiplayerENet::get_available_packet_count() const { - return incoming_packets.size(); } Error NetworkedMultiplayerENet::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { - ERR_FAIL_COND_V_MSG(incoming_packets.size() == 0, ERR_UNAVAILABLE, "No incoming packets available."); _pop_current_packet(); @@ -540,7 +512,6 @@ Error NetworkedMultiplayerENet::get_packet(const uint8_t **r_buffer, int &r_buff } Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer_size) { - ERR_FAIL_COND_V_MSG(!active, ERR_UNCONFIGURED, "The multiplayer instance isn't currently active."); ERR_FAIL_COND_V_MSG(connection_status != CONNECTION_CONNECTED, ERR_UNCONFIGURED, "The multiplayer instance isn't currently connected to any server or client."); @@ -571,7 +542,6 @@ Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer Map::Element *E = nullptr; if (target_peer != 0) { - E = peer_map.find(ABS(target_peer)); ERR_FAIL_COND_V_MSG(!E, ERR_INVALID_PARAMETER, vformat("Invalid target peer: %d", target_peer)); } @@ -582,7 +552,6 @@ Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer copymem(&packet->data[8], p_buffer, p_buffer_size); if (server) { - if (target_peer == 0) { enet_host_broadcast(host, channel, packet); } else if (target_peer < 0) { @@ -592,7 +561,6 @@ Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer int exclude = -target_peer; for (Map::Element *F = peer_map.front(); F; F = F->next()) { - if (F->key() == exclude) // Exclude packet continue; @@ -606,7 +574,6 @@ Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer enet_peer_send(E->get(), channel, packet); } } else { - ERR_FAIL_COND_V(!peer_map.has(1), ERR_BUG); enet_peer_send(peer_map[1], channel, packet); // Send to server for broadcast } @@ -617,12 +584,10 @@ Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer } int NetworkedMultiplayerENet::get_max_packet_size() const { - return 1 << 24; // Anything is good } void NetworkedMultiplayerENet::_pop_current_packet() { - if (current_packet.packet) { enet_packet_destroy(current_packet.packet); current_packet.packet = nullptr; @@ -632,16 +597,13 @@ void NetworkedMultiplayerENet::_pop_current_packet() { } NetworkedMultiplayerPeer::ConnectionStatus NetworkedMultiplayerENet::get_connection_status() const { - return connection_status; } uint32_t NetworkedMultiplayerENet::_gen_unique_id() const { - uint32_t hash = 0; while (hash == 0 || hash == 1) { - hash = hash_djb2_one_32( (uint32_t)OS::get_singleton()->get_ticks_usec()); hash = hash_djb2_one_32( @@ -660,33 +622,27 @@ uint32_t NetworkedMultiplayerENet::_gen_unique_id() const { } int NetworkedMultiplayerENet::get_unique_id() const { - ERR_FAIL_COND_V_MSG(!active, 0, "The multiplayer instance isn't currently active."); return unique_id; } void NetworkedMultiplayerENet::set_refuse_new_connections(bool p_enable) { - refuse_connections = p_enable; } bool NetworkedMultiplayerENet::is_refusing_new_connections() const { - return refuse_connections; } void NetworkedMultiplayerENet::set_compression_mode(CompressionMode p_mode) { - compression_mode = p_mode; } NetworkedMultiplayerENet::CompressionMode NetworkedMultiplayerENet::get_compression_mode() const { - return compression_mode; } size_t NetworkedMultiplayerENet::enet_compress(void *context, const ENetBuffer *inBuffers, size_t inBufferCount, size_t inLimit, enet_uint8 *outData, size_t outLimit) { - NetworkedMultiplayerENet *enet = (NetworkedMultiplayerENet *)(context); if (size_t(enet->src_compressor_mem.size()) < inLimit) { @@ -739,20 +695,16 @@ size_t NetworkedMultiplayerENet::enet_compress(void *context, const ENetBuffer * } size_t NetworkedMultiplayerENet::enet_decompress(void *context, const enet_uint8 *inData, size_t inLimit, enet_uint8 *outData, size_t outLimit) { - NetworkedMultiplayerENet *enet = (NetworkedMultiplayerENet *)(context); int ret = -1; switch (enet->compression_mode) { case COMPRESS_FASTLZ: { - ret = Compression::decompress(outData, outLimit, inData, inLimit, Compression::MODE_FASTLZ); } break; case COMPRESS_ZLIB: { - ret = Compression::decompress(outData, outLimit, inData, inLimit, Compression::MODE_DEFLATE); } break; case COMPRESS_ZSTD: { - ret = Compression::decompress(outData, outLimit, inData, inLimit, Compression::MODE_ZSTD); } break; default: { @@ -766,11 +718,8 @@ size_t NetworkedMultiplayerENet::enet_decompress(void *context, const enet_uint8 } void NetworkedMultiplayerENet::_setup_compressor() { - switch (compression_mode) { - case COMPRESS_NONE: { - enet_host_compress(host, nullptr); } break; case COMPRESS_RANGE_CODER: { @@ -779,19 +728,16 @@ void NetworkedMultiplayerENet::_setup_compressor() { case COMPRESS_FASTLZ: case COMPRESS_ZLIB: case COMPRESS_ZSTD: { - enet_host_compress(host, &enet_compressor); } break; } } void NetworkedMultiplayerENet::enet_compressor_destroy(void *context) { - // Nothing to do } IP_Address NetworkedMultiplayerENet::get_peer_address(int p_peer_id) const { - ERR_FAIL_COND_V_MSG(!peer_map.has(p_peer_id), IP_Address(), vformat("Peer ID %d not found in the list of peers.", p_peer_id)); ERR_FAIL_COND_V_MSG(!is_server() && p_peer_id != 1, IP_Address(), "Can't get the address of peers other than the server (ID -1) when acting as a client."); ERR_FAIL_COND_V_MSG(peer_map[p_peer_id] == nullptr, IP_Address(), vformat("Peer ID %d found in the list of peers, but is null.", p_peer_id)); @@ -807,7 +753,6 @@ IP_Address NetworkedMultiplayerENet::get_peer_address(int p_peer_id) const { } int NetworkedMultiplayerENet::get_peer_port(int p_peer_id) const { - ERR_FAIL_COND_V_MSG(!peer_map.has(p_peer_id), 0, vformat("Peer ID %d not found in the list of peers.", p_peer_id)); ERR_FAIL_COND_V_MSG(!is_server() && p_peer_id != 1, 0, "Can't get the address of peers other than the server (ID -1) when acting as a client."); ERR_FAIL_COND_V_MSG(peer_map[p_peer_id] == nullptr, 0, vformat("Peer ID %d found in the list of peers, but is null.", p_peer_id)); @@ -819,7 +764,6 @@ int NetworkedMultiplayerENet::get_peer_port(int p_peer_id) const { } void NetworkedMultiplayerENet::set_transfer_channel(int p_channel) { - ERR_FAIL_COND_MSG(p_channel < -1 || p_channel >= channel_count, vformat("The transfer channel must be set between 0 and %d, inclusive (got %d).", channel_count - 1, p_channel)); ERR_FAIL_COND_MSG(p_channel == SYSCH_CONFIG, vformat("The channel %d is reserved.", SYSCH_CONFIG)); transfer_channel = p_channel; @@ -830,7 +774,6 @@ int NetworkedMultiplayerENet::get_transfer_channel() const { } void NetworkedMultiplayerENet::set_channel_count(int p_channel) { - ERR_FAIL_COND_MSG(active, "The channel count can't be set while the multiplayer instance is active."); ERR_FAIL_COND_MSG(p_channel < SYSCH_MAX, vformat("The channel count must be greater than or equal to %d to account for reserved channels (got %d).", SYSCH_MAX, p_channel)); channel_count = p_channel; @@ -859,7 +802,6 @@ bool NetworkedMultiplayerENet::is_server_relay_enabled() const { } void NetworkedMultiplayerENet::_bind_methods() { - ClassDB::bind_method(D_METHOD("create_server", "port", "max_clients", "in_bandwidth", "out_bandwidth"), &NetworkedMultiplayerENet::create_server, DEFVAL(32), DEFVAL(0), DEFVAL(0)); ClassDB::bind_method(D_METHOD("create_client", "address", "port", "in_bandwidth", "out_bandwidth", "client_port"), &NetworkedMultiplayerENet::create_client, DEFVAL(0), DEFVAL(0), DEFVAL(0)); ClassDB::bind_method(D_METHOD("close_connection", "wait_usec"), &NetworkedMultiplayerENet::close_connection, DEFVAL(100)); @@ -903,7 +845,6 @@ void NetworkedMultiplayerENet::_bind_methods() { } NetworkedMultiplayerENet::NetworkedMultiplayerENet() { - active = false; server = false; refuse_connections = false; @@ -929,7 +870,6 @@ NetworkedMultiplayerENet::NetworkedMultiplayerENet() { } NetworkedMultiplayerENet::~NetworkedMultiplayerENet() { - if (active) { close_connection(); } diff --git a/modules/enet/networked_multiplayer_enet.h b/modules/enet/networked_multiplayer_enet.h index ff436ce2c0..b2ed951327 100644 --- a/modules/enet/networked_multiplayer_enet.h +++ b/modules/enet/networked_multiplayer_enet.h @@ -38,7 +38,6 @@ #include class NetworkedMultiplayerENet : public NetworkedMultiplayerPeer { - GDCLASS(NetworkedMultiplayerENet, NetworkedMultiplayerPeer); public: @@ -86,7 +85,6 @@ private: Map peer_map; struct Packet { - ENetPacket *packet; int from; int channel; diff --git a/modules/enet/register_types.cpp b/modules/enet/register_types.cpp index 27f27196d6..e5e9628c26 100644 --- a/modules/enet/register_types.cpp +++ b/modules/enet/register_types.cpp @@ -35,7 +35,6 @@ static bool enet_ok = false; void register_enet_types() { - if (enet_initialize() != 0) { ERR_PRINT("ENet initialization failure"); } else { @@ -46,7 +45,6 @@ void register_enet_types() { } void unregister_enet_types() { - if (enet_ok) enet_deinitialize(); } diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp index 223830f445..6bf4a7ef47 100644 --- a/modules/etc/image_etc.cpp +++ b/modules/etc/image_etc.cpp @@ -219,7 +219,6 @@ static void _compress_etc2(Image *p_img, float p_lossy_quality, Image::UsedChann } void _register_etc_compress_func() { - Image::_image_compress_etc1_func = _compress_etc1; Image::_image_compress_etc2_func = _compress_etc2; } diff --git a/modules/etc/register_types.cpp b/modules/etc/register_types.cpp index 26809e0de9..0972857808 100644 --- a/modules/etc/register_types.cpp +++ b/modules/etc/register_types.cpp @@ -36,7 +36,6 @@ static Ref resource_loader_pkm; void register_etc_types() { - resource_loader_pkm.instance(); ResourceLoader::add_resource_format_loader(resource_loader_pkm); @@ -44,7 +43,6 @@ void register_etc_types() { } void unregister_etc_types() { - ResourceLoader::remove_resource_format_loader(resource_loader_pkm); resource_loader_pkm.unref(); } diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp index bfb2098dff..78768c5ba9 100644 --- a/modules/etc/texture_loader_pkm.cpp +++ b/modules/etc/texture_loader_pkm.cpp @@ -43,7 +43,6 @@ struct ETC1Header { }; RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { - if (r_error) *r_error = ERR_CANT_OPEN; @@ -96,17 +95,14 @@ RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, } void ResourceFormatPKM::get_recognized_extensions(List *p_extensions) const { - p_extensions->push_back("pkm"); } bool ResourceFormatPKM::handles_type(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Texture2D"); } String ResourceFormatPKM::get_resource_type(const String &p_path) const { - if (p_path.get_extension().to_lower() == "pkm") return "ImageTexture"; return ""; diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index a131e3a78f..7a231ac903 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -63,7 +63,6 @@ GDNativeLibrary::~GDNativeLibrary() { } bool GDNativeLibrary::_set(const StringName &p_name, const Variant &p_property) { - String name = p_name; if (name.begins_with("entry/")) { @@ -148,7 +147,6 @@ void GDNativeLibrary::_get_property_list(List *p_list) const { } void GDNativeLibrary::set_config_file(Ref p_config_file) { - set_singleton(p_config_file->get_value("general", "singleton", default_singleton)); set_load_once(p_config_file->get_value("general", "load_once", default_load_once)); set_symbol_prefix(p_config_file->get_value("general", "symbol_prefix", default_symbol_prefix)); @@ -156,7 +154,6 @@ void GDNativeLibrary::set_config_file(Ref p_config_file) { String entry_lib_path; { - List entry_keys; if (p_config_file->has_section("entry")) @@ -188,7 +185,6 @@ void GDNativeLibrary::set_config_file(Ref p_config_file) { Vector dependency_paths; { - List dependency_keys; if (p_config_file->has_section("dependencies")) @@ -383,7 +379,6 @@ bool GDNative::initialize() { } bool GDNative::terminate() { - if (!initialized) { ERR_PRINT("No valid library handle, can't terminate GDNative object"); return false; @@ -452,7 +447,6 @@ Vector GDNativeCallRegistry::get_native_call_types() { } Variant GDNative::call_native(StringName p_native_call_type, StringName p_procedure_name, Array p_arguments) { - Map::Element *E = GDNativeCallRegistry::singleton->native_calls.find(p_native_call_type); if (!E) { ERR_PRINT((String("No handler for native call type \"" + p_native_call_type) + "\" found").utf8().get_data()); @@ -478,7 +472,6 @@ Variant GDNative::call_native(StringName p_native_call_type, StringName p_proced } Error GDNative::get_symbol(StringName p_procedure_name, void *&r_handle, bool p_optional) const { - if (!initialized) { ERR_PRINT("No valid library handle, can't get symbol from GDNative object"); return ERR_CANT_OPEN; @@ -526,7 +519,6 @@ String GDNativeLibraryResourceLoader::get_resource_type(const String &p_path) co } Error GDNativeLibraryResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t p_flags) { - Ref lib = p_resource; if (lib.is_null()) { diff --git a/modules/gdnative/gdnative/color.cpp b/modules/gdnative/gdnative/color.cpp index 68c83e05a6..d79170771a 100644 --- a/modules/gdnative/gdnative/color.cpp +++ b/modules/gdnative/gdnative/color.cpp @@ -38,13 +38,11 @@ extern "C" { #endif void GDAPI godot_color_new_rgba(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b, const godot_real p_a) { - Color *dest = (Color *)r_dest; *dest = Color(p_r, p_g, p_b, p_a); } void GDAPI godot_color_new_rgb(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b) { - Color *dest = (Color *)r_dest; *dest = Color(p_r, p_g, p_b); } diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp index 1216d1d9d3..234dbe9534 100644 --- a/modules/gdnative/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative/gdnative.cpp @@ -56,14 +56,12 @@ godot_object GDAPI *godot_global_get_singleton(char *p_name) { // MethodBind API godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname) { - MethodBind *mb = ClassDB::get_method(StringName(p_classname), StringName(p_methodname)); // MethodBind *mb = ClassDB::get_method("Node", "get_name"); return (godot_method_bind *)mb; } void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_object *p_instance, const void **p_args, void *p_ret) { - MethodBind *mb = (MethodBind *)p_method_bind; Object *o = (Object *)p_instance; mb->ptrcall(o, p_args, p_ret); diff --git a/modules/gdnative/gdnative/plane.cpp b/modules/gdnative/gdnative/plane.cpp index 17221fe081..923308dc34 100644 --- a/modules/gdnative/gdnative/plane.cpp +++ b/modules/gdnative/gdnative/plane.cpp @@ -38,7 +38,6 @@ extern "C" { #endif void GDAPI godot_plane_new_with_reals(godot_plane *r_dest, const godot_real p_a, const godot_real p_b, const godot_real p_c, const godot_real p_d) { - Plane *dest = (Plane *)r_dest; *dest = Plane(p_a, p_b, p_c, p_d); } diff --git a/modules/gdnative/gdnative/quat.cpp b/modules/gdnative/gdnative/quat.cpp index be30b89e5f..15c04f7191 100644 --- a/modules/gdnative/gdnative/quat.cpp +++ b/modules/gdnative/gdnative/quat.cpp @@ -38,7 +38,6 @@ extern "C" { #endif void GDAPI godot_quat_new(godot_quat *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z, const godot_real p_w) { - Quat *dest = (Quat *)r_dest; *dest = Quat(p_x, p_y, p_z, p_w); } diff --git a/modules/gdnative/gdnative/rect2.cpp b/modules/gdnative/gdnative/rect2.cpp index 906b4f0932..a2f735172f 100644 --- a/modules/gdnative/gdnative/rect2.cpp +++ b/modules/gdnative/gdnative/rect2.cpp @@ -45,7 +45,6 @@ void GDAPI godot_rect2_new_with_position_and_size(godot_rect2 *r_dest, const god } void GDAPI godot_rect2_new(godot_rect2 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_width, const godot_real p_height) { - Rect2 *dest = (Rect2 *)r_dest; *dest = Rect2(p_x, p_y, p_width, p_height); } diff --git a/modules/gdnative/gdnative/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp index dc273e7951..b6c3569f42 100644 --- a/modules/gdnative/gdnative/vector2.cpp +++ b/modules/gdnative/gdnative/vector2.cpp @@ -38,7 +38,6 @@ extern "C" { #endif void GDAPI godot_vector2_new(godot_vector2 *r_dest, const godot_real p_x, const godot_real p_y) { - Vector2 *dest = (Vector2 *)r_dest; *dest = Vector2(p_x, p_y); } diff --git a/modules/gdnative/gdnative/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp index bb27ad5a00..3e272ae9df 100644 --- a/modules/gdnative/gdnative/vector3.cpp +++ b/modules/gdnative/gdnative/vector3.cpp @@ -38,7 +38,6 @@ extern "C" { #endif void GDAPI godot_vector3_new(godot_vector3 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z) { - Vector3 *dest = (Vector3 *)r_dest; *dest = Vector3(p_x, p_y, p_z); } diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp index 10ddd79d3a..278bc7217d 100644 --- a/modules/gdnative/gdnative_library_editor_plugin.cpp +++ b/modules/gdnative/gdnative_library_editor_plugin.cpp @@ -40,7 +40,6 @@ void GDNativeLibraryEditor::edit(Ref p_library) { for (Map::Element *E = platforms.front(); E; E = E->next()) { for (List::Element *it = E->value().entries.front(); it; it = it->next()) { - String target = E->key() + "." + it->get(); TargetConfig ecfg; ecfg.library = config->get_value("entry", target, ""); @@ -56,14 +55,12 @@ void GDNativeLibraryEditor::_bind_methods() { } void GDNativeLibraryEditor::_update_tree() { - tree->clear(); TreeItem *root = tree->create_item(); PopupMenu *filter_list = filter->get_popup(); String text = ""; for (int i = 0; i < filter_list->get_item_count(); i++) { - if (!filter_list->is_item_checked(i)) { continue; } @@ -84,7 +81,6 @@ void GDNativeLibraryEditor::_update_tree() { platform->set_expand_right(0, true); for (List::Element *it = E->value().entries.front(); it; it = it->next()) { - String target = E->key() + "." + it->get(); TreeItem *bit = tree->create_item(platform); @@ -125,14 +121,12 @@ void GDNativeLibraryEditor::_update_tree() { } void GDNativeLibraryEditor::_on_item_button(Object *item, int column, int id) { - String target = Object::cast_to(item)->get_metadata(0); String platform = target.substr(0, target.find(".")); String entry = target.substr(platform.length() + 1, target.length()); String section = (id == BUTTON_SELECT_DEPENDENCES || id == BUTTON_CLEAR_DEPENDENCES) ? "dependencies" : "entry"; if (id == BUTTON_SELECT_LIBRARY || id == BUTTON_SELECT_DEPENDENCES) { - EditorFileDialog::FileMode mode = EditorFileDialog::FILE_MODE_OPEN_FILE; if (id == BUTTON_SELECT_DEPENDENCES) mode = EditorFileDialog::FILE_MODE_OPEN_FILES; @@ -156,24 +150,20 @@ void GDNativeLibraryEditor::_on_item_button(Object *item, int column, int id) { } void GDNativeLibraryEditor::_on_library_selected(const String &file) { - _set_target_value(file_dialog->get_meta("section"), file_dialog->get_meta("target"), file); } void GDNativeLibraryEditor::_on_dependencies_selected(const PackedStringArray &files) { - _set_target_value(file_dialog->get_meta("section"), file_dialog->get_meta("target"), files); } void GDNativeLibraryEditor::_on_filter_selected(int index) { - PopupMenu *filter_list = filter->get_popup(); filter_list->set_item_checked(index, !filter_list->is_item_checked(index)); _update_tree(); } void GDNativeLibraryEditor::_on_item_collapsed(Object *p_item) { - TreeItem *item = Object::cast_to(p_item); String name = item->get_text(0); @@ -185,7 +175,6 @@ void GDNativeLibraryEditor::_on_item_collapsed(Object *p_item) { } void GDNativeLibraryEditor::_on_item_activated() { - TreeItem *item = tree->get_selected(); if (item && tree->get_selected_column() == 0 && item->get_metadata(0).get_type() == Variant::NIL) { new_architecture_dialog->set_meta("platform", item->get_metadata(1)); @@ -194,7 +183,6 @@ void GDNativeLibraryEditor::_on_item_activated() { } void GDNativeLibraryEditor::_on_create_new_entry() { - String platform = new_architecture_dialog->get_meta("platform"); String entry = new_architecture_input->get_text().strip_edges(); if (!entry.empty()) { @@ -213,10 +201,8 @@ void GDNativeLibraryEditor::_set_target_value(const String §ion, const Strin } void GDNativeLibraryEditor::_erase_entry(const String &platform, const String &entry) { - if (platforms.has(platform)) { if (List::Element *E = platforms[platform].entries.find(entry)) { - String target = platform + "." + entry; platforms[platform].entries.erase(E); @@ -243,16 +229,13 @@ void GDNativeLibraryEditor::_move_entry(const String &platform, const String &en } void GDNativeLibraryEditor::_translate_to_config_file() { - if (!library.is_null()) { - Ref config = library->get_config_file(); config->erase_section("entry"); config->erase_section("dependencies"); for (Map::Element *E = platforms.front(); E; E = E->next()) { for (List::Element *it = E->value().entries.front(); it; it = it->next()) { - String target = E->key() + "." + it->get(); if (entry_configs[target].library.empty() && entry_configs[target].dependencies.empty()) continue; @@ -267,7 +250,6 @@ void GDNativeLibraryEditor::_translate_to_config_file() { } GDNativeLibraryEditor::GDNativeLibraryEditor() { - { // Define platforms NativePlatformConfig platform_windows; platform_windows.name = "Windows"; @@ -388,19 +370,16 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() { } void GDNativeLibraryEditorPlugin::edit(Object *p_node) { - Ref new_library = Object::cast_to(p_node); if (new_library.is_valid()) library_editor->edit(new_library); } bool GDNativeLibraryEditorPlugin::handles(Object *p_node) const { - return p_node->is_class("GDNativeLibrary"); } void GDNativeLibraryEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { button->show(); EditorNode::get_singleton()->make_bottom_panel_item_visible(library_editor); @@ -413,7 +392,6 @@ void GDNativeLibraryEditorPlugin::make_visible(bool p_visible) { } GDNativeLibraryEditorPlugin::GDNativeLibraryEditorPlugin(EditorNode *p_node) { - library_editor = memnew(GDNativeLibraryEditor); library_editor->set_custom_minimum_size(Size2(0, 250 * EDSCALE)); button = p_node->add_bottom_panel_item(TTR("GDNativeLibrary"), library_editor); diff --git a/modules/gdnative/gdnative_library_editor_plugin.h b/modules/gdnative/gdnative_library_editor_plugin.h index b1274d08b3..5fdb860ca3 100644 --- a/modules/gdnative/gdnative_library_editor_plugin.h +++ b/modules/gdnative/gdnative_library_editor_plugin.h @@ -36,7 +36,6 @@ #include "gdnative.h" class GDNativeLibraryEditor : public Control { - GDCLASS(GDNativeLibraryEditor, Control); struct NativePlatformConfig { @@ -94,7 +93,6 @@ public: }; class GDNativeLibraryEditorPlugin : public EditorPlugin { - GDCLASS(GDNativeLibraryEditorPlugin, EditorPlugin); GDNativeLibraryEditor *library_editor; diff --git a/modules/gdnative/gdnative_library_singleton_editor.cpp b/modules/gdnative/gdnative_library_singleton_editor.cpp index 378339ecea..27f18c91a8 100644 --- a/modules/gdnative/gdnative_library_singleton_editor.cpp +++ b/modules/gdnative/gdnative_library_singleton_editor.cpp @@ -35,7 +35,6 @@ #include "editor/editor_node.h" Set GDNativeLibrarySingletonEditor::_find_singletons_recursive(EditorFileSystemDirectory *p_dir) { - Set file_paths; // check children @@ -67,7 +66,6 @@ Set GDNativeLibrarySingletonEditor::_find_singletons_recursive(EditorFil } void GDNativeLibrarySingletonEditor::_discover_singletons() { - EditorFileSystemDirectory *dir = EditorFileSystem::get_singleton()->get_filesystem(); Set file_paths = _find_singletons_recursive(dir); @@ -97,7 +95,6 @@ void GDNativeLibrarySingletonEditor::_discover_singletons() { } if (changed) { - ProjectSettings::get_singleton()->set("gdnative/singletons", files); _update_libraries(); // So singleton options (i.e. disabled) updates too ProjectSettings::get_singleton()->save(); @@ -105,7 +102,6 @@ void GDNativeLibrarySingletonEditor::_discover_singletons() { } void GDNativeLibrarySingletonEditor::_update_libraries() { - updating = true; libraries->clear(); libraries->create_item(); // root item @@ -182,7 +178,6 @@ void GDNativeLibrarySingletonEditor::_item_edited() { } void GDNativeLibrarySingletonEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { if (is_visible_in_tree()) { _update_libraries(); @@ -191,7 +186,6 @@ void GDNativeLibrarySingletonEditor::_notification(int p_what) { } void GDNativeLibrarySingletonEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_update_libraries"), &GDNativeLibrarySingletonEditor::_update_libraries); } diff --git a/modules/gdnative/include/net/godot_net.h b/modules/gdnative/include/net/godot_net.h index d245f3b965..42804112f2 100644 --- a/modules/gdnative/include/net/godot_net.h +++ b/modules/gdnative/include/net/godot_net.h @@ -45,7 +45,6 @@ extern "C" { #define GODOT_NET_API_MINOR 1 typedef struct { - godot_gdnative_api_version version; /* version of our API */ godot_object *data; /* User reference */ diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index 3c0cfd0484..62f2ec5024 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -41,7 +41,6 @@ // helper stuff static Error save_file(const String &p_path, const List &p_content) { - FileAccessRef file = FileAccess::open(p_path, FileAccess::WRITE); ERR_FAIL_COND_V(!file, ERR_FILE_CANT_WRITE); @@ -146,7 +145,6 @@ static String get_type_name(const PropertyInfo &info) { struct MethodInfoComparator { StringName::AlphCompare compare; bool operator()(const MethodInfo &p_a, const MethodInfo &p_b) const { - return compare(p_a.name, p_b.name); } }; @@ -154,7 +152,6 @@ struct MethodInfoComparator { struct PropertyInfoComparator { StringName::AlphCompare compare; bool operator()(const PropertyInfo &p_a, const PropertyInfo &p_b) const { - return compare(p_a.name, p_b.name); } }; @@ -162,7 +159,6 @@ struct PropertyInfoComparator { struct ConstantAPIComparator { NoCaseComparator compare; bool operator()(const ConstantAPI &p_a, const ConstantAPI &p_b) const { - return compare(p_a.constant_name, p_b.constant_name); } }; @@ -171,7 +167,6 @@ struct ConstantAPIComparator { * Reads the entire Godot API to a list */ List generate_c_api_classes() { - List api; List classes; @@ -410,7 +405,6 @@ List generate_c_api_classes() { * Generates the JSON source from the API in p_api */ static List generate_c_api_json(const List &p_api) { - // I'm sorry for the \t mess List source; @@ -520,7 +514,6 @@ static List generate_c_api_json(const List &p_api) { * p_path */ Error generate_c_api(const String &p_path) { - #ifndef TOOLS_ENABLED return ERR_BUG; #else diff --git a/modules/gdnative/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp index 0502458b4f..ee944ee7cb 100644 --- a/modules/gdnative/nativescript/godot_nativescript.cpp +++ b/modules/gdnative/nativescript/godot_nativescript.cpp @@ -52,7 +52,6 @@ extern "C" void _native_script_hook() { // Script API void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func) { - String *s = (String *)p_gdnative_handle; Map *classes = &NSL->library_classes[*s]; @@ -85,7 +84,6 @@ void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char } void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func) { - String *s = (String *)p_gdnative_handle; Map *classes = &NSL->library_classes[*s]; @@ -119,7 +117,6 @@ void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const } void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_method_attributes p_attr, godot_instance_method p_method) { - String *s = (String *)p_gdnative_handle; Map::Element *E = NSL->library_classes[*s].find(p_name); @@ -139,7 +136,6 @@ void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const cha } void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_property_attributes *p_attr, godot_property_set_func p_set_func, godot_property_get_func p_get_func) { - String *s = (String *)p_gdnative_handle; Map::Element *E = NSL->library_classes[*s].find(p_name); @@ -164,7 +160,6 @@ void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const c } void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_signal *p_signal) { - String *s = (String *)p_gdnative_handle; Map::Element *E = NSL->library_classes[*s].find(p_name); @@ -315,7 +310,6 @@ void GDAPI godot_nativescript_set_type_tag(void *p_gdnative_handle, const char * } const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object) { - const Object *o = (Object *)p_object; if (!o->get_script_instance()) { diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index ed3ec44bf7..70a651be1e 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -169,7 +169,6 @@ String NativeScript::get_script_class_icon_path() const { } bool NativeScript::can_instance() const { - NativeScriptDesc *script_data = get_script_desc(); #ifdef TOOLS_ENABLED @@ -207,7 +206,6 @@ StringName NativeScript::get_instance_base_type() const { } ScriptInstance *NativeScript::instance_create(Object *p_this) { - NativeScriptDesc *script_data = get_script_desc(); if (!script_data) { @@ -336,7 +334,6 @@ void NativeScript::get_script_signal_list(List *r_signals) const { Set signals_; while (script_data) { - for (Map::Element *S = script_data->signals_.front(); S; S = S->next()) { signals_.insert(S->get().signal); } @@ -376,7 +373,6 @@ void NativeScript::get_script_method_list(List *p_list) const { Set methods; while (script_data) { - for (Map::Element *E = script_data->methods.front(); E; E = E->next()) { methods.insert(E->get().info); } @@ -408,13 +404,11 @@ void NativeScript::get_script_property_list(List *p_list) const { } Vector NativeScript::get_rpc_methods() const { - Vector v; NativeScriptDesc *script_data = get_script_desc(); while (script_data) { - for (Map::Element *E = script_data->methods.front(); E; E = E->next()) { if (E->get().rpc_mode != GODOT_METHOD_RPC_MODE_DISABLED) { ScriptNetData nd; @@ -434,7 +428,6 @@ uint16_t NativeScript::get_rpc_method_id(const StringName &p_method) const { NativeScriptDesc *script_data = get_script_desc(); while (script_data) { - Map::Element *E = script_data->methods.find(p_method); if (E) { return E->get().rpc_method_id; @@ -452,7 +445,6 @@ StringName NativeScript::get_rpc_method(uint16_t p_id) const { NativeScriptDesc *script_data = get_script_desc(); while (script_data) { - for (Map::Element *E = script_data->methods.front(); E; E = E->next()) { if (E->get().rpc_method_id == p_id) { return E->key(); @@ -466,13 +458,11 @@ StringName NativeScript::get_rpc_method(uint16_t p_id) const { } MultiplayerAPI::RPCMode NativeScript::get_rpc_mode_by_id(uint16_t p_id) const { - ERR_FAIL_COND_V(p_id == UINT16_MAX, MultiplayerAPI::RPC_MODE_DISABLED); NativeScriptDesc *script_data = get_script_desc(); while (script_data) { - for (Map::Element *E = script_data->methods.front(); E; E = E->next()) { if (E->get().rpc_method_id == p_id) { switch (E->get().rpc_mode) { @@ -503,11 +493,9 @@ MultiplayerAPI::RPCMode NativeScript::get_rpc_mode_by_id(uint16_t p_id) const { } MultiplayerAPI::RPCMode NativeScript::get_rpc_mode(const StringName &p_method) const { - NativeScriptDesc *script_data = get_script_desc(); while (script_data) { - Map::Element *E = script_data->methods.find(p_method); if (E) { switch (E->get().rpc_mode) { @@ -542,7 +530,6 @@ Vector NativeScript::get_rset_properties() const { NativeScriptDesc *script_data = get_script_desc(); while (script_data) { - for (OrderedHashMap::Element E = script_data->properties.front(); E; E = E.next()) { if (E.get().rset_mode != GODOT_METHOD_RPC_MODE_DISABLED) { ScriptNetData nd; @@ -561,7 +548,6 @@ uint16_t NativeScript::get_rset_property_id(const StringName &p_variable) const NativeScriptDesc *script_data = get_script_desc(); while (script_data) { - OrderedHashMap::Element E = script_data->properties.find(p_variable); if (E) { return E.get().rset_property_id; @@ -579,7 +565,6 @@ StringName NativeScript::get_rset_property(uint16_t p_id) const { NativeScriptDesc *script_data = get_script_desc(); while (script_data) { - for (OrderedHashMap::Element E = script_data->properties.front(); E; E = E.next()) { if (E.get().rset_property_id == p_id) { return E.key(); @@ -593,13 +578,11 @@ StringName NativeScript::get_rset_property(uint16_t p_id) const { } MultiplayerAPI::RPCMode NativeScript::get_rset_mode_by_id(uint16_t p_id) const { - ERR_FAIL_COND_V(p_id == UINT16_MAX, MultiplayerAPI::RPC_MODE_DISABLED); NativeScriptDesc *script_data = get_script_desc(); while (script_data) { - for (OrderedHashMap::Element E = script_data->properties.front(); E; E = E.next()) { if (E.get().rset_property_id == p_id) { switch (E.get().rset_mode) { @@ -630,11 +613,9 @@ MultiplayerAPI::RPCMode NativeScript::get_rset_mode_by_id(uint16_t p_id) const { } MultiplayerAPI::RPCMode NativeScript::get_rset_mode(const StringName &p_variable) const { - NativeScriptDesc *script_data = get_script_desc(); while (script_data) { - OrderedHashMap::Element E = script_data->properties.find(p_variable); if (E) { switch (E.get().rset_mode) { @@ -677,7 +658,6 @@ String NativeScript::get_method_documentation(const StringName &p_method) const ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get method documentation on invalid NativeScript."); while (script_data) { - Map::Element *method = script_data->methods.find(p_method); if (method) { @@ -696,7 +676,6 @@ String NativeScript::get_signal_documentation(const StringName &p_signal_name) c ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get signal documentation on invalid NativeScript."); while (script_data) { - Map::Element *signal = script_data->signals_.find(p_signal_name); if (signal) { @@ -715,7 +694,6 @@ String NativeScript::get_property_documentation(const StringName &p_path) const ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get property documentation on invalid NativeScript."); while (script_data) { - OrderedHashMap::Element property = script_data->properties.find(p_path); if (property) { @@ -729,7 +707,6 @@ String NativeScript::get_property_documentation(const StringName &p_path) const } Variant NativeScript::_new(const Variant **p_args, int p_argcount, Callable::CallError &r_error) { - if (lib_path.empty() || class_name.empty() || library.is_null()) { r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; return Variant(); @@ -884,10 +861,8 @@ void NativeScriptInstance::get_property_list(List *p_properties) c NativeScriptDesc *script_data = GET_SCRIPT_DESC(); while (script_data) { - Map::Element *E = script_data->methods.find("_get_property_list"); if (E) { - godot_variant result; result = E->get().method.method((godot_object *)owner, E->get().method.method_data, @@ -936,11 +911,9 @@ void NativeScriptInstance::get_property_list(List *p_properties) c } Variant::Type NativeScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const { - NativeScriptDesc *script_data = GET_SCRIPT_DESC(); while (script_data) { - OrderedHashMap::Element P = script_data->properties.find(p_name); if (P) { *r_is_valid = true; @@ -961,7 +934,6 @@ bool NativeScriptInstance::has_method(const StringName &p_method) const { } Variant NativeScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { - NativeScriptDesc *script_data = GET_SCRIPT_DESC(); while (script_data) { @@ -1127,7 +1099,6 @@ void NativeScriptInstance::call_multilevel_reversed(const StringName &p_method, } NativeScriptInstance::~NativeScriptInstance() { - NativeScriptDesc *script_data = GET_SCRIPT_DESC(); if (!script_data) @@ -1145,16 +1116,13 @@ NativeScriptInstance::~NativeScriptInstance() { NativeScriptLanguage *NativeScriptLanguage::singleton; void NativeScriptLanguage::_unload_stuff(bool p_reload) { - Map> erase_and_unload; for (Map>::Element *L = library_classes.front(); L; L = L->next()) { - String lib_path = L->key(); Map classes = L->get(); if (p_reload) { - Map>::Element *E = library_gdnatives.find(lib_path); Ref gdn; @@ -1184,7 +1152,6 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) { } for (Map::Element *C = classes.front(); C; C = C->next()) { - // free property stuff first for (OrderedHashMap::Element P = C->get().properties.front(); P; P = P.next()) { if (P.get().getter.free_func) @@ -1253,13 +1220,10 @@ NativeScriptLanguage::NativeScriptLanguage() { } NativeScriptLanguage::~NativeScriptLanguage() { - for (Map>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { - Ref lib = L->get(); // only shut down valid libs, duh! if (lib.is_valid()) { - // If it's a singleton-library then the gdnative module // manages the destruction at engine shutdown, not NativeScript. if (!lib->get_library()->is_singleton()) { @@ -1285,7 +1249,6 @@ void _add_reload_node() { } void NativeScriptLanguage::init() { - #if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED) List args = OS::get_singleton()->get_cmdline_args(); @@ -1490,7 +1453,6 @@ void NativeScriptLanguage::profiling_add_data(StringName p_signature, uint64_t p } int NativeScriptLanguage::register_binding_functions(godot_instance_binding_functions p_binding_functions) { - // find index int idx = -1; @@ -1553,7 +1515,6 @@ void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_objec } if (!(*binding_data)[p_idx]) { - const void *global_type_tag = get_global_type_tag(p_idx, p_object->get_class_name()); // no binding data yet, soooooo alloc new one \o/ @@ -1564,7 +1525,6 @@ void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_objec } void *NativeScriptLanguage::alloc_instance_binding_data(Object *p_object) { - Vector *binding_data = new Vector; binding_data->resize(binding_functions.size()); @@ -1579,7 +1539,6 @@ void *NativeScriptLanguage::alloc_instance_binding_data(Object *p_object) { } void NativeScriptLanguage::free_instance_binding_data(void *p_data) { - if (!p_data) return; @@ -1600,7 +1559,6 @@ void NativeScriptLanguage::free_instance_binding_data(void *p_data) { } void NativeScriptLanguage::refcount_incremented_instance_binding(Object *p_object) { - void *data = p_object->get_script_instance_binding(lang_idx); if (!data) @@ -1622,7 +1580,6 @@ void NativeScriptLanguage::refcount_incremented_instance_binding(Object *p_objec } bool NativeScriptLanguage::refcount_decremented_instance_binding(Object *p_object) { - void *data = p_object->get_script_instance_binding(lang_idx); if (!data) @@ -1741,13 +1698,11 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) { void NativeScriptLanguage::call_libraries_cb(const StringName &name) { // library_gdnatives is modified only from the main thread, so it's safe not to use mutex here for (Map>::Element *L = library_gdnatives.front(); L; L = L->next()) { - if (L->get().is_null()) { continue; } if (L->get()->is_initialized()) { - void *proc_ptr; Error err = L->get()->get_symbol(L->get()->get_library()->get_symbol_prefix() + name, proc_ptr); @@ -1835,14 +1790,12 @@ void NativeReloadNode::_notification(int p_what) { switch (p_what) { case NOTIFICATION_WM_FOCUS_OUT: { - if (unloaded) break; MutexLock lock(NSL->mutex); NSL->_unload_stuff(true); for (Map>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { - Ref gdn = L->get(); if (gdn.is_null()) { @@ -1870,14 +1823,12 @@ void NativeReloadNode::_notification(int p_what) { } break; case NOTIFICATION_WM_FOCUS_IN: { - if (!unloaded) break; MutexLock lock(NSL->mutex); Set libs_to_remove; for (Map>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { - Ref gdn = L->get(); if (gdn.is_null()) { diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h index d24b247e59..1aca142889 100644 --- a/modules/gdnative/nativescript/nativescript.h +++ b/modules/gdnative/nativescript/nativescript.h @@ -47,7 +47,6 @@ #include struct NativeScriptDesc { - struct Method { godot_instance_method method; MethodInfo info; @@ -194,7 +193,6 @@ public: }; class NativeScriptInstance : public ScriptInstance { - friend class NativeScript; Object *owner; @@ -245,7 +243,6 @@ public: class NativeReloadNode; class NativeScriptLanguage : public ScriptLanguage { - friend class NativeScript; friend class NativeScriptInstance; friend class NativeReloadNode; diff --git a/modules/gdnative/nativescript/register_types.cpp b/modules/gdnative/nativescript/register_types.cpp index b5e8174e43..ac8c7ab2fd 100644 --- a/modules/gdnative/nativescript/register_types.cpp +++ b/modules/gdnative/nativescript/register_types.cpp @@ -58,7 +58,6 @@ void register_nativescript_types() { } void unregister_nativescript_types() { - ResourceLoader::remove_resource_format_loader(resource_loader_gdns); resource_loader_gdns.unref(); diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.cpp b/modules/gdnative/net/multiplayer_peer_gdnative.cpp index a95697ea65..997eec6425 100644 --- a/modules/gdnative/net/multiplayer_peer_gdnative.cpp +++ b/modules/gdnative/net/multiplayer_peer_gdnative.cpp @@ -120,7 +120,6 @@ void MultiplayerPeerGDNative::_bind_methods() { extern "C" { void GDAPI godot_net_bind_multiplayer_peer(godot_object *p_obj, const godot_net_multiplayer_peer *p_impl) { - ((MultiplayerPeerGDNative *)p_obj)->set_native_multiplayer_peer(p_impl); } } diff --git a/modules/gdnative/net/packet_peer_gdnative.cpp b/modules/gdnative/net/packet_peer_gdnative.cpp index 28135df3b6..6bb21cb48d 100644 --- a/modules/gdnative/net/packet_peer_gdnative.cpp +++ b/modules/gdnative/net/packet_peer_gdnative.cpp @@ -67,7 +67,6 @@ int PacketPeerGDNative::get_available_packet_count() const { extern "C" { void GDAPI godot_net_bind_packet_peer(godot_object *p_obj, const godot_net_packet_peer *p_impl) { - ((PacketPeerGDNative *)p_obj)->set_native_packet_peer(p_impl); } } diff --git a/modules/gdnative/net/stream_peer_gdnative.h b/modules/gdnative/net/stream_peer_gdnative.h index f3711e0f0f..0b2f995aa7 100644 --- a/modules/gdnative/net/stream_peer_gdnative.h +++ b/modules/gdnative/net/stream_peer_gdnative.h @@ -36,7 +36,6 @@ #include "modules/gdnative/include/net/godot_net.h" class StreamPeerGDNative : public StreamPeer { - GDCLASS(StreamPeerGDNative, StreamPeer); protected: diff --git a/modules/gdnative/pluginscript/pluginscript_loader.cpp b/modules/gdnative/pluginscript/pluginscript_loader.cpp index 64582cc517..7ce124c16a 100644 --- a/modules/gdnative/pluginscript/pluginscript_loader.cpp +++ b/modules/gdnative/pluginscript/pluginscript_loader.cpp @@ -101,13 +101,11 @@ Error ResourceFormatSaverPluginScript::save(const String &p_path, const RES &p_r } void ResourceFormatSaverPluginScript::get_recognized_extensions(const RES &p_resource, List *p_extensions) const { - if (Object::cast_to(*p_resource)) { p_extensions->push_back(_language->get_extension()); } } bool ResourceFormatSaverPluginScript::recognize(const RES &p_resource) const { - return Object::cast_to(*p_resource) != nullptr; } diff --git a/modules/gdnative/pluginscript/pluginscript_loader.h b/modules/gdnative/pluginscript/pluginscript_loader.h index e47754490a..35fc79c2ca 100644 --- a/modules/gdnative/pluginscript/pluginscript_loader.h +++ b/modules/gdnative/pluginscript/pluginscript_loader.h @@ -39,7 +39,6 @@ class PluginScriptLanguage; class ResourceFormatLoaderPluginScript : public ResourceFormatLoader { - PluginScriptLanguage *_language; public: @@ -51,7 +50,6 @@ public: }; class ResourceFormatSaverPluginScript : public ResourceFormatSaver { - PluginScriptLanguage *_language; public: diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp index 9b00d654d1..d659ade876 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.cpp +++ b/modules/gdnative/pluginscript/pluginscript_script.cpp @@ -56,7 +56,6 @@ void PluginScript::_bind_methods() { } PluginScriptInstance *PluginScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, Callable::CallError &r_error) { - r_error.error = Callable::CallError::CALL_OK; // Create instance @@ -84,7 +83,6 @@ PluginScriptInstance *PluginScript::_create_instance(const Variant **p_args, int } Variant PluginScript::_new(const Variant **p_args, int p_argcount, Callable::CallError &r_error) { - r_error.error = Callable::CallError::CALL_OK; if (!_valid) { @@ -167,7 +165,6 @@ void PluginScript::update_exports() { #ifdef TOOLS_ENABLED ASSERT_SCRIPT_VALID(); if (placeholders.size()) { - //update placeholders if any Map propdefvalues; List propinfos; @@ -281,7 +278,6 @@ Error PluginScript::reload(bool p_keep_state) { // ClassDB name (i.e. `Node2D`) or a resource path (i.e. `res://foo/bar.gd`) StringName *base_name = (StringName *)&manifest.base; if (*base_name) { - if (ClassDB::class_exists(*base_name)) { _native_parent = *base_name; } else { @@ -434,7 +430,6 @@ ScriptLanguage *PluginScript::get_language() const { } Error PluginScript::load_source_code(const String &p_path) { - Vector sourcef; Error err; FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err); diff --git a/modules/gdnative/pluginscript/pluginscript_script.h b/modules/gdnative/pluginscript/pluginscript_script.h index 287f42bf7b..659289ef9b 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.h +++ b/modules/gdnative/pluginscript/pluginscript_script.h @@ -38,7 +38,6 @@ #include class PluginScript : public Script { - GDCLASS(PluginScript, Script); friend class PluginScriptInstance; diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp index 67a286ee2e..bffbb86526 100644 --- a/modules/gdnative/register_types.cpp +++ b/modules/gdnative/register_types.cpp @@ -53,7 +53,6 @@ #include "gdnative_library_singleton_editor.h" class GDNativeExportPlugin : public EditorExportPlugin { - protected: virtual void _export_file(const String &p_path, const String &p_type, const Set &p_features); }; @@ -77,7 +76,6 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty Ref config = lib->get_config_file(); { - List entry_keys; config->get_section_keys("entry", &entry_keys); @@ -189,7 +187,6 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty } static void editor_init_callback() { - GDNativeLibrarySingletonEditor *library_editor = memnew(GDNativeLibrarySingletonEditor); library_editor->set_name(TTR("GDNative")); ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(library_editor); @@ -205,7 +202,6 @@ static void editor_init_callback() { #endif static godot_variant cb_standard_varcall(void *p_procedure_handle, godot_array *p_args) { - godot_gdnative_procedure_fn proc; proc = (godot_gdnative_procedure_fn)p_procedure_handle; @@ -220,7 +216,6 @@ Ref resource_loader_gdnlib; Ref resource_saver_gdnlib; void register_gdnative_types() { - #ifdef TOOLS_ENABLED EditorNode::add_init_callback(editor_init_callback); @@ -287,9 +282,7 @@ void register_gdnative_types() { } void unregister_gdnative_types() { - for (int i = 0; i < singleton_gdnatives.size(); i++) { - if (singleton_gdnatives[i].is_null()) { continue; } diff --git a/modules/gdnative/videodecoder/register_types.cpp b/modules/gdnative/videodecoder/register_types.cpp index c53e8f2c78..4181d8813f 100644 --- a/modules/gdnative/videodecoder/register_types.cpp +++ b/modules/gdnative/videodecoder/register_types.cpp @@ -36,7 +36,6 @@ static Ref resource_loader_vsgdnative; void register_videodecoder_types() { - resource_loader_vsgdnative.instance(); ResourceLoader::add_resource_format_loader(resource_loader_vsgdnative, true); @@ -44,7 +43,6 @@ void register_videodecoder_types() { } void unregister_videodecoder_types() { - ResourceLoader::remove_resource_format_loader(resource_loader_vsgdnative); resource_loader_vsgdnative.unref(); } diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp index a2ff376e31..476f44b185 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp +++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp @@ -105,7 +105,6 @@ int64_t GDAPI godot_videodecoder_file_seek(void *ptr, int64_t pos, int whence) { } void GDAPI godot_videodecoder_register_decoder(const godot_videodecoder_interface_gdnative *p_interface) { - decoder_server.register_decoder_interface(p_interface); } } @@ -240,7 +239,6 @@ bool VideoStreamPlaybackGDNative::is_paused() const { } void VideoStreamPlaybackGDNative::play() { - stop(); playing = true; @@ -282,7 +280,6 @@ float VideoStreamPlaybackGDNative::get_length() const { } float VideoStreamPlaybackGDNative::get_playback_position() const { - ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_playback_position(data_struct); } @@ -302,7 +299,6 @@ void VideoStreamPlaybackGDNative::set_audio_track(int p_idx) { } void VideoStreamPlaybackGDNative::set_mix_callback(AudioMixCallback p_callback, void *p_userdata) { - mix_udata = p_userdata; mix_callback = p_callback; } @@ -334,17 +330,14 @@ Ref VideoStreamGDNative::instance_playback() { } void VideoStreamGDNative::set_file(const String &p_file) { - file = p_file; } String VideoStreamGDNative::get_file() { - return file; } void VideoStreamGDNative::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_file", "file"), &VideoStreamGDNative::set_file); ClassDB::bind_method(D_METHOD("get_file"), &VideoStreamGDNative::get_file); @@ -352,7 +345,6 @@ void VideoStreamGDNative::_bind_methods() { } void VideoStreamGDNative::set_audio_track(int p_track) { - audio_track = p_track; } diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h index f1bae22801..2da63e96d6 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.h +++ b/modules/gdnative/videodecoder/video_stream_gdnative.h @@ -105,7 +105,6 @@ public: }; class VideoStreamPlaybackGDNative : public VideoStreamPlayback { - GDCLASS(VideoStreamPlaybackGDNative, VideoStreamPlayback); Ref texture; @@ -175,7 +174,6 @@ public: }; class VideoStreamGDNative : public VideoStream { - GDCLASS(VideoStreamGDNative, VideoStream); String file; diff --git a/modules/gdnative/xr/xr_interface_gdnative.cpp b/modules/gdnative/xr/xr_interface_gdnative.cpp index d65089a123..d03fc33935 100644 --- a/modules/gdnative/xr/xr_interface_gdnative.cpp +++ b/modules/gdnative/xr/xr_interface_gdnative.cpp @@ -80,7 +80,6 @@ void XRInterfaceGDNative::set_interface(const godot_xr_interface_gdnative *p_int } StringName XRInterfaceGDNative::get_name() const { - ERR_FAIL_COND_V(interface == nullptr, StringName()); godot_string result = interface->get_name(data); @@ -103,21 +102,18 @@ int XRInterfaceGDNative::get_capabilities() const { } bool XRInterfaceGDNative::get_anchor_detection_is_enabled() const { - ERR_FAIL_COND_V(interface == nullptr, false); return interface->get_anchor_detection_is_enabled(data); } void XRInterfaceGDNative::set_anchor_detection_is_enabled(bool p_enable) { - ERR_FAIL_COND(interface == nullptr); interface->set_anchor_detection_is_enabled(data, p_enable); } int XRInterfaceGDNative::get_camera_feed_id() { - ERR_FAIL_COND_V(interface == nullptr, 0); return (unsigned int)interface->get_camera_feed_id(data); @@ -134,7 +130,6 @@ bool XRInterfaceGDNative::is_stereo() { } bool XRInterfaceGDNative::is_initialized() const { - ERR_FAIL_COND_V(interface == nullptr, false); return interface->is_initialized(data); @@ -170,7 +165,6 @@ void XRInterfaceGDNative::uninitialize() { } Size2 XRInterfaceGDNative::get_render_targetsize() { - ERR_FAIL_COND_V(interface == nullptr, Size2()); godot_vector2 result = interface->get_render_targetsize(data); @@ -202,14 +196,12 @@ CameraMatrix XRInterfaceGDNative::get_projection_for_eye(XRInterface::Eyes p_eye } unsigned int XRInterfaceGDNative::get_external_texture_for_eye(XRInterface::Eyes p_eye) { - ERR_FAIL_COND_V(interface == nullptr, 0); return (unsigned int)interface->get_external_texture_for_eye(data, (godot_int)p_eye); } void XRInterfaceGDNative::commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) { - ERR_FAIL_COND(interface == nullptr); interface->commit_for_eye(data, (godot_int)p_eye, (godot_rid *)&p_render_target, (godot_rect2 *)&p_screen_rect); diff --git a/modules/gdnavigation/gd_navigation_server.cpp b/modules/gdnavigation/gd_navigation_server.cpp index 3792098af4..5aea9f8b9f 100644 --- a/modules/gdnavigation/gd_navigation_server.cpp +++ b/modules/gdnavigation/gd_navigation_server.cpp @@ -249,7 +249,6 @@ COMMAND_2(region_set_map, RID, p_region, RID, p_map) { ERR_FAIL_COND(region == nullptr); if (region->get_map() != nullptr) { - if (region->get_map()->get_self() == p_map) return; // Pointless diff --git a/modules/gdnavigation/nav_map.cpp b/modules/gdnavigation/nav_map.cpp index d6dd95d6e7..e55a3deb8f 100644 --- a/modules/gdnavigation/nav_map.cpp +++ b/modules/gdnavigation/nav_map.cpp @@ -71,7 +71,6 @@ gd::PointKey NavMap::get_point_key(const Vector3 &p_pos) const { } Vector NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p_optimize) const { - const gd::Polygon *begin_poly = nullptr; const gd::Polygon *end_poly = nullptr; Vector3 begin_point; @@ -85,7 +84,6 @@ Vector NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p // For each point cast a face and check the distance between the origin/destination for (size_t point_id = 2; point_id < p.points.size(); point_id++) { - Face3 f(p.points[point_id - 2].pos, p.points[point_id - 1].pos, p.points[point_id].pos); Vector3 spoint = f.get_closest_point_to(p_origin); float dpoint = spoint.distance_to(p_origin); @@ -111,7 +109,6 @@ Vector NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p } if (begin_poly == end_poly) { - Vector path; path.resize(2); path.write[0] = begin_point; @@ -142,7 +139,6 @@ Vector NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p bool is_reachable = true; while (found_route == false) { - { // Takes the current least_cost_poly neighbors and compute the traveled_distance of each for (size_t i = 0; i < navigation_polys[least_cost_id].poly->edges.size(); i++) { @@ -172,7 +168,6 @@ Vector NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p if (it != navigation_polys.end()) { // Oh this was visited already, can we win the cost? if (it->traveled_distance > new_distance) { - it->prev_navigation_poly_id = least_cost_id; it->back_navigation_edge = edge.other_edge; it->traveled_distance = new_distance; @@ -274,10 +269,8 @@ Vector NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p } if (found_route) { - Vector path; if (p_optimize) { - // String pulling gd::NavigationPoly *apex_poly = &navigation_polys[least_cost_id]; @@ -291,7 +284,6 @@ Vector NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p path.push_back(end_point); while (p) { - Vector3 left; Vector3 right; @@ -320,7 +312,6 @@ Vector NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p left_poly = p; portal_left = left; } else { - clip_path(navigation_polys, path, apex_poly, portal_right, right_poly); apex_point = portal_right; @@ -340,7 +331,6 @@ Vector NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p right_poly = p; portal_right = right; } else { - clip_path(navigation_polys, path, apex_poly, portal_left, left_poly); apex_point = portal_left; @@ -371,7 +361,6 @@ Vector NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p // Add mid points int np_id = least_cost_id; while (np_id != -1) { - #ifdef USE_ENTRY_POINT Vector3 point = navigation_polys[np_id].entry; #else @@ -393,7 +382,6 @@ Vector NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p } Vector3 NavMap::get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision) const { - bool use_collision = p_use_collision; Vector3 closest_point; real_t closest_point_d = 1e20; @@ -404,7 +392,6 @@ Vector3 NavMap::get_closest_point_to_segment(const Vector3 &p_from, const Vector // For each point cast a face and check the distance to the segment for (size_t point_id = 2; point_id < p.points.size(); point_id += 1) { - const Face3 f(p.points[point_id - 2].pos, p.points[point_id - 1].pos, p.points[point_id].pos); Vector3 inters; if (f.intersects_segment(p_from, p_to, &inters)) { @@ -414,7 +401,6 @@ Vector3 NavMap::get_closest_point_to_segment(const Vector3 &p_from, const Vector use_collision = true; closest_point_d = d; } else if (closest_point_d > d) { - closest_point = inters; closest_point_d = d; } @@ -422,9 +408,7 @@ Vector3 NavMap::get_closest_point_to_segment(const Vector3 &p_from, const Vector } if (use_collision == false) { - for (size_t point_id = 0; point_id < p.points.size(); point_id += 1) { - Vector3 a, b; Geometry::get_closest_points_between_segments( @@ -437,7 +421,6 @@ Vector3 NavMap::get_closest_point_to_segment(const Vector3 &p_from, const Vector const real_t d = a.distance_to(b); if (d < closest_point_d) { - closest_point_d = d; closest_point = b; } @@ -460,7 +443,6 @@ Vector3 NavMap::get_closest_point(const Vector3 &p_point) const { // For each point cast a face and check the distance to the point for (size_t point_id = 2; point_id < p.points.size(); point_id += 1) { - const Face3 f(p.points[point_id - 2].pos, p.points[point_id - 1].pos, p.points[point_id].pos); const Vector3 inters = f.get_closest_point_to(p_point); const real_t d = inters.distance_to(p_point); @@ -487,7 +469,6 @@ Vector3 NavMap::get_closest_point_normal(const Vector3 &p_point) const { // For each point cast a face and check the distance to the point for (size_t point_id = 2; point_id < p.points.size(); point_id += 1) { - const Face3 f(p.points[point_id - 2].pos, p.points[point_id - 1].pos, p.points[point_id].pos); const Vector3 inters = f.get_closest_point_to(p_point); const real_t d = inters.distance_to(p_point); @@ -515,7 +496,6 @@ RID NavMap::get_closest_point_owner(const Vector3 &p_point) const { // For each point cast a face and check the distance to the point for (size_t point_id = 2; point_id < p.points.size(); point_id += 1) { - const Face3 f(p.points[point_id - 2].pos, p.points[point_id - 1].pos, p.points[point_id].pos); const Vector3 inters = f.get_closest_point_to(p_point); const real_t d = inters.distance_to(p_point); @@ -579,7 +559,6 @@ void NavMap::remove_agent_as_controlled(RvoAgent *agent) { } void NavMap::sync() { - if (regenerate_polygons) { for (size_t r(0); r < regions.size(); r++) { regions[r]->scratch_polygons(); @@ -777,7 +756,6 @@ void NavMap::clip_path(const std::vector &p_navigation_polys cut_plane.d = cut_plane.normal.dot(from); while (from_poly != p_to_poly) { - int back_nav_edge = from_poly->back_navigation_edge; Vector3 a = from_poly->poly->points[back_nav_edge].pos; Vector3 b = from_poly->poly->points[(back_nav_edge + 1) % from_poly->poly->points.size()].pos; @@ -786,7 +764,6 @@ void NavMap::clip_path(const std::vector &p_navigation_polys from_poly = &p_navigation_polys[from_poly->prev_navigation_poly_id]; if (a.distance_to(b) > CMP_EPSILON) { - Vector3 inters; if (cut_plane.intersects_segment(a, b, &inters)) { if (inters.distance_to(p_to_point) > CMP_EPSILON && inters.distance_to(path[path.size() - 1]) > CMP_EPSILON) { diff --git a/modules/gdnavigation/nav_map.h b/modules/gdnavigation/nav_map.h index d39e301511..892755f3f9 100644 --- a/modules/gdnavigation/nav_map.h +++ b/modules/gdnavigation/nav_map.h @@ -46,7 +46,6 @@ class RvoAgent; class NavRegion; class NavMap : public NavRid { - /// Map Up Vector3 up = Vector3(0, 1, 0); diff --git a/modules/gdnavigation/nav_region.cpp b/modules/gdnavigation/nav_region.cpp index 2bd42ba980..3dff19cd65 100644 --- a/modules/gdnavigation/nav_region.cpp +++ b/modules/gdnavigation/nav_region.cpp @@ -84,7 +84,6 @@ void NavRegion::update_polygons() { // Build for (size_t i(0); i < polygons.size(); i++) { - gd::Polygon &p = polygons[i]; p.owner = this; @@ -98,7 +97,6 @@ void NavRegion::update_polygons() { float sum(0); for (int j(0); j < mesh_poly.size(); j++) { - int idx = indices[j]; if (idx < 0 || idx >= len) { valid = false; diff --git a/modules/gdnavigation/nav_utils.h b/modules/gdnavigation/nav_utils.h index 388e53a66a..40e54df553 100644 --- a/modules/gdnavigation/nav_utils.h +++ b/modules/gdnavigation/nav_utils.h @@ -45,7 +45,6 @@ namespace gd { struct Polygon; union PointKey { - struct { int64_t x : 21; int64_t y : 22; @@ -57,7 +56,6 @@ union PointKey { }; struct EdgeKey { - PointKey a; PointKey b; @@ -109,7 +107,6 @@ struct Polygon { }; struct Connection { - Polygon *A = nullptr; int A_edge = -1; Polygon *B = nullptr; diff --git a/modules/gdnavigation/navigation_mesh_editor_plugin.cpp b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp index abaf73ba6a..379131864e 100644 --- a/modules/gdnavigation/navigation_mesh_editor_plugin.cpp +++ b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp @@ -38,7 +38,6 @@ #include "scene/gui/box_container.h" void NavigationMeshEditor::_node_removed(Node *p_node) { - if (p_node == node) { node = nullptr; @@ -47,9 +46,7 @@ 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("Bake", "EditorIcons")); button_reset->set_icon(get_theme_icon("Reload", "EditorIcons")); } @@ -72,7 +69,6 @@ void NavigationMeshEditor::_bake_pressed() { } void NavigationMeshEditor::_clear_pressed() { - if (node) NavigationMeshGenerator::get_singleton()->clear(node->get_navigation_mesh()); @@ -85,7 +81,6 @@ void NavigationMeshEditor::_clear_pressed() { } void NavigationMeshEditor::edit(NavigationRegion3D *p_nav_region) { - if (p_nav_region == nullptr || node == p_nav_region) { return; } @@ -97,7 +92,6 @@ void NavigationMeshEditor::_bind_methods() { } NavigationMeshEditor::NavigationMeshEditor() { - bake_hbox = memnew(HBoxContainer); button_bake = memnew(ToolButton); @@ -124,22 +118,18 @@ NavigationMeshEditor::~NavigationMeshEditor() { } void NavigationMeshEditorPlugin::edit(Object *p_object) { - navigation_mesh_editor->edit(Object::cast_to(p_object)); } bool NavigationMeshEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("NavigationRegion3D"); } void NavigationMeshEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { navigation_mesh_editor->show(); navigation_mesh_editor->bake_hbox->show(); } else { - navigation_mesh_editor->hide(); navigation_mesh_editor->bake_hbox->hide(); navigation_mesh_editor->edit(nullptr); @@ -147,7 +137,6 @@ void NavigationMeshEditorPlugin::make_visible(bool p_visible) { } NavigationMeshEditorPlugin::NavigationMeshEditorPlugin(EditorNode *p_node) { - editor = p_node; navigation_mesh_editor = memnew(NavigationMeshEditor); editor->get_viewport()->add_child(navigation_mesh_editor); diff --git a/modules/gdnavigation/navigation_mesh_editor_plugin.h b/modules/gdnavigation/navigation_mesh_editor_plugin.h index 434981c9e0..da3a981f8c 100644 --- a/modules/gdnavigation/navigation_mesh_editor_plugin.h +++ b/modules/gdnavigation/navigation_mesh_editor_plugin.h @@ -67,7 +67,6 @@ public: }; class NavigationMeshEditorPlugin : public EditorPlugin { - GDCLASS(NavigationMeshEditorPlugin, EditorPlugin); NavigationMeshEditor *navigation_mesh_editor; diff --git a/modules/gdnavigation/navigation_mesh_generator.cpp b/modules/gdnavigation/navigation_mesh_generator.cpp index acb4f0461f..78818fd990 100644 --- a/modules/gdnavigation/navigation_mesh_generator.cpp +++ b/modules/gdnavigation/navigation_mesh_generator.cpp @@ -94,7 +94,6 @@ void NavigationMeshGenerator::_add_mesh(const Ref &p_mesh, const Transform const Vector3 *vr = mesh_vertices.ptr(); if (p_mesh->surface_get_format(i) & Mesh::ARRAY_FORMAT_INDEX) { - Vector mesh_indices = a[Mesh::ARRAY_INDEX]; const int *ir = mesh_indices.ptr(); @@ -139,9 +138,7 @@ void NavigationMeshGenerator::_add_faces(const PackedVector3Array &p_faces, cons } void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform, Node *p_node, Vector &p_verticies, Vector &p_indices, int p_generate_from, uint32_t p_collision_mask, bool p_recurse_children) { - if (Object::cast_to(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) { - MeshInstance3D *mesh_instance = Object::cast_to(p_node); Ref mesh = mesh_instance->get_mesh(); if (mesh.is_valid()) { @@ -151,7 +148,6 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform, #ifdef MODULE_CSG_ENABLED if (Object::cast_to(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) { - CSGShape3D *csg_shape = Object::cast_to(p_node); Array meshes = csg_shape->get_meshes(); if (!meshes.empty()) { @@ -167,7 +163,6 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform, StaticBody3D *static_body = Object::cast_to(p_node); if (static_body->get_collision_layer() & p_collision_mask) { - for (int i = 0; i < p_node->get_child_count(); ++i) { Node *child = p_node->get_child(i); if (Object::cast_to(child)) { @@ -278,7 +273,6 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform, } void NavigationMeshGenerator::_convert_detail_mesh_to_native_navigation_mesh(const rcPolyMeshDetail *p_detail_mesh, Ref p_nav_mesh) { - Vector nav_vertices; for (int i = 0; i < p_detail_mesh->nverts; i++) { @@ -481,7 +475,6 @@ NavigationMeshGenerator::~NavigationMeshGenerator() { } void NavigationMeshGenerator::bake(Ref p_nav_mesh, Node *p_node) { - ERR_FAIL_COND(!p_nav_mesh.is_valid()); #ifdef TOOLS_ENABLED @@ -514,7 +507,6 @@ void NavigationMeshGenerator::bake(Ref p_nav_mesh, Node *p_node) } if (vertices.size() > 0 && indices.size() > 0) { - rcHeightfield *hf = nullptr; rcCompactHeightfield *chf = nullptr; rcContourSet *cset = nullptr; diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index 0aca4dbc5e..c3091a56a6 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -34,17 +34,14 @@ #include "scene/gui/text_edit.h" inline bool _is_symbol(CharType c) { - return is_symbol(c); } static bool _is_text_char(CharType c) { - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_'; } static bool _is_char(CharType c) { - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_'; } @@ -180,7 +177,6 @@ Map GDScriptSyntaxHighlighter::_get_line_syntax_ } if (in_region == -1 && !in_keyword && is_char && !prev_is_char) { - int to = j; while (to < str.length() && _is_text_char(str[to])) to++; @@ -208,7 +204,6 @@ Map GDScriptSyntaxHighlighter::_get_line_syntax_ } if (!in_function_name && in_word && !in_keyword) { - int k = j; while (k < str.length() && !_is_symbol(str[k]) && str[k] != '\t' && str[k] != ' ') { k++; @@ -238,7 +233,6 @@ Map GDScriptSyntaxHighlighter::_get_line_syntax_ } if (is_symbol) { - if (in_function_name) { in_function_args = true; } diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 8559fac57c..d42fdb1e04 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -44,12 +44,10 @@ /////////////////////////// GDScriptNativeClass::GDScriptNativeClass(const StringName &p_name) { - name = p_name; } bool GDScriptNativeClass::_get(const StringName &p_name, Variant &r_ret) const { - bool ok; int v = ClassDB::get_integer_constant(name, p_name, &ok); @@ -62,12 +60,10 @@ bool GDScriptNativeClass::_get(const StringName &p_name, Variant &r_ret) const { } void GDScriptNativeClass::_bind_methods() { - ClassDB::bind_method(D_METHOD("new"), &GDScriptNativeClass::_new); } Variant GDScriptNativeClass::_new() { - Object *o = instance(); ERR_FAIL_COND_V_MSG(!o, Variant(), "Class type: '" + String(name) + "' is not instantiable."); @@ -80,12 +76,10 @@ Variant GDScriptNativeClass::_new() { } Object *GDScriptNativeClass::instance() { - return ClassDB::instance(name); } GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Callable::CallError &r_error) { - /* STEP 1, CREATE */ GDScriptInstance *instance = memnew(GDScriptInstance); @@ -125,7 +119,6 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco } Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallError &r_error) { - /* STEP 1, CREATE */ if (!valid) { @@ -171,7 +164,6 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallErr } bool GDScript::can_instance() const { - #ifdef TOOLS_ENABLED return valid && (tool || ScriptServer::is_scripting_enabled()); #else @@ -180,7 +172,6 @@ bool GDScript::can_instance() const { } Ref